+ gtk_widget_get_style(button),
+ gdk_window,
+ state,
+ flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
+ NULL,
+ button,
+ "button",
+ dc.LogicalToDeviceX(rect.x),
+ dc.LogicalToDeviceY(rect.y),
+ rect.width,
+ rect.height
+ );
+#endif
+}
+
+void
+wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags )
+{
+ wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
+ if (drawable == NULL)
+ return;
+
+ if (flags & wxCONTROL_SELECTED)
+ {
+ int x_diff = 0;
+ if (win->GetLayoutDirection() == wxLayout_RightToLeft)
+ x_diff = rect.width;
+
+ GtkWidget* treeWidget = wxGTKPrivate::GetTreeWidget();
+
+#ifdef __WXGTK3__
+ GtkStyleContext* sc = gtk_widget_get_style_context(treeWidget);
+ gtk_style_context_save(sc);
+ gtk_style_context_set_state(sc, GTK_STATE_FLAG_SELECTED);
+ gtk_style_context_add_class(sc, GTK_STYLE_CLASS_CELL);
+ gtk_render_background(sc, drawable, rect.x - x_diff, rect.y, rect.width, rect.height);
+ gtk_style_context_restore(sc);
+#else
+ // the wxCONTROL_FOCUSED state is deduced
+ // directly from the m_wxwindow by GTK+
+ gtk_paint_flat_box(gtk_widget_get_style(treeWidget),
+ drawable,
+ GTK_STATE_SELECTED,
+ GTK_SHADOW_NONE,
+ NULL_RECT
+ win->m_wxwindow,
+ "cell_even",
+ dc.LogicalToDeviceX(rect.x) - x_diff,
+ dc.LogicalToDeviceY(rect.y),
+ rect.width,
+ rect.height );
+#endif
+ }
+
+ if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED))
+ DrawFocusRect(win, dc, rect, flags);
+}
+
+void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
+{
+ wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
+ if (drawable == NULL)
+ return;
+
+ GtkStateType state;
+ if (flags & wxCONTROL_SELECTED)
+ state = GTK_STATE_SELECTED;
+ else
+ state = GTK_STATE_NORMAL;
+
+#ifdef __WXGTK3__
+ GtkStyleContext* sc = gtk_widget_get_style_context(win->m_widget);
+ gtk_style_context_save(sc);
+ gtk_style_context_set_state(sc, stateTypeToFlags[state]);
+ gtk_render_focus(sc, drawable, rect.x, rect.y, rect.width, rect.height);
+ gtk_style_context_restore(sc);
+#else
+ gtk_paint_focus( gtk_widget_get_style(win->m_widget),
+ drawable,
+ state,
+ NULL_RECT
+ win->m_wxwindow,
+ NULL,
+ dc.LogicalToDeviceX(rect.x),
+ dc.LogicalToDeviceY(rect.y),
+ rect.width,
+ rect.height );
+#endif
+}
+
+// Uses the theme to draw the border and fill for something like a wxTextCtrl
+void wxRendererGTK::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
+{
+ wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
+ if (drawable == NULL)
+ return;
+
+ GtkWidget* entry = wxGTKPrivate::GetTextEntryWidget();
+
+ GtkStateType state = GTK_STATE_NORMAL;
+ if ( flags & wxCONTROL_DISABLED )
+ state = GTK_STATE_INSENSITIVE;
+
+ gtk_widget_set_can_focus(entry, (flags & wxCONTROL_CURRENT) != 0);
+
+#ifdef __WXGTK3__
+ GtkStyleContext* sc = gtk_widget_get_style_context(entry);
+ gtk_style_context_save(sc);
+ gtk_style_context_set_state(sc, stateTypeToFlags[state]);
+ gtk_render_background(sc, drawable, rect.x, rect.y, rect.width, rect.height);
+ gtk_render_frame(sc, drawable, rect.x, rect.y, rect.width, rect.height);
+ gtk_style_context_restore(sc);
+#else
+ gtk_paint_shadow
+ (
+ gtk_widget_get_style(entry),
+ drawable,
+ state,