diff -r a952760955b4 -r 4f5b32a2a60f ui/winui/button.cpp --- a/ui/winui/button.cpp Fri Jan 26 17:17:14 2024 +0100 +++ b/ui/winui/button.cpp Sun Jan 28 09:35:44 2024 +0100 @@ -46,13 +46,39 @@ -static void set_button_label(ButtonBase button, const char* label, const char* stockid) { - if (label) { +static void set_button_label(ButtonBase button, const char* label, const char* stockid, const char *icon, UiLabelType type) { + // TODO: stockid + + if (type == UI_LABEL_ICON) { + label = NULL; + } + else if (type == UI_LABEL_TEXT) { + icon = NULL; + } + + if (label && icon) { + StackPanel panel = StackPanel(); + panel.Orientation(Orientation::Horizontal); + panel.Spacing(5); + + panel.Children().Append(ui_get_icon(icon)); + + wchar_t* wlabel = str2wstr(label, nullptr); + TextBlock label = TextBlock(); + label.Text(wlabel); + panel.Children().Append(label); + free(wlabel); + + button.Content(panel); + } + else if (label) { wchar_t* wlabel = str2wstr(label, nullptr); button.Content(box_value(wlabel)); free(wlabel); } - // TODO: stockid + else if (icon) { + button.Content(ui_get_icon(icon)); + } } @@ -61,7 +87,7 @@ // create button with label Button button = Button(); - set_button_label(button, args.label, args.stockid); + set_button_label(button, args.label, args.stockid, args.icon, args.labeltype); // create toolkit wrapper object and register destructor UIElement elm = button; @@ -149,7 +175,7 @@ UiObject* current = uic_current_obj(obj); // set label - set_button_label(button, args.label, args.stockid); + set_button_label(button, args.label, args.stockid, args.icon, args.labeltype); togglebutton_register_callback(button, obj, args); // create toolkit wrapper object and register destructor @@ -236,7 +262,7 @@ UiObject* current = uic_current_obj(obj); // set label - set_button_label(button, args.label, args.stockid); + set_button_label(button, args.label, args.stockid, args.icon, args.labeltype); togglebutton_register_callback(button, obj, args); // create toolkit wrapper object and register destructor