]> Pileus Git - ~andy/gtk/blob - gtk/gtkhseparator.c
main part for GtkArgSetFunc/GtkArgGetFunc implementation.
[~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         (GtkArgSetFunc) NULL,
42         (GtkArgGetFunc) NULL,
43       };
44
45       hseparator_type = gtk_type_unique (gtk_separator_get_type (), &hseparator_info);
46     }
47
48   return hseparator_type;
49 }
50
51 static void
52 gtk_hseparator_class_init (GtkHSeparatorClass *class)
53 {
54   GtkWidgetClass *widget_class;
55
56   widget_class = (GtkWidgetClass*) class;
57
58   widget_class->expose_event = gtk_hseparator_expose;
59 }
60
61 static void
62 gtk_hseparator_init (GtkHSeparator *hseparator)
63 {
64   GTK_WIDGET (hseparator)->requisition.width = 1;
65   GTK_WIDGET (hseparator)->requisition.height = GTK_WIDGET (hseparator)->style->klass->ythickness;
66 }
67
68 GtkWidget*
69 gtk_hseparator_new ()
70 {
71   return GTK_WIDGET (gtk_type_new (gtk_hseparator_get_type ()));
72 }
73
74
75 static gint
76 gtk_hseparator_expose (GtkWidget      *widget,
77                        GdkEventExpose *event)
78 {
79   g_return_val_if_fail (widget != NULL, FALSE);
80   g_return_val_if_fail (GTK_IS_HSEPARATOR (widget), FALSE);
81   g_return_val_if_fail (event != NULL, FALSE);
82
83   if (GTK_WIDGET_DRAWABLE (widget))
84     gtk_draw_hline (widget->style, widget->window, GTK_STATE_NORMAL,
85                     widget->allocation.x,
86                     widget->allocation.x + widget->allocation.width,
87                     widget->allocation.y + (widget->allocation.height -
88                                             widget->style->klass->ythickness) / 2);
89
90   return FALSE;
91 }