1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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.
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.
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.
19 #include "gtksignal.h"
20 #include "gtkinvisible.h"
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);
30 gtk_invisible_get_type (void)
32 static GtkType invisible_type = 0;
36 GtkTypeInfo invisible_info =
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,
48 invisible_type = gtk_type_unique (gtk_widget_get_type (), &invisible_info);
51 return invisible_type;
55 gtk_invisible_class_init (GtkInvisibleClass *class)
57 GtkWidgetClass *widget_class;
59 widget_class = (GtkWidgetClass*) class;
61 widget_class->realize = gtk_invisible_realize;
62 widget_class->show = gtk_invisible_show;
63 widget_class->size_allocate = gtk_invisible_size_allocate;
67 gtk_invisible_init (GtkInvisible *invisible)
69 GTK_WIDGET_UNSET_FLAGS (invisible, GTK_NO_WINDOW);
71 gtk_widget_ref (GTK_WIDGET (invisible));
72 gtk_object_sink (GTK_OBJECT (invisible));
76 gtk_invisible_new (void)
78 return GTK_WIDGET ( gtk_type_new (gtk_invisible_get_type ()));
82 gtk_invisible_realize (GtkWidget *widget)
84 GdkWindowAttr attributes;
87 g_return_if_fail (widget != NULL);
88 g_return_if_fail (GTK_IS_INVISIBLE (widget));
90 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
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);
101 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
103 widget->window = gdk_window_new (NULL, &attributes, attributes_mask);
104 gdk_window_set_user_data (widget->window, widget);
108 gtk_invisible_show (GtkWidget *widget)
110 g_return_if_fail (widget != NULL);
112 GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
113 gtk_widget_map (widget);
117 gtk_invisible_size_allocate (GtkWidget *widget,
118 GtkAllocation *allocation)
120 widget->allocation = *allocation;