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