summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-04-30 23:23:54 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-04-30 23:23:54 +0000
commit2d372c4053d512c1825f681326f6e4187c399e5a (patch)
treef88f272aef4068e7614f02c68b33584b27eac334 /gtk
parent483f2d520346952ed7f20d632b1a5967549d3a53 (diff)
downloadgdk-pixbuf-2d372c4053d512c1825f681326f6e4187c399e5a.tar.gz
Add an extra parameter use_text to gtk_paint_label() to deal with
Mon Apr 30 19:18:07 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkstyle.[ch] gtk/gtkaccellabel.c gtk/gtkcellrenderertext.c gtk/gtkhruler.c gtk/gtkhscale.c gtk/gtklabel.c gtk/gtkprogressbar.c gtk/gtkvruler.c gtk/gtkvscale.c: Add an extra parameter use_text to gtk_paint_label() to deal with style->bg[] vs style->text[]. * gtk/gtkbbox.c gtk/gtkdialog.c: Tweak padding some to deal with GtkWidget::interior_focus = TRUE better. * gtk/gtkbutton.c * gtk/gtkwidget.c (gtk_widget_style_get_valist): Remove G_VALUE_NO_COPY_CONTENTS, to correspond with the recent change that had to be made with g_object_get.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkaccellabel.c1
-rw-r--r--gtk/gtkbbox.c2
-rw-r--r--gtk/gtkbutton.c103
-rw-r--r--gtk/gtkcellrenderertext.c1
-rw-r--r--gtk/gtkdialog.c4
-rw-r--r--gtk/gtkhruler.c1
-rw-r--r--gtk/gtkhscale.c1
-rw-r--r--gtk/gtklabel.c1
-rw-r--r--gtk/gtkoptionmenu.c63
-rw-r--r--gtk/gtkprogressbar.c1
-rw-r--r--gtk/gtkstyle.c20
-rw-r--r--gtk/gtkstyle.h3
-rw-r--r--gtk/gtkvruler.c1
-rw-r--r--gtk/gtkvscale.c1
-rw-r--r--gtk/gtkwidget.c2
15 files changed, 142 insertions, 63 deletions
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c
index c872677d8..bb332f1fa 100644
--- a/gtk/gtkaccellabel.c
+++ b/gtk/gtkaccellabel.c
@@ -292,6 +292,7 @@ gtk_accel_label_expose_event (GtkWidget *widget,
gtk_paint_layout (widget->style,
widget->window,
GTK_WIDGET_STATE (widget),
+ FALSE,
&event->area,
widget,
"accellabel",
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index 720248e95..51f2bb5e1 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -33,7 +33,7 @@ static void gtk_button_box_init (GtkButtonBox *box);
#define DEFAULT_CHILD_MIN_WIDTH 85
#define DEFAULT_CHILD_MIN_HEIGHT 27
-#define DEFAULT_CHILD_IPAD_X 7
+#define DEFAULT_CHILD_IPAD_X 4
#define DEFAULT_CHILD_IPAD_Y 0
GtkType
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index bb9a0cd2e..38eee0571 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -36,7 +36,9 @@
#include "gtkintl.h"
#define CHILD_SPACING 1
-#define DEFAULT_SPACING 7
+
+static GtkBorder default_default_border = { 5, 5, 6, 6 };
+static GtkBorder default_default_outside_border = { 5, 5, 6, 6 };
/* Time out before giving up on getting a key release when animatng
* the close button.
@@ -233,13 +235,18 @@ gtk_button_class_init (GtkButtonClass *klass)
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));
+ g_param_spec_boxed ("default_border",
+ _("Default Spacing"),
+ _("Extra space to add for CAN_DEFAULT buttons"),
+ GTK_TYPE_BORDER,
+ G_PARAM_READABLE));
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("default_outside_border",
+ _("Default Outside Spacing"),
+ _("Extra space to add for CAN_DEFAULT buttons that is always drawn outside the border"),
+ GTK_TYPE_BORDER,
+ G_PARAM_READABLE));
}
static void
@@ -540,13 +547,38 @@ gtk_button_unrealize (GtkWidget *widget)
static void
gtk_button_get_props (GtkButton *button,
- gint *default_spacing,
+ GtkBorder *default_border,
+ GtkBorder *default_outside_border,
gboolean *interior_focus)
{
GtkWidget *widget = GTK_WIDGET (button);
+ GtkBorder *tmp_border;
+
+ if (default_border)
+ {
+ gtk_widget_style_get (widget, "default_border", &tmp_border, NULL);
+
+ if (tmp_border)
+ {
+ *default_border = *tmp_border;
+ g_free (tmp_border);
+ }
+ else
+ *default_border = default_default_border;
+ }
- if (default_spacing)
- gtk_widget_style_get (widget, "default_spacing", default_spacing, NULL);
+ if (default_outside_border)
+ {
+ gtk_widget_style_get (widget, "default_outside_border", &tmp_border, NULL);
+
+ if (tmp_border)
+ {
+ *default_outside_border = *tmp_border;
+ g_free (tmp_border);
+ }
+ else
+ *default_outside_border = default_default_outside_border;
+ }
if (interior_focus)
gtk_widget_style_get (widget, "interior_focus", interior_focus, NULL);
@@ -557,10 +589,10 @@ gtk_button_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkButton *button = GTK_BUTTON (widget);
- gint default_spacing;
+ GtkBorder default_border;
gboolean interior_focus;
- gtk_button_get_props (button, &default_spacing, &interior_focus);
+ gtk_button_get_props (button, &default_border, NULL, &interior_focus);
requisition->width = (GTK_CONTAINER (widget)->border_width + CHILD_SPACING +
GTK_WIDGET (widget)->style->xthickness) * 2;
@@ -569,10 +601,8 @@ gtk_button_size_request (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (widget))
{
- requisition->width += (GTK_WIDGET (widget)->style->xthickness * 2 +
- default_spacing);
- requisition->height += (GTK_WIDGET (widget)->style->ythickness * 2 +
- default_spacing);
+ requisition->width += default_border.left + default_border.right;
+ requisition->height += default_border.top + default_border.bottom;
}
if (GTK_BIN (button)->child && GTK_WIDGET_VISIBLE (GTK_BIN (button)->child))
@@ -602,9 +632,9 @@ gtk_button_size_allocate (GtkWidget *widget,
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;
+ GtkBorder default_border;
- gtk_button_get_props (button, &default_spacing, NULL);
+ gtk_button_get_props (button, &default_border, NULL, NULL);
widget->allocation = *allocation;
@@ -627,14 +657,10 @@ gtk_button_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_CAN_DEFAULT (button))
{
- child_allocation.x += (GTK_WIDGET (widget)->style->xthickness +
- (1 + default_spacing) / 2);
- child_allocation.y += (GTK_WIDGET (widget)->style->ythickness +
- (1 + default_spacing) / 2);
- child_allocation.width = MAX (1, (gint)child_allocation.width -
- (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));
+ child_allocation.x += default_border.left;
+ child_allocation.y += default_border.top;
+ child_allocation.width = MAX (1, child_allocation.width - default_border.left - default_border.right);
+ child_allocation.height = MAX (1, child_allocation.height - default_border.top - default_border.bottom);
}
gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
@@ -675,14 +701,15 @@ gtk_button_paint (GtkWidget *widget,
GtkShadowType shadow_type;
gint width, height;
gint x, y;
- gint default_spacing;
+ GtkBorder default_border;
+ GtkBorder default_outside_border;
gboolean interior_focus;
if (GTK_WIDGET_DRAWABLE (widget))
{
button = GTK_BUTTON (widget);
- gtk_button_get_props (button, &default_spacing, &interior_focus);
+ gtk_button_get_props (button, &default_border, &default_outside_border, &interior_focus);
x = 0;
y = 0;
@@ -699,16 +726,18 @@ gtk_button_paint (GtkWidget *widget,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
area, widget, "buttondefault",
x, y, width, height);
- }
- if (GTK_WIDGET_CAN_DEFAULT (widget))
+ x += default_border.left;
+ y += default_border.top;
+ width -= default_border.left + default_border.right;
+ height -= default_border.top + default_border.bottom;
+ }
+ else if (GTK_WIDGET_CAN_DEFAULT (widget))
{
- x += widget->style->xthickness;
- y += widget->style->ythickness;
- width -= 2 * x + default_spacing;
- height -= 2 * y + default_spacing;
- x += (1 + default_spacing) / 2;
- y += (1 + default_spacing) / 2;
+ x += default_outside_border.left;
+ y += default_outside_border.top;
+ width -= default_outside_border.left + default_outside_border.right;
+ height -= default_outside_border.top + default_outside_border.bottom;
}
if (!interior_focus && GTK_WIDGET_HAS_FOCUS (widget))
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 50afc6b8f..9a6f65cbf 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -1139,6 +1139,7 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
gtk_paint_layout (widget->style,
window,
state,
+ TRUE,
cell_area,
widget,
"cellrenderertext",
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 324f781d1..c0f0ea118 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -146,7 +146,7 @@ gtk_dialog_class_init (GtkDialogClass *class)
_("Spacing between buttons"),
0,
G_MAXINT,
- 1,
+ 10,
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
@@ -155,7 +155,7 @@ gtk_dialog_class_init (GtkDialogClass *class)
_("Width of border around the button area at the bottom of the dialog"),
0,
G_MAXINT,
- 0,
+ 5,
G_PARAM_READABLE));
}
diff --git a/gtk/gtkhruler.c b/gtk/gtkhruler.c
index d1d637c4a..c220d14f7 100644
--- a/gtk/gtkhruler.c
+++ b/gtk/gtkhruler.c
@@ -264,6 +264,7 @@ gtk_hruler_draw_ticks (GtkRuler *ruler)
gtk_paint_layout (widget->style,
ruler->backing_store,
GTK_WIDGET_STATE (widget),
+ FALSE,
NULL,
widget,
"hruler",
diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c
index 43739548b..0fa644b68 100644
--- a/gtk/gtkhscale.c
+++ b/gtk/gtkhscale.c
@@ -588,6 +588,7 @@ gtk_hscale_draw_value (GtkScale *scale)
gtk_paint_layout (widget->style,
widget->window,
state_type,
+ FALSE,
NULL,
widget,
"hscale",
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 028b6a709..ddcfd428f 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -1258,6 +1258,7 @@ gtk_label_expose (GtkWidget *widget,
gtk_paint_layout (widget->style,
widget->window,
GTK_WIDGET_STATE (widget),
+ FALSE,
&event->area,
widget,
"label",
diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c
index 6c8a18f4c..7343efffb 100644
--- a/gtk/gtkoptionmenu.c
+++ b/gtk/gtkoptionmenu.c
@@ -41,11 +41,13 @@ typedef struct _GtkOptionMenuProps GtkOptionMenuProps;
struct _GtkOptionMenuProps
{
+ gboolean interior_focus;
GtkRequisition indicator_size;
GtkBorder indicator_spacing;
};
static GtkOptionMenuProps default_props = {
+ FALSE,
{ 12, 8 },
{ 3, 7, 2, 2 } /* Left, right, top, bottom */
};
@@ -336,6 +338,7 @@ gtk_option_menu_get_props (GtkOptionMenu *option_menu,
gtk_widget_style_get (GTK_WIDGET (option_menu),
"indicator_size", &indicator_size,
"indicator_spacing", &indicator_spacing,
+ "interior_focus", &props->interior_focus,
NULL);
if (indicator_size)
@@ -439,19 +442,29 @@ gtk_option_menu_paint (GtkWidget *widget,
if (GTK_WIDGET_DRAWABLE (widget))
{
+ gint border_width = GTK_CONTAINER (widget)->border_width;
+
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;
- button_area.height = widget->allocation.height - button_area.y * 2;
+ button_area.x = border_width;
+ button_area.y = border_width;
+ button_area.width = widget->allocation.width - 2 * border_width;
+ button_area.height = widget->allocation.height - 2 * border_width;
- /* This is evil, and should be elimated here and in the button
- * code. The point is to clear the focus, and make it
- * sort of transparent if it isn't there.
- */
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
- gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
+ if (!props.interior_focus)
+ {
+ button_area.x += 1;
+ button_area.y += 1;
+ button_area.width -= 2;
+ button_area.height -= 2;
+
+ /* This is evil, and should be elimated here and in the button
+ * code. The point is to clear the focus, and make it
+ * sort of transparent if it isn't there.
+ */
+ gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+ gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
+ }
gtk_paint_box(widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_OUT,
@@ -469,12 +482,30 @@ gtk_option_menu_paint (GtkWidget *widget,
props.indicator_size.width, props.indicator_size.height);
if (GTK_WIDGET_HAS_FOCUS (widget))
- gtk_paint_focus (widget->style, widget->window,
- area, widget, "button",
- button_area.x - 1,
- button_area.y - 1,
- button_area.width + 1,
- button_area.height + 1);
+ {
+ if (props.interior_focus)
+ {
+ button_area.x += widget->style->xthickness + 1;
+ button_area.y += widget->style->ythickness + 1;
+ button_area.width -= 2 * (widget->style->xthickness + 1)
+ + props.indicator_spacing.left + props.indicator_spacing.right + props.indicator_size.width;
+ button_area.height -= 2 * (widget->style->ythickness + 1);
+ }
+ else
+ {
+ button_area.x -= 1;
+ button_area.y -= 1;
+ button_area.width += 2;
+ button_area.height += 2;
+ }
+
+ gtk_paint_focus (widget->style, widget->window,
+ area, widget, "button",
+ button_area.x,
+ button_area.y,
+ button_area.width - 1,
+ button_area.height - 1);
+ }
}
}
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index af1e82cd5..c02a9814d 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -833,6 +833,7 @@ gtk_progress_bar_paint (GtkProgress *progress)
gtk_paint_layout (widget->style,
progress->offscreen_pixmap,
GTK_WIDGET_STATE (widget),
+ FALSE,
&rect,
widget,
"progressbar",
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index d0c46fd91..3bc711cd9 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -281,6 +281,7 @@ static void gtk_default_draw_expander (GtkStyle *style,
static void gtk_default_draw_layout (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
+ gboolean use_text,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
@@ -1030,6 +1031,7 @@ void
gtk_draw_layout (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
+ gboolean use_text,
gint x,
gint y,
PangoLayout *layout)
@@ -1037,7 +1039,7 @@ gtk_draw_layout (GtkStyle *style,
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
- GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type,
+ GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text,
NULL, NULL, NULL,
x, y, layout);
}
@@ -3903,6 +3905,7 @@ static void
gtk_default_draw_layout (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
+ gboolean use_text,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
@@ -3910,11 +3913,15 @@ gtk_default_draw_layout (GtkStyle *style,
gint y,
PangoLayout *layout)
{
+ GdkGC *gc;
+
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (window != NULL);
+
+ gc = use_text ? style->text_gc[state_type] : style->fg_gc[state_type];
if (area)
- gdk_gc_set_clip_rectangle (style->text_gc[state_type], area);
+ gdk_gc_set_clip_rectangle (gc, area);
if (state_type == GTK_STATE_INSENSITIVE)
{
@@ -3922,17 +3929,17 @@ gtk_default_draw_layout (GtkStyle *style,
ins = get_insensitive_layout (layout);
- gdk_draw_layout (window, style->text_gc[state_type], x, y, ins);
+ gdk_draw_layout (window, gc, x, y, ins);
g_object_unref (G_OBJECT (ins));
}
else
{
- gdk_draw_layout (window, style->text_gc[state_type], x, y, layout);
+ gdk_draw_layout (window, gc, x, y, layout);
}
if (area)
- gdk_gc_set_clip_rectangle (style->text_gc[state_type], NULL);
+ gdk_gc_set_clip_rectangle (gc, NULL);
}
static void
@@ -4561,6 +4568,7 @@ void
gtk_paint_layout (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
+ gboolean use_text,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
@@ -4571,7 +4579,7 @@ gtk_paint_layout (GtkStyle *style,
g_return_if_fail (GTK_IS_STYLE (style));
g_return_if_fail (GTK_STYLE_GET_CLASS (style)->draw_layout != NULL);
- GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, area,
+ GTK_STYLE_GET_CLASS (style)->draw_layout (style, window, state_type, use_text, area,
widget, detail, x, y, layout);
}
diff --git a/gtk/gtkstyle.h b/gtk/gtkstyle.h
index a07965f5c..1109071c0 100644
--- a/gtk/gtkstyle.h
+++ b/gtk/gtkstyle.h
@@ -381,6 +381,7 @@ struct _GtkStyleClass
void (*draw_layout) (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
+ gboolean use_text,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
@@ -588,6 +589,7 @@ void gtk_draw_expander (GtkStyle *style,
void gtk_draw_layout (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
+ gboolean use_text,
gint x,
gint y,
PangoLayout *layout);
@@ -804,6 +806,7 @@ void gtk_paint_expander (GtkStyle *style,
void gtk_paint_layout (GtkStyle *style,
GdkWindow *window,
GtkStateType state_type,
+ gboolean use_text,
GdkRectangle *area,
GtkWidget *widget,
const gchar *detail,
diff --git a/gtk/gtkvruler.c b/gtk/gtkvruler.c
index 6b5d6caa8..e22cfb30d 100644
--- a/gtk/gtkvruler.c
+++ b/gtk/gtkvruler.c
@@ -261,6 +261,7 @@ gtk_vruler_draw_ticks (GtkRuler *ruler)
gtk_paint_layout (widget->style,
ruler->backing_store,
GTK_WIDGET_STATE (widget),
+ FALSE,
NULL,
widget,
"vruler",
diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c
index 71e4a0e79..72b8b209a 100644
--- a/gtk/gtkvscale.c
+++ b/gtk/gtkvscale.c
@@ -598,6 +598,7 @@ gtk_vscale_draw_value (GtkScale *scale)
gtk_paint_layout (widget->style,
widget->window,
state_type,
+ FALSE,
NULL,
widget,
"vscale",
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8e89f6f3e..8692ca65f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5504,7 +5504,7 @@ gtk_widget_style_get_valist (GtkWidget *widget,
G_OBJECT_TYPE (widget),
pspec,
g_param_spec_get_qdata (pspec, quark_property_parser));
- G_VALUE_LCOPY (peek_value, var_args, G_VALUE_NOCOPY_CONTENTS, &error);
+ G_VALUE_LCOPY (peek_value, var_args, 0, &error);
if (error)
{
g_warning ("%s: %s", G_STRLOC, error);