+#endif
+}
+
+void
+wxRendererGTK::DrawDropArrow(wxWindow* win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ GtkWidget *button = wxGTKPrivate::GetButtonWidget();
+
+ // If we give WX_PIZZA(win->m_wxwindow)->bin_window as
+ // a window for gtk_paint_xxx function, then it won't
+ // work for wxMemoryDC. So that is why we assume wxDC
+ // is wxWindowDC (wxClientDC, wxMemoryDC and wxPaintDC
+ // are derived from it) and use its m_window.
+
+ // draw arrow so that there is even space horizontally
+ // on both sides
+ const int size = rect.width / 2;
+ const int x = rect.x + (size + 1) / 2;
+ const int y = rect.y + (rect.height - size + 1) / 2;
+
+ GtkStateType state;
+
+ if ( flags & wxCONTROL_PRESSED )
+ state = GTK_STATE_ACTIVE;
+ else if ( flags & wxCONTROL_DISABLED )
+ state = GTK_STATE_INSENSITIVE;
+ else if ( flags & wxCONTROL_CURRENT )
+ state = GTK_STATE_PRELIGHT;
+ else
+ state = GTK_STATE_NORMAL;
+
+#ifdef __WXGTK3__
+ cairo_t* cr = wxGetGTKDrawable(win, dc);
+ if (cr)
+ {
+ gtk_widget_set_state_flags(button, stateTypeToFlags[state], true);
+ GtkStyleContext* sc = gtk_widget_get_style_context(button);
+ gtk_render_arrow(sc, cr, G_PI, x, y, size);
+ }
+#else
+ GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
+ if (gdk_window == NULL)
+ return;
+ // draw arrow on button
+ gtk_paint_arrow
+ (
+ gtk_widget_get_style(button),
+ gdk_window,
+ state,
+ flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
+ NULL,
+ button,
+ "arrow",
+ GTK_ARROW_DOWN,
+ FALSE,
+ x, y,
+ size, size
+ );
+#endif
+}
+
+void
+wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ DrawPushButton(win,dc,rect,flags);
+ DrawDropArrow(win,dc,rect);
+}
+
+wxSize
+wxRendererGTK::GetCheckBoxSize(wxWindow *WXUNUSED(win))
+{
+ gint indicator_size, indicator_spacing;
+ gtk_widget_style_get(wxGTKPrivate::GetCheckButtonWidget(),
+ "indicator_size", &indicator_size,
+ "indicator_spacing", &indicator_spacing,
+ NULL);
+
+ int size = indicator_size + indicator_spacing * 2;
+ return wxSize(size, size);
+}
+
+void
+wxRendererGTK::DrawCheckBox(wxWindow* win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags )
+{
+ GtkWidget *button = wxGTKPrivate::GetCheckButtonWidget();
+
+ gint indicator_size, indicator_spacing;
+ gtk_widget_style_get(button,
+ "indicator_size", &indicator_size,
+ "indicator_spacing", &indicator_spacing,
+ NULL);
+
+#ifndef __WXGTK3__
+ GtkStateType state;
+
+ if ( flags & wxCONTROL_PRESSED )
+ state = GTK_STATE_ACTIVE;
+ else if ( flags & wxCONTROL_DISABLED )
+ state = GTK_STATE_INSENSITIVE;
+ else if ( flags & wxCONTROL_CURRENT )
+ state = GTK_STATE_PRELIGHT;
+ else
+ state = GTK_STATE_NORMAL;
+
+ GtkShadowType shadow_type;
+
+ if ( flags & wxCONTROL_UNDETERMINED )
+ shadow_type = GTK_SHADOW_ETCHED_IN;
+ else if ( flags & wxCONTROL_CHECKED )
+ shadow_type = GTK_SHADOW_IN;
+ else
+ shadow_type = GTK_SHADOW_OUT;
+#endif
+
+#ifdef __WXGTK3__
+ cairo_t* cr = wxGetGTKDrawable(win, dc);
+ if (cr)
+ {
+ int stateFlags = GTK_STATE_FLAG_NORMAL;
+ if (flags & wxCONTROL_CHECKED)
+ stateFlags = GTK_STATE_FLAG_ACTIVE;
+ if (flags & wxCONTROL_DISABLED)
+ stateFlags |= GTK_STATE_FLAG_INSENSITIVE;
+ if (flags & wxCONTROL_UNDETERMINED)
+ stateFlags |= GTK_STATE_FLAG_INCONSISTENT;
+ if (flags & wxCONTROL_CURRENT)
+ stateFlags |= GTK_STATE_FLAG_PRELIGHT;
+ GtkStyleContext* sc = gtk_widget_get_style_context(button);
+ gtk_style_context_save(sc);
+ gtk_style_context_set_state(sc, GtkStateFlags(stateFlags));
+ gtk_style_context_add_class(sc, GTK_STYLE_CLASS_CHECK);
+ gtk_render_check(sc, cr,
+ rect.x + (rect.width - indicator_size) / 2,
+ rect.y + (rect.height - indicator_size) / 2,
+ indicator_size, indicator_size);
+ gtk_style_context_restore(sc);
+ }
+#else
+ GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
+ if (gdk_window == NULL)
+ return;
+
+ gtk_paint_check
+ (
+ gtk_widget_get_style(button),
+ gdk_window,
+ state,
+ shadow_type,
+ NULL,
+ button,
+ "cellcheck",
+ dc.LogicalToDeviceX(rect.x) + indicator_spacing,
+ dc.LogicalToDeviceY(rect.y) + indicator_spacing,
+ indicator_size, indicator_size
+ );
+#endif
+}
+
+void
+wxRendererGTK::DrawPushButton(wxWindow* win,
+ wxDC& dc,
+ const wxRect& rect,
+ int flags)
+{
+ GtkWidget *button = wxGTKPrivate::GetButtonWidget();
+
+ // draw button
+ GtkStateType state;
+
+ if ( flags & wxCONTROL_PRESSED )
+ state = GTK_STATE_ACTIVE;
+ else if ( flags & wxCONTROL_DISABLED )
+ state = GTK_STATE_INSENSITIVE;
+ else if ( flags & wxCONTROL_CURRENT )
+ state = GTK_STATE_PRELIGHT;
+ else
+ state = GTK_STATE_NORMAL;
+
+#ifdef __WXGTK3__
+ cairo_t* cr = wxGetGTKDrawable(win, dc);
+ if (cr)
+ {
+ GtkStyleContext* sc = gtk_widget_get_style_context(button);
+ gtk_style_context_save(sc);
+ gtk_style_context_set_state(sc, stateTypeToFlags[state]);
+ gtk_render_background(sc, cr, rect.x, rect.y, rect.width, rect.height);
+ gtk_render_frame(sc, cr, rect.x, rect.y, rect.width, rect.height);
+ gtk_style_context_restore(sc);
+ }
+#else
+ GdkWindow* gdk_window = wxGetGTKDrawable(win, dc);
+ if (gdk_window == NULL)
+ return;