Fix G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE

Mon Apr  2 10:47:57 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.c (gtk_widget_class_init): Fix
	G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
	stupidity.

Mon Apr  2 00:51:11 2001  Owen Taylor  <otaylor@redhat.com>

	[ First pass at adding style properties. Still needs some definite
	fine-tuning. ]

        * gtk/gtkbutton.c: Add ::default_spacing style property.

	* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
	::indicator_spacing style properties.

	* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
	style properties.

	* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
	rather than a normal property.

	* gtk/gtkwidget.c: Add an ::interior_focus style property to
	draw focus inside buttons, in the Windows/Java Metal/etc. style.

	* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
	Honor ::interior_focus.

	* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
	TRUE.

	* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
	Add ::slider_width, ::trough_border, ::stepper_size,
	::stepper_spacing style properties.

	* gtk/gtkscale.[ch] Add ::slider-length style property.
This commit is contained in:
Owen Taylor 2001-04-02 15:51:28 +00:00 committed by Owen Taylor
parent 5d1ee0929e
commit c944151a3c
29 changed files with 890 additions and 354 deletions

View File

@ -1,3 +1,40 @@
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:

View File

@ -1,3 +1,40 @@
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:

View File

@ -1,3 +1,40 @@
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:

View File

@ -1,3 +1,40 @@
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:

View File

@ -1,3 +1,40 @@
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:

View File

@ -1,3 +1,40 @@
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:

View File

@ -1,3 +1,40 @@
Mon Apr 2 10:47:57 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.c (gtk_widget_class_init): Fix
G_VALUE_NO_COPY_CONTENTS instead of G_SIGNAL_TYPE_STATIC_SCOPE
stupidity.
Mon Apr 2 00:51:11 2001 Owen Taylor <otaylor@redhat.com>
[ First pass at adding style properties. Still needs some definite
fine-tuning. ]
* gtk/gtkbutton.c: Add ::default_spacing style property.
* gtk/gtkcheckbutton.[ch] gtkradiobutton.c: Add ::indicator_size,
::indicator_spacing style properties.
* gtk/gtkoptionmenu.c: Add ::indicator_size, ::indicator_spacing
style properties.
* gtk/gtk{,h,v}paned.[ch]: Make handle_size a style property
rather than a normal property.
* gtk/gtkwidget.c: Add an ::interior_focus style property to
draw focus inside buttons, in the Windows/Java Metal/etc. style.
* gtk/gtkbutton.c gtk/gtkcheckbutton.c gtk/gtktogglenbutton.c:
Honor ::interior_focus.
* gtk/gtkentry.c: Don't draw focus at all when ::interior_focus is
TRUE.
* gtk/gtkrange.[ch] gtk/gtk{h,v}scrollbar.c gtk/gtk{h,v}scale.c:
Add ::slider_width, ::trough_border, ::stepper_size,
::stepper_spacing style properties.
* gtk/gtkscale.[ch] Add ::slider-length style property.
2001-04-02 Alexander Larsson <alexl@redhat.com>
* gdk/linux-fb/gdkwindow-fb.c:

View File

@ -36,8 +36,6 @@
#include "gtkintl.h"
#define CHILD_SPACING 1
#define DEFAULT_LEFT_POS 4
#define DEFAULT_TOP_POS 4
#define DEFAULT_SPACING 7
/* Time out before giving up on getting a key release when animatng
@ -233,6 +231,15 @@ gtk_button_class_init (GtkButtonClass *klass)
gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
widget_class->activate_signal = button_signals[ACTIVATE];
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("default_spacing",
_("Default Spacing"),
_("Extra space to add for CAN_DEFAULT buttons"),
0,
G_MAXINT,
DEFAULT_SPACING,
G_PARAM_READABLE));
}
static void
@ -531,18 +538,30 @@ gtk_button_unrealize (GtkWidget *widget)
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
gtk_button_get_props (GtkButton *button,
gint *default_spacing,
gboolean *interior_focus)
{
GtkWidget *widget = GTK_WIDGET (button);
if (default_spacing)
gtk_widget_style_get (widget, "default_spacing", default_spacing, NULL);
if (interior_focus)
gtk_widget_style_get (widget, "interior_focus", interior_focus, NULL);
}
static void
gtk_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkButton *button;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BUTTON (widget));
g_return_if_fail (requisition != NULL);
button = GTK_BUTTON (widget);
GtkButton *button = GTK_BUTTON (widget);
gint default_spacing;
gboolean interior_focus;
gtk_button_get_props (button, &default_spacing, &interior_focus);
requisition->width = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
GTK_WIDGET (widget)->style->xthickness) * 2;
requisition->height = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
@ -551,9 +570,9 @@ gtk_button_size_request (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (widget))
{
requisition->width += (GTK_WIDGET (widget)->style->xthickness * 2 +
DEFAULT_SPACING);
default_spacing);
requisition->height += (GTK_WIDGET (widget)->style->ythickness * 2 +
DEFAULT_SPACING);
default_spacing);
}
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
@ -565,22 +584,29 @@ gtk_button_size_request (GtkWidget *widget,
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
if (interior_focus)
{
requisition->width += 2;
requisition->height += 2;
}
}
static void
gtk_button_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkButton *button;
GtkButton *button = GTK_BUTTON (widget);
GtkAllocation child_allocation;
gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BUTTON (widget));
g_return_if_fail (allocation != NULL);
gint border_width = GTK_CONTAINER (widget)->border_width;
gint xthickness = GTK_WIDGET (widget)->style->xthickness;
gint ythickness = GTK_WIDGET (widget)->style->ythickness;
gint default_spacing;
gtk_button_get_props (button, &default_spacing, NULL);
widget->allocation = *allocation;
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
@ -589,12 +615,10 @@ gtk_button_size_allocate (GtkWidget *widget,
widget->allocation.width - border_width * 2,
widget->allocation.height - border_width * 2);
button = GTK_BUTTON (widget);
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
child_allocation.x = (CHILD_SPACING + GTK_WIDGET (widget)->style->xthickness);
child_allocation.y = (CHILD_SPACING + GTK_WIDGET (widget)->style->ythickness);
child_allocation.x = (CHILD_SPACING + xthickness);
child_allocation.y = (CHILD_SPACING + ythickness);
child_allocation.width = MAX (1, (gint)widget->allocation.width - child_allocation.x * 2 -
border_width * 2);
@ -604,13 +628,13 @@ gtk_button_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (button))
{
child_allocation.x += (GTK_WIDGET (widget)->style->xthickness +
DEFAULT_LEFT_POS);
(1 + default_spacing) / 2);
child_allocation.y += (GTK_WIDGET (widget)->style->ythickness +
DEFAULT_TOP_POS);
(1 + default_spacing) / 2);
child_allocation.width = MAX (1, (gint)child_allocation.width -
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + DEFAULT_SPACING));
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + default_spacing));
child_allocation.height = MAX (1, (gint)child_allocation.height -
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + DEFAULT_SPACING));
(gint)(GTK_WIDGET (widget)->style->xthickness * 2 + default_spacing));
}
gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
@ -651,10 +675,14 @@ gtk_button_paint (GtkWidget *widget,
GtkShadowType shadow_type;
gint width, height;
gint x, y;
gint default_spacing;
gboolean interior_focus;
if (GTK_WIDGET_DRAWABLE (widget))
{
button = GTK_BUTTON (widget);
gtk_button_get_props (button, &default_spacing, &interior_focus);
x = 0;
y = 0;
@ -677,13 +705,13 @@ gtk_button_paint (GtkWidget *widget,
{
x += widget->style->xthickness;
y += widget->style->ythickness;
width -= 2 * x + DEFAULT_SPACING;
height -= 2 * y + DEFAULT_SPACING;
x += DEFAULT_LEFT_POS;
y += DEFAULT_TOP_POS;
width -= 2 * x + default_spacing;
height -= 2 * y + default_spacing;
x += (1 + default_spacing) / 2;
y += (1 + default_spacing) / 2;
}
if (GTK_WIDGET_HAS_FOCUS (widget))
if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget))
{
x += 1;
y += 1;
@ -706,10 +734,20 @@ gtk_button_paint (GtkWidget *widget,
if (GTK_WIDGET_HAS_FOCUS (widget))
{
x -= 1;
y -= 1;
width += 2;
height += 2;
if (interior_focus)
{
x += widget->style->xthickness + 1;
y += widget->style->ythickness + 1;
width -= 2 * (widget->style->xthickness + 1);
height -= 2 * (widget->style->xthickness + 1);
}
else
{
x -= 1;
y -= 1;
width += 2;
height += 2;
}
gtk_paint_focus (widget->style, widget->window,
area, widget, "button",

View File

@ -25,6 +25,7 @@
*/
#include "gtkcheckbutton.h"
#include "gtkintl.h"
#include "gtklabel.h"
@ -86,10 +87,25 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
widget_class->size_request = gtk_check_button_size_request;
widget_class->size_allocate = gtk_check_button_size_allocate;
widget_class->expose_event = gtk_check_button_expose;
class->indicator_size = INDICATOR_SIZE;
class->indicator_spacing = INDICATOR_SPACING;
class->draw_indicator = gtk_real_check_button_draw_indicator;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("indicator_size",
_("Indicator Size"),
_("Size of check or radio indicator"),
0,
G_MAXINT,
INDICATOR_SIZE,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("indicator_spacing",
_("Indicator Spacing"),
_("Spacing around check or radio indicator"),
0,
G_MAXINT,
INDICATOR_SPACING,
G_PARAM_READABLE));
}
static void
@ -159,36 +175,62 @@ static void
gtk_check_button_paint (GtkWidget *widget,
GdkRectangle *area)
{
GtkCheckButton *check_button;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
check_button = GTK_CHECK_BUTTON (widget);
GtkCheckButton *check_button = GTK_CHECK_BUTTON (widget);
if (GTK_WIDGET_DRAWABLE (widget))
{
gint border_width;
gint interior_focus;
gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
gtk_check_button_draw_indicator (check_button, area);
border_width = GTK_CONTAINER (widget)->border_width;
if (GTK_WIDGET_HAS_FOCUS (widget))
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "checkbutton",
border_width + widget->allocation.x,
border_width + widget->allocation.y,
widget->allocation.width - 2 * border_width - 1,
widget->allocation.height - 2 * border_width - 1);
{
if (interior_focus)
{
GtkWidget *child = GTK_BIN (widget)->child;
if (child && GTK_WIDGET_VISIBLE (child))
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "checkbutton",
child->allocation.x - 1,
child->allocation.y - 1,
child->allocation.width + 1,
child->allocation.height + 1);
}
else
gtk_paint_focus (widget->style, widget->window,
NULL, widget, "checkbutton",
border_width + widget->allocation.x,
border_width + widget->allocation.y,
widget->allocation.width - 2 * border_width - 1,
widget->allocation.height - 2 * border_width - 1);
}
}
}
void
_gtk_check_button_get_props (GtkCheckButton *check_button,
gint *indicator_size,
gint *indicator_spacing)
{
GtkWidget *widget = GTK_WIDGET (check_button);
if (indicator_size)
gtk_widget_style_get (widget, "indicator_size", indicator_size, NULL);
if (indicator_spacing)
gtk_widget_style_get (widget, "indicator_spacing", indicator_spacing, NULL);
}
static void
gtk_check_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkToggleButton *toggle_button;
gint temp;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_CHECK_BUTTON (widget));
@ -196,18 +238,38 @@ gtk_check_button_size_request (GtkWidget *widget,
toggle_button = GTK_TOGGLE_BUTTON (widget);
if (GTK_WIDGET_CLASS (parent_class)->size_request)
(* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
if (toggle_button->draw_indicator)
{
requisition->width += (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 2);
GtkWidget *child;
gint temp;
gint indicator_size;
gint indicator_spacing;
gint border_width = GTK_CONTAINER (widget)->border_width;
temp = (GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 2);
requisition->width = border_width + 2;
requisition->height = border_width + 2;
child = GTK_BIN (widget)->child;
if (child && GTK_WIDGET_VISIBLE (child))
{
GtkRequisition child_requisition;
gtk_widget_size_request (child, &child_requisition);
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing);
requisition->width += (indicator_size + indicator_spacing * 3 + 2);
temp = (indicator_size + indicator_spacing * 2);
requisition->height = MAX (requisition->height, temp) + 2;
}
else
(* GTK_WIDGET_CLASS (parent_class)->size_request) (widget, requisition);
}
static void
@ -228,6 +290,11 @@ gtk_check_button_size_allocate (GtkWidget *widget,
if (toggle_button->draw_indicator)
{
gint indicator_size;
gint indicator_spacing;
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (toggle_button->event_window,
@ -238,18 +305,15 @@ gtk_check_button_size_allocate (GtkWidget *widget,
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
{
child_allocation.x = (GTK_CONTAINER (widget)->border_width +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1 +
gint border_width = GTK_CONTAINER (widget)->border_width;
child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 + 1 +
widget->allocation.x);
child_allocation.y = GTK_CONTAINER (widget)->border_width + 1 +
widget->allocation.y;
child_allocation.y = border_width + 1 + widget->allocation.y;
child_allocation.width = MAX (1, allocation->width -
(GTK_CONTAINER (widget)->border_width +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size +
GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing * 3 + 1) -
GTK_CONTAINER (widget)->border_width - 1);
child_allocation.height = MAX (1, allocation->height - (GTK_CONTAINER (widget)->border_width + 1) * 2);
(border_width + indicator_size + indicator_spacing * 3 + 1) -
border_width - 1);
child_allocation.height = MAX (1, allocation->height - (border_width + 1) * 2);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
child_allocation.x = allocation->x + allocation->width
@ -259,10 +323,7 @@ gtk_check_button_size_allocate (GtkWidget *widget,
}
}
else
{
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
}
(* GTK_WIDGET_CLASS (parent_class)->size_allocate) (widget, allocation);
}
static gint
@ -327,6 +388,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle new_area;
gint width, height;
gint x, y;
gint indicator_size;
gint indicator_spacing;
GdkWindow *window;
g_return_if_fail (check_button != NULL);
@ -339,6 +402,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
{
window = widget->window;
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
state_type = GTK_WIDGET_STATE (widget);
if (state_type != GTK_STATE_NORMAL &&
state_type != GTK_STATE_PRELIGHT)
@ -359,10 +424,10 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
new_area.width, new_area.height);
}
x = widget->allocation.x + GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
width = indicator_size;
height = indicator_size;
if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
{

View File

@ -57,9 +57,6 @@ struct _GtkCheckButtonClass
{
GtkToggleButtonClass parent_class;
guint16 indicator_size;
guint16 indicator_spacing;
void (* draw_indicator) (GtkCheckButton *check_button,
GdkRectangle *area);
};
@ -70,6 +67,9 @@ GtkWidget* gtk_check_button_new (void);
GtkWidget* gtk_check_button_new_with_label (const gchar *label);
GtkWidget* gtk_check_button_new_with_mnemonic (const gchar *label);
void _gtk_check_button_get_props (GtkCheckButton *check_button,
gint *indicator_size,
gint *indicator_spacing);
#ifdef __cplusplus
}

View File

@ -1104,10 +1104,13 @@ gtk_entry_draw_focus (GtkWidget *widget)
{
gint width, height;
GtkEntry *entry;
gboolean interior_focus;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ENTRY (widget));
gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
entry = GTK_ENTRY (widget);
if (GTK_WIDGET_DRAWABLE (widget))
@ -1118,7 +1121,7 @@ gtk_entry_draw_focus (GtkWidget *widget)
gdk_window_get_size (widget->window, &width, &height);
if (GTK_WIDGET_HAS_FOCUS (widget))
if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
{
x += 1;
y += 1;
@ -1126,7 +1129,6 @@ gtk_entry_draw_focus (GtkWidget *widget)
height -= 2;
}
gtk_paint_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
NULL, widget, "entry",
@ -1135,7 +1137,7 @@ gtk_entry_draw_focus (GtkWidget *widget)
else
gdk_window_clear (widget->window);
if (GTK_WIDGET_HAS_FOCUS (widget))
if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
{
gdk_window_get_size (widget->window, &width, &height);
gtk_paint_focus (widget->style, widget->window,

View File

@ -113,14 +113,12 @@ static void
gtk_hpaned_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
GtkRequisition child_requisition;
gint handle_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HPANED (widget));
g_return_if_fail (requisition != NULL);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
paned = GTK_PANED (widget);
requisition->width = 0;
requisition->height = 0;
@ -140,7 +138,7 @@ gtk_hpaned_size_request (GtkWidget *widget,
requisition->width += child_requisition.width;
}
requisition->width += GTK_CONTAINER (paned)->border_width * 2 + paned->handle_size;
requisition->width += GTK_CONTAINER (paned)->border_width * 2 + handle_size;
requisition->height += GTK_CONTAINER (paned)->border_width * 2;
}
@ -148,20 +146,17 @@ static void
gtk_hpaned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
gint border_width = GTK_CONTAINER (paned)->border_width;
gint handle_size;
GtkRequisition child1_requisition;
GtkRequisition child2_requisition;
GtkAllocation child1_allocation;
GtkAllocation child2_allocation;
gint border_width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HPANED (widget));
g_return_if_fail (allocation != NULL);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
widget->allocation = *allocation;
paned = GTK_PANED (widget);
border_width = GTK_CONTAINER (paned)->border_width;
if (paned->child1)
gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
@ -174,8 +169,8 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
child2_requisition.width = 0;
gtk_paned_compute_position (paned,
MAX (1, (gint) widget->allocation.width
- (gint) paned->handle_size
MAX (1, widget->allocation.width
- handle_size
- 2 * border_width),
child1_requisition.width,
child2_requisition.width);
@ -184,8 +179,8 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
paned->handle_xpos = paned->child1_size + border_width;
paned->handle_ypos = border_width;
paned->handle_width = paned->handle_size;
paned->handle_height = MAX (1, (gint) widget->allocation.height - 2 * border_width);
paned->handle_width = handle_size;
paned->handle_height = MAX (1, widget->allocation.height - 2 * border_width);
if (GTK_WIDGET_REALIZED (widget))
{
@ -197,7 +192,7 @@ gtk_hpaned_size_allocate (GtkWidget *widget,
gdk_window_move_resize (paned->handle,
paned->handle_xpos,
paned->handle_ypos,
paned->handle_size,
handle_size,
paned->handle_height);
}
@ -276,8 +271,11 @@ gtk_hpaned_xor_line (GtkPaned *paned)
GtkWidget *widget;
GdkGCValues values;
guint16 xpos;
gint handle_size;
widget = GTK_WIDGET(paned);
widget = GTK_WIDGET (paned);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (!paned->xor_gc)
{
@ -292,7 +290,7 @@ gtk_hpaned_xor_line (GtkPaned *paned)
GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
xpos = paned->child1_size
+ GTK_CONTAINER (paned)->border_width + paned->handle_size / 2;
+ GTK_CONTAINER (paned)->border_width + handle_size / 2;
gdk_draw_line (widget->window, paned->xor_gc,
xpos,
@ -305,12 +303,10 @@ static gboolean
gtk_hpaned_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
gint handle_size;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
paned = GTK_PANED (widget);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (!paned->in_drag &&
event->window == paned->handle && event->button == 1)
@ -323,10 +319,10 @@ gtk_hpaned_button_press (GtkWidget *widget,
| GDK_BUTTON1_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK,
NULL, NULL, event->time);
paned->child1_size += event->x - paned->handle_size / 2;
paned->child1_size += event->x - handle_size / 2;
paned->child1_size = CLAMP (paned->child1_size, 0,
widget->allocation.width
- paned->handle_size
- handle_size
- 2 * GTK_CONTAINER (paned)->border_width);
gtk_hpaned_xor_line (paned);
@ -365,13 +361,11 @@ static gboolean
gtk_hpaned_motion (GtkWidget *widget,
GdkEventMotion *event)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
gint x;
gint handle_size;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
paned = GTK_PANED (widget);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (event->is_hint || event->window != widget->window)
gtk_widget_get_pointer(widget, &x, NULL);
@ -380,7 +374,7 @@ gtk_hpaned_motion (GtkWidget *widget,
if (paned->in_drag)
{
gint size = x - GTK_CONTAINER (paned)->border_width - paned->handle_size / 2;
gint size = x - GTK_CONTAINER (paned)->border_width - handle_size / 2;
gtk_hpaned_xor_line (paned);
paned->child1_size = CLAMP (size, paned->min_position, paned->max_position);

View File

@ -209,12 +209,16 @@ gtk_hscale_realize (GtkWidget *widget)
GdkWindowAttr attributes;
gint attributes_mask;
gint x, y, w, h;
gint slider_width, slider_length;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCALE (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
_gtk_range_get_props (range, &slider_width, NULL, NULL, NULL);
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
@ -241,8 +245,8 @@ gtk_hscale_realize (GtkWidget *widget)
range->trough = gdk_window_new (widget->window, &attributes, attributes_mask);
attributes.width = SCALE_CLASS (range)->slider_length;
attributes.height = RANGE_CLASS (range)->slider_width;
attributes.width = slider_length;
attributes.height = slider_width;
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
@ -281,18 +285,19 @@ static void
gtk_hscale_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkScale *scale;
GtkScale *scale = GTK_SCALE (widget);
gint slider_width, slider_length, trough_border;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCALE (widget));
g_return_if_fail (requisition != NULL);
scale = GTK_SCALE (widget);
requisition->width = (SCALE_CLASS (scale)->slider_length +
widget->style->xthickness) * 2;
requisition->height = (RANGE_CLASS (scale)->slider_width +
widget->style->ythickness * 2);
_gtk_range_get_props (GTK_RANGE (scale),
&slider_width, &trough_border, NULL, NULL);
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
requisition->width = (slider_length + trough_border) * 2;
requisition->height = (slider_width + trough_border * 2);
if (scale->draw_value)
{
@ -350,19 +355,16 @@ gtk_hscale_pos_trough (GtkHScale *hscale,
gint *w,
gint *h)
{
GtkWidget *widget;
GtkScale *scale;
GtkWidget *widget = GTK_WIDGET (hscale);
GtkScale *scale = GTK_SCALE (hscale);
gint slider_width;
gint trough_border;
g_return_if_fail (hscale != NULL);
g_return_if_fail (GTK_IS_HSCALE (hscale));
g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL));
widget = GTK_WIDGET (hscale);
scale = GTK_SCALE (hscale);
_gtk_range_get_props (GTK_RANGE (scale),
&slider_width, &trough_border, NULL, NULL);
*w = widget->allocation.width;
*h = (RANGE_CLASS (scale)->slider_width +
widget->style->ythickness * 2);
*h = (slider_width + trough_border * 2);
if (scale->draw_value)
{

View File

@ -50,6 +50,8 @@ static void gtk_hscrollbar_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec);
static void gtk_hscrollbar_realize (GtkWidget *widget);
static void gtk_hscrollbar_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_hscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_hscrollbar_draw_step_forw (GtkRange *range);
@ -61,7 +63,6 @@ static gboolean gtk_hscrollbar_trough_keys (GtkRange *range,
GtkScrollType *scroll,
GtkTroughType *pos);
GtkType
gtk_hscrollbar_get_type (void)
{
@ -104,6 +105,7 @@ gtk_hscrollbar_class_init (GtkHScrollbarClass *class)
gobject_class->get_property = gtk_hscrollbar_get_property;
widget_class->realize = gtk_hscrollbar_realize;
widget_class->size_request = gtk_hscrollbar_size_request;
widget_class->size_allocate = gtk_hscrollbar_size_allocate;
range_class->draw_step_forw = gtk_hscrollbar_draw_step_forw;
@ -169,18 +171,6 @@ gtk_hscrollbar_get_property (GObject *object,
static void
gtk_hscrollbar_init (GtkHScrollbar *hscrollbar)
{
GtkWidget *widget;
GtkRequisition *requisition;
widget = GTK_WIDGET (hscrollbar);
requisition = &widget->requisition;
requisition->width = (RANGE_CLASS (widget)->min_slider_size +
RANGE_CLASS (widget)->stepper_size +
RANGE_CLASS (widget)->stepper_slider_spacing +
widget->style->xthickness) * 2;
requisition->height = (RANGE_CLASS (widget)->slider_width +
widget->style->ythickness * 2);
}
GtkWidget*
@ -202,6 +192,9 @@ gtk_hscrollbar_realize (GtkWidget *widget)
GtkRange *range;
GdkWindowAttr attributes;
gint attributes_mask;
gint slider_width;
gint trough_border;
gint stepper_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCROLLBAR (widget));
@ -209,6 +202,9 @@ gtk_hscrollbar_realize (GtkWidget *widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
_gtk_range_get_props (range, &slider_width, &trough_border,
&stepper_size, NULL);
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y + (widget->allocation.height - widget->requisition.height) / 2;
attributes.width = widget->allocation.width;
@ -230,23 +226,24 @@ gtk_hscrollbar_realize (GtkWidget *widget)
range->trough = widget->window;
gdk_window_ref (range->trough);
attributes.x = widget->style->xthickness;
attributes.y = widget->style->ythickness;
attributes.width = RANGE_CLASS (widget)->stepper_size;
attributes.height = RANGE_CLASS (widget)->stepper_size;
attributes.x = trough_border;
attributes.y = trough_border;
attributes.width = stepper_size;
attributes.height = stepper_size;
range->step_back = gdk_window_new (range->trough, &attributes, attributes_mask);
attributes.x = (widget->allocation.width -
widget->style->xthickness -
RANGE_CLASS (widget)->stepper_size);
trough_border -
stepper_size);
range->step_forw = gdk_window_new (range->trough, &attributes, attributes_mask);
attributes.x = 0;
attributes.y = widget->style->ythickness;
attributes.y = trough_border;
attributes.width = RANGE_CLASS (widget)->min_slider_size;
attributes.height = RANGE_CLASS (widget)->slider_width;
attributes.height = slider_width;
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
@ -272,11 +269,35 @@ gtk_hscrollbar_realize (GtkWidget *widget)
gdk_window_show (range->step_back);
}
static void
gtk_hscrollbar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
gint slider_width;
gint trough_border;
gint stepper_size;
gint stepper_spacing;
GtkRange *range = GTK_RANGE (widget);
_gtk_range_get_props (range, &slider_width, &trough_border,
&stepper_size, &stepper_spacing);
requisition->width = (RANGE_CLASS (widget)->min_slider_size +
stepper_size +
stepper_spacing +
trough_border) * 2;
requisition->height = (slider_width +
trough_border * 2);
}
static void
gtk_hscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkRange *range;
gint trough_border;
gint stepper_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_HSCROLLBAR (widget));
@ -287,21 +308,24 @@ gtk_hscrollbar_size_allocate (GtkWidget *widget,
{
range = GTK_RANGE (widget);
_gtk_range_get_props (range, NULL, &trough_border,
&stepper_size, NULL);
gdk_window_move_resize (range->trough,
allocation->x,
allocation->y + (allocation->height - widget->requisition.height) / 2,
allocation->width, widget->requisition.height);
gdk_window_move_resize (range->step_back,
widget->style->xthickness,
widget->style->ythickness,
RANGE_CLASS (widget)->stepper_size,
widget->requisition.height - widget->style->ythickness * 2);
trough_border,
trough_border,
stepper_size,
widget->requisition.height - trough_border * 2);
gdk_window_move_resize (range->step_forw,
allocation->width - widget->style->xthickness -
RANGE_CLASS (widget)->stepper_size,
widget->style->ythickness,
RANGE_CLASS (widget)->stepper_size,
widget->requisition.height - widget->style->ythickness * 2);
allocation->width - trough_border -
stepper_size,
trough_border,
stepper_size,
widget->requisition.height - trough_border * 2);
_gtk_range_slider_update (GTK_RANGE (widget));
}
@ -394,15 +418,18 @@ gtk_hscrollbar_calc_slider_size (GtkHScrollbar *hscrollbar)
gint step_forw_x;
gint slider_width;
gint slider_height;
gint stepper_spacing;
gint left, right;
gint width;
g_return_if_fail (hscrollbar != NULL);
g_return_if_fail (GTK_IS_HSCROLLBAR (hscrollbar));
if (GTK_WIDGET_REALIZED (hscrollbar))
{
range = GTK_RANGE (hscrollbar);
_gtk_range_get_props (range, NULL, NULL, NULL, &stepper_spacing);
gdk_window_get_size (range->step_back, &step_back_width, NULL);
gdk_window_get_position (range->step_back, &step_back_x, NULL);
@ -410,8 +437,8 @@ gtk_hscrollbar_calc_slider_size (GtkHScrollbar *hscrollbar)
left = (step_back_x +
step_back_width +
RANGE_CLASS (hscrollbar)->stepper_slider_spacing);
right = step_forw_x - RANGE_CLASS (hscrollbar)->stepper_slider_spacing;
stepper_spacing);
right = step_forw_x - stepper_spacing;
width = right - left;
if ((range->adjustment->page_size > 0) &&

View File

@ -24,6 +24,7 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "gtkintl.h"
#include "gtkmenu.h"
#include "gtkmenuitem.h"
#include "gtkoptionmenu.h"
@ -35,10 +36,19 @@
#define CHILD_RIGHT_SPACING 1
#define CHILD_TOP_SPACING 1
#define CHILD_BOTTOM_SPACING 1
#define OPTION_INDICATOR_WIDTH 12
#define OPTION_INDICATOR_HEIGHT 8
#define OPTION_INDICATOR_SPACING 2
typedef struct _GtkOptionMenuProps GtkOptionMenuProps;
struct _GtkOptionMenuProps
{
GtkRequisition indicator_size;
GtkBorder indicator_spacing;
};
static GtkOptionMenuProps default_props = {
{ 12, 8 },
{ 3, 7, 2, 2 } /* Left, right, top, bottom */
};
static void gtk_option_menu_class_init (GtkOptionMenuClass *klass);
static void gtk_option_menu_init (GtkOptionMenu *option_menu);
@ -139,6 +149,19 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
widget_class->hide_all = gtk_option_menu_hide_all;
container_class->child_type = gtk_option_menu_child_type;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boxed ("indicator_size",
_("Indicator Size"),
_("Size of dropdown indicator"),
GTK_TYPE_REQUISITION,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boxed ("indicator_spacing",
_("Indicator Spacing"),
_("Spacing around indicator"),
GTK_TYPE_BORDER,
G_PARAM_READABLE));
}
static GtkType
@ -303,21 +326,41 @@ gtk_option_menu_destroy (GtkObject *object)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
gtk_option_menu_get_props (GtkOptionMenu *option_menu,
GtkOptionMenuProps *props)
{
GtkRequisition *indicator_size;
GtkBorder *indicator_spacing;
gtk_widget_style_get (GTK_WIDGET (option_menu),
"indicator_size", &indicator_size,
"indicator_spacing", &indicator_spacing,
NULL);
if (indicator_size)
{
props->indicator_size = *indicator_size;
gtk_requisition_free (indicator_size);
}
if (indicator_spacing)
{
props->indicator_spacing = *indicator_spacing;
gtk_border_free (indicator_spacing);
}
}
static void
gtk_option_menu_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkOptionMenu *option_menu;
GtkOptionMenu *option_menu = GTK_OPTION_MENU (widget);
GtkOptionMenuProps props;
gint tmp;
GtkRequisition child_requisition = { 0, 0 };
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
g_return_if_fail (requisition != NULL);
option_menu = GTK_OPTION_MENU (widget);
gtk_option_menu_get_props (option_menu, &props);
if (GTK_BIN (option_menu)->child && GTK_WIDGET_VISIBLE (GTK_BIN (option_menu)->child))
{
gtk_widget_size_request (GTK_BIN (option_menu)->child, &child_requisition);
@ -329,8 +372,8 @@ gtk_option_menu_size_request (GtkWidget *widget,
requisition->width = ((GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->xthickness) * 2 +
MAX (child_requisition.width, option_menu->width) +
OPTION_INDICATOR_WIDTH +
OPTION_INDICATOR_SPACING * 5 +
props.indicator_size.width +
props.indicator_spacing.left + props.indicator_spacing.right +
CHILD_LEFT_SPACING + CHILD_RIGHT_SPACING + 2);
requisition->height = ((GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->ythickness) * 2 +
@ -338,7 +381,7 @@ gtk_option_menu_size_request (GtkWidget *widget,
CHILD_TOP_SPACING + CHILD_BOTTOM_SPACING + 2);
tmp = (requisition->height - option_menu->height +
OPTION_INDICATOR_HEIGHT + OPTION_INDICATOR_SPACING * 2);
props.indicator_size.height + props.indicator_spacing.top + props.indicator_spacing.bottom);
requisition->height = MAX (requisition->height, tmp);
}
@ -348,11 +391,14 @@ gtk_option_menu_size_allocate (GtkWidget *widget,
{
GtkWidget *child;
GtkAllocation child_allocation;
GtkOptionMenuProps props;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
g_return_if_fail (allocation != NULL);
gtk_option_menu_get_props (GTK_OPTION_MENU (widget), &props);
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window,
@ -367,12 +413,12 @@ gtk_option_menu_size_allocate (GtkWidget *widget,
child_allocation.y = (GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->ythickness) + 1;
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2 -
OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 5 -
props.indicator_size.width - props.indicator_spacing.left - props.indicator_spacing.right -
CHILD_LEFT_SPACING - CHILD_RIGHT_SPACING - 2);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2 -
CHILD_TOP_SPACING - CHILD_BOTTOM_SPACING - 2);
child_allocation.x += CHILD_LEFT_SPACING;
child_allocation.y += CHILD_RIGHT_SPACING;
child_allocation.y += CHILD_TOP_SPACING;
gtk_widget_size_allocate (child, &child_allocation);
}
@ -383,6 +429,7 @@ gtk_option_menu_paint (GtkWidget *widget,
GdkRectangle *area)
{
GdkRectangle button_area;
GtkOptionMenuProps props;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
@ -390,6 +437,8 @@ gtk_option_menu_paint (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
gtk_option_menu_get_props (GTK_OPTION_MENU (widget), &props);
button_area.x = GTK_CONTAINER (widget)->border_width + 1;
button_area.y = GTK_CONTAINER (widget)->border_width + 1;
button_area.width = widget->allocation.width - button_area.x * 2;
@ -411,10 +460,11 @@ gtk_option_menu_paint (GtkWidget *widget,
gtk_paint_tab (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT,
area, widget, "optionmenutab",
button_area.x + button_area.width - button_area.x -
OPTION_INDICATOR_WIDTH - OPTION_INDICATOR_SPACING * 4,
button_area.y + (button_area.height - OPTION_INDICATOR_HEIGHT) / 2,
OPTION_INDICATOR_WIDTH, OPTION_INDICATOR_HEIGHT);
button_area.x + button_area.width -
props.indicator_size.width - props.indicator_spacing.right -
widget->style->xthickness,
button_area.y + (button_area.height - props.indicator_size.height) / 2,
props.indicator_size.width, props.indicator_size.height);
if (GTK_WIDGET_HAS_FOCUS (widget))
gtk_paint_focus (widget->style, widget->window,

View File

@ -24,11 +24,11 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "gtkintl.h"
#include "gtkpaned.h"
enum {
ARG_0,
ARG_HANDLE_SIZE
};
static void gtk_paned_class_init (GtkPanedClass *klass);
@ -110,8 +110,14 @@ gtk_paned_class_init (GtkPanedClass *class)
container_class->forall = gtk_paned_forall;
container_class->child_type = gtk_paned_child_type;
gtk_object_add_arg_type("GtkPaned::handle_size", GTK_TYPE_UINT,
GTK_ARG_READWRITE, ARG_HANDLE_SIZE);
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("handle_size",
_("Handle Size"),
_("Width of handle"),
0,
G_MAXINT,
5,
G_PARAM_READABLE));
}
static GtkType
@ -136,7 +142,6 @@ gtk_paned_init (GtkPaned *paned)
paned->handle_width = 5;
paned->handle_height = 5;
paned->handle_size = 5;
paned->position_set = FALSE;
paned->last_allocation = -1;
paned->in_drag = FALSE;
@ -150,13 +155,8 @@ gtk_paned_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkPaned *paned = GTK_PANED (object);
switch (arg_id)
{
case ARG_HANDLE_SIZE:
gtk_paned_set_handle_size (paned, GTK_VALUE_UINT (*arg));
break;
default:
break;
}
@ -167,13 +167,8 @@ gtk_paned_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id)
{
GtkPaned *paned = GTK_PANED (object);
switch (arg_id)
{
case ARG_HANDLE_SIZE:
GTK_VALUE_UINT (*arg) = paned->handle_size;
break;
default:
arg->type = GTK_TYPE_INVALID;
break;
@ -517,18 +512,6 @@ gtk_paned_set_position (GtkPaned *paned,
gtk_widget_queue_resize (GTK_WIDGET (paned));
}
void
gtk_paned_set_handle_size (GtkPaned *paned,
guint16 size)
{
g_return_if_fail (paned != NULL);
g_return_if_fail (GTK_IS_PANED (paned));
gtk_widget_queue_resize (GTK_WIDGET (paned));
paned->handle_size = size;
}
void
gtk_paned_compute_position(GtkPaned *paned,
gint allocation,

View File

@ -57,9 +57,6 @@ struct _GtkPaned
GdkGC *xor_gc;
GdkCursorType cursor_type;
/*< public >*/
guint16 handle_size;
/*< private >*/
guint16 handle_width;
guint16 handle_height;
@ -102,8 +99,6 @@ void gtk_paned_pack2 (GtkPaned *paned,
gint gtk_paned_get_position (GtkPaned *paned);
void gtk_paned_set_position (GtkPaned *paned,
gint position);
void gtk_paned_set_handle_size (GtkPaned *paned,
guint16 size);
/* Internal function */
void gtk_paned_compute_position (GtkPaned *paned,

View File

@ -375,8 +375,8 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
GtkShadowType shadow_type;
GdkRectangle restrict_area;
GdkRectangle new_area;
gint width, height;
gint x, y;
gint indicator_size, indicator_spacing;
g_return_if_fail (check_button != NULL);
g_return_if_fail (GTK_IS_RADIO_BUTTON (check_button));
@ -392,6 +392,8 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
(state_type != GTK_STATE_PRELIGHT))
state_type = GTK_STATE_NORMAL;
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width;
restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width;
restrict_area.width = widget->allocation.width - ( 2 * GTK_CONTAINER (widget)->border_width);
@ -407,10 +409,8 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
new_area.width, new_area.height);
}
x = widget->allocation.x + GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width;
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
if (GTK_TOGGLE_BUTTON (widget)->active)
shadow_type = GTK_SHADOW_IN;
@ -421,11 +421,11 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
shadow_type = GTK_SHADOW_ETCHED_IN;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
x = widget->allocation.x + widget->allocation.width - (width + x - widget->allocation.x);
x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x);
gtk_paint_option (widget->style, widget->window,
GTK_WIDGET_STATE (widget), shadow_type,
area, widget, "radiobutton",
x, y, width, height);
x, y, indicator_size, indicator_size);
}
}

View File

@ -25,6 +25,7 @@
*/
#include <stdio.h>
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkrange.h"
#include "gtksignal.h"
@ -150,9 +151,6 @@ gtk_range_class_init (GtkRangeClass *class)
widget_class->leave_notify_event = gtk_range_leave_notify;
widget_class->style_set = gtk_range_style_set;
class->slider_width = 11;
class->stepper_size = 11;
class->stepper_slider_spacing = 1;
class->min_slider_size = 7;
class->trough = 1;
class->slider = 2;
@ -176,7 +174,40 @@ gtk_range_class_init (GtkRangeClass *class)
_("How the range should be updated on the screen"),
GTK_TYPE_UPDATE_TYPE,
GTK_UPDATE_CONTINUOUS,
G_PARAM_READWRITE));
G_PARAM_READWRITE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("slider_width",
_("Slider Width"),
_("Width of scrollbar or scale thumb"),
0,
G_MAXINT,
11,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("trough_border",
_("Trough Border"),
_("Width of border around range"),
0,
G_MAXINT,
2,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("stepper_size",
_("Stepper Size"),
_("Size of step buttons at ends"),
0,
G_MAXINT,
11,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("stepper_spacing",
_("Stepper Spacing"),
_("Spacing between step buttons and thumb"),
G_MININT,
G_MAXINT,
1,
G_PARAM_READABLE));
}
static void
@ -471,10 +502,13 @@ _gtk_range_default_hslider_update (GtkRange *range)
gint left;
gint right;
gint x;
gint trough_border;
g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
_gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
if (GTK_WIDGET_REALIZED (range))
{
gtk_range_trough_hdims (range, &left, &right);
@ -503,7 +537,7 @@ _gtk_range_default_hslider_update (GtkRange *range)
if (should_invert (range, TRUE))
x = right - (x - left);
move_and_update_window (range->slider, x, GTK_WIDGET (range)->style->ythickness);
move_and_update_window (range->slider, x, trough_border);
}
}
@ -513,10 +547,13 @@ _gtk_range_default_vslider_update (GtkRange *range)
gint top;
gint bottom;
gint y;
gint trough_border;
g_return_if_fail (range != NULL);
g_return_if_fail (GTK_IS_RANGE (range));
_gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
if (GTK_WIDGET_REALIZED (range))
{
gtk_range_trough_vdims (range, &top, &bottom);
@ -545,7 +582,7 @@ _gtk_range_default_vslider_update (GtkRange *range)
if (should_invert (range, FALSE))
y = bottom - (y - top);
move_and_update_window (range->slider, GTK_WIDGET (range)->style->xthickness, y);
move_and_update_window (range->slider, trough_border, y);
}
}
@ -555,7 +592,7 @@ _gtk_range_default_htrough_click (GtkRange *range,
gint y,
gdouble *jump_perc)
{
gint ythickness;
gint trough_border;
gint trough_width;
gint trough_height;
gint slider_x;
@ -565,7 +602,7 @@ _gtk_range_default_htrough_click (GtkRange *range,
g_return_val_if_fail (range != NULL, GTK_TROUGH_NONE);
g_return_val_if_fail (GTK_IS_RANGE (range), GTK_TROUGH_NONE);
ythickness = GTK_WIDGET (range)->style->ythickness;
_gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
gtk_range_trough_hdims (range, &left, &right);
gdk_window_get_size (range->slider, &slider_length, NULL);
@ -574,11 +611,11 @@ _gtk_range_default_htrough_click (GtkRange *range,
if (should_invert (range, TRUE))
x = (right - x) + left;
if ((x > left) && (y > ythickness))
if ((x > left) && (y > trough_border))
{
gdk_window_get_size (range->trough, &trough_width, &trough_height);
if ((x < right) && (y < (trough_height - ythickness)))
if ((x < right) && (y < (trough_height - trough_border)))
{
if (jump_perc)
{
@ -604,7 +641,7 @@ _gtk_range_default_vtrough_click (GtkRange *range,
gint y,
gdouble *jump_perc)
{
gint xthickness;
gint trough_border;
gint trough_width;
gint trough_height;
gint slider_y;
@ -614,8 +651,8 @@ _gtk_range_default_vtrough_click (GtkRange *range,
g_return_val_if_fail (range != NULL, GTK_TROUGH_NONE);
g_return_val_if_fail (GTK_IS_RANGE (range), GTK_TROUGH_NONE);
xthickness = GTK_WIDGET (range)->style->xthickness;
_gtk_range_get_props (range, NULL, &trough_border, NULL, NULL);
gtk_range_trough_vdims (range, &top, &bottom);
gdk_window_get_size (range->slider, NULL, &slider_length);
bottom += slider_length;
@ -623,11 +660,11 @@ _gtk_range_default_vtrough_click (GtkRange *range,
if (should_invert (range, FALSE))
y = (bottom - y) + top;
if ((x > xthickness) && (y > top))
if ((x > trough_border) && (y > top))
{
gdk_window_get_size (range->trough, &trough_width, &trough_height);
if ((x < (trough_width - xthickness) && (y < bottom)))
if ((x < (trough_width - trough_border) && (y < bottom)))
{
if (jump_perc)
{
@ -1662,25 +1699,29 @@ gtk_range_trough_hdims (GtkRange *range,
gint tmp_width;
gint tleft;
gint tright;
gint stepper_spacing;
gint trough_border;
g_return_if_fail (range != NULL);
gdk_window_get_size (range->trough, &trough_width, NULL);
gdk_window_get_size (range->slider, &slider_length, NULL);
tleft = GTK_WIDGET (range)->style->xthickness;
tright = trough_width - slider_length - GTK_WIDGET (range)->style->xthickness;
_gtk_range_get_props (range, NULL, &trough_border, NULL, &stepper_spacing);
tleft = trough_border;
tright = trough_width - slider_length - trough_border;
if (range->step_back)
{
gdk_window_get_size (range->step_back, &tmp_width, NULL);
tleft += (tmp_width + RANGE_CLASS (range)->stepper_slider_spacing);
tleft += (tmp_width + stepper_spacing);
}
if (range->step_forw)
{
gdk_window_get_size (range->step_forw, &tmp_width, NULL);
tright -= (tmp_width + RANGE_CLASS (range)->stepper_slider_spacing);
tright -= (tmp_width + stepper_spacing);
}
if (left)
@ -1699,25 +1740,29 @@ gtk_range_trough_vdims (GtkRange *range,
gint tmp_height;
gint ttop;
gint tbottom;
gint stepper_spacing;
gint trough_border;
g_return_if_fail (range != NULL);
_gtk_range_get_props (range, NULL, &trough_border, NULL, &stepper_spacing);
gdk_window_get_size (range->trough, NULL, &trough_height);
gdk_window_get_size (range->slider, NULL, &slider_length);
ttop = GTK_WIDGET (range)->style->ythickness;
tbottom = trough_height - slider_length - GTK_WIDGET (range)->style->ythickness;
ttop = trough_border;
tbottom = trough_height - slider_length - trough_border;
if (range->step_back)
{
gdk_window_get_size (range->step_back, NULL, &tmp_height);
ttop += (tmp_height + RANGE_CLASS (range)->stepper_slider_spacing);
ttop += (tmp_height + stepper_spacing);
}
if (range->step_forw)
{
gdk_window_get_size (range->step_forw, NULL, &tmp_height);
tbottom -= (tmp_height + RANGE_CLASS (range)->stepper_slider_spacing);
tbottom -= (tmp_height + stepper_spacing);
}
if (top)
@ -1763,3 +1808,27 @@ gtk_range_style_set (GtkWidget *widget,
}
}
}
void
_gtk_range_get_props (GtkRange *range,
gint *slider_width,
gint *trough_border,
gint *stepper_size,
gint *stepper_spacing)
{
GtkWidget *widget = GTK_WIDGET (range);
if (slider_width)
gtk_widget_style_get (widget, "slider_width", slider_width, NULL);
if (trough_border)
gtk_widget_style_get (widget, "trough_border", trough_border, NULL);
if (stepper_size)
gtk_widget_style_get (widget, "stepper_size", stepper_size, NULL);
if (stepper_spacing)
gtk_widget_style_get (widget, "stepper_spacing", stepper_spacing, NULL);
}

View File

@ -85,9 +85,6 @@ struct _GtkRangeClass
{
GtkWidgetClass parent_class;
gint slider_width;
gint stepper_size;
gint stepper_slider_spacing;
gint min_slider_size;
guint8 trough;
@ -157,6 +154,11 @@ void _gtk_range_default_vmotion (GtkRange *range,
gint xdelta,
gint ydelta);
void _gtk_range_get_props (GtkRange *range,
gint *slider_width,
gint *trough_border,
gint *stepper_size,
gint *stepper_spacing);
#ifdef __cplusplus
}

View File

@ -25,7 +25,7 @@
*/
#include <math.h>
#include "gtkcontainer.h"
#include "gtkintl.h"
#include "gtkscale.h"
enum {
@ -112,7 +112,14 @@ gtk_scale_class_init (GtkScaleClass *class)
range_class->draw_background = gtk_scale_draw_background;
class->slider_length = 31;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("slider_length",
_("Slider Length"),
_("Length of scale's slider"),
0,
G_MAXINT,
31,
G_PARAM_READABLE));
class->value_spacing = 2;
class->draw_value = NULL;
}

View File

@ -60,7 +60,6 @@ struct _GtkScaleClass
{
GtkRangeClass parent_class;
gint slider_length;
gint value_spacing;
void (* draw_value) (GtkScale *scale);

View File

@ -360,6 +360,7 @@ gtk_toggle_button_paint (GtkWidget *widget,
GtkShadowType shadow_type;
GtkStateType state_type;
gint width, height;
gboolean interior_focus;
gint x, y;
button = GTK_BUTTON (widget);
@ -367,6 +368,8 @@ gtk_toggle_button_paint (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL);
x = 0;
y = 0;
width = widget->allocation.width - GTK_CONTAINER (widget)->border_width * 2;
@ -394,7 +397,7 @@ gtk_toggle_button_paint (GtkWidget *widget,
y += DEFAULT_TOP_POS;
}
if (GTK_WIDGET_HAS_FOCUS (widget))
if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus)
{
x += 1;
y += 1;
@ -426,10 +429,20 @@ gtk_toggle_button_paint (GtkWidget *widget,
if (GTK_WIDGET_HAS_FOCUS (widget))
{
x -= 1;
y -= 1;
width += 2;
height += 2;
if (interior_focus)
{
x += widget->style->xthickness + 1;
y += widget->style->xthickness + 1;
width -= 2 * (widget->style->xthickness + 1);
height -= 2 * (widget->style->ythickness + 1);
}
else
{
x -= 1;
y -= 1;
width += 2;
height += 2;
}
gtk_paint_focus (widget->style, widget->window,
area, widget, "togglebutton",

View File

@ -113,14 +113,12 @@ static void
gtk_vpaned_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
GtkRequisition child_requisition;
gint handle_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VPANED (widget));
g_return_if_fail (requisition != NULL);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
paned = GTK_PANED (widget);
requisition->width = 0;
requisition->height = 0;
@ -140,7 +138,7 @@ gtk_vpaned_size_request (GtkWidget *widget,
requisition->height += child_requisition.height;
}
requisition->height += GTK_CONTAINER (paned)->border_width * 2 + paned->handle_size;
requisition->height += GTK_CONTAINER (paned)->border_width * 2 + handle_size;
requisition->width += GTK_CONTAINER (paned)->border_width * 2;
}
@ -148,20 +146,18 @@ static void
gtk_vpaned_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
GtkRequisition child1_requisition;
GtkRequisition child2_requisition;
GtkAllocation child1_allocation;
GtkAllocation child2_allocation;
gint border_width;
gint handle_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VPANED (widget));
g_return_if_fail (allocation != NULL);
widget->allocation = *allocation;
paned = GTK_PANED (widget);
border_width = GTK_CONTAINER (widget)->border_width;
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (paned->child1)
gtk_widget_get_child_requisition (paned->child1, &child1_requisition);
@ -174,8 +170,8 @@ gtk_vpaned_size_allocate (GtkWidget *widget,
child2_requisition.height = 0;
gtk_paned_compute_position (paned,
MAX (1, (gint) widget->allocation.height
- (gint) paned->handle_size
MAX (1, widget->allocation.height
- handle_size
- 2 * border_width),
child1_requisition.height,
child2_requisition.height);
@ -185,7 +181,7 @@ gtk_vpaned_size_allocate (GtkWidget *widget,
paned->handle_xpos = border_width;
paned->handle_ypos = paned->child1_size + border_width;
paned->handle_width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
paned->handle_height = paned->handle_size;
paned->handle_height = handle_size;
if (GTK_WIDGET_REALIZED(widget))
{
@ -198,7 +194,7 @@ gtk_vpaned_size_allocate (GtkWidget *widget,
paned->handle_xpos,
paned->handle_ypos,
paned->handle_width,
paned->handle_size);
handle_size);
}
child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
@ -278,9 +274,12 @@ gtk_vpaned_xor_line (GtkPaned *paned)
GtkWidget *widget;
GdkGCValues values;
guint16 ypos;
gint handle_size;
widget = GTK_WIDGET (paned);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (!paned->xor_gc)
{
values.function = GDK_INVERT;
@ -294,7 +293,7 @@ gtk_vpaned_xor_line (GtkPaned *paned)
GDK_CAP_NOT_LAST, GDK_JOIN_BEVEL);
ypos = paned->child1_size
+ GTK_CONTAINER (paned)->border_width + paned->handle_size / 2;
+ GTK_CONTAINER (paned)->border_width + handle_size / 2;
gdk_draw_line (widget->window, paned->xor_gc,
0,
@ -307,12 +306,10 @@ static gboolean
gtk_vpaned_button_press (GtkWidget *widget,
GdkEventButton *event)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
gint handle_size;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
paned = GTK_PANED (widget);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (!paned->in_drag &&
(event->window == paned->handle) && (event->button == 1))
@ -325,10 +322,10 @@ gtk_vpaned_button_press (GtkWidget *widget,
| GDK_BUTTON1_MOTION_MASK
| GDK_BUTTON_RELEASE_MASK, NULL, NULL,
event->time);
paned->child1_size += event->y - paned->handle_size / 2;
paned->child1_size += event->y - handle_size / 2;
paned->child1_size = CLAMP (paned->child1_size, 0,
widget->allocation.height -
paned->handle_size -
handle_size -
2 * GTK_CONTAINER (paned)->border_width);
gtk_vpaned_xor_line(paned);
@ -367,22 +364,20 @@ static gboolean
gtk_vpaned_motion (GtkWidget *widget,
GdkEventMotion *event)
{
GtkPaned *paned;
GtkPaned *paned = GTK_PANED (widget);
gint y;
gint handle_size;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_PANED (widget), FALSE);
gtk_widget_style_get (widget, "handle_size", &handle_size, NULL);
if (event->is_hint || event->window != widget->window)
gtk_widget_get_pointer (widget, NULL, &y);
else
y = event->y;
paned = GTK_PANED (widget);
if (paned->in_drag)
{
gint size = y - GTK_CONTAINER(paned)->border_width - paned->handle_size / 2;
gint size = y - GTK_CONTAINER(paned)->border_width - handle_size / 2;
gtk_vpaned_xor_line (paned);
paned->child1_size = CLAMP (size, paned->min_position, paned->max_position);

View File

@ -206,12 +206,16 @@ gtk_vscale_realize (GtkWidget *widget)
GdkWindowAttr attributes;
gint attributes_mask;
gint x, y, w, h;
gint slider_width, slider_length;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VSCALE (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
_gtk_range_get_props (range, &slider_width, NULL, NULL, NULL);
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
widget->window = gtk_widget_get_parent_window (widget);
gdk_window_ref (widget->window);
@ -238,8 +242,8 @@ gtk_vscale_realize (GtkWidget *widget)
range->trough = gdk_window_new (widget->window, &attributes, attributes_mask);
attributes.width = RANGE_CLASS (range)->slider_width;
attributes.height = SCALE_CLASS (range)->slider_length;
attributes.width = slider_width;
attributes.height = slider_length;
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
@ -281,22 +285,19 @@ static void
gtk_vscale_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkScale *scale;
gint value_width, value_height;
GtkScale *scale = GTK_SCALE (widget);
gint slider_width, slider_length, trough_border;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VSCALE (widget));
g_return_if_fail (requisition != NULL);
scale = GTK_SCALE (widget);
requisition->width = (RANGE_CLASS (scale)->slider_width +
widget->style->ythickness * 2);
requisition->height = (SCALE_CLASS (scale)->slider_length +
widget->style->xthickness) * 2;
_gtk_range_get_props (GTK_RANGE (scale),
&slider_width, &trough_border, NULL, NULL);
gtk_widget_style_get (widget, "slider_length", &slider_length, NULL);
requisition->width = (slider_width + trough_border * 2);
requisition->height = (slider_length + trough_border) * 2;
if (scale->draw_value)
{
gint value_width, value_height;
gtk_scale_get_value_size (scale, &value_width, &value_height);
if ((scale->value_pos == GTK_POS_LEFT) ||
@ -349,19 +350,15 @@ gtk_vscale_pos_trough (GtkVScale *vscale,
gint *w,
gint *h)
{
GtkWidget *widget;
GtkScale *scale;
GtkWidget *widget = GTK_WIDGET (vscale);
GtkScale *scale = GTK_SCALE (vscale);
gint value_width, value_height;
gint slider_width, trough_border;
g_return_if_fail (vscale != NULL);
g_return_if_fail (GTK_IS_VSCALE (vscale));
g_return_if_fail ((x != NULL) && (y != NULL) && (w != NULL) && (h != NULL));
widget = GTK_WIDGET (vscale);
scale = GTK_SCALE (vscale);
*w = (RANGE_CLASS (scale)->slider_width +
widget->style->xthickness * 2);
_gtk_range_get_props (GTK_RANGE (scale),
&slider_width, &trough_border, NULL, NULL);
*w = (slider_width + trough_border * 2);
*h = widget->allocation.height;
if (scale->draw_value)
@ -412,6 +409,7 @@ gtk_vscale_pos_background (GtkVScale *vscale,
{
GtkWidget *widget;
GtkScale *scale;
gint slider_width, trough_border;
gint tx, ty, twidth, theight;

View File

@ -50,6 +50,8 @@ static void gtk_vscrollbar_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gtk_vscrollbar_realize (GtkWidget *widget);
static void gtk_vscrollbar_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_vscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_vscrollbar_draw_step_forw (GtkRange *range);
@ -61,7 +63,6 @@ static gboolean gtk_vscrollbar_trough_keys (GtkRange *range,
GtkScrollType *scroll,
GtkTroughType *pos);
GtkType
gtk_vscrollbar_get_type (void)
{
@ -102,6 +103,7 @@ gtk_vscrollbar_class_init (GtkVScrollbarClass *class)
gobject_class->get_property = gtk_vscrollbar_get_property;
widget_class->realize = gtk_vscrollbar_realize;
widget_class->size_request = gtk_vscrollbar_size_request;
widget_class->size_allocate = gtk_vscrollbar_size_allocate;
range_class->draw_step_forw = gtk_vscrollbar_draw_step_forw;
@ -166,18 +168,6 @@ gtk_vscrollbar_get_property (GObject *object,
static void
gtk_vscrollbar_init (GtkVScrollbar *vscrollbar)
{
GtkWidget *widget;
GtkRequisition *requisition;
widget = GTK_WIDGET (vscrollbar);
requisition = &widget->requisition;
requisition->width = (RANGE_CLASS (widget)->slider_width +
widget->style->xthickness * 2);
requisition->height = (RANGE_CLASS (widget)->min_slider_size +
RANGE_CLASS (widget)->stepper_size +
RANGE_CLASS (widget)->stepper_slider_spacing +
widget->style->ythickness) * 2;
}
GtkWidget*
@ -199,6 +189,9 @@ gtk_vscrollbar_realize (GtkWidget *widget)
GtkRange *range;
GdkWindowAttr attributes;
gint attributes_mask;
gint slider_width;
gint stepper_size;
gint trough_border;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VSCROLLBAR (widget));
@ -206,6 +199,9 @@ gtk_vscrollbar_realize (GtkWidget *widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
range = GTK_RANGE (widget);
_gtk_range_get_props (range, &slider_width, &trough_border,
&stepper_size, NULL);
attributes.x = widget->allocation.x + (widget->allocation.width - widget->requisition.width) / 2;
attributes.y = widget->allocation.y;
attributes.width = widget->requisition.width;
@ -227,22 +223,22 @@ gtk_vscrollbar_realize (GtkWidget *widget)
range->trough = widget->window;
gdk_window_ref (range->trough);
attributes.x = widget->style->xthickness;
attributes.y = widget->style->ythickness;
attributes.width = RANGE_CLASS (widget)->stepper_size;
attributes.height = RANGE_CLASS (widget)->stepper_size;
attributes.x = trough_border;
attributes.y = trough_border;
attributes.width = stepper_size;
attributes.height = stepper_size;
range->step_back = gdk_window_new (range->trough, &attributes, attributes_mask);
attributes.y = (widget->allocation.height -
widget->style->ythickness -
RANGE_CLASS (widget)->stepper_size);
trough_border -
stepper_size);
range->step_forw = gdk_window_new (range->trough, &attributes, attributes_mask);
attributes.x = widget->style->ythickness;
attributes.x = trough_border;
attributes.y = 0;
attributes.width = RANGE_CLASS (widget)->slider_width;
attributes.width = slider_width;
attributes.height = RANGE_CLASS (widget)->min_slider_size;
attributes.event_mask |= (GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
@ -269,11 +265,35 @@ gtk_vscrollbar_realize (GtkWidget *widget)
gdk_window_show (range->step_back);
}
static void
gtk_vscrollbar_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
gint slider_width;
gint trough_border;
gint stepper_size;
gint stepper_spacing;
GtkRange *range = GTK_RANGE (widget);
_gtk_range_get_props (range, &slider_width, &trough_border,
&stepper_size, &stepper_spacing);
requisition->width = (slider_width +
trough_border * 2);
requisition->height = (RANGE_CLASS (widget)->min_slider_size +
stepper_size +
stepper_spacing +
trough_border) * 2;
}
static void
gtk_vscrollbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkRange *range;
gint trough_border;
gint stepper_size;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_VSCROLLBAR (widget));
@ -284,21 +304,24 @@ gtk_vscrollbar_size_allocate (GtkWidget *widget,
{
range = GTK_RANGE (widget);
_gtk_range_get_props (range, NULL, &trough_border,
&stepper_size, NULL);
gdk_window_move_resize (range->trough,
allocation->x + (allocation->width - widget->requisition.width) / 2,
allocation->y,
widget->requisition.width, allocation->height);
gdk_window_move_resize (range->step_back,
widget->style->xthickness,
widget->style->ythickness,
widget->requisition.width - widget->style->xthickness * 2,
RANGE_CLASS (widget)->stepper_size);
trough_border,
trough_border,
widget->requisition.width - trough_border * 2,
stepper_size);
gdk_window_move_resize (range->step_forw,
widget->style->xthickness,
allocation->height - widget->style->ythickness -
RANGE_CLASS (widget)->stepper_size,
widget->requisition.width - widget->style->xthickness * 2,
RANGE_CLASS (widget)->stepper_size);
trough_border,
allocation->height - trough_border -
stepper_size,
widget->requisition.width - trough_border * 2,
stepper_size);
_gtk_range_slider_update (GTK_RANGE (widget));
}
@ -389,6 +412,7 @@ gtk_vscrollbar_calc_slider_size (GtkVScrollbar *vscrollbar)
gint step_back_y;
gint step_back_height;
gint step_forw_y;
gint stepper_spacing;
gint slider_width;
gint slider_height;
gint top, bottom;
@ -401,14 +425,16 @@ gtk_vscrollbar_calc_slider_size (GtkVScrollbar *vscrollbar)
{
range = GTK_RANGE (vscrollbar);
_gtk_range_get_props (range, NULL, NULL, NULL, &stepper_spacing);
gdk_window_get_size (range->step_back, NULL, &step_back_height);
gdk_window_get_position (range->step_back, NULL, &step_back_y);
gdk_window_get_position (range->step_forw, NULL, &step_forw_y);
top = (step_back_y +
step_back_height +
RANGE_CLASS (vscrollbar)->stepper_slider_spacing);
bottom = step_forw_y - RANGE_CLASS (vscrollbar)->stepper_slider_spacing;
stepper_spacing);
bottom = step_forw_y - stepper_spacing;
height = bottom - top;
if ((range->adjustment->page_size > 0) &&

View File

@ -29,6 +29,7 @@
#include <locale.h>
#include "gtkcontainer.h"
#include "gtkiconfactory.h"
#include "gtkintl.h"
#include "gtkmain.h"
#include "gtkrc.h"
#include "gtkselection.h"
@ -565,13 +566,14 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_marshal_VOID__VOID,
GTK_TYPE_NONE, 0);
widget_signals[SIZE_REQUEST] =
gtk_signal_new ("size_request",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, size_request),
gtk_marshal_VOID__BOXED,
GTK_TYPE_NONE, 1,
GTK_TYPE_REQUISITION | G_VALUE_NOCOPY_CONTENTS);
g_signal_newc ("size_request",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkWidgetClass, size_request),
NULL, NULL,
gtk_marshal_VOID__BOXED,
GTK_TYPE_NONE, 1,
GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE);
widget_signals[SIZE_ALLOCATE] =
gtk_signal_new ("size_allocate",
GTK_RUN_FIRST,
@ -955,6 +957,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_marshal_BOOLEAN__BOXED,
GTK_TYPE_BOOL, 1,
GTK_TYPE_GDK_EVENT);
widget_signals[POPUP_MENU] =
gtk_signal_new ("popup_menu",
GTK_RUN_LAST | GTK_RUN_ACTION,
@ -970,6 +973,13 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_binding_entry_add_signal (binding_set, GDK_Menu, 0,
"popup_menu", 0);
gtk_widget_class_install_style_property (klass,
g_param_spec_boolean ("interior_focus",
_("Interior Focus"),
_("Whether to draw the focus indicator inside widgets."),
FALSE,
G_PARAM_READABLE));
}
static void

View File

@ -32,6 +32,7 @@ style "global-style-properties"
{
# xthickness = 20
GtkSpinButton::shadow_type = etched-out
GtkOptionMenu::indicator_spacing = { 10, 10, 10, 10 }
}
class "GtkWidget" style "global-style-properties"

View File

@ -32,6 +32,7 @@ style "global-style-properties"
{
# xthickness = 20
GtkSpinButton::shadow_type = etched-out
GtkOptionMenu::indicator_spacing = { 10, 10, 10, 10 }
}
class "GtkWidget" style "global-style-properties"