gtkcontainer.h 11.1 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Elliot Lee's avatar
Elliot Lee committed
2 3 4
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6 7 8 9 10
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * 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.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
Elliot Lee's avatar
Elliot Lee committed
16
 */
17 18

/*
19
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
20 21
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
22
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 24
 */

Elliot Lee's avatar
Elliot Lee committed
25 26 27 28
#ifndef __GTK_CONTAINER_H__
#define __GTK_CONTAINER_H__


29 30 31 32
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

Elliot Lee's avatar
Elliot Lee committed
33 34
#include <gtk/gtkwidget.h>

35
G_BEGIN_DECLS
Elliot Lee's avatar
Elliot Lee committed
36

Tim Janik's avatar
Tim Janik committed
37
#define GTK_TYPE_CONTAINER              (gtk_container_get_type ())
Manish Singh's avatar
Manish Singh committed
38 39 40 41 42
#define GTK_CONTAINER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CONTAINER, GtkContainer))
#define GTK_CONTAINER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CONTAINER, GtkContainerClass))
#define GTK_IS_CONTAINER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CONTAINER))
#define GTK_IS_CONTAINER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CONTAINER))
#define GTK_CONTAINER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CONTAINER, GtkContainerClass))
43

Elliot Lee's avatar
Elliot Lee committed
44

45 46 47
typedef struct _GtkContainer              GtkContainer;
typedef struct _GtkContainerPrivate       GtkContainerPrivate;
typedef struct _GtkContainerClass         GtkContainerClass;
Elliot Lee's avatar
Elliot Lee committed
48 49 50 51

struct _GtkContainer
{
  GtkWidget widget;
52

53
  /*< private >*/
54
  GtkContainerPrivate *priv;
Elliot Lee's avatar
Elliot Lee committed
55 56
};

57 58 59 60 61 62 63 64 65
/**
 * GtkContainerClass:
 * @parent_class: The parent class.
 * @add: Signal emitted when a widget is added to container.
 * @remove: Signal emitted when a widget is removed from container.
 * @check_resize: Signal emitted when a size recalculation is needed.
 * @forall: Invokes callback on each child of container.
 * @set_focus_child: Sets the focused child of container.
 * @child_type: Returns the type of the children supported by the container.
66
 * @composite_name: Gets a widget’s composite name. Deprecated: 3.10.
67
 * @set_child_property: Set a property on a child of container.
68
 * @get_child_property: Get a property from a child of container.
69 70 71 72 73
 * @get_path_for_child: Get path representing entire widget hierarchy
 *    from the toplevel down to and including @child.
 *
 * Base class for containers.
 */
Elliot Lee's avatar
Elliot Lee committed
74 75 76
struct _GtkContainerClass
{
  GtkWidgetClass parent_class;
77

78 79
  /*< public >*/

Tim Janik's avatar
Tim Janik committed
80
  void    (*add)       		(GtkContainer	 *container,
81
				 GtkWidget	 *widget);
Tim Janik's avatar
Tim Janik committed
82
  void    (*remove)    		(GtkContainer	 *container,
83
				 GtkWidget	 *widget);
Tim Janik's avatar
Tim Janik committed
84 85
  void    (*check_resize)	(GtkContainer	 *container);
  void    (*forall)    		(GtkContainer	 *container,
86
				 gboolean	  include_internals,
87
				 GtkCallback	  callback,
88
				 gpointer	  callback_data);
Tim Janik's avatar
Tim Janik committed
89
  void    (*set_focus_child)	(GtkContainer	 *container,
90
				 GtkWidget	 *child);
Manish Singh's avatar
Manish Singh committed
91
  GType   (*child_type)		(GtkContainer	 *container);
Tim Janik's avatar
Tim Janik committed
92 93 94 95 96 97 98 99 100 101 102 103
  gchar*  (*composite_name)	(GtkContainer	 *container,
				 GtkWidget	 *child);
  void    (*set_child_property) (GtkContainer    *container,
				 GtkWidget       *child,
				 guint            property_id,
				 const GValue    *value,
				 GParamSpec      *pspec);
  void    (*get_child_property) (GtkContainer    *container,
                                 GtkWidget       *child,
				 guint            property_id,
				 GValue          *value,
				 GParamSpec      *pspec);
104 105
  GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
                                         GtkWidget    *child);
106

107 108 109 110 111

  /*< private >*/

  unsigned int _handle_border_width : 1;

112
  /* Padding for future expansion */
113 114 115 116
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
117 118 119 120
  void (*_gtk_reserved5) (void);
  void (*_gtk_reserved6) (void);
  void (*_gtk_reserved7) (void);
  void (*_gtk_reserved8) (void);
Elliot Lee's avatar
Elliot Lee committed
121 122
};

123

Matthias Clasen's avatar
Matthias Clasen committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137
/**
 * GtkResizeMode:
 * @GTK_RESIZE_PARENT: Pass resize request to the parent
 * @GTK_RESIZE_QUEUE: Queue resizes on this widget
 * @GTK_RESIZE_IMMEDIATE: Resize immediately. Deprecated.
 */
typedef enum
{
  GTK_RESIZE_PARENT,
  GTK_RESIZE_QUEUE,
  GTK_RESIZE_IMMEDIATE
} GtkResizeMode;


138
/* Application-level methods */
Elliot Lee's avatar
Elliot Lee committed
139

140
GDK_AVAILABLE_IN_ALL
Manish Singh's avatar
Manish Singh committed
141
GType   gtk_container_get_type		 (void) G_GNUC_CONST;
142
GDK_AVAILABLE_IN_ALL
143
void    gtk_container_set_border_width	 (GtkContainer	   *container,
144
					  guint		    border_width);
145
GDK_AVAILABLE_IN_ALL
146
guint   gtk_container_get_border_width   (GtkContainer     *container);
147
GDK_AVAILABLE_IN_ALL
148 149
void    gtk_container_add		 (GtkContainer	   *container,
					  GtkWidget	   *widget);
150
GDK_AVAILABLE_IN_ALL
151 152
void    gtk_container_remove		 (GtkContainer	   *container,
					  GtkWidget	   *widget);
153

154
GDK_DEPRECATED_IN_3_12
155 156
void    gtk_container_set_resize_mode    (GtkContainer     *container,
					  GtkResizeMode     resize_mode);
157
GDK_DEPRECATED_IN_3_12
158
GtkResizeMode gtk_container_get_resize_mode (GtkContainer     *container);
159

160
GDK_AVAILABLE_IN_ALL
161 162
void    gtk_container_check_resize       (GtkContainer     *container);

163
GDK_AVAILABLE_IN_ALL
164 165 166
void     gtk_container_foreach      (GtkContainer       *container,
				     GtkCallback         callback,
				     gpointer            callback_data);
167
GDK_AVAILABLE_IN_ALL
168 169
GList*   gtk_container_get_children     (GtkContainer       *container);

170
GDK_AVAILABLE_IN_ALL
171 172 173
void     gtk_container_propagate_draw   (GtkContainer   *container,
					 GtkWidget      *child,
					 cairo_t        *cr);
174

175
GDK_AVAILABLE_IN_ALL
176 177
void     gtk_container_set_focus_chain  (GtkContainer   *container,
                                         GList          *focusable_widgets);
178
GDK_AVAILABLE_IN_ALL
179 180
gboolean gtk_container_get_focus_chain  (GtkContainer   *container,
					 GList         **focusable_widgets);
181
GDK_AVAILABLE_IN_ALL
182 183
void     gtk_container_unset_focus_chain (GtkContainer  *container);

184 185 186
#define GTK_IS_RESIZE_CONTAINER(widget) (GTK_IS_CONTAINER (widget) && \
                                        (gtk_container_get_resize_mode (GTK_CONTAINER (widget)) != GTK_RESIZE_PARENT))

187 188
/* Widget-level methods */

189
GDK_DEPRECATED_IN_3_14
190 191
void   gtk_container_set_reallocate_redraws (GtkContainer    *container,
					     gboolean         needs_redraws);
192
GDK_AVAILABLE_IN_ALL
193 194
void   gtk_container_set_focus_child	   (GtkContainer     *container,
					    GtkWidget	     *child);
195
GDK_AVAILABLE_IN_ALL
196 197
GtkWidget *
       gtk_container_get_focus_child	   (GtkContainer     *container);
198
GDK_AVAILABLE_IN_ALL
199 200
void   gtk_container_set_focus_vadjustment (GtkContainer     *container,
					    GtkAdjustment    *adjustment);
201
GDK_AVAILABLE_IN_ALL
202
GtkAdjustment *gtk_container_get_focus_vadjustment (GtkContainer *container);
203
GDK_AVAILABLE_IN_ALL
204 205
void   gtk_container_set_focus_hadjustment (GtkContainer     *container,
					    GtkAdjustment    *adjustment);
206
GDK_AVAILABLE_IN_ALL
207
GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container);
208

209
GDK_DEPRECATED_IN_3_10
210
void    gtk_container_resize_children      (GtkContainer     *container);
211

212
GDK_AVAILABLE_IN_ALL
Manish Singh's avatar
Manish Singh committed
213
GType   gtk_container_child_type	   (GtkContainer     *container);
214

215

216
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
217 218 219
void         gtk_container_class_install_child_property (GtkContainerClass *cclass,
							 guint		    property_id,
							 GParamSpec	   *pspec);
220 221 222 223
GDK_AVAILABLE_IN_3_18
void         gtk_container_class_install_child_properties (GtkContainerClass *cclass,
                                                           guint              n_pspecs,
                                                           GParamSpec       **pspecs);
224
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
225 226
GParamSpec*  gtk_container_class_find_child_property	(GObjectClass	   *cclass,
							 const gchar	   *property_name);
227
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
228 229
GParamSpec** gtk_container_class_list_child_properties	(GObjectClass	   *cclass,
							 guint		   *n_properties);
230
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
231 232 233
void         gtk_container_add_with_properties		(GtkContainer	   *container,
							 GtkWidget	   *widget,
							 const gchar	   *first_prop_name,
234
							 ...) G_GNUC_NULL_TERMINATED;
235
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
236 237 238
void         gtk_container_child_set			(GtkContainer	   *container,
							 GtkWidget	   *child,
							 const gchar	   *first_prop_name,
239
							 ...) G_GNUC_NULL_TERMINATED;
240
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
241 242 243
void         gtk_container_child_get			(GtkContainer	   *container,
							 GtkWidget	   *child,
							 const gchar	   *first_prop_name,
244
							 ...) G_GNUC_NULL_TERMINATED;
245
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
246 247 248 249
void         gtk_container_child_set_valist		(GtkContainer	   *container,
							 GtkWidget	   *child,
							 const gchar	   *first_property_name,
							 va_list	    var_args);
250
GDK_AVAILABLE_IN_ALL
Tim Janik's avatar
Tim Janik committed
251 252 253 254
void         gtk_container_child_get_valist		(GtkContainer	   *container,
							 GtkWidget	   *child,
							 const gchar	   *first_property_name,
							 va_list	    var_args);
255
GDK_AVAILABLE_IN_ALL
256 257 258 259
void	     gtk_container_child_set_property		(GtkContainer	   *container,
							 GtkWidget	   *child,
							 const gchar	   *property_name,
							 const GValue	   *value);
260
GDK_AVAILABLE_IN_ALL
261 262 263
void	     gtk_container_child_get_property		(GtkContainer	   *container,
							 GtkWidget	   *child,
							 const gchar	   *property_name,
264 265
	                                                 GValue		   *value);

266
GDK_AVAILABLE_IN_3_2
267 268
void gtk_container_child_notify (GtkContainer *container,
                                 GtkWidget    *child,
269
                                 const gchar  *child_property);
Tim Janik's avatar
Tim Janik committed
270

271 272 273 274 275
GDK_AVAILABLE_IN_3_18
void gtk_container_child_notify_by_pspec (GtkContainer *container,
                                          GtkWidget    *child,
                                          GParamSpec   *pspec);

276 277
/**
 * GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID:
278
 * @object: the #GObject on which set_child_property() or get_child_property()
279 280 281 282 283
 *  was called
 * @property_id: the numeric id of the property
 * @pspec: the #GParamSpec of the property
 *
 * This macro should be used to emit a standard warning about unexpected
284
 * properties in set_child_property() and get_child_property() implementations.
285
 */
Tim Janik's avatar
Tim Janik committed
286
#define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
287
    G_OBJECT_WARN_INVALID_PSPEC ((object), "child property", (property_id), (pspec))
288

Tim Janik's avatar
Tim Janik committed
289

290
GDK_AVAILABLE_IN_ALL
291 292 293
void    gtk_container_forall		     (GtkContainer *container,
					      GtkCallback   callback,
					      gpointer	    callback_data);
294

295
GDK_AVAILABLE_IN_ALL
296 297
void    gtk_container_class_handle_border_width (GtkContainerClass *klass);

298
GDK_AVAILABLE_IN_ALL
299 300 301
GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer      *container,
                                                  GtkWidget         *child);

302 303
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref)

304
G_END_DECLS
Elliot Lee's avatar
Elliot Lee committed
305 306

#endif /* __GTK_CONTAINER_H__ */