summaryrefslogtreecommitdiff
path: root/gtk/gtkbutton.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@gtk.org>1998-05-03 22:41:32 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-05-03 22:41:32 +0000
commit4851efe29604e1d950dc9711d9d7ced69771f2e9 (patch)
treece3b07c7f78836ae33f34479193041f19e9548d6 /gtk/gtkbutton.c
parentc0b92323516fef167517dc9ab645dcfd4075227e (diff)
downloadgtk+-4851efe29604e1d950dc9711d9d7ced69771f2e9.tar.gz
configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on
Sun May 3 13:38:22 1998 Owen Taylor <otaylor@gtk.org> * configure.in acheader.h gdk/gdkwindow.c Check for Shape extension both on the client and server side. (And, more importantly, check for the shape extension so we may include -lXext even when compiling with --disable-xshm) Don't set override_redirect on all shaped windows. It isn't necessary. * gdk/gdkwindow.c: Set ->colormap to NULL for root and foreign windows. Use this to check if we need to get the colormap from X. Fri May 1 22:32:47 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkbutton.c (gtk_button_paint): Draw the areas between the default and the button always in GTK_STATE_NORMAL. * gtk/gtkrange.c (gtk_range_style_set): Added a style_set callback. Fri May 1 16:40:57 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkpixmap.c (gdk_pixmap_colormap_create_from_xpmp[_d]): Fix a buffer overflow on pixmaps that claim to have more than 31 characters per pixel. (gdk_pixmap_read_string): Don't wrap around strings longer than half of address space ;-) * gtk/gtk[vh]ruler.c gtk/gtkinputdialog.c: Expand some buffers that were used for printing integers. * */* (almost): Style: All int foo () { ... } changed to int foo (void) { ... } ^^^^^^^ This is why some many files changed Even where there were proper prototypes elsewhere. * gdk/gxid.c (handle_claim_device): Some extra checks. It isn't safe against being fed bad X id's, but at least it should be safe against deleting all your files.
Diffstat (limited to 'gtk/gtkbutton.c')
-rw-r--r--gtk/gtkbutton.c106
1 files changed, 92 insertions, 14 deletions
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 6263d4b763..7bed40f52a 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -41,7 +41,7 @@ enum {
ARG_0,
ARG_LABEL
};
-
+
static void gtk_button_class_init (GtkButtonClass *klass);
@@ -94,7 +94,7 @@ static guint button_signals[LAST_SIGNAL] = { 0 };
guint
-gtk_button_get_type ()
+gtk_button_get_type (void)
{
static guint button_type = 0;
@@ -219,16 +219,16 @@ gtk_button_set_arg (GtkButton *button,
{
case ARG_LABEL:
gtk_container_disable_resize (GTK_CONTAINER (button));
-
+
if (button->child)
{
gtk_widget_unparent (button->child);
button->child = NULL;
}
-
+
label = gtk_label_new (GTK_VALUE_STRING(*arg));
gtk_widget_show (label);
-
+
gtk_container_add (GTK_CONTAINER (button), label);
gtk_container_enable_resize (GTK_CONTAINER (button));
break;
@@ -239,7 +239,7 @@ gtk_button_set_arg (GtkButton *button,
}
GtkWidget*
-gtk_button_new ()
+gtk_button_new (void)
{
return GTK_WIDGET (gtk_type_new (gtk_button_get_type ()));
}
@@ -433,9 +433,9 @@ gtk_button_size_allocate (GtkWidget *widget,
DEFAULT_LEFT_POS);
child_allocation.y += (GTK_WIDGET (widget)->style->klass->ythickness +
DEFAULT_TOP_POS);
- child_allocation.width = MAX (1, child_allocation.width -
+ child_allocation.width = MAX (1, child_allocation.width -
(GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
- child_allocation.height = MAX (1, child_allocation.height -
+ child_allocation.height = MAX (1, child_allocation.height -
(GTK_WIDGET (widget)->style->klass->xthickness * 2 + DEFAULT_SPACING));
}
@@ -443,25 +443,60 @@ gtk_button_size_allocate (GtkWidget *widget,
}
}
+/*
+ * +------------------------------------------------+
+ * | BORDER |
+ * | +------------------------------------------+ |
+ * | |\\\\\\\\\\\\\\\\DEFAULT\\\\\\\\\\\\\\\\\ | |
+ * | |\\+------------------------------------+ | |
+ * | |\\| | SPACING 3 | | | |
+ * | |\\| +--------------------------------+ | | |
+ * | |\\| |########## FOCUS ###############| | | |
+ * | |\\| |#+----------------------------+#| | | |
+ * | |\\| |#| RELIEF \|#| | | |
+ * | |\\| |#| +-----------------------+\|#| | | |
+ * | |\\|1|#| + THE TEXT +\|#|2| | |
+ * | |\\| |#| +-----------------------+\|#| | | |
+ * | |\\| |#| \\\\\ ythickness \\\\\\\\\\|#| | | |
+ * | |\\| |#+----------------------------+#| | | |
+ * | |\\| |########### 1 ##################| | | |
+ * | |\\| +--------------------------------+ | | |
+ * | |\\| | default spacing 4 | | | |
+ * | |\\+------------------------------------+ | |
+ * | |\ ythickness | |
+ * | +------------------------------------------+ |
+ * | border_width |
+ * +------------------------------------------------+
+ */
+
static void
gtk_button_paint (GtkWidget *widget,
GdkRectangle *area)
{
GdkRectangle restrict_area;
+ GdkRectangle outer_area;
+ GdkRectangle tmp_area;
GdkRectangle new_area;
+ gint xthickness;
+ gint ythickness;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_BUTTON (widget));
+ xthickness = widget->style->klass->xthickness;
+ ythickness = widget->style->klass->ythickness;
+
if (GTK_WIDGET_DRAWABLE (widget))
{
- restrict_area.x = GTK_WIDGET (widget)->style->klass->xthickness;
- restrict_area.y = GTK_WIDGET (widget)->style->klass->ythickness;
- restrict_area.width = GTK_WIDGET (widget)->allocation.width -
+ restrict_area.x = xthickness;
+ restrict_area.y = ythickness;
+ restrict_area.width = GTK_WIDGET (widget)->allocation.width -
restrict_area.x * 2 - GTK_CONTAINER (widget)->border_width * 2;
- restrict_area.height = GTK_WIDGET (widget)->allocation.height -
+ restrict_area.height = GTK_WIDGET (widget)->allocation.height -
restrict_area.y * 2 - GTK_CONTAINER (widget)->border_width * 2;
+ outer_area = restrict_area;
+
if (GTK_WIDGET_CAN_DEFAULT (widget))
{
restrict_area.x += DEFAULT_LEFT_POS;
@@ -477,6 +512,49 @@ gtk_button_paint (GtkWidget *widget,
new_area.x, new_area.y,
new_area.width, new_area.height);
}
+
+ if (GTK_WIDGET_CAN_DEFAULT (widget))
+ {
+ /* Now fill spacing area between the default border and the button */
+
+ /* 1 */ tmp_area = outer_area;
+ tmp_area.width = restrict_area.x - outer_area.x;
+ if (gdk_rectangle_intersect (area, &tmp_area, &new_area))
+ gdk_draw_rectangle (widget->window,
+ widget->style->bg_gc[GTK_STATE_NORMAL],
+ TRUE,
+ new_area.x, new_area.y,
+ new_area.width, new_area.height);
+
+ /* 2 */ tmp_area.x = restrict_area.x + restrict_area.width;
+
+ if (gdk_rectangle_intersect (area, &tmp_area, &new_area))
+ gdk_draw_rectangle (widget->window,
+ widget->style->bg_gc[GTK_STATE_NORMAL],
+ TRUE,
+ new_area.x, new_area.y,
+ new_area.width, new_area.height);
+
+ /* 3 */ tmp_area.width = restrict_area.width;
+ tmp_area.height = restrict_area.y - outer_area.y;
+ tmp_area.x = restrict_area.x;
+
+ if (gdk_rectangle_intersect (area, &tmp_area, &new_area))
+ gdk_draw_rectangle (widget->window,
+ widget->style->bg_gc[GTK_STATE_NORMAL],
+ TRUE,
+ new_area.x, new_area.y,
+ new_area.width, new_area.height);
+
+ /* 4 */ tmp_area.y = restrict_area.y + restrict_area.height;
+
+ if (gdk_rectangle_intersect (area, &tmp_area, &new_area))
+ gdk_draw_rectangle (widget->window,
+ widget->style->bg_gc[GTK_STATE_NORMAL],
+ TRUE,
+ new_area.x, new_area.y,
+ new_area.width, new_area.height);
+ }
}
}
@@ -790,12 +868,12 @@ gtk_button_add (GtkContainer *container,
if (GTK_WIDGET_REALIZED (widget->parent) &&
!GTK_WIDGET_REALIZED (widget))
gtk_widget_realize (widget);
-
+
if (GTK_WIDGET_MAPPED (widget->parent) &&
!GTK_WIDGET_MAPPED (widget))
gtk_widget_map (widget);
}
-
+
button->child = widget;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container))