]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkeventbox.c
Make code compile with unknown value of GDK_WINDOWING
[~andy/gtk] / gtk / gtkeventbox.c
index b18e1646ae721e5d60b2c9d3d9f43c950625b431..fb3775fd9107248009d9fc051663d5f58eff1f66 100644 (file)
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
  */
+
+/*
+ * Modified by the GTK+ Team and others 1997-1999.  See the AUTHORS
+ * 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/. 
+ */
+
 #include "gtksignal.h"
 #include "gtkeventbox.h"
 
@@ -23,31 +32,34 @@ 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,
-                                                  GtkRequisition   *requisition);
+                                                   GtkRequisition   *requisition);
 static void gtk_event_box_size_allocate            (GtkWidget        *widget,
-                                                  GtkAllocation    *allocation);
-static void gtk_event_box_draw                     (GtkWidget    *widget,
-                                                  GdkRectangle *area);
-static gint gtk_event_box_expose                   (GtkWidget      *widget,
-                                                  GdkEventExpose *event);
+                                                   GtkAllocation    *allocation);
+static void gtk_event_box_paint                    (GtkWidget         *widget,
+                                                   GdkRectangle      *area);
+static void gtk_event_box_draw                     (GtkWidget         *widget,
+                                                  GdkRectangle       *area);
+static gint gtk_event_box_expose                   (GtkWidget         *widget,
+                                                  GdkEventExpose     *event);
 
 
-guint
-gtk_event_box_get_type ()
+GtkType
+gtk_event_box_get_type (void)
 {
-  static guint event_box_type = 0;
+  static GtkType event_box_type = 0;
 
   if (!event_box_type)
     {
-      GtkTypeInfo event_box_info =
+      static const GtkTypeInfo event_box_info =
       {
        "GtkEventBox",
        sizeof (GtkEventBox),
        sizeof (GtkEventBoxClass),
        (GtkClassInitFunc) gtk_event_box_class_init,
        (GtkObjectInitFunc) gtk_event_box_init,
-       (GtkArgSetFunc) NULL,
-        (GtkArgGetFunc) NULL,
+       /* reserved_1 */ NULL,
+        /* reserved_2 */ NULL,
+        (GtkClassInitFunc) NULL,
       };
 
       event_box_type = gtk_type_unique (gtk_bin_get_type (), &event_box_info);
@@ -74,11 +86,10 @@ static void
 gtk_event_box_init (GtkEventBox *event_box)
 {
   GTK_WIDGET_UNSET_FLAGS (event_box, GTK_NO_WINDOW);
-  GTK_WIDGET_SET_FLAGS (event_box, GTK_BASIC);
 }
 
 GtkWidget*
-gtk_event_box_new ()
+gtk_event_box_new (void)
 {
   return GTK_WIDGET ( gtk_type_new (gtk_event_box_get_type ()));
 }
@@ -139,10 +150,12 @@ gtk_event_box_size_request (GtkWidget      *widget,
 
   if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
     {
-      gtk_widget_size_request (bin->child, &bin->child->requisition);
+      GtkRequisition child_requisition;
+      
+      gtk_widget_size_request (bin->child, &child_requisition);
 
-      requisition->width += bin->child->requisition.width;
-      requisition->height += bin->child->requisition.height;
+      requisition->width += child_requisition.width;
+      requisition->height += child_requisition.height;
     }
 }
 
@@ -162,8 +175,8 @@ gtk_event_box_size_allocate (GtkWidget     *widget,
 
   child_allocation.x = 0;
   child_allocation.y = 0;
-  child_allocation.width = allocation->width - GTK_CONTAINER (widget)->border_width * 2;
-  child_allocation.height = allocation->height - GTK_CONTAINER (widget)->border_width * 2;
+  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);
 
   if (GTK_WIDGET_REALIZED (widget))
     {
@@ -174,15 +187,25 @@ gtk_event_box_size_allocate (GtkWidget     *widget,
                              child_allocation.height);
     }
   
-  if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
+  if (bin->child)
     {
       gtk_widget_size_allocate (bin->child, &child_allocation);
     }
 }
 
+static void
+gtk_event_box_paint (GtkWidget    *widget,
+                    GdkRectangle *area)
+{
+  gtk_paint_flat_box (widget->style, widget->window,
+                     widget->state, GTK_SHADOW_NONE,
+                     area, widget, "eventbox",
+                     0, 0, -1, -1);
+}
+
 static void
 gtk_event_box_draw (GtkWidget    *widget,
-                  GdkRectangle *area)
+                   GdkRectangle *area)
 {
   GtkBin *bin;
   GdkRectangle tmp_area;
@@ -197,6 +220,8 @@ gtk_event_box_draw (GtkWidget    *widget,
       tmp_area = *area;
       tmp_area.x -= GTK_CONTAINER (widget)->border_width;
       tmp_area.y -= GTK_CONTAINER (widget)->border_width;
+
+      gtk_event_box_paint (widget, &tmp_area);
       
       if (bin->child)
        {
@@ -221,6 +246,8 @@ gtk_event_box_expose (GtkWidget      *widget,
     {
       bin = GTK_BIN (widget);
 
+      gtk_event_box_paint (widget, &event->area);
+      
       child_event = *event;
       if (bin->child &&
          GTK_WIDGET_NO_WINDOW (bin->child) &&