static GtkWidget* MenuItemWidget() { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_menu_item_new(); gtk_container_add(ContainerWidget(), s_widget); gtk_widget_ensure_style(s_widget); } return s_widget; }
static GtkWidget* TextCtrlWidget() { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_text_view_new(); gtk_container_add(ContainerWidget(), s_widget); gtk_widget_ensure_style(s_widget); } return s_widget; }
static const GtkStyle* MenuBarStyle() { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_menu_bar_new(); gtk_container_add(ContainerWidget(), s_widget); gtk_widget_ensure_style(s_widget); } return s_widget->style; }
static void border(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA) { GtkStyleContext* sc = gtk_widget_get_style_context(widget); gtk_style_context_get_border_color(sc, state, &gdkRGBA); if (gdkRGBA.alpha <= 0) { widget = gtk_widget_get_parent(GTK_WIDGET(ContainerWidget())); sc = gtk_widget_get_style_context(widget); gtk_style_context_get_border_color(sc, state, &gdkRGBA); } }
static GtkWidget* ListWidget() { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_tree_view_new_with_model( GTK_TREE_MODEL(gtk_list_store_new(1, G_TYPE_INT))); gtk_container_add(ContainerWidget(), s_widget); gtk_widget_ensure_style(s_widget); } return s_widget; }
static GtkWidget* ButtonWidget() { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_button_new(); gtk_container_add(ContainerWidget(), s_widget); gtk_widget_ensure_style(s_widget); g_signal_connect(s_widget, "style_set", G_CALLBACK(style_set), NULL); } return s_widget; }
static GtkWidget* MenuBarWidget() { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_menu_bar_new(); gtk_container_add(ContainerWidget(), s_widget); #ifndef __WXGTK3__ gtk_widget_ensure_style(s_widget); #endif } return s_widget; }
static GtkWidget* ButtonWidget() { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_button_new(); gtk_container_add(ContainerWidget(), s_widget); #ifdef __WXGTK3__ g_signal_connect(s_widget, "style_updated", G_CALLBACK(style_updated), NULL); #else gtk_widget_ensure_style(s_widget); g_signal_connect(s_widget, "style_set", G_CALLBACK(style_set), NULL); #endif } return s_widget; }
wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) { GdkRGBA gdkRGBA = { 0, 0, 0, 1 }; switch (index) { case wxSYS_COLOUR_3DLIGHT: case wxSYS_COLOUR_ACTIVEBORDER: case wxSYS_COLOUR_BTNFACE: case wxSYS_COLOUR_DESKTOP: case wxSYS_COLOUR_INACTIVEBORDER: case wxSYS_COLOUR_INACTIVECAPTION: case wxSYS_COLOUR_SCROLLBAR: case wxSYS_COLOUR_WINDOWFRAME: bg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_BTNHIGHLIGHT: case wxSYS_COLOUR_HIGHLIGHT: bg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA); break; case wxSYS_COLOUR_BTNSHADOW: border(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_BTNTEXT: case wxSYS_COLOUR_WINDOWTEXT: fg(ButtonWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_GRAYTEXT: case wxSYS_COLOUR_INACTIVECAPTIONTEXT: fg(ButtonWidget(), GTK_STATE_FLAG_INSENSITIVE, gdkRGBA); break; case wxSYS_COLOUR_HIGHLIGHTTEXT: fg(ButtonWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA); break; case wxSYS_COLOUR_HOTLIGHT: { static GtkWidget* s_widget; if (s_widget == NULL) { s_widget = gtk_link_button_new(""); gtk_container_add(ContainerWidget(), s_widget); } fg(s_widget, GTK_STATE_FLAG_NORMAL, gdkRGBA); } break; case wxSYS_COLOUR_INFOBK: bg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_INFOTEXT: fg(ToolTipWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_LISTBOX: bg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT: fg(ListWidget(), GTK_STATE_FLAG_SELECTED, gdkRGBA); break; case wxSYS_COLOUR_LISTBOXTEXT: fg(ListWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_MENU: bg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_MENUBAR: bg(MenuBarWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_ACTIVECAPTION: case wxSYS_COLOUR_MENUHILIGHT: bg(MenuItemWidget(), GTK_STATE_FLAG_PRELIGHT, gdkRGBA); break; case wxSYS_COLOUR_MENUTEXT: fg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA); break; case wxSYS_COLOUR_APPWORKSPACE: case wxSYS_COLOUR_WINDOW: { GtkWidget* widget = TextCtrlWidget(); GtkStyleContext* sc = gtk_widget_get_style_context(widget); gtk_style_context_save(sc); gtk_style_context_add_class(sc, GTK_STYLE_CLASS_VIEW); bg(widget, GTK_STATE_FLAG_NORMAL, gdkRGBA); gtk_style_context_restore(sc); } break; case wxSYS_COLOUR_CAPTIONTEXT: { GdkRGBA c = { 1, 1, 1, 1 }; gdkRGBA = c; } break; default: wxFAIL_MSG("unknown system colour index"); // fallthrough case wxSYS_COLOUR_3DDKSHADOW: case wxSYS_COLOUR_GRADIENTACTIVECAPTION: case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: // black break; } return wxColour(gdkRGBA); }