Debian Codegraph @

phoenix/windows/widget/radio-label.cpp

raw
1 namespace phoenix {
2
3 Size pRadioLabel::minimumSize() {
4 Size size = pFont::size(hfont, radioLabel.state.text);
5 return {size.width + 20, size.height + 4};
6 }
7
8 void pRadioLabel::setChecked() {
9 for(auto& item : radioLabel.state.group) {
10 SendMessage(item.p.hwnd, BM_SETCHECK, (WPARAM)(&item == &radioLabel), 0);
11 }
12 }
13
14 void pRadioLabel::setGroup(const group<RadioLabel>& group) {
15 }
16
17 void pRadioLabel::setText(string text) {
18 SetWindowText(hwnd, utf16_t(text));
19 }
20
21 void pRadioLabel::constructor() {
22 hwnd = CreateWindow(
23 L"BUTTON", L"",
24 WS_CHILD | WS_TABSTOP | BS_RADIOBUTTON,
25 0, 0, 0, 0, parentHwnd, (HMENU)id, GetModuleHandle(0), 0
26 );
27 SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&radioLabel);
28 setDefaultFont();
29 if(radioLabel.state.checked) setChecked();
30 setText(radioLabel.state.text);
31 synchronize();
32 }
33
34 void pRadioLabel::destructor() {
35 DestroyWindow(hwnd);
36 }
37
38 void pRadioLabel::orphan() {
39 destructor();
40 constructor();
41 }
42
43 void pRadioLabel::onActivate() {
44 if(radioLabel.state.checked) return;
45 radioLabel.setChecked();
46 if(radioLabel.onActivate) radioLabel.onActivate();
47 }
48
49 }