2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_VerticalScroller)
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
namespace hiro {
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pVerticalScroller::construct() -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
hwnd = CreateWindow(
|
|
|
|
L"SCROLLBAR", L"", WS_CHILD | SBS_VERT,
|
2015-06-12 13:14:38 +00:00
|
|
|
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0
|
2013-03-15 13:11:33 +00:00
|
|
|
);
|
2015-06-12 13:14:38 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
|
|
|
|
pWidget::_setState();
|
|
|
|
setLength(state().length);
|
|
|
|
setPosition(state().position);
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pVerticalScroller::destruct() -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pVerticalScroller::minimumSize() const -> Size {
|
|
|
|
return {18, 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pVerticalScroller::setLength(unsigned length) -> void {
|
|
|
|
length += (length == 0);
|
|
|
|
SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE);
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pVerticalScroller::setPosition(unsigned position) -> void {
|
|
|
|
SetScrollPos(hwnd, SB_CTL, position, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pVerticalScroller::onChange(WPARAM wparam) -> void {
|
2013-11-28 10:29:01 +00:00
|
|
|
unsigned position = ScrollEvent(hwnd, wparam);
|
2015-06-12 13:14:38 +00:00
|
|
|
if(position == state().position) return;
|
|
|
|
state().position = position;
|
|
|
|
self().doChange();
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
|
|
|
|
#endif
|