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