]> Pileus Git - ~andy/gtk/blob - gtk/gtkcontainer.h
285b4a4da43d4b01a470162acb8b9036e117bfaa
[~andy/gtk] / gtk / gtkcontainer.h
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 #ifndef __GTK_CONTAINER_H__
20 #define __GTK_CONTAINER_H__
21
22
23 #include <gdk/gdk.h>
24 #include <gtk/gtkenums.h>
25 #include <gtk/gtkwidget.h>
26 #include <gtk/gtkadjustment.h>
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33
34 #define GTK_TYPE_CONTAINER              (gtk_container_get_type ())
35 #define GTK_CONTAINER(obj)              (GTK_CHECK_CAST ((obj), GTK_TYPE_CONTAINER, GtkContainer))
36 #define GTK_CONTAINER_CLASS(klass)      (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_CONTAINER, GtkContainerClass))
37 #define GTK_IS_CONTAINER(obj)           (GTK_CHECK_TYPE ((obj), GTK_TYPE_CONTAINER))
38 #define GTK_IS_CONTAINER_CLASS(klass)   (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CONTAINER))
39
40 #define GTK_IS_RESIZE_CONTAINER(widget) (GTK_IS_CONTAINER (widget) && ((GtkContainer*) (widget))->resize_mode != GTK_RESIZE_PARENT)
41
42
43 typedef struct _GtkContainer       GtkContainer;
44 typedef struct _GtkContainerClass  GtkContainerClass;
45
46 struct _GtkContainer
47 {
48   GtkWidget widget;
49   
50   GtkWidget *focus_child;
51   
52   guint border_width : 16;
53   guint need_resize : 1;
54   guint resize_mode : 2;
55   
56   
57   /* The list of children that requested a resize
58    */
59   GSList *resize_widgets;
60 };
61
62 struct _GtkContainerClass
63 {
64   GtkWidgetClass parent_class;
65   
66   guint   n_child_args;
67
68   void (* add)                  (GtkContainer    *container,
69                                  GtkWidget       *widget);
70   void (* remove)               (GtkContainer    *container,
71                                  GtkWidget       *widget);
72   void (* check_resize)         (GtkContainer    *container);
73   void (* forall)               (GtkContainer    *container,
74                                  gboolean         include_internals,
75                                  GtkCallback      callback,
76                                  gpointer         callbabck_data);
77   gint (* focus)                (GtkContainer    *container,
78                                  GtkDirectionType  direction);
79   void (* set_focus_child)      (GtkContainer    *container,
80                                  GtkWidget       *widget);
81   GtkType (*child_type)         (GtkContainer   *container);
82   void    (*set_child_arg)      (GtkContainer   *container,
83                                  GtkWidget      *child,
84                                  GtkArg         *arg,
85                                  guint           arg_id);
86   void    (*get_child_arg)      (GtkContainer   *container,
87                                  GtkWidget      *child,
88                                  GtkArg         *arg,
89                                  guint           arg_id);
90 };
91
92 /* Application-level methods */
93
94 GtkType gtk_container_get_type           (void);
95 void    gtk_container_border_width       (GtkContainer     *container,
96                                           guint             border_width);
97 void    gtk_container_add                (GtkContainer     *container,
98                                           GtkWidget        *widget);
99 void    gtk_container_remove             (GtkContainer     *container,
100                                           GtkWidget        *widget);
101
102 void    gtk_container_set_resize_mode    (GtkContainer     *container,
103                                           GtkResizeMode     resize_mode);
104
105 void    gtk_container_check_resize       (GtkContainer     *container);
106
107 void    gtk_container_foreach            (GtkContainer     *container,
108                                           GtkCallback       callback,
109                                           gpointer          callback_data);
110 void    gtk_container_foreach_interp     (GtkContainer     *container,
111                                           GtkCallbackMarshal marshal,
112                                           gpointer          callback_data,
113                                           GtkDestroyNotify  notify);
114 void    gtk_container_foreach_full       (GtkContainer     *container,
115                                           GtkCallback       callback,
116                                           GtkCallbackMarshal marshal,
117                                           gpointer          callback_data,
118                                           GtkDestroyNotify  notify);
119 GList* gtk_container_children            (GtkContainer     *container);
120 gint   gtk_container_focus                 (GtkContainer     *container,
121                                             GtkDirectionType  direction);
122
123 /* Widget-level methods */
124
125 void   gtk_container_set_focus_child       (GtkContainer     *container,
126                                             GtkWidget        *child);
127 void   gtk_container_set_focus_vadjustment (GtkContainer     *container,
128                                             GtkAdjustment    *adjustment);
129 void   gtk_container_set_focus_hadjustment (GtkContainer     *container,
130                                             GtkAdjustment    *adjustment);
131 void    gtk_container_register_toplevel    (GtkContainer     *container);
132 void    gtk_container_unregister_toplevel  (GtkContainer     *container);
133 GList * gtk_container_get_toplevels        (void);
134
135 void    gtk_container_resize_children      (GtkContainer     *container);
136
137 GtkType gtk_container_child_type           (GtkContainer     *container);
138
139 /* the `arg_name' argument needs to be a const static string */
140 void    gtk_container_add_child_arg_type   (const gchar      *arg_name,
141                                             GtkType           arg_type,
142                                             guint             arg_flags,
143                                             guint             arg_id);
144      
145 /* Allocate a GtkArg array of size nargs that hold the
146  * names and types of the args that can be used with
147  * gtk_container_child_getv/gtk_container_child_setv.
148  * if (arg_flags!=NULL),
149  * (*arg_flags) will be set to point to a newly allocated
150  * guint array that holds the flags of the args.
151  * It is the callers response to do a
152  * g_free (returned_args); g_free (*arg_flags).
153  */
154 GtkArg* gtk_container_query_child_args     (GtkType            class_type,
155                                             guint32          **arg_flags,
156                                             guint             *nargs);
157
158 /* gtk_container_child_getv() sets an arguments type and value, or just
159  * its type to GTK_TYPE_INVALID.
160  * if GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_STRING, it's the callers
161  * response to do a g_free (GTK_VALUE_STRING (arg));
162  */
163 void    gtk_container_child_getv           (GtkContainer      *container,
164                                             GtkWidget         *child,
165                                             guint              n_args,
166                                             GtkArg            *args);
167 void    gtk_container_child_setv           (GtkContainer      *container,
168                                             GtkWidget         *child,
169                                             guint              n_args,
170                                             GtkArg            *args);
171
172 /* gtk_container_add_with_args() takes a variable argument list of the form:
173  * (..., gchar *arg_name, ARG_VALUES, [repeatedly name/value pairs,] NULL)
174  * where ARG_VALUES type depend on the argument and can consist of
175  * more than one c-function argument.
176  */
177 void    gtk_container_add_with_args        (GtkContainer      *container,
178                                             GtkWidget         *widget,
179                                             const gchar       *first_arg_name,
180                                             ...);
181 void    gtk_container_addv                 (GtkContainer      *container,
182                                             GtkWidget         *widget,
183                                             guint              n_args,
184                                             GtkArg            *args);
185 void    gtk_container_child_set            (GtkContainer      *container,
186                                             GtkWidget         *child,
187                                             const gchar       *first_arg_name,
188                                             ...);
189      
190
191 /* Non-public methods */
192
193 void    gtk_container_queue_resize         (GtkContainer *container);
194 void    gtk_container_clear_resize_widgets (GtkContainer *container);
195 void    gtk_container_arg_set              (GtkContainer *container,
196                                             GtkWidget    *child,
197                                             GtkArg       *arg,
198                                             GtkArgInfo   *info);
199 void    gtk_container_arg_get              (GtkContainer *container,
200                                             GtkWidget    *child,
201                                             GtkArg       *arg,
202                                             GtkArgInfo   *info);
203 gchar*  gtk_container_child_args_collect   (GtkType       object_type,
204                                             GSList      **arg_list_p,
205                                             GSList      **info_list_p,
206                                             const gchar  *first_arg_name,
207                                             va_list       args);
208 gchar*  gtk_container_child_arg_get_info   (GtkType       object_type,
209                                             const gchar  *arg_name,
210                                             GtkArgInfo  **info_p);
211 void    gtk_container_forall               (GtkContainer *container,
212                                             GtkCallback   callback,
213                                             gpointer      callback_data);
214
215
216 /* Deprecated methods */
217
218 /* Use gtk_container_set_resize_mode() instead */
219 void    gtk_container_block_resize       (GtkContainer     *container);
220 void    gtk_container_unblock_resize     (GtkContainer     *container);
221
222 /* Use gtk_container_check_resize() instead */
223 gint    gtk_container_need_resize        (GtkContainer     *container);
224
225 #ifdef __cplusplus
226 }
227 #endif /* __cplusplus */
228
229
230 #endif /* __GTK_CONTAINER_H__ */