2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_HorizontalSlider)
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
namespace hiro {
|
2011-03-22 12:56:49 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pHorizontalSlider::construct() -> void {
|
2011-02-24 09:25:20 +00:00
|
|
|
hwnd = CreateWindow(
|
2013-11-28 10:32:53 +00:00
|
|
|
TRACKBAR_CLASS, L"", WS_CHILD | WS_TABSTOP | TBS_TRANSPARENTBKGND | TBS_NOTICKS | TBS_BOTH | TBS_HORZ,
|
2015-06-12 13:14:38 +00:00
|
|
|
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0
|
2011-02-24 09:25:20 +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);
|
2011-09-05 03:48:23 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pHorizontalSlider::destruct() -> void {
|
2011-09-05 03:48:23 +00:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pHorizontalSlider::minimumSize() const -> Size {
|
|
|
|
return {0, 25};
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pHorizontalSlider::setLength(unsigned length) -> void {
|
|
|
|
length += (length == 0);
|
|
|
|
SendMessage(hwnd, TBM_SETRANGE, (WPARAM)true, (LPARAM)MAKELONG(0, length - 1));
|
|
|
|
SendMessage(hwnd, TBM_SETPAGESIZE, 0, (LPARAM)(length >> 3));
|
2011-02-24 09:25:20 +00:00
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pHorizontalSlider::setPosition(unsigned position) -> void {
|
|
|
|
SendMessage(hwnd, TBM_SETPOS, (WPARAM)true, (LPARAM)position);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pHorizontalSlider::onChange() -> void {
|
2013-11-28 10:29:01 +00:00
|
|
|
unsigned position = SendMessage(hwnd, TBM_GETPOS, 0, 0);
|
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
|