2015-08-21 10:56:39 +00:00
|
|
|
#if defined(Hiro_HorizontalScrollBar)
|
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-08-21 10:56:39 +00:00
|
|
|
auto pHorizontalScrollBar::construct() -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
hwnd = CreateWindow(
|
|
|
|
L"SCROLLBAR", L"", WS_CHILD | WS_TABSTOP | SBS_HORZ,
|
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-08-21 10:56:39 +00:00
|
|
|
auto pHorizontalScrollBar::destruct() -> void {
|
2013-03-15 13:11:33 +00:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2015-08-21 10:56:39 +00:00
|
|
|
auto pHorizontalScrollBar::minimumSize() const -> Size {
|
2015-06-12 13:14:38 +00:00
|
|
|
return {0, 18};
|
|
|
|
}
|
|
|
|
|
2015-08-21 10:56:39 +00:00
|
|
|
auto pHorizontalScrollBar::setLength(unsigned length) -> void {
|
2015-06-12 13:14:38 +00:00
|
|
|
length += (length == 0);
|
|
|
|
SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE);
|
2013-03-15 13:11:33 +00:00
|
|
|
}
|
|
|
|
|
2015-08-21 10:56:39 +00:00
|
|
|
auto pHorizontalScrollBar::setPosition(unsigned position) -> void {
|
2015-06-12 13:14:38 +00:00
|
|
|
SetScrollPos(hwnd, SB_CTL, position, TRUE);
|
|
|
|
}
|
|
|
|
|
2015-08-21 10:56:39 +00:00
|
|
|
auto pHorizontalScrollBar::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
|