Debian Codegraph @

phoenix/windows/widget/horizontal-slider.cpp

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