]> Pileus Git - ~andy/gtk/blob - gtk/gtkcontainer.h
Add ability to override the focus chain for a container explicitly
[~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 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, 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-2000.  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   guint has_focus_chain : 1;
66   
67   /* The list of children that requested a resize
68    */
69   GSList *resize_widgets;
70 };
71
72 struct _GtkContainerClass
73 {
74   GtkWidgetClass parent_class;
75   
76   guint   n_child_args;
77
78   void (* add)                  (GtkContainer    *container,
79                                  GtkWidget       *widget);
80   void (* remove)               (GtkContainer    *container,
81                                  GtkWidget       *widget);
82   void (* check_resize)         (GtkContainer    *container);
83   void (* forall)               (GtkContainer    *container,
84                                  gboolean         include_internals,
85                                  GtkCallback      callback,
86                                  gpointer         callbabck_data);
87   gboolean (* focus)            (GtkContainer    *container,
88                                  GtkDirectionType  direction);
89   void (* set_focus_child)      (GtkContainer    *container,
90                                  GtkWidget       *widget);
91   GtkType (*child_type)         (GtkContainer   *container);
92   void    (*set_child_arg)      (GtkContainer   *container,
93                                  GtkWidget      *child,
94                                  GtkArg         *arg,
95                                  guint           arg_id);
96   void    (*get_child_arg)      (GtkContainer   *container,
97                                  GtkWidget      *child,
98                                  GtkArg         *arg,
99                                  guint           arg_id);
100   gchar*  (*composite_name)     (GtkContainer   *container,
101                                  GtkWidget      *child);
102
103   /* Padding for future expansion */
104   GtkFunction pad1;
105   GtkFunction pad2;
106 };
107
108 /* Application-level methods */
109
110 GtkType gtk_container_get_type           (void) G_GNUC_CONST;
111 void    gtk_container_set_border_width   (GtkContainer     *container,
112                                           guint             border_width);
113 void    gtk_container_add                (GtkContainer     *container,
114                                           GtkWidget        *widget);
115 void    gtk_container_remove             (GtkContainer     *container,
116                                           GtkWidget        *widget);
117
118 void    gtk_container_set_resize_mode    (GtkContainer     *container,
119                                           GtkResizeMode     resize_mode);
120
121 void    gtk_container_check_resize       (GtkContainer     *container);
122
123 void     gtk_container_foreach      (GtkContainer       *container,
124                                      GtkCallback         callback,
125                                      gpointer            callback_data);
126 void     gtk_container_foreach_full (GtkContainer       *container,
127                                      GtkCallback         callback,
128                                      GtkCallbackMarshal  marshal,
129                                      gpointer            callback_data,
130                                      GtkDestroyNotify    notify);
131 GList*   gtk_container_children     (GtkContainer       *container);
132 gboolean gtk_container_focus        (GtkContainer       *container,
133                                      GtkDirectionType    direction);
134 void     gtk_container_propagate_expose (GtkContainer   *container,
135                                          GtkWidget      *child,
136                                          GdkEventExpose *event);
137
138 void     gtk_container_set_focus_chain  (GtkContainer   *container,
139                                          GList          *focusable_widgets);
140 void     gtk_container_unset_focus_chain (GtkContainer  *container);
141
142 /* Widget-level methods */
143
144 void   gtk_container_set_reallocate_redraws (GtkContainer    *container,
145                                              gboolean         needs_redraws);
146 void   gtk_container_set_focus_child       (GtkContainer     *container,
147                                             GtkWidget        *child);
148 void   gtk_container_set_focus_vadjustment (GtkContainer     *container,
149                                             GtkAdjustment    *adjustment);
150 void   gtk_container_set_focus_hadjustment (GtkContainer     *container,
151                                             GtkAdjustment    *adjustment);
152
153 void    gtk_container_resize_children      (GtkContainer     *container);
154
155 GtkType gtk_container_child_type           (GtkContainer     *container);
156
157 /* the `arg_name' argument needs to be a const static string */
158 void    gtk_container_add_child_arg_type   (const gchar      *arg_name,
159                                             GtkType           arg_type,
160                                             guint             arg_flags,
161                                             guint             arg_id);
162      
163 /* Allocate a GtkArg array of size nargs that hold the
164  * names and types of the args that can be used with
165  * gtk_container_child_getv/gtk_container_child_setv.
166  * if (arg_flags!=NULL),
167  * (*arg_flags) will be set to point to a newly allocated
168  * guint array that holds the flags of the args.
169  * It is the callers response to do a
170  * g_free (returned_args); g_free (*arg_flags).
171  */
172 GtkArg* gtk_container_query_child_args     (GtkType            class_type,
173                                             guint32          **arg_flags,
174                                             guint             *nargs);
175
176 /* gtk_container_child_getv() sets an arguments type and value, or just
177  * its type to GTK_TYPE_INVALID.
178  * if GTK_FUNDAMENTAL_TYPE (arg->type) == GTK_TYPE_STRING, it's the callers
179  * response to do a g_free (GTK_VALUE_STRING (arg));
180  */
181 void    gtk_container_child_getv           (GtkContainer      *container,
182                                             GtkWidget         *child,
183                                             guint              n_args,
184                                             GtkArg            *args);
185 void    gtk_container_child_setv           (GtkContainer      *container,
186                                             GtkWidget         *child,
187                                             guint              n_args,
188                                             GtkArg            *args);
189
190 /* gtk_container_add_with_args() takes a variable argument list of the form:
191  * (..., gchar *arg_name, ARG_VALUES, [repeatedly name/value pairs,] NULL)
192  * where ARG_VALUES type depend on the argument and can consist of
193  * more than one c-function argument.
194  */
195 void    gtk_container_add_with_args        (GtkContainer      *container,
196                                             GtkWidget         *widget,
197                                             const gchar       *first_arg_name,
198                                             ...);
199 void    gtk_container_addv                 (GtkContainer      *container,
200                                             GtkWidget         *widget,
201                                             guint              n_args,
202                                             GtkArg            *args);
203 void    gtk_container_child_set            (GtkContainer      *container,
204                                             GtkWidget         *child,
205                                             const gchar       *first_arg_name,
206                                             ...);
207      
208
209 /* Non-public methods */
210
211 void    gtk_container_queue_resize           (GtkContainer *container);
212 void    gtk_container_clear_resize_widgets   (GtkContainer *container);
213 void    gtk_container_arg_set                (GtkContainer *container,
214                                               GtkWidget    *child,
215                                               GtkArg       *arg,
216                                               GtkArgInfo   *info);
217 void    gtk_container_arg_get                (GtkContainer *container,
218                                               GtkWidget    *child,
219                                               GtkArg       *arg,
220                                               GtkArgInfo   *info);
221 gchar*  gtk_container_child_args_collect     (GtkType       object_type,
222                                               GSList      **arg_list_p,
223                                               GSList      **info_list_p,
224                                               const gchar  *first_arg_name,
225                                               va_list       args);
226 gchar*  gtk_container_child_arg_get_info     (GtkType       object_type,
227                                               const gchar  *arg_name,
228                                               GtkArgInfo  **info_p);
229 void    gtk_container_forall                 (GtkContainer *container,
230                                               GtkCallback   callback,
231                                               gpointer      callback_data);
232 gchar*  gtk_container_child_composite_name   (GtkContainer *container,
233                                               GtkWidget    *child);
234 void    gtk_container_dequeue_resize_handler (GtkContainer *container);
235
236 #ifdef __cplusplus
237 }
238 #endif /* __cplusplus */
239
240
241 #endif /* __GTK_CONTAINER_H__ */