]> Pileus Git - ~andy/gtk/blob - gtk/gtkinvisible.c
Missed two files.
[~andy/gtk] / gtk / gtkinvisible.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 "gtksignal.h"
20 #include "gtkinvisible.h"
21
22 static void gtk_invisible_class_init               (GtkInvisibleClass *klass);
23 static void gtk_invisible_init                     (GtkInvisible      *invisible);
24 static void gtk_invisible_realize                  (GtkWidget        *widget);
25 static void gtk_invisible_show                     (GtkWidget        *widget);
26 static void gtk_invisible_size_allocate            (GtkWidget        *widget,
27                                                     GtkAllocation    *allocation);
28
29 GtkType
30 gtk_invisible_get_type (void)
31 {
32   static GtkType invisible_type = 0;
33
34   if (!invisible_type)
35     {
36       GtkTypeInfo invisible_info =
37       {
38         "GtkInvisible",
39         sizeof (GtkInvisible),
40         sizeof (GtkInvisibleClass),
41         (GtkClassInitFunc) gtk_invisible_class_init,
42         (GtkObjectInitFunc) gtk_invisible_init,
43         /* reserved_1 */ NULL,
44         /* reserved_2 */ NULL,
45         (GtkClassInitFunc) NULL,
46       };
47
48       invisible_type = gtk_type_unique (gtk_widget_get_type (), &invisible_info);
49     }
50
51   return invisible_type;
52 }
53
54 static void
55 gtk_invisible_class_init (GtkInvisibleClass *class)
56 {
57   GtkWidgetClass *widget_class;
58
59   widget_class = (GtkWidgetClass*) class;
60
61   widget_class->realize = gtk_invisible_realize;
62   widget_class->show = gtk_invisible_show;
63   widget_class->size_allocate = gtk_invisible_size_allocate;
64 }
65
66 static void
67 gtk_invisible_init (GtkInvisible *invisible)
68 {
69   GTK_WIDGET_UNSET_FLAGS (invisible, GTK_NO_WINDOW);
70
71   gtk_widget_ref (GTK_WIDGET (invisible));
72   gtk_object_sink (GTK_OBJECT (invisible));
73 }
74
75 GtkWidget*
76 gtk_invisible_new (void)
77 {
78   return GTK_WIDGET ( gtk_type_new (gtk_invisible_get_type ()));
79 }
80
81 static void
82 gtk_invisible_realize (GtkWidget *widget)
83 {
84   GdkWindowAttr attributes;
85   gint attributes_mask;
86
87   g_return_if_fail (widget != NULL);
88   g_return_if_fail (GTK_IS_INVISIBLE (widget));
89
90   GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
91
92   attributes.x = -100;
93   attributes.y = -100;
94   attributes.width = 10;
95   attributes.height = 10;
96   attributes.window_type = GDK_WINDOW_TEMP;
97   attributes.wclass = GDK_INPUT_ONLY;
98   attributes.override_redirect = TRUE;
99   attributes.event_mask = gtk_widget_get_events (widget);
100
101   attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
102
103   widget->window = gdk_window_new (NULL, &attributes, attributes_mask);
104   gdk_window_set_user_data (widget->window, widget);
105 }
106
107 static void
108 gtk_invisible_show (GtkWidget *widget)
109 {
110   g_return_if_fail (widget != NULL);
111
112   GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
113   gtk_widget_map (widget);
114 }
115
116 static void
117 gtk_invisible_size_allocate (GtkWidget     *widget,
118                             GtkAllocation *allocation)
119 {
120   widget->allocation = *allocation;
121 }