]> Pileus Git - ~andy/gtk/blob - gtk/gtkhseparator.c
Revert name change
[~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 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 "config.h"
28 #include "gtkhseparator.h"
29 #include "gtkintl.h"
30 #include "gtkalias.h"
31
32
33 static void gtk_hseparator_size_request (GtkWidget          *widget,
34                                          GtkRequisition     *requisition);
35 static gint gtk_hseparator_expose       (GtkWidget          *widget,
36                                          GdkEventExpose     *event);
37
38 G_DEFINE_TYPE (GtkHSeparator, gtk_hseparator, GTK_TYPE_SEPARATOR)
39
40 static void
41 gtk_hseparator_class_init (GtkHSeparatorClass *class)
42 {
43   GtkWidgetClass *widget_class;
44
45   widget_class = (GtkWidgetClass*) class;
46
47   widget_class->size_request = gtk_hseparator_size_request;
48   widget_class->expose_event = gtk_hseparator_expose;
49 }
50
51 static void
52 gtk_hseparator_init (GtkHSeparator *hseparator)
53 {
54   GTK_WIDGET (hseparator)->requisition.width = 1;
55   GTK_WIDGET (hseparator)->requisition.height = GTK_WIDGET (hseparator)->style->ythickness;
56 }
57
58 GtkWidget*
59 gtk_hseparator_new (void)
60 {
61   return g_object_new (GTK_TYPE_HSEPARATOR, NULL);
62 }
63
64 static void
65 gtk_hseparator_size_request (GtkWidget      *widget,
66                              GtkRequisition *requisition)
67 {
68   gboolean wide_separators;
69   gint     separator_height;
70
71   gtk_widget_style_get (widget,
72                         "wide-separators",  &wide_separators,
73                         "separator-height", &separator_height,
74                         NULL);
75
76   if (wide_separators)
77     requisition->height = separator_height;
78   else
79     requisition->height = widget->style->ythickness;
80 }
81
82 static gint
83 gtk_hseparator_expose (GtkWidget      *widget,
84                        GdkEventExpose *event)
85 {
86   if (GTK_WIDGET_DRAWABLE (widget))
87     {
88       gboolean wide_separators;
89       gint     separator_height;
90
91       gtk_widget_style_get (widget,
92                             "wide-separators",  &wide_separators,
93                             "separator-height", &separator_height,
94                             NULL);
95
96       if (wide_separators)
97         gtk_paint_box (widget->style, widget->window,
98                        GTK_WIDGET_STATE (widget), GTK_SHADOW_ETCHED_OUT,
99                        &event->area, widget, "hseparator",
100                        widget->allocation.x,
101                        widget->allocation.y + (widget->allocation.height -
102                                                separator_height) / 2,
103                        widget->allocation.width,
104                        separator_height);
105       else
106         gtk_paint_hline (widget->style, widget->window,
107                          GTK_WIDGET_STATE (widget),
108                          &event->area, widget, "hseparator",
109                          widget->allocation.x,
110                          widget->allocation.x + widget->allocation.width - 1,
111                          widget->allocation.y + (widget->allocation.height -
112                                                  widget->style->ythickness) / 2);
113     }
114
115   return FALSE;
116 }
117
118 #define __GTK_HSEPARATOR_C__
119 #include "gtkaliasdef.c"