Improve look of GtkScrolledWindow on Windows by implementing a

2007-03-08  Mathias Hasselmann <mathias.hasselmann@gmx.de>

	* gtk/gtkscrolledindow.c: Improve look of GtkScrolledWindow on Windows
	by implementing a scrollbars-within-bevel style property. (#168326)

svn path=/trunk/; revision=17425
This commit is contained in:
Mathias Hasselmann
2007-03-08 02:33:15 +00:00
committed by Dom Lachowicz
parent 4312d351ec
commit 439fd2147f
3 changed files with 74 additions and 5 deletions

View File

@@ -1,3 +1,8 @@
2007-03-08 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* gtk/gtkscrolledindow.c: Improve look of GtkScrolledWindow on Windows
by implementing a scrollbars-within-bevel style property. (#168326)
2007-03-08 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* gtk/gtkfilesystemwin32.c: Use Windows shell icons. Icons are

View File

@@ -280,6 +280,13 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
GTK_SHADOW_NONE,
GTK_PARAM_READABLE | GTK_PARAM_WRITABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("scrollbars-within-bevel",
P_("Scrollbars within bevel"),
P_("Place scrollbars within the scrolled window's bevel"),
FALSE,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("scrollbar-spacing",
P_("Scrollbar spacing"),
@@ -938,17 +945,43 @@ static void
gtk_scrolled_window_paint (GtkWidget *widget,
GdkRectangle *area)
{
GtkAllocation relative_allocation;
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
{
GtkAllocation relative_allocation;
gboolean scrollbars_within_bevel;
gint scrollbar_spacing;
gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
scrollbar_spacing = _gtk_scrolled_window_get_scrollbar_spacing (scrolled_window);
relative_allocation.x -= widget->style->xthickness;
relative_allocation.y -= widget->style->ythickness;
relative_allocation.width += 2 * widget->style->xthickness;
relative_allocation.height += 2 * widget->style->ythickness;
if (scrollbars_within_bevel)
{
if (GTK_WIDGET_VISIBLE (scrolled_window->hscrollbar))
{
gint dy = scrolled_window->hscrollbar->allocation.height + scrollbar_spacing;
relative_allocation.height += dy;
if (relative_allocation.y)
relative_allocation.y -= dy;
}
if (GTK_WIDGET_VISIBLE (scrolled_window->vscrollbar))
{
gint dx = scrolled_window->vscrollbar->allocation.width + scrollbar_spacing;
relative_allocation.width += dx;
if (relative_allocation.x)
relative_allocation.x -= dx;
}
}
gtk_paint_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, scrolled_window->shadow_type,
@@ -1291,6 +1324,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
GtkBin *bin;
GtkAllocation relative_allocation;
GtkAllocation child_allocation;
gboolean scrollbars_within_bevel;
gint scrollbar_spacing;
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (widget));
@@ -1300,6 +1334,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
bin = GTK_BIN (scrolled_window);
scrollbar_spacing = _gtk_scrolled_window_get_scrollbar_spacing (scrolled_window);
gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
priv = GTK_SCROLLED_WINDOW_GET_PRIVATE (scrolled_window);
@@ -1389,8 +1424,20 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
{
child_allocation.x -= widget->style->xthickness;
child_allocation.width += 2 * widget->style->xthickness;
if (!scrollbars_within_bevel)
{
child_allocation.x -= widget->style->xthickness;
child_allocation.width += 2 * widget->style->xthickness;
}
else if (GTK_CORNER_TOP_RIGHT == priv->real_window_placement ||
GTK_CORNER_TOP_LEFT == priv->real_window_placement)
{
child_allocation.y -= widget->style->ythickness;
}
else
{
child_allocation.y += widget->style->ythickness;
}
}
gtk_widget_size_allocate (scrolled_window->hscrollbar, &child_allocation);
@@ -1429,8 +1476,20 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
{
child_allocation.y -= widget->style->ythickness;
child_allocation.height += 2 * widget->style->ythickness;
if (!scrollbars_within_bevel)
{
child_allocation.y -= widget->style->ythickness;
child_allocation.height += 2 * widget->style->ythickness;
}
else if (GTK_CORNER_BOTTOM_LEFT == priv->real_window_placement ||
GTK_CORNER_TOP_LEFT == priv->real_window_placement)
{
child_allocation.x -= widget->style->xthickness;
}
else
{
child_allocation.x += widget->style->xthickness;
}
}
gtk_widget_size_allocate (scrolled_window->vscrollbar, &child_allocation);

View File

@@ -830,6 +830,11 @@ setup_msw_rc_style (void)
11);
gtk_rc_parse_string (buf);
gtk_rc_parse_string (
"style \"msw-scrolled-window\" = \"msw-default\"\n"
"{GtkScrolledWindow::scrollbars-within-bevel = 1}\n"
"class \"GtkScrolledWindow\" style \"msw-scrolled-window\"\n");
/* radio/check button sizes */
g_snprintf (buf, sizeof (buf),
"style \"msw-checkbutton\" = \"msw-button\"\n"