]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/renderer.cpp
missing commit
[wxWidgets.git] / src / gtk / renderer.cpp
index b65721598ccc31df1fc83cd5b1d4383aab59c622..de1ebc1728532f788cb570edfbf17fdc8ad2bac2 100644 (file)
@@ -650,16 +650,28 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
                                      int flags )
 {
     wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
+    if (drawable == NULL)
+        return;
 
-    if (drawable && (flags & wxCONTROL_SELECTED))
+    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(wxGTKPrivate::GetTreeWidget()),
+        gtk_paint_flat_box(gtk_widget_get_style(treeWidget),
                         drawable,
                         GTK_STATE_SELECTED,
                         GTK_SHADOW_NONE,
@@ -670,6 +682,7 @@ wxRendererGTK::DrawItemSelectionRect(wxWindow* win,
                         dc.LogicalToDeviceY(rect.y),
                         rect.width,
                         rect.height );
+#endif
     }
 
     if ((flags & wxCONTROL_CURRENT) && (flags & wxCONTROL_FOCUSED))
@@ -708,23 +721,29 @@ void wxRendererGTK::DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, i
 #endif
 }
 
-//TODO: GTK3 implementations for the remaining functions below
-
 // 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)
 {
-    GtkWidget *entry = wxGTKPrivate::GetTextEntryWidget();
-
     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),
@@ -739,14 +758,17 @@ void wxRendererGTK::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, in
         rect.width,
         rect.height
   );
+#endif
 }
 
 // Draw the equivalent of a wxComboBox
 void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
 {
-    GtkWidget *combo = wxGTKPrivate::GetComboBoxWidget();
-
     wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
+    if (drawable == NULL)
+        return;
+
+    GtkWidget* combo = wxGTKPrivate::GetComboBoxWidget();
 
     GtkStateType state = GTK_STATE_NORMAL;
     if ( flags & wxCONTROL_DISABLED )
@@ -754,9 +776,18 @@ void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, in
 
     gtk_widget_set_can_focus(combo, (flags & wxCONTROL_CURRENT) != 0);
 
-    if (drawable == NULL)
-        return;
-
+#ifdef __WXGTK3__
+    GtkStyleContext* sc = gtk_widget_get_style_context(combo);
+    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);
+    wxRect r = rect;
+    r.x += r.width - r.height;
+    r.width = r.height;
+    DrawComboBoxDropButton(win, dc, r, flags);
+#else
     gtk_paint_shadow
     (
         gtk_widget_get_style(combo),
@@ -814,9 +845,9 @@ void wxRendererGTK::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, in
         r.width,
         r.height-2
     );
+#endif
 }
 
-
 void wxRendererGTK::DrawChoice(wxWindow* win, wxDC& dc,
                            const wxRect& rect, int flags)
 {
@@ -827,12 +858,28 @@ void wxRendererGTK::DrawChoice(wxWindow* win, wxDC& dc,
 // Draw a themed radio button
 void wxRendererGTK::DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
 {
-    GtkWidget *button = wxGTKPrivate::GetRadioButtonWidget();
-
     wxGTKDrawable* drawable = wxGetGTKDrawable(win, dc);
     if (drawable == NULL)
         return;
 
+    GtkWidget* button = wxGTKPrivate::GetRadioButtonWidget();
+
+#ifdef __WXGTK3__
+    int state = GTK_STATE_FLAG_NORMAL;
+    if (flags & wxCONTROL_CHECKED)
+        state = GTK_STATE_FLAG_ACTIVE;
+    else if (flags & wxCONTROL_UNDETERMINED)
+        state = GTK_STATE_FLAG_INCONSISTENT;
+    if (flags & wxCONTROL_DISABLED)
+        state |= GTK_STATE_FLAG_INSENSITIVE;
+
+    GtkStyleContext* sc = gtk_widget_get_style_context(button);
+    gtk_style_context_save(sc);
+    gtk_style_context_add_class(sc, GTK_STYLE_CLASS_RADIO);
+    gtk_style_context_set_state(sc, GtkStateFlags(state));
+    gtk_render_option(sc, drawable, rect.x, rect.y, rect.width, rect.height); 
+    gtk_style_context_restore(sc);
+#else
     GtkShadowType shadow_type = GTK_SHADOW_OUT;
     if ( flags & wxCONTROL_CHECKED )
         shadow_type = GTK_SHADOW_IN;
@@ -862,4 +909,5 @@ void wxRendererGTK::DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect,
         dc.LogicalToDeviceY(rect.y),
         rect.width, rect.height
     );
+#endif
 }