From 1f9978e7d21268c12b059793493f7563a00b32f8 Mon Sep 17 00:00:00 2001 From: "jonas%sicking.cc" Date: Thu, 15 Nov 2007 03:47:16 +0000 Subject: [PATCH] relanding bug 118312 since it doesn't look to be the source of the Ts regression --- toolkit/themes/gnomestripe/global/tree.css | 15 +------ widget/src/gtk2/gtk2drawing.c | 51 +++++++++++++++++++++- widget/src/gtk2/gtkdrawing.h | 10 +++++ widget/src/gtk2/nsNativeThemeGTK.cpp | 24 +++++++++- 4 files changed, 84 insertions(+), 16 deletions(-) diff --git a/toolkit/themes/gnomestripe/global/tree.css b/toolkit/themes/gnomestripe/global/tree.css index d175d66fcdd..0a77559f8c0 100644 --- a/toolkit/themes/gnomestripe/global/tree.css +++ b/toolkit/themes/gnomestripe/global/tree.css @@ -171,19 +171,6 @@ tree[seltype="text"] > treechildren::-moz-tree-cell-text(active, selected, curre border: 1px dotted #C0C0C0; } -/* ::::: lines connecting cells ::::: */ - -tree[seltype="cell"] > treechildren::-moz-tree-line, -tree[seltype="text"] > treechildren::-moz-tree-line, -treechildren::-moz-tree-line { - border: 1px dotted ThreeDShadow; -} - -tree[seltype="cell"] > treechildren::-moz-tree-line(active, selected, focus), -treechildren::-moz-tree-line(selected, focus) { - border: 1px dotted HighlightText; -} - /* ::::: tree separator ::::: */ @@ -323,6 +310,7 @@ treechildren::-moz-tree-column(insertafter) { /* ::::: twisty ::::: */ treechildren::-moz-tree-twisty { + -moz-appearance: treetwisty; padding-right: 4px; padding-top: 1px; width: 9px; /* The image's width is 9 pixels */ @@ -330,6 +318,7 @@ treechildren::-moz-tree-twisty { } treechildren::-moz-tree-twisty(open) { + -moz-appearance: treetwistyopen; width: 9px; /* The image's width is 9 pixels */ list-style-image: url("chrome://global/skin/tree/twisty-open.png"); } diff --git a/widget/src/gtk2/gtk2drawing.c b/widget/src/gtk2/gtk2drawing.c index 32293a2f9b7..936041d7d03 100644 --- a/widget/src/gtk2/gtk2drawing.c +++ b/widget/src/gtk2/gtk2drawing.c @@ -81,6 +81,7 @@ static GtkWidget* gCheckMenuItemWidget; static GtkWidget* gTreeViewWidget; static GtkWidget* gTreeHeaderCellWidget; static GtkWidget* gTreeHeaderSortArrowWidget; +static GtkWidget* gExpanderWidget; static GtkShadowType gMenuBarShadowType; static GtkShadowType gToolbarShadowType; @@ -376,7 +377,17 @@ ensure_tree_header_cell_widget() gTreeHeaderSortArrowWidget = treeViewColumn->arrow; } return MOZ_GTK_SUCCESS; -} +} + +static gint +ensure_expander_widget() +{ + if (!gExpanderWidget) { + gExpanderWidget = gtk_expander_new("M"); + setup_widget_prototype(gExpanderWidget); + } + return MOZ_GTK_SUCCESS; +} static GtkStateType ConvertGtkState(GtkWidgetState* state) @@ -1080,6 +1091,28 @@ moz_gtk_tree_header_sort_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect, return MOZ_GTK_SUCCESS; } +static gint +moz_gtk_expander_paint(GdkDrawable* drawable, GdkRectangle* rect, + GdkRectangle* cliprect, GtkWidgetState* state, + GtkExpanderStyle expander_state) +{ + GtkStyle *style; + GtkStateType state_type; + + ensure_expander_widget(); + style = gExpanderWidget->style; + + /* Because the frame we get is of the entire treeview, we can't get the precise + * event state of one expander, thus rendering hover and active feedback useless. */ + state_type = state->disabled ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL; + + TSOffsetStyleGCs(style, rect->x, rect->y); + gtk_paint_expander(style, drawable, state_type, cliprect, gExpanderWidget, "expander", + rect->x + rect->width / 2, rect->y + rect->height / 2, expander_state); + + return MOZ_GTK_SUCCESS; +} + static gint moz_gtk_option_menu_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state) @@ -1823,6 +1856,7 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* left, gint* top, case MOZ_GTK_GRIPPER: case MOZ_GTK_PROGRESS_CHUNK: case MOZ_GTK_TAB: + case MOZ_GTK_EXPANDER: /* These widgets have no borders.*/ case MOZ_GTK_TOOLTIP: case MOZ_GTK_WINDOW: @@ -1860,6 +1894,17 @@ moz_gtk_get_dropdown_arrow_size(gint* width, gint* height) return MOZ_GTK_SUCCESS; } +gint +moz_gtk_get_expander_size(gint* size) +{ + ensure_expander_widget(); + gtk_widget_style_get(gExpanderWidget, + "expander-size", size, + NULL); + + return MOZ_GTK_SUCCESS; +} + gint moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height) { @@ -1950,6 +1995,9 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable, case MOZ_GTK_TREE_HEADER_SORTARROW: return moz_gtk_tree_header_sort_arrow_paint(drawable, rect, cliprect, state, (GtkArrowType) flags); break; + case MOZ_GTK_EXPANDER: + return moz_gtk_expander_paint(drawable, rect, cliprect, state, (GtkExpanderStyle) flags); + break; case MOZ_GTK_ENTRY: return moz_gtk_entry_paint(drawable, rect, cliprect, state); break; @@ -2060,6 +2108,7 @@ moz_gtk_shutdown() gTreeViewWidget = NULL; gTreeHeaderCellWidget = NULL; gTreeHeaderSortArrowWidget = NULL; + gExpanderWidget = NULL; is_initialized = FALSE; diff --git a/widget/src/gtk2/gtkdrawing.h b/widget/src/gtk2/gtkdrawing.h index 25365b109c4..8715765a5a2 100644 --- a/widget/src/gtk2/gtkdrawing.h +++ b/widget/src/gtk2/gtkdrawing.h @@ -159,6 +159,8 @@ typedef enum { MOZ_GTK_TREE_HEADER_CELL, /* Paints sort arrows in treeheader cells */ MOZ_GTK_TREE_HEADER_SORTARROW, + /* Paints a GtkExpander for treeviews */ + MOZ_GTK_EXPANDER, /* Paints the background of the menu bar. */ MOZ_GTK_MENUBAR, /* Paints the background of menus, context menus. */ @@ -291,6 +293,14 @@ moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics); */ gint moz_gtk_get_dropdown_arrow_size(gint* width, gint* height); +/** + * Get the size of a treeview's expander (we call them twisties) + * size: [OUT] the size of the GTK expander, size = width = height. + * + * returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise + */ +gint moz_gtk_get_expander_size(gint* size); + /** * Retrieve an actual GTK scrollbar widget for style analysis. It will not * be modified. diff --git a/widget/src/gtk2/nsNativeThemeGTK.cpp b/widget/src/gtk2/nsNativeThemeGTK.cpp index 830f582f830..289b5d387fc 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -403,6 +403,16 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame, } aGtkWidgetType = MOZ_GTK_TREE_HEADER_SORTARROW; break; + case NS_THEME_TREEVIEW_TWISTY: + aGtkWidgetType = MOZ_GTK_EXPANDER; + if (aWidgetFlags) + *aWidgetFlags = GTK_EXPANDER_COLLAPSED; + break; + case NS_THEME_TREEVIEW_TWISTY_OPEN: + aGtkWidgetType = MOZ_GTK_EXPANDER; + if (aWidgetFlags) + *aWidgetFlags = GTK_EXPANDER_EXPANDED; + break; case NS_THEME_DROPDOWN: aGtkWidgetType = MOZ_GTK_DROPDOWN; break; @@ -888,6 +898,16 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext, // same as Windows to make our lives easier aResult->width = aResult->height = 15; break; + case NS_THEME_TREEVIEW_TWISTY: + case NS_THEME_TREEVIEW_TWISTY_OPEN: + { + gint expander_size; + + moz_gtk_get_expander_size(&expander_size); + aResult->width = aResult->height = expander_size; + *aIsOverridable = PR_FALSE; + } + break; } return NS_OK; } @@ -982,12 +1002,12 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext, // case NS_THEME_LISTBOX_LISTITEM: case NS_THEME_TREEVIEW: // case NS_THEME_TREEVIEW_TREEITEM: - // case NS_THEME_TREEVIEW_TWISTY: + case NS_THEME_TREEVIEW_TWISTY: // case NS_THEME_TREEVIEW_LINE: // case NS_THEME_TREEVIEW_HEADER: case NS_THEME_TREEVIEW_HEADER_CELL: case NS_THEME_TREEVIEW_HEADER_SORTARROW: - // case NS_THEME_TREEVIEW_TWISTY_OPEN: + case NS_THEME_TREEVIEW_TWISTY_OPEN: case NS_THEME_PROGRESSBAR: case NS_THEME_PROGRESSBAR_CHUNK: case NS_THEME_PROGRESSBAR_VERTICAL: