1997-11-24 22:37:52 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
1999-02-24 07:37:18 +00:00
|
|
|
|
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
|
|
|
*/
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
#include "gtksignal.h"
|
|
|
|
#include "gtkeventbox.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void gtk_event_box_class_init (GtkEventBoxClass *klass);
|
|
|
|
static void gtk_event_box_init (GtkEventBox *event_box);
|
|
|
|
static void gtk_event_box_realize (GtkWidget *widget);
|
|
|
|
static void gtk_event_box_size_request (GtkWidget *widget,
|
1998-06-14 16:50:48 +00:00
|
|
|
GtkRequisition *requisition);
|
1997-11-24 22:37:52 +00:00
|
|
|
static void gtk_event_box_size_allocate (GtkWidget *widget,
|
1998-06-14 16:50:48 +00:00
|
|
|
GtkAllocation *allocation);
|
1999-01-15 16:00:39 +00:00
|
|
|
static void gtk_event_box_paint (GtkWidget *widget,
|
|
|
|
GdkRectangle *area);
|
|
|
|
static gint gtk_event_box_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
|
2001-03-09 13:28:26 +00:00
|
|
|
static GtkBinClass *parent_class = NULL;
|
|
|
|
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
GtkType
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_event_box_get_type (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
new function gtk_container_child_arg_set, similar to
Wed Jun 24 14:14:32 1998 Tim Janik <timj@gtk.org>
* gtk/gtkcontainer.c: new function gtk_container_child_arg_set, similar
to gtk_container_child_arg_setv, but takes a variable argument list.
new function gtk_container_get_child_arg_type, which is needed by
gtk_object_collect_args.
* gtk/gtkobject.c: changed prototype for gtk_object_collect_args, to
take a function pointer to figure the argument type.
adapted callers to pass gtk_object_get_arg_type.
* gtk/gtkwidget.c: adapted gtk_object_collect_args callers to pass
gtk_object_get_arg_type..
* gtk/gtkpacker.h:
* gtk/gtkpacker.c:
(gtk_packer_reorder_child): new function to change the packing order
of a child.
(gtk_packer_size_request):
(gtk_packer_size_allocate): take container->border_width into acount.
* gtk/gtkpacker.c: implemented widget arguments:
"GtkPacker::spacing", "GtkPacker::border_width", "GtkPacker::pad_x",
"GtkPacker::pad_y", "GtkPacker::ipad_x", "GtkPacker::ipad_y".
implemented child arguments:
"GtkPacker::side", "GtkPacker::anchor", "GtkPacker::expand",
"GtkPacker::fill_x", "GtkPacker::fill_y", "GtkPacker::use_default",
"GtkPacker::border_width", "GtkPacker::pad_x", "GtkPacker::pad_y",
"GtkPacker::ipad_x", "GtkPacker::ipad_y", "GtkPacker::position".
* gtk/gtkmisc.c (gtk_misc_set_arg): for padding args, set the padding,
not the alignment.
* gtk/gtkeventbox.h:
* gtk/gtkeventbox.c: GtkType and macro fixups.
* gtk/testgtk.c (entry_toggle_sensitive): new function to toggle
sensitivity of an entry.
* gtk/gtkstyle.c (gtk_style_new): support normal grey as default color
for insensitive base.
* gtk/gtkentry.c (gtk_entry_realize): set the window backgrounds
widget state dependent.
(gtk_entry_style_set): likewise.
(gtk_entry_state_changed): set background color on state changes.
(gtk_entry_draw_text): for non selected text, use state dependent
colors.
* gtk/gtktogglebutton.c: support for widget arguments
"GtkToggleButton::active" and "GtkToggleButton::draw_indicator".
1998-06-24 12:22:23 +00:00
|
|
|
static GtkType event_box_type = 0;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
if (!event_box_type)
|
|
|
|
{
|
1998-11-30 19:07:15 +00:00
|
|
|
static const GtkTypeInfo event_box_info =
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
"GtkEventBox",
|
|
|
|
sizeof (GtkEventBox),
|
|
|
|
sizeof (GtkEventBoxClass),
|
|
|
|
(GtkClassInitFunc) gtk_event_box_class_init,
|
|
|
|
(GtkObjectInitFunc) gtk_event_box_init,
|
1998-07-04 15:31:30 +00:00
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
1998-06-28 07:46:10 +00:00
|
|
|
(GtkClassInitFunc) NULL,
|
1997-11-24 22:37:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
event_box_type = gtk_type_unique (gtk_bin_get_type (), &event_box_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return event_box_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_event_box_class_init (GtkEventBoxClass *class)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class;
|
|
|
|
|
2001-03-09 13:28:26 +00:00
|
|
|
parent_class = g_type_class_peek_parent (class);
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
widget_class = (GtkWidgetClass*) class;
|
|
|
|
|
|
|
|
widget_class->realize = gtk_event_box_realize;
|
|
|
|
widget_class->size_request = gtk_event_box_size_request;
|
|
|
|
widget_class->size_allocate = gtk_event_box_size_allocate;
|
|
|
|
widget_class->expose_event = gtk_event_box_expose;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_event_box_init (GtkEventBox *event_box)
|
|
|
|
{
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (event_box, GTK_NO_WINDOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget*
|
1998-05-03 22:41:32 +00:00
|
|
|
gtk_event_box_new (void)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-01-30 22:29:03 +00:00
|
|
|
return GTK_WIDGET (gtk_type_new (gtk_event_box_get_type ()));
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_event_box_realize (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GdkWindowAttr attributes;
|
|
|
|
gint attributes_mask;
|
1998-03-24 01:43:21 +00:00
|
|
|
gint border_width;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
|
|
|
|
|
1998-03-24 01:43:21 +00:00
|
|
|
border_width = GTK_CONTAINER (widget)->border_width;
|
|
|
|
|
|
|
|
attributes.x = widget->allocation.x + border_width;
|
|
|
|
attributes.y = widget->allocation.y + border_width;
|
|
|
|
attributes.width = widget->allocation.width - 2*border_width;
|
|
|
|
attributes.height = widget->allocation.height - 2*border_width;
|
1997-11-24 22:37:52 +00:00
|
|
|
attributes.window_type = GDK_WINDOW_CHILD;
|
|
|
|
attributes.wclass = GDK_INPUT_OUTPUT;
|
|
|
|
attributes.visual = gtk_widget_get_visual (widget);
|
|
|
|
attributes.colormap = gtk_widget_get_colormap (widget);
|
|
|
|
attributes.event_mask = gtk_widget_get_events (widget)
|
|
|
|
| GDK_BUTTON_MOTION_MASK
|
|
|
|
| GDK_BUTTON_PRESS_MASK
|
|
|
|
| GDK_BUTTON_RELEASE_MASK
|
|
|
|
| GDK_EXPOSURE_MASK
|
|
|
|
| GDK_ENTER_NOTIFY_MASK
|
|
|
|
| GDK_LEAVE_NOTIFY_MASK;
|
|
|
|
|
|
|
|
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
|
|
|
|
1998-01-18 15:09:10 +00:00
|
|
|
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
|
1997-11-24 22:37:52 +00:00
|
|
|
gdk_window_set_user_data (widget->window, widget);
|
|
|
|
|
|
|
|
widget->style = gtk_style_attach (widget->style, widget->window);
|
|
|
|
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_event_box_size_request (GtkWidget *widget,
|
2002-01-28 18:52:49 +00:00
|
|
|
GtkRequisition *requisition)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-01-30 22:29:03 +00:00
|
|
|
GtkBin *bin = GTK_BIN (widget);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
requisition->width = GTK_CONTAINER (widget)->border_width * 2;
|
|
|
|
requisition->height = GTK_CONTAINER (widget)->border_width * 2;
|
|
|
|
|
|
|
|
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
|
|
|
|
{
|
1999-02-10 02:35:09 +00:00
|
|
|
GtkRequisition child_requisition;
|
|
|
|
|
|
|
|
gtk_widget_size_request (bin->child, &child_requisition);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
1999-02-10 02:35:09 +00:00
|
|
|
requisition->width += child_requisition.width;
|
|
|
|
requisition->height += child_requisition.height;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_event_box_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation)
|
|
|
|
{
|
|
|
|
GtkBin *bin;
|
|
|
|
GtkAllocation child_allocation;
|
|
|
|
|
|
|
|
widget->allocation = *allocation;
|
|
|
|
bin = GTK_BIN (widget);
|
|
|
|
|
1998-05-23 21:55:40 +00:00
|
|
|
child_allocation.x = 0;
|
|
|
|
child_allocation.y = 0;
|
1998-04-03 23:17:16 +00:00
|
|
|
child_allocation.width = MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0);
|
|
|
|
child_allocation.height = MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
if (GTK_WIDGET_REALIZED (widget))
|
|
|
|
{
|
|
|
|
gdk_window_move_resize (widget->window,
|
|
|
|
allocation->x + GTK_CONTAINER (widget)->border_width,
|
|
|
|
allocation->y + GTK_CONTAINER (widget)->border_width,
|
|
|
|
child_allocation.width,
|
|
|
|
child_allocation.height);
|
|
|
|
}
|
|
|
|
|
1998-05-22 21:33:44 +00:00
|
|
|
if (bin->child)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
gtk_widget_size_allocate (bin->child, &child_allocation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-15 16:00:39 +00:00
|
|
|
static void
|
|
|
|
gtk_event_box_paint (GtkWidget *widget,
|
|
|
|
GdkRectangle *area)
|
|
|
|
{
|
2002-09-24 10:22:45 +00:00
|
|
|
if (!GTK_WIDGET_APP_PAINTABLE (widget))
|
|
|
|
gtk_paint_flat_box (widget->style, widget->window,
|
|
|
|
widget->state, GTK_SHADOW_NONE,
|
|
|
|
area, widget, "eventbox",
|
|
|
|
0, 0, -1, -1);
|
1999-01-15 16:00:39 +00:00
|
|
|
}
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
static gint
|
|
|
|
gtk_event_box_expose (GtkWidget *widget,
|
|
|
|
GdkEventExpose *event)
|
|
|
|
{
|
|
|
|
if (GTK_WIDGET_DRAWABLE (widget))
|
|
|
|
{
|
1999-01-15 16:00:39 +00:00
|
|
|
gtk_event_box_paint (widget, &event->area);
|
|
|
|
|
2001-03-09 13:28:26 +00:00
|
|
|
(* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|