+ static GtkWidget* s_widget;
+ if (s_widget == NULL)
+ {
+ s_widget = gtk_menu_item_new();
+ gtk_container_add(ContainerWidget(), s_widget);
+#ifndef __WXGTK3__
+ gtk_widget_ensure_style(s_widget);
+#endif
+ }
+ 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* ToolTipWidget()
+{
+ static GtkWidget* s_widget;
+ if (s_widget == NULL)
+ {
+ s_widget = gtk_window_new(GTK_WINDOW_POPUP);
+ const char* name = "gtk-tooltip";
+#ifndef __WXGTK3__
+ if (gtk_check_version(2, 11, 0))
+ name = "gtk-tooltips";
+#endif
+ gtk_widget_set_name(s_widget, name);
+#ifndef __WXGTK3__
+ gtk_widget_ensure_style(s_widget);
+#endif
+ }
+ return s_widget;
+}
+
+#ifdef __WXGTK3__
+static void bg(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
+{
+ GtkStyleContext* sc = gtk_widget_get_style_context(widget);
+ gtk_style_context_get_background_color(sc, state, &gdkRGBA);
+}
+static void fg(GtkWidget* widget, GtkStateFlags state, GdkRGBA& gdkRGBA)
+{
+ GtkStyleContext* sc = gtk_widget_get_style_context(widget);
+ gtk_style_context_get_color(sc, state, &gdkRGBA);
+}
+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);
+}
+
+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_SELECTED, gdkRGBA);
+ break;
+ case wxSYS_COLOUR_MENUTEXT:
+ fg(MenuItemWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
+ break;
+ case wxSYS_COLOUR_APPWORKSPACE:
+ case wxSYS_COLOUR_WINDOW:
+ bg(TextCtrlWidget(), GTK_STATE_FLAG_NORMAL, gdkRGBA);
+ 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);
+}
+#else
+static const GtkStyle* ButtonStyle()
+{
+ return gtk_widget_get_style(ButtonWidget());
+}
+
+static const GtkStyle* ListStyle()
+{
+ return gtk_widget_get_style(ListWidget());
+}
+
+static const GtkStyle* TextCtrlStyle()
+{
+ return gtk_widget_get_style(TextCtrlWidget());
+}
+
+static const GtkStyle* MenuItemStyle()
+{
+ return gtk_widget_get_style(MenuItemWidget());
+}
+
+static const GtkStyle* MenuBarStyle()
+{
+ return gtk_widget_get_style(MenuBarWidget());
+}
+
+static const GtkStyle* ToolTipStyle()
+{
+ return gtk_widget_get_style(ToolTipWidget());
+}
+
+wxColour wxSystemSettingsNative::GetColour( wxSystemColour index )
+{
+ wxColor color;