ui/winui/button.cpp

changeset 76
641dcc79e0ef
parent 3
f154867f54dc
child 79
483d7342b439
equal deleted inserted replaced
75:73c8a3780c72 76:641dcc79e0ef
54 } 54 }
55 else if (type == UI_LABEL_TEXT) { 55 else if (type == UI_LABEL_TEXT) {
56 icon = NULL; 56 icon = NULL;
57 } 57 }
58 58
59 if (label && icon) { 59 IconElement icon_elm = { nullptr };
60 if (icon) {
61 icon_elm = ui_get_icon(icon);
62 }
63
64 if (label && icon_elm) {
60 StackPanel panel = StackPanel(); 65 StackPanel panel = StackPanel();
61 panel.Orientation(Orientation::Horizontal); 66 panel.Orientation(Orientation::Horizontal);
62 panel.Spacing(5); 67 panel.Spacing(5);
63 68
64 panel.Children().Append(ui_get_icon(icon)); 69 panel.Children().Append(icon_elm);
65 70
66 wchar_t* wlabel = str2wstr(label, nullptr); 71 wchar_t* wlabel = str2wstr(label, nullptr);
67 TextBlock label = TextBlock(); 72 TextBlock label = TextBlock();
68 label.Text(wlabel); 73 label.Text(wlabel);
69 panel.Children().Append(label); 74 panel.Children().Append(label);
74 else if (label) { 79 else if (label) {
75 wchar_t* wlabel = str2wstr(label, nullptr); 80 wchar_t* wlabel = str2wstr(label, nullptr);
76 button.Content(box_value(wlabel)); 81 button.Content(box_value(wlabel));
77 free(wlabel); 82 free(wlabel);
78 } 83 }
79 else if (icon) { 84 else if (icon_elm) {
80 button.Content(ui_get_icon(icon)); 85 button.Content(ui_get_icon(icon));
81 } 86 }
82 } 87 }
83 88
84 89
285 // store a list of radio buttons in the value 290 // store a list of radio buttons in the value
286 CxList* radioButtons = (CxList*) (value->obj ? value->obj : cxLinkedListCreate(current->ctx->allocator, NULL, CX_STORE_POINTERS)); 291 CxList* radioButtons = (CxList*) (value->obj ? value->obj : cxLinkedListCreate(current->ctx->allocator, NULL, CX_STORE_POINTERS));
287 // get or create the group name 292 // get or create the group name
288 static int groupCount = 0; 293 static int groupCount = 0;
289 winrt::hstring groupName; 294 winrt::hstring groupName;
290 if (radioButtons->size == 0) { 295 if (cxListSize(radioButtons) == 0) {
291 groupName = winrt::to_hstring(groupCount++); 296 groupName = winrt::to_hstring(groupCount++);
292 } else { 297 } else {
293 UiWidget* firstButtonWidget = (UiWidget*)cxListAt(radioButtons, 0); 298 UiWidget* firstButtonWidget = (UiWidget*)cxListAt(radioButtons, 0);
294 RadioButton firstRadioButton = firstButtonWidget->uielement.as<RadioButton>(); 299 RadioButton firstRadioButton = firstButtonWidget->uielement.as<RadioButton>();
295 groupName = firstRadioButton.GroupName(); 300 groupName = firstRadioButton.GroupName();

mercurial