Debian Codegraph @

phoenix/windows/widget/vertical-scroller.cpp

raw
1 namespace phoenix {
2
3 Size pVerticalScroller::minimumSize() {
4 return {18, 0};
5 }
6
7 void pVerticalScroller::setLength(unsigned length) {
8 length += (length == 0);
9 SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE);
10 verticalScroller.setPosition(0);
11 }
12
13 void pVerticalScroller::setPosition(unsigned position) {
14 SetScrollPos(hwnd, SB_CTL, position, TRUE);
15 }
16
17 void pVerticalScroller::constructor() {
18 hwnd = CreateWindow(
19 L"SCROLLBAR", L"", WS_CHILD | SBS_VERT,
20 0, 0, 0, 0, parentHwnd, (HMENU)id, GetModuleHandle(0), 0
21 );
22 SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&verticalScroller);
23 unsigned position = verticalScroller.state.position;
24 setLength(verticalScroller.state.length);
25 verticalScroller.setPosition(position);
26 synchronize();
27 }
28
29 void pVerticalScroller::destructor() {
30 DestroyWindow(hwnd);
31 }
32
33 void pVerticalScroller::orphan() {
34 destructor();
35 constructor();
36 }
37
38 void pVerticalScroller::onChange(WPARAM wparam) {
39 unsigned position = ScrollEvent(hwnd, wparam);
40 if(position == verticalScroller.state.position) return;
41 verticalScroller.state.position = position;
42 if(verticalScroller.onChange) verticalScroller.onChange();
43 }
44
45 }