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