gtkcontainer.h 11 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 35
#include <gtk/gtkwidget.h>


36
G_BEGIN_DECLS
Elliot Lee's avatar
Elliot Lee committed
37

Tim Janik's avatar
Tim Janik committed
38
#define GTK_TYPE_CONTAINER              (gtk_container_get_type ())
Manish Singh's avatar
Manish Singh committed
39 40 41 42 43
#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))
44

Elliot Lee's avatar
Elliot Lee committed
45

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

struct _GtkContainer
{
  GtkWidget widget;
53

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

58 59 60 61 62 63 64 65 66
/**
 * 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.
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 71 72 73 74
 * @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
75 76 77
struct _GtkContainerClass
{
  GtkWidgetClass parent_class;
78

79 80
  /*< public >*/

Tim Janik's avatar
Tim Janik committed
81
  void    (*add)       		(GtkContainer	 *container,
82
				 GtkWidget	 *widget);
Tim Janik's avatar
Tim Janik committed
83
  void    (*remove)    		(GtkContainer	 *container,
84
				 GtkWidget	 *widget);
Tim Janik's avatar
Tim Janik committed
85 86
  void    (*check_resize)	(GtkContainer	 *container);
  void    (*forall)    		(GtkContainer	 *container,
87
				 gboolean	  include_internals,
88
				 GtkCallback	  callback,
89
				 gpointer	  callback_data);
Tim Janik's avatar
Tim Janik committed
90
  void    (*set_focus_child)	(GtkContainer	 *container,
91
				 GtkWidget	 *child);
Manish Singh's avatar
Manish Singh committed
92
  GType   (*child_type)		(GtkContainer	 *container);
Tim Janik's avatar
Tim Janik committed
93 94 95 96 97 98 99 100 101 102 103 104
  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);
105 106
  GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
                                         GtkWidget    *child);
107

108 109 110 111 112

  /*< private >*/

  unsigned int _handle_border_width : 1;

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

124

Matthias Clasen's avatar
Matthias Clasen committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138
/**
 * 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;


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

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

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

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

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

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

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

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

188 189
/* Widget-level methods */

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

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

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

216

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

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

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

277 278
/**
 * GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID:
279
 * @object: the #GObject on which set_child_property() or get_child_property()
280 281 282 283 284
 *  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
285
 * properties in set_child_property() and get_child_property() implementations.
286
 */
Tim Janik's avatar
Tim Janik committed
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

Tim Janik's avatar
Tim Janik committed
290

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

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

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

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

#endif /* __GTK_CONTAINER_H__ */