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