2015-06-12 13:14:38 +00:00
|
|
|
#if defined(Hiro_CheckLabel)
|
2013-11-28 10:29:01 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
namespace hiro {
|
2013-11-28 10:29:01 +00:00
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pCheckLabel::construct() -> void {
|
2013-11-28 10:29:01 +00:00
|
|
|
hwnd = CreateWindow(
|
|
|
|
L"BUTTON", L"",
|
|
|
|
WS_CHILD | WS_TABSTOP | BS_CHECKBOX,
|
2015-06-12 13:14:38 +00:00
|
|
|
0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0
|
2013-11-28 10:29:01 +00:00
|
|
|
);
|
2015-06-12 13:14:38 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
|
|
|
|
pWidget::_setState();
|
|
|
|
setChecked(state().checked);
|
|
|
|
setText(state().text);
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pCheckLabel::destruct() -> void {
|
2013-11-28 10:29:01 +00:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pCheckLabel::minimumSize() -> Size {
|
|
|
|
auto size = pFont::size(hfont, state().text);
|
|
|
|
return {size.width() + 20, size.height() + 4};
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pCheckLabel::setChecked(bool checked) -> void {
|
|
|
|
SendMessage(hwnd, BM_SETCHECK, (WPARAM)checked, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
auto pCheckLabel::setText(const string& text) -> void {
|
|
|
|
SetWindowText(hwnd, utf16_t(text));
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
2015-06-12 13:14:38 +00:00
|
|
|
auto pCheckLabel::onToggle() -> void {
|
|
|
|
state().checked = !state().checked;
|
|
|
|
setChecked(state().checked);
|
|
|
|
self().doToggle();
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
2015-06-12 13:14:38 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|