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