]> Pileus Git - ~andy/gtk/blob - gtk/gtkhseparator.c
Initial revision
[~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 Library 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  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 #include "gtkhseparator.h"
19
20
21 static void gtk_hseparator_class_init (GtkHSeparatorClass *klass);
22 static void gtk_hseparator_init       (GtkHSeparator      *hseparator);
23 static gint gtk_hseparator_expose     (GtkWidget          *widget,
24                                        GdkEventExpose     *event);
25
26
27 guint
28 gtk_hseparator_get_type ()
29 {
30   static guint hseparator_type = 0;
31
32   if (!hseparator_type)
33     {
34       GtkTypeInfo hseparator_info =
35       {
36         "GtkHSeparator",
37         sizeof (GtkHSeparator),
38         sizeof (GtkHSeparatorClass),
39         (GtkClassInitFunc) gtk_hseparator_class_init,
40         (GtkObjectInitFunc) gtk_hseparator_init,
41         (GtkArgFunc) NULL,
42       };
43
44       hseparator_type = gtk_type_unique (gtk_separator_get_type (), &hseparator_info);
45     }
46
47   return hseparator_type;
48 }
49
50 static void
51 gtk_hseparator_class_init (GtkHSeparatorClass *class)
52 {
53   GtkWidgetClass *widget_class;
54
55   widget_class = (GtkWidgetClass*) class;
56
57   widget_class->expose_event = gtk_hseparator_expose;
58 }
59
60 static void
61 gtk_hseparator_init (GtkHSeparator *hseparator)
62 {
63   GTK_WIDGET (hseparator)->requisition.width = 1;
64   GTK_WIDGET (hseparator)->requisition.height = GTK_WIDGET (hseparator)->style->klass->ythickness;
65 }
66
67 GtkWidget*
68 gtk_hseparator_new ()
69 {
70   return GTK_WIDGET (gtk_type_new (gtk_hseparator_get_type ()));
71 }
72
73
74 static gint
75 gtk_hseparator_expose (GtkWidget      *widget,
76                        GdkEventExpose *event)
77 {
78   g_return_val_if_fail (widget != NULL, FALSE);
79   g_return_val_if_fail (GTK_IS_HSEPARATOR (widget), FALSE);
80   g_return_val_if_fail (event != NULL, FALSE);
81
82   if (GTK_WIDGET_DRAWABLE (widget))
83     gtk_draw_hline (widget->style, widget->window, GTK_STATE_NORMAL,
84                     widget->allocation.x,
85                     widget->allocation.x + widget->allocation.width,
86                     widget->allocation.y + (widget->allocation.height -
87                                             widget->style->klass->ythickness) / 2);
88
89   return FALSE;
90 }