]> Pileus Git - ~andy/gtk/blob - gtk/gtkvseparator.c
Initial revision
[~andy/gtk] / gtk / gtkvseparator.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 "gtkvseparator.h"
19
20
21 static void gtk_vseparator_class_init (GtkVSeparatorClass *klass);
22 static void gtk_vseparator_init       (GtkVSeparator      *vseparator);
23 static gint gtk_vseparator_expose     (GtkWidget          *widget,
24                                        GdkEventExpose     *event);
25
26
27 guint
28 gtk_vseparator_get_type ()
29 {
30   static guint vseparator_type = 0;
31
32   if (!vseparator_type)
33     {
34       GtkTypeInfo vseparator_info =
35       {
36         "GtkVSeparator",
37         sizeof (GtkVSeparator),
38         sizeof (GtkVSeparatorClass),
39         (GtkClassInitFunc) gtk_vseparator_class_init,
40         (GtkObjectInitFunc) gtk_vseparator_init,
41         (GtkArgFunc) NULL,
42       };
43
44       vseparator_type = gtk_type_unique (gtk_separator_get_type (), &vseparator_info);
45     }
46
47   return vseparator_type;
48 }
49
50 static void
51 gtk_vseparator_class_init (GtkVSeparatorClass *klass)
52 {
53   GtkWidgetClass *widget_class;
54
55   widget_class = (GtkWidgetClass*) klass;
56
57   widget_class->expose_event = gtk_vseparator_expose;
58 }
59
60 static void
61 gtk_vseparator_init (GtkVSeparator *vseparator)
62 {
63   GTK_WIDGET (vseparator)->requisition.width = GTK_WIDGET (vseparator)->style->klass->xthickness;
64   GTK_WIDGET (vseparator)->requisition.height = 1;
65 }
66
67 GtkWidget*
68 gtk_vseparator_new ()
69 {
70   return GTK_WIDGET (gtk_type_new (gtk_vseparator_get_type ()));
71 }
72
73
74 static gint
75 gtk_vseparator_expose (GtkWidget      *widget,
76                        GdkEventExpose *event)
77 {
78   g_return_val_if_fail (widget != NULL, FALSE);
79   g_return_val_if_fail (GTK_IS_VSEPARATOR (widget), FALSE);
80   g_return_val_if_fail (event != NULL, FALSE);
81
82   if (GTK_WIDGET_DRAWABLE (widget))
83     gtk_draw_vline (widget->style, widget->window, GTK_STATE_NORMAL,
84                     widget->allocation.y,
85                     widget->allocation.y + widget->allocation.height,
86                     widget->allocation.x + (widget->allocation.width -
87                                             widget->style->klass->xthickness) / 2);
88
89   return FALSE;
90 }