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, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __GTK_CONTAINER_H__
26#define __GTK_CONTAINER_H__
27
28
29#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
30#error "Only <gtk/gtk.h> can be included directly."
31#endif
32
33#include <gtk/gtkwidget.h>
34
35G_BEGIN_DECLS
36
37#define GTK_TYPE_CONTAINER (gtk_container_get_type ())
38#define GTK_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CONTAINER, GtkContainer))
39#define GTK_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CONTAINER, GtkContainerClass))
40#define GTK_IS_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CONTAINER))
41#define GTK_IS_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CONTAINER))
42#define GTK_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CONTAINER, GtkContainerClass))
43
44
45typedef struct _GtkContainer GtkContainer;
46typedef struct _GtkContainerPrivate GtkContainerPrivate;
47typedef struct _GtkContainerClass GtkContainerClass;
48
49struct _GtkContainer
50{
51 GtkWidget widget;
52
53 /*< private >*/
54 GtkContainerPrivate *priv;
55};
56
57/**
58 * GtkContainerClass:
59 * @parent_class: The parent class.
60 * @add: Signal emitted when a widget is added to container.
61 * @remove: Signal emitted when a widget is removed from container.
62 * @check_resize: Signal emitted when a size recalculation is needed.
63 * @forall: Invokes callback on each child of container. The callback handler
64 * may remove the child.
65 * @set_focus_child: Sets the focused child of container.
66 * @child_type: Returns the type of the children supported by the container.
67 * @composite_name: Gets a widget’s composite name. Deprecated: 3.10.
68 * @set_child_property: Set a property on a child of container.
69 * @get_child_property: Get a property from a child of container.
70 * @get_path_for_child: Get path representing entire widget hierarchy
71 * from the toplevel down to and including @child.
72 *
73 * Base class for containers.
74 */
75struct _GtkContainerClass
76{
77 GtkWidgetClass parent_class;
78
79 /*< public >*/
80
81 void (*add) (GtkContainer *container,
82 GtkWidget *widget);
83 void (*remove) (GtkContainer *container,
84 GtkWidget *widget);
85 void (*check_resize) (GtkContainer *container);
86 void (*forall) (GtkContainer *container,
87 gboolean include_internals,
88 GtkCallback callback,
89 gpointer callback_data);
90 void (*set_focus_child) (GtkContainer *container,
91 GtkWidget *child);
92 GType (*child_type) (GtkContainer *container);
93 gchar* (*composite_name) (GtkContainer *container,
94 GtkWidget *child);
95 void (*set_child_property) (GtkContainer *container,
96 GtkWidget *child,
97 guint property_id,
98 const GValue *value,
99 GParamSpec *pspec);
100 void (*get_child_property) (GtkContainer *container,
101 GtkWidget *child,
102 guint property_id,
103 GValue *value,
104 GParamSpec *pspec);
105 GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
106 GtkWidget *child);
107
108
109 /*< private >*/
110
111 unsigned int _handle_border_width : 1;
112
113 /* Padding for future expansion */
114 void (*_gtk_reserved1) (void);
115 void (*_gtk_reserved2) (void);
116 void (*_gtk_reserved3) (void);
117 void (*_gtk_reserved4) (void);
118 void (*_gtk_reserved5) (void);
119 void (*_gtk_reserved6) (void);
120 void (*_gtk_reserved7) (void);
121 void (*_gtk_reserved8) (void);
122};
123
124
125/**
126 * GtkResizeMode:
127 * @GTK_RESIZE_PARENT: Pass resize request to the parent
128 * @GTK_RESIZE_QUEUE: Queue resizes on this widget
129 * @GTK_RESIZE_IMMEDIATE: Resize immediately. Deprecated.
130 */
131typedef enum
132{
133 GTK_RESIZE_PARENT,
134 GTK_RESIZE_QUEUE,
135 GTK_RESIZE_IMMEDIATE
136} GtkResizeMode;
137
138
139/* Application-level methods */
140
141GDK_AVAILABLE_IN_ALL
142GType gtk_container_get_type (void) G_GNUC_CONST;
143GDK_AVAILABLE_IN_ALL
144void gtk_container_set_border_width (GtkContainer *container,
145 guint border_width);
146GDK_AVAILABLE_IN_ALL
147guint gtk_container_get_border_width (GtkContainer *container);
148GDK_AVAILABLE_IN_ALL
149void gtk_container_add (GtkContainer *container,
150 GtkWidget *widget);
151GDK_AVAILABLE_IN_ALL
152void gtk_container_remove (GtkContainer *container,
153 GtkWidget *widget);
154
155GDK_DEPRECATED_IN_3_12
156void gtk_container_set_resize_mode (GtkContainer *container,
157 GtkResizeMode resize_mode);
158GDK_DEPRECATED_IN_3_12
159GtkResizeMode gtk_container_get_resize_mode (GtkContainer *container);
160
161GDK_AVAILABLE_IN_ALL
162void gtk_container_check_resize (GtkContainer *container);
163
164GDK_AVAILABLE_IN_ALL
165void gtk_container_foreach (GtkContainer *container,
166 GtkCallback callback,
167 gpointer callback_data);
168GDK_AVAILABLE_IN_ALL
169GList* gtk_container_get_children (GtkContainer *container);
170
171GDK_AVAILABLE_IN_ALL
172void gtk_container_propagate_draw (GtkContainer *container,
173 GtkWidget *child,
174 cairo_t *cr);
175
176GDK_DEPRECATED_IN_3_24
177void gtk_container_set_focus_chain (GtkContainer *container,
178 GList *focusable_widgets);
179GDK_DEPRECATED_IN_3_24
180gboolean gtk_container_get_focus_chain (GtkContainer *container,
181 GList **focusable_widgets);
182GDK_DEPRECATED_IN_3_24
183void gtk_container_unset_focus_chain (GtkContainer *container);
184
185#define GTK_IS_RESIZE_CONTAINER(widget) (GTK_IS_CONTAINER (widget) && \
186 (gtk_container_get_resize_mode (GTK_CONTAINER (widget)) != GTK_RESIZE_PARENT))
187
188/* Widget-level methods */
189
190GDK_DEPRECATED_IN_3_14
191void gtk_container_set_reallocate_redraws (GtkContainer *container,
192 gboolean needs_redraws);
193GDK_AVAILABLE_IN_ALL
194void gtk_container_set_focus_child (GtkContainer *container,
195 GtkWidget *child);
196GDK_AVAILABLE_IN_ALL
197GtkWidget *
198 gtk_container_get_focus_child (GtkContainer *container);
199GDK_AVAILABLE_IN_ALL
200void gtk_container_set_focus_vadjustment (GtkContainer *container,
201 GtkAdjustment *adjustment);
202GDK_AVAILABLE_IN_ALL
203GtkAdjustment *gtk_container_get_focus_vadjustment (GtkContainer *container);
204GDK_AVAILABLE_IN_ALL
205void gtk_container_set_focus_hadjustment (GtkContainer *container,
206 GtkAdjustment *adjustment);
207GDK_AVAILABLE_IN_ALL
208GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container);
209
210GDK_DEPRECATED_IN_3_10
211void gtk_container_resize_children (GtkContainer *container);
212
213GDK_AVAILABLE_IN_ALL
214GType gtk_container_child_type (GtkContainer *container);
215
216
217GDK_AVAILABLE_IN_ALL
218void gtk_container_class_install_child_property (GtkContainerClass *cclass,
219 guint property_id,
220 GParamSpec *pspec);
221GDK_AVAILABLE_IN_3_18
222void gtk_container_class_install_child_properties (GtkContainerClass *cclass,
223 guint n_pspecs,
224 GParamSpec **pspecs);
225GDK_AVAILABLE_IN_ALL
226GParamSpec* gtk_container_class_find_child_property (GObjectClass *cclass,
227 const gchar *property_name);
228GDK_AVAILABLE_IN_ALL
229GParamSpec** gtk_container_class_list_child_properties (GObjectClass *cclass,
230 guint *n_properties);
231GDK_AVAILABLE_IN_ALL
232void gtk_container_add_with_properties (GtkContainer *container,
233 GtkWidget *widget,
234 const gchar *first_prop_name,
235 ...) G_GNUC_NULL_TERMINATED;
236GDK_AVAILABLE_IN_ALL
237void gtk_container_child_set (GtkContainer *container,
238 GtkWidget *child,
239 const gchar *first_prop_name,
240 ...) G_GNUC_NULL_TERMINATED;
241GDK_AVAILABLE_IN_ALL
242void gtk_container_child_get (GtkContainer *container,
243 GtkWidget *child,
244 const gchar *first_prop_name,
245 ...) G_GNUC_NULL_TERMINATED;
246GDK_AVAILABLE_IN_ALL
247void gtk_container_child_set_valist (GtkContainer *container,
248 GtkWidget *child,
249 const gchar *first_property_name,
250 va_list var_args);
251GDK_AVAILABLE_IN_ALL
252void gtk_container_child_get_valist (GtkContainer *container,
253 GtkWidget *child,
254 const gchar *first_property_name,
255 va_list var_args);
256GDK_AVAILABLE_IN_ALL
257void gtk_container_child_set_property (GtkContainer *container,
258 GtkWidget *child,
259 const gchar *property_name,
260 const GValue *value);
261GDK_AVAILABLE_IN_ALL
262void gtk_container_child_get_property (GtkContainer *container,
263 GtkWidget *child,
264 const gchar *property_name,
265 GValue *value);
266
267GDK_AVAILABLE_IN_3_2
268void gtk_container_child_notify (GtkContainer *container,
269 GtkWidget *child,
270 const gchar *child_property);
271
272GDK_AVAILABLE_IN_3_18
273void gtk_container_child_notify_by_pspec (GtkContainer *container,
274 GtkWidget *child,
275 GParamSpec *pspec);
276
277/**
278 * GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID:
279 * @object: the #GObject on which set_child_property() or get_child_property()
280 * was called
281 * @property_id: the numeric id of the property
282 * @pspec: the #GParamSpec of the property
283 *
284 * This macro should be used to emit a standard warning about unexpected
285 * properties in set_child_property() and get_child_property() implementations.
286 */
287#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
288 G_OBJECT_WARN_INVALID_PSPEC ((object), "child property", (property_id), (pspec))
289
290
291GDK_AVAILABLE_IN_ALL
292void gtk_container_forall (GtkContainer *container,
293 GtkCallback callback,
294 gpointer callback_data);
295
296GDK_AVAILABLE_IN_ALL
297void gtk_container_class_handle_border_width (GtkContainerClass *klass);
298
299GDK_AVAILABLE_IN_ALL
300GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container,
301 GtkWidget *child);
302
303G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref)
304
305G_END_DECLS
306
307#endif /* __GTK_CONTAINER_H__ */
308