]> Pileus Git - ~andy/gtk/blob - gtk/gtkhseparator.c
18c9c37b57868130669498b8bdf26a340bc2419e
[~andy/gtk] / gtk / gtkhseparator.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /*
21  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
22  * file for a list of people on the GTK+ Team.  See the ChangeLog
23  * files for a list of changes.  These files are distributed with
24  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
25  */
26
27 #include <config.h>
28 #include "gtkhseparator.h"
29 #include "gtkalias.h"
30
31
32 static void gtk_hseparator_class_init (GtkHSeparatorClass *klass);
33 static void gtk_hseparator_init       (GtkHSeparator      *hseparator);
34 static gint gtk_hseparator_expose     (GtkWidget          *widget,
35                                        GdkEventExpose     *event);
36
37
38 GType
39 gtk_hseparator_get_type (void)
40 {
41   static GType hseparator_type = 0;
42
43   if (!hseparator_type)
44     {
45       static const GTypeInfo hseparator_info =
46       {
47         sizeof (GtkHSeparatorClass),
48         NULL,           /* base_init */
49         NULL,           /* base_finalize */
50         (GClassInitFunc) gtk_hseparator_class_init,
51         NULL,           /* class_finalize */
52         NULL,           /* class_init */
53         sizeof (GtkHSeparator),
54         0,              /* n_preallocs */
55         (GInstanceInitFunc) gtk_hseparator_init,
56       };
57
58       hseparator_type =
59         g_type_register_static (GTK_TYPE_SEPARATOR, g_intern_static_string ("GtkHSeparator"),
60                                 &hseparator_info, 0);
61     }
62
63   return hseparator_type;
64 }
65
66 static void
67 gtk_hseparator_class_init (GtkHSeparatorClass *class)
68 {
69   GtkWidgetClass *widget_class;
70
71   widget_class = (GtkWidgetClass*) class;
72
73   widget_class->expose_event = gtk_hseparator_expose;
74 }
75
76 static void
77 gtk_hseparator_init (GtkHSeparator *hseparator)
78 {
79   GTK_WIDGET (hseparator)->requisition.width = 1;
80   GTK_WIDGET (hseparator)->requisition.height = GTK_WIDGET (hseparator)->style->ythickness;
81 }
82
83 GtkWidget*
84 gtk_hseparator_new (void)
85 {
86   return g_object_new (GTK_TYPE_HSEPARATOR, NULL);
87 }
88
89
90 static gint
91 gtk_hseparator_expose (GtkWidget      *widget,
92                        GdkEventExpose *event)
93 {
94   if (GTK_WIDGET_DRAWABLE (widget))
95     gtk_paint_hline (widget->style, widget->window, GTK_WIDGET_STATE (widget),
96                      &event->area, widget, "hseparator",
97                      widget->allocation.x,
98                      widget->allocation.x + widget->allocation.width - 1,
99                      widget->allocation.y + (widget->allocation.height -
100                                              widget->style->ythickness) / 2);
101
102   return FALSE;
103 }
104
105 #define __GTK_HSEPARATOR_C__
106 #include "gtkaliasdef.c"