]> Pileus Git - ~andy/gtk/blob - gtk/gtkcontainer.h
035cf3260b9a79a167e59e779df436f39a967f17
[~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)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CONTAINER, GtkContainer))
44 #define GTK_CONTAINER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CONTAINER, GtkContainerClass))
45 #define GTK_IS_CONTAINER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CONTAINER))
46 #define GTK_IS_CONTAINER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CONTAINER))
47 #define GTK_CONTAINER_GET_CLASS(obj)    (G_TYPE_INSTANCE_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
63   /*< private >*/
64   guint need_resize : 1;
65   guint resize_mode : 2;
66   guint reallocate_redraws : 1;
67   guint has_focus_chain : 1;
68 };
69
70 struct _GtkContainerClass
71 {
72   GtkWidgetClass parent_class;
73
74   void    (*add)                (GtkContainer    *container,
75                                  GtkWidget       *widget);
76   void    (*remove)             (GtkContainer    *container,
77                                  GtkWidget       *widget);
78   void    (*check_resize)       (GtkContainer    *container);
79   void    (*forall)             (GtkContainer    *container,
80                                  gboolean         include_internals,
81                                  GtkCallback      callback,
82                                  gpointer         callback_data);
83   void    (*set_focus_child)    (GtkContainer    *container,
84                                  GtkWidget       *widget);
85   GType   (*child_type)         (GtkContainer    *container);
86   gchar*  (*composite_name)     (GtkContainer    *container,
87                                  GtkWidget       *child);
88   void    (*set_child_property) (GtkContainer    *container,
89                                  GtkWidget       *child,
90                                  guint            property_id,
91                                  const GValue    *value,
92                                  GParamSpec      *pspec);
93   void    (*get_child_property) (GtkContainer    *container,
94                                  GtkWidget       *child,
95                                  guint            property_id,
96                                  GValue          *value,
97                                  GParamSpec      *pspec);
98
99   /* Padding for future expansion */
100   void (*_gtk_reserved1) (void);
101   void (*_gtk_reserved2) (void);
102   void (*_gtk_reserved3) (void);
103   void (*_gtk_reserved4) (void);
104 };
105
106 /* Application-level methods */
107
108 GType   gtk_container_get_type           (void) G_GNUC_CONST;
109 void    gtk_container_set_border_width   (GtkContainer     *container,
110                                           guint             border_width);
111 guint   gtk_container_get_border_width   (GtkContainer     *container);
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 GtkResizeMode gtk_container_get_resize_mode (GtkContainer     *container);
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 #ifndef GTK_DISABLE_DEPRECATED
127 void     gtk_container_foreach_full (GtkContainer       *container,
128                                      GtkCallback         callback,
129                                      GtkCallbackMarshal  marshal,
130                                      gpointer            callback_data,
131                                      GtkDestroyNotify    notify);
132 #endif /*  GTK_DISABLE_DEPRECATED */
133 GList*   gtk_container_get_children     (GtkContainer       *container);
134
135 #ifndef GTK_DISABLE_DEPRECATED
136 #define gtk_container_children gtk_container_get_children
137 #endif
138
139 void     gtk_container_propagate_expose (GtkContainer   *container,
140                                          GtkWidget      *child,
141                                          GdkEventExpose *event);
142
143 void     gtk_container_set_focus_chain  (GtkContainer   *container,
144                                          GList          *focusable_widgets);
145 gboolean gtk_container_get_focus_chain  (GtkContainer   *container,
146                                          GList         **focusable_widgets);
147 void     gtk_container_unset_focus_chain (GtkContainer  *container);
148
149 /* Widget-level methods */
150
151 void   gtk_container_set_reallocate_redraws (GtkContainer    *container,
152                                              gboolean         needs_redraws);
153 void   gtk_container_set_focus_child       (GtkContainer     *container,
154                                             GtkWidget        *child);
155 void   gtk_container_set_focus_vadjustment (GtkContainer     *container,
156                                             GtkAdjustment    *adjustment);
157 GtkAdjustment *gtk_container_get_focus_vadjustment (GtkContainer *container);
158 void   gtk_container_set_focus_hadjustment (GtkContainer     *container,
159                                             GtkAdjustment    *adjustment);
160 GtkAdjustment *gtk_container_get_focus_hadjustment (GtkContainer *container);
161
162 void    gtk_container_resize_children      (GtkContainer     *container);
163
164 GType   gtk_container_child_type           (GtkContainer     *container);
165
166
167 void         gtk_container_class_install_child_property (GtkContainerClass *cclass,
168                                                          guint              property_id,
169                                                          GParamSpec        *pspec);
170 GParamSpec*  gtk_container_class_find_child_property    (GObjectClass      *cclass,
171                                                          const gchar       *property_name);
172 GParamSpec** gtk_container_class_list_child_properties  (GObjectClass      *cclass,
173                                                          guint             *n_properties);
174 void         gtk_container_add_with_properties          (GtkContainer      *container,
175                                                          GtkWidget         *widget,
176                                                          const gchar       *first_prop_name,
177                                                          ...);
178 void         gtk_container_child_set                    (GtkContainer      *container,
179                                                          GtkWidget         *child,
180                                                          const gchar       *first_prop_name,
181                                                          ...);     
182 void         gtk_container_child_get                    (GtkContainer      *container,
183                                                          GtkWidget         *child,
184                                                          const gchar       *first_prop_name,
185                                                          ...);     
186 void         gtk_container_child_set_valist             (GtkContainer      *container,
187                                                          GtkWidget         *child,
188                                                          const gchar       *first_property_name,
189                                                          va_list            var_args);
190 void         gtk_container_child_get_valist             (GtkContainer      *container,
191                                                          GtkWidget         *child,
192                                                          const gchar       *first_property_name,
193                                                          va_list            var_args);
194 void         gtk_container_child_set_property           (GtkContainer      *container,
195                                                          GtkWidget         *child,
196                                                          const gchar       *property_name,
197                                                          const GValue      *value);
198 void         gtk_container_child_get_property           (GtkContainer      *container,
199                                                          GtkWidget         *child,
200                                                          const gchar       *property_name,
201                                                          GValue            *value);
202
203 #define GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID(object, property_id, pspec) \
204     G_OBJECT_WARN_INVALID_PSPEC ((object), "child property id", (property_id), (pspec))
205
206
207 void    gtk_container_forall                 (GtkContainer *container,
208                                               GtkCallback   callback,
209                                               gpointer      callback_data);
210
211 /* Non-public methods */
212 void    _gtk_container_queue_resize          (GtkContainer *container);
213 void    _gtk_container_clear_resize_widgets   (GtkContainer *container);
214 gchar*  _gtk_container_child_composite_name   (GtkContainer *container,
215                                               GtkWidget    *child);
216 void   _gtk_container_dequeue_resize_handler (GtkContainer *container);
217 GList *_gtk_container_focus_sort             (GtkContainer     *container,
218                                               GList            *children,
219                                               GtkDirectionType  direction,
220                                               GtkWidget        *old_focus);
221
222 #ifndef GTK_DISABLE_DEPRECATED
223 #define gtk_container_border_width              gtk_container_set_border_width
224 #endif /* GTK_DISABLE_DEPRECATED */
225
226 #ifdef __cplusplus
227 }
228 #endif /* __cplusplus */
229
230
231 #endif /* __GTK_CONTAINER_H__ */