Debian Codegraph @

phoenix/windows/widget/vertical-slider.cpp

raw
1 namespace phoenix {
2
3 Size pVerticalSlider::minimumSize() {
4 return {0, 25};
5 }
6
7 void pVerticalSlider::setLength(unsigned length) {
8 length += (length == 0);
9 SendMessage(hwnd, TBM_SETRANGE, (WPARAM)true, (LPARAM)MAKELONG(0, length - 1));
10 SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)(length >> 3));
11 verticalSlider.setPosition(0);
12 }
13
14 void pVerticalSlider::setPosition(unsigned position) {
15 SendMessage(hwnd, TBM_SETPOS, (WPARAM)true, (LPARAM)position);
16 }
17
18 void pVerticalSlider::constructor() {
19 hwnd = CreateWindow(
20 TRACKBAR_CLASS, L"", WS_CHILD | WS_TABSTOP | TBS_TRANSPARENTBKGND | TBS_NOTICKS | TBS_BOTH | TBS_VERT,
21 0, 0, 0, 0, parentHwnd, (HMENU)id, GetModuleHandle(0), 0
22 );
23 SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&verticalSlider);
24
25 unsigned position = verticalSlider.state.position;
26 setLength(verticalSlider.state.length);
27 verticalSlider.setPosition(position);
28 synchronize();
29 }
30
31 void pVerticalSlider::destructor() {
32 DestroyWindow(hwnd);
33 }
34
35 void pVerticalSlider::orphan() {
36 destructor();
37 constructor();
38 }
39
40 void pVerticalSlider::onChange() {
41 unsigned position = SendMessage(hwnd, TBM_GETPOS, 0, 0);
42 if(position == verticalSlider.state.position) return;
43 verticalSlider.state.position = position;
44 if(verticalSlider.onChange) verticalSlider.onChange();
45 }
46
47 }