Skip to content
Browse files

win32: fix expander rendering for horizontal GtkToolItemGroups

Expanders are usually drawn as little triangles and unfortunately
do not support rotated drawing modes. So a hack is applied (see
gtk_tool_item_group_header_expose_event_cb for details) when
drawing a GtkToolItemGroup's header for horizontal GtkToolShells,
forcing the triangle to point in the right direction. Except we
don't draw expanders as triangles on Windows. Usually, expanders
are represented as "+" and "-". It sucks for "+" to become "-" and
the inverse when we don't want to, so reverse the hack here.
  • Loading branch information...
1 parent d9906a9 commit 7cfefd6e98e02c3dc3f80673f70ca6789d12bccc @dieterv dieterv committed Dec 7, 2011
Showing with 32 additions and 8 deletions.
  1. +32 −8 modules/engines/ms-windows/msw_style.c
View
40 modules/engines/ms-windows/msw_style.c
@@ -1034,32 +1034,56 @@ draw_check (GtkStyle *style,
}
static void
-draw_expander (GtkStyle *style,
- GdkWindow *window,
- GtkStateType state,
- GdkRectangle *area,
- GtkWidget *widget,
- const gchar *detail,
- gint x, gint y, GtkExpanderStyle expander_style)
+draw_expander (GtkStyle *style,
+ GdkWindow *window,
+ GtkStateType state,
+ GdkRectangle *area,
+ GtkWidget *widget,
+ const gchar *detail,
+ gint x,
+ gint y,
+ GtkExpanderStyle expander_style)
{
cairo_t *cr = gdk_cairo_create (window);
gint expander_size;
gint expander_semi_size;
XpThemeElement xp_expander;
+ GtkOrientation orientation;
gtk_widget_style_get (widget, "expander_size", &expander_size, NULL);
+ if (DETAIL("tool-palette-header"))
+ {
+ /* Expanders are usually drawn as little triangles and unfortunately
+ * do not support rotated drawing modes. So a hack is applied (see
+ * gtk_tool_item_group_header_expose_event_cb for details) when
+ * drawing a GtkToolItemGroup's header for horizontal GtkToolShells,
+ * forcing the triangle to point in the right direction. Except we
+ * don't draw expanders as triangles on Windows. Usually, expanders
+ * are represented as "+" and "-". It sucks for "+" to become "-" and
+ * the inverse when we don't want to, so reverse the hack here. */
+
+ orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (widget));
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ expander_style = GTK_EXPANDER_EXPANDED - expander_style;
+ }
+
switch (expander_style)
{
case GTK_EXPANDER_COLLAPSED:
case GTK_EXPANDER_SEMI_COLLAPSED:
xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED;
break;
- default:
+ case GTK_EXPANDER_EXPANDED:
+ case GTK_EXPANDER_SEMI_EXPANDED:
xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED;
break;
+
+ default:
+ g_assert_not_reached ();
}
if ((expander_size % 2) == 0)

0 comments on commit 7cfefd6

Please sign in to comment.
Something went wrong with that request. Please try again.