| 1 |
namespace phoenix { |
| 2 |
|
| 3 |
Size pCheckLabel::minimumSize() { |
| 4 |
Size size = pFont::size(hfont, checkLabel.state.text); |
| 5 |
return {size.width + 20, size.height + 4}; |
| 6 |
} |
| 7 |
|
| 8 |
void pCheckLabel::setChecked(bool checked) { |
| 9 |
SendMessage(hwnd, BM_SETCHECK, (WPARAM)checked, 0); |
| 10 |
} |
| 11 |
|
| 12 |
void pCheckLabel::setText(string text) { |
| 13 |
SetWindowText(hwnd, utf16_t(text)); |
| 14 |
} |
| 15 |
|
| 16 |
void pCheckLabel::constructor() { |
| 17 |
hwnd = CreateWindow( |
| 18 |
L"BUTTON", L"", |
| 19 |
WS_CHILD | WS_TABSTOP | BS_CHECKBOX, |
| 20 |
0, 0, 0, 0, parentHwnd, (HMENU)id, GetModuleHandle(0), 0 |
| 21 |
); |
| 22 |
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&checkLabel); |
| 23 |
setDefaultFont(); |
| 24 |
setChecked(checkLabel.state.checked); |
| 25 |
setText(checkLabel.state.text); |
| 26 |
synchronize(); |
| 27 |
} |
| 28 |
|
| 29 |
void pCheckLabel::destructor() { |
| 30 |
DestroyWindow(hwnd); |
| 31 |
} |
| 32 |
|
| 33 |
void pCheckLabel::orphan() { |
| 34 |
destructor(); |
| 35 |
constructor(); |
| 36 |
} |
| 37 |
|
| 38 |
void pCheckLabel::onToggle() { |
| 39 |
checkLabel.state.checked = !checkLabel.state.checked; |
| 40 |
setChecked(checkLabel.state.checked); |
| 41 |
if(checkLabel.onToggle) checkLabel.onToggle(); |
| 42 |
} |
| 43 |
|
| 44 |
} |