]> Pileus Git - ~andy/gtk/blob - gtk/gtkhseparator.c
Use gdk_window_get_origin() instead of gdk_window_get_position, because
[~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
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 #include "gtkhseparator.h"
20
21
22 static void gtk_hseparator_class_init (GtkHSeparatorClass *klass);
23 static void gtk_hseparator_init       (GtkHSeparator      *hseparator);
24 static gint gtk_hseparator_expose     (GtkWidget          *widget,
25                                        GdkEventExpose     *event);
26
27
28 GtkType
29 gtk_hseparator_get_type (void)
30 {
31   static GtkType hseparator_type = 0;
32
33   if (!hseparator_type)
34     {
35       static const GtkTypeInfo hseparator_info =
36       {
37         "GtkHSeparator",
38         sizeof (GtkHSeparator),
39         sizeof (GtkHSeparatorClass),
40         (GtkClassInitFunc) gtk_hseparator_class_init,
41         (GtkObjectInitFunc) gtk_hseparator_init,
42         /* reserved_1 */ NULL,
43         /* reserved_2 */ NULL,
44         (GtkClassInitFunc) NULL,
45       };
46
47       hseparator_type = gtk_type_unique (GTK_TYPE_SEPARATOR, &hseparator_info);
48     }
49
50   return hseparator_type;
51 }
52
53 static void
54 gtk_hseparator_class_init (GtkHSeparatorClass *class)
55 {
56   GtkWidgetClass *widget_class;
57
58   widget_class = (GtkWidgetClass*) class;
59
60   widget_class->expose_event = gtk_hseparator_expose;
61 }
62
63 static void
64 gtk_hseparator_init (GtkHSeparator *hseparator)
65 {
66   GTK_WIDGET (hseparator)->requisition.width = 1;
67   GTK_WIDGET (hseparator)->requisition.height = GTK_WIDGET (hseparator)->style->klass->ythickness;
68 }
69
70 GtkWidget*
71 gtk_hseparator_new (void)
72 {
73   return GTK_WIDGET (gtk_type_new (GTK_TYPE_HSEPARATOR));
74 }
75
76
77 static gint
78 gtk_hseparator_expose (GtkWidget      *widget,
79                        GdkEventExpose *event)
80 {
81   g_return_val_if_fail (widget != NULL, FALSE);
82   g_return_val_if_fail (GTK_IS_HSEPARATOR (widget), FALSE);
83   g_return_val_if_fail (event != NULL, FALSE);
84
85   if (GTK_WIDGET_DRAWABLE (widget))
86     gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
87                      &event->area, widget, "hseparator",
88                      widget->allocation.x,
89                      widget->allocation.x + widget->allocation.width,
90                      widget->allocation.y + (widget->allocation.height -
91                                              widget->style->klass->ythickness) / 2);
92
93   return FALSE;
94 }