]> Pileus Git - ~andy/gtk/blob - gtk/gtkvseparator.c
Use the correct screen for getting the height. (Fix from Stephen Browne,
[~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 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 "gtkvseparator.h"
28
29
30 static void gtk_vseparator_class_init (GtkVSeparatorClass *klass);
31 static void gtk_vseparator_init       (GtkVSeparator      *vseparator);
32 static gint gtk_vseparator_expose     (GtkWidget          *widget,
33                                        GdkEventExpose     *event);
34
35
36 GType
37 gtk_vseparator_get_type (void)
38 {
39   static GType vseparator_type = 0;
40
41   if (!vseparator_type)
42     {
43       static const GTypeInfo vseparator_info =
44       {
45         sizeof (GtkVSeparatorClass),
46         NULL,           /* base_init */
47         NULL,           /* base_finalize */
48         (GClassInitFunc) gtk_vseparator_class_init,
49         NULL,           /* class_finalize */
50         NULL,           /* class_init */
51         sizeof (GtkVSeparator),
52         0,              /* n_preallocs */
53         (GInstanceInitFunc) gtk_vseparator_init,
54       };
55
56       vseparator_type =
57         g_type_register_static (GTK_TYPE_SEPARATOR, "GtkVSeparator",
58                                 &vseparator_info, 0);
59     }
60
61   return vseparator_type;
62 }
63
64 static void
65 gtk_vseparator_class_init (GtkVSeparatorClass *klass)
66 {
67   GtkWidgetClass *widget_class;
68
69   widget_class = (GtkWidgetClass*) klass;
70
71   widget_class->expose_event = gtk_vseparator_expose;
72 }
73
74 static void
75 gtk_vseparator_init (GtkVSeparator *vseparator)
76 {
77   GTK_WIDGET (vseparator)->requisition.width = GTK_WIDGET (vseparator)->style->xthickness;
78   GTK_WIDGET (vseparator)->requisition.height = 1;
79 }
80
81 GtkWidget*
82 gtk_vseparator_new (void)
83 {
84   return g_object_new (GTK_TYPE_VSEPARATOR, NULL);
85 }
86
87
88 static gint
89 gtk_vseparator_expose (GtkWidget      *widget,
90                        GdkEventExpose *event)
91 {
92   if (GTK_WIDGET_DRAWABLE (widget))
93     gtk_paint_vline (widget->style, widget->window, GTK_STATE_NORMAL,
94                      &event->area, widget, "vseparator",
95                      widget->allocation.y,
96                      widget->allocation.y + widget->allocation.height,
97                      widget->allocation.x + (widget->allocation.width -
98                                              widget->style->xthickness) / 2);
99
100   return FALSE;
101 }