Debian Codegraph @

gtk/src/container.hg

raw
1 /* Copyright (C) 1998-2002 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <vector>
18
19 #include <gtkmm/widget.h>
20 #include <gtkmm/childpropertyproxy.h>
21
22 _DEFS(gtkmm,gtk)
23 _PINCLUDE(gtkmm/private/widget_p.h)
24
25 /** @defgroup Containers Container Widgets
26 * These widgets can be used to group other widgets together.
27 */
28
29 /* we'll include gtkfeatures because we dont want to include the whole
30 gtk/gtk.h - this file is used by almost ALL our widgets, so dependencies
31 in minimum - adding things here will increase compile times ALOT */
32
33
34 namespace Gtk
35 {
36
37 class GTKMM_API Adjustment;
38 class GTKMM_API Label;
39
40 /** Abstract container class
41 *
42 * This is the abstract container from which all gtk+ widgets which hold
43 * other items derive from. It mainly houses virtual functions
44 * used for inserting and removing children. Containers in gtk+
45 * may hold one item or many items depending on the implementation.
46 *
47 * This interface is used for all single item holding containers.
48 * Multi-item containers provide their own unique interface as their
49 * items are generally more complex. The methods of the derived
50 * classes should be prefered over these.
51 *
52 * @ingroup Widgets
53 */
54 class GTKMM_API Container : public Widget
55 {
56 _CLASS_GTKOBJECT(Container,GtkContainer,GTK_CONTAINER,Gtk::Widget,GtkWidget,,,GTKMM_API)
57 _IGNORE(gtk_container_child_set_valist, gtk_container_get_focus_chain)
58 public:
59
60 /* Application-level methods */
61
62 _WRAP_METHOD(void set_border_width(guint border_width),
63 gtk_container_set_border_width)
64
65 _WRAP_METHOD(guint get_border_width() const,
66 gtk_container_get_border_width)
67
68 //This is virtual so that we can override it in Gtk::ScrolledWindow.
69 //TODO: Remove the virtual keyword when we can break ABI,
70 //because the override in ScrolledWindow is no longer necessary.
71 _WRAP_METHOD_DOCS_ONLY(gtk_container_add)
72 virtual void add(Widget& widget);
73 _IGNORE(gtk_container_add)
74
75 /** Removes @a widget from the container.
76 * @a widget must be inside this container.
77 * If @a widget is managed with Gtk::manage(), and you don't want to use @a widget
78 * again, then you should delete it, because there will no longer be any parent
79 * container to delete it automatically.
80 *
81 * What's said about ScrolledWindow in the documentation of Bin::remove()
82 * applies also to Container::remove().
83 *
84 * @param widget A current child of the container.
85 */
86 void remove(Widget& widget);
87 _IGNORE(gtk_container_remove)
88
89 _WRAP_METHOD(void set_resize_mode(ResizeMode resize_mode),
90 gtk_container_set_resize_mode,
91 deprecated "Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.")
92
93 _WRAP_METHOD(ResizeMode get_resize_mode() const,
94 gtk_container_get_resize_mode,
95 deprecated "Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.")
96
97 /// Request that contained widgets check their size
98 _WRAP_METHOD(void check_resize(), gtk_container_check_resize)
99
100 /** A slot to invoke with each child iterated over by foreach() or forall().
101 * For instance,<br>
102 * void on_foreach(Gtk::Widget& widget);
103 */
104 typedef sigc::slot<void, Widget&> ForeachSlot;
105
106 /** Operate on contained items.
107 *
108 * Invokes the @a slot on each non-internal child of the container. See
109 * forall() for details on what constitutes an
110 * "internal" child. Most applications should use foreach()
111 * rather than forall().
112 */
113 void foreach(const ForeachSlot& slot);
114 _IGNORE(gtk_container_foreach)
115
116
117 /** Operate on contained items, including internal children.
118 *
119 * Invokes the @a slot on each child of the container, including children
120 * that are considered "internal" (implementation details of the
121 * container). "Internal" children generally weren't added by the user
122 * of the container, but were added by the container implementation
123 * itself. Most applications should use foreach(),
124 * rather than forall().
125 *
126 * @newin{3,6}
127 */
128 void forall(const ForeachSlot& slot);
129 _IGNORE(gtk_container_forall)
130
131 #m4 _CONVERSION(`GList*',`std::vector<Widget*>',`Glib::ListHandler<Widget*>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
132 _WRAP_METHOD(std::vector<Widget*> get_children(), gtk_container_get_children)
133 #m4 _CONVERSION(`GList*',`std::vector<const Widget*>',`Glib::ListHandler<const Widget*>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
134 _WRAP_METHOD(std::vector<const Widget*> get_children() const, gtk_container_get_children)
135
136 _WRAP_METHOD(void propagate_draw(Widget& child, const ::Cairo::RefPtr< ::Cairo::Context>& cr), gtk_container_propagate_draw)
137
138 #m4 _CONVERSION(`const std::vector<Widget*>&',`GList*',`Glib::ListHandler<Widget*>::vector_to_list($3).data ()')
139 _WRAP_METHOD(void set_focus_chain(const std::vector<Widget*>& focusable_widgets), gtk_container_set_focus_chain,
140 deprecated "For overriding focus behavior, use Gtk::Widget::signal_focus().")
141
142 #ifndef GTKMM_DISABLE_DEPRECATED
143 // gtk_container_get_focus_chain() has been split up into two
144 // functions in order to make implicit container conversion possible.
145 /** @deprecated For overriding focus behavior, use Gtk::Widget::signal_focus().
146 */
147 bool has_focus_chain() const;
148 /** @deprecated For overriding focus behavior, use Gtk::Widget::signal_focus().
149 */
150 std::vector<Widget*> get_focus_chain();
151 /** @deprecated For overriding focus behavior, use Gtk::Widget::signal_focus().
152 */
153 std::vector<const Widget*> get_focus_chain() const;
154 #endif // GTKMM_DISABLE_DEPRECATED
155
156 _WRAP_METHOD(void unset_focus_chain(), gtk_container_unset_focus_chain,
157 deprecated "For overriding focus behavior, use Gtk::Widget::signal_focus().")
158
159 /* Widget-level methods */
160
161 _WRAP_METHOD(void set_reallocate_redraws(bool needs_redraws = true),
162 gtk_container_set_reallocate_redraws,
163 deprecated "Call Gtk::Widget::queue_draw() in your Gtk::Widget::signal_size_allocate() handler.")
164
165 /// Sets the focus on a child
166 _WRAP_METHOD(void set_focus_child(Widget& widget),gtk_container_set_focus_child)
167
168 _WRAP_METHOD(Widget* get_focus_child(), gtk_container_get_focus_child)
169 _WRAP_METHOD(const Widget* get_focus_child() const, gtk_container_get_focus_child, constversion)
170
171 _WRAP_METHOD(void set_focus_vadjustment(const Glib::RefPtr<Adjustment>& adjustment),
172 gtk_container_set_focus_vadjustment)
173
174 _WRAP_METHOD(Glib::RefPtr<Adjustment> get_focus_vadjustment(),
175 gtk_container_get_focus_vadjustment, refreturn)
176 _WRAP_METHOD(Glib::RefPtr<const Adjustment> get_focus_vadjustment() const,
177 gtk_container_get_focus_vadjustment, refreturn, constversion)
178
179 _WRAP_METHOD(void set_focus_hadjustment(const Glib::RefPtr<Adjustment>& adjustment),
180 gtk_container_set_focus_hadjustment)
181
182 _WRAP_METHOD(Glib::RefPtr<Adjustment> get_focus_hadjustment(),
183 gtk_container_get_focus_hadjustment, refreturn)
184 _WRAP_METHOD(Glib::RefPtr<const Adjustment> get_focus_hadjustment() const,
185 gtk_container_get_focus_hadjustment, refreturn, constversion)
186
187 /** @deprecated No replacement available.
188 */
189 _WRAP_METHOD(void resize_children(), gtk_container_resize_children, deprecated "No replacement available.")
190
191 _WRAP_METHOD(GType child_type() const, gtk_container_child_type)
192
193 _WRAP_METHOD(WidgetPath get_path_for_child(const Widget& child) const, gtk_container_get_path_for_child)
194
195 // Ignore functions such as gtk_container_class_install_child_property(), which I think are for themes, like the GtkWidget style properties.
196 _IGNORE(gtk_container_class_install_child_property, gtk_container_class_find_child_property, gtk_container_class_list_child_properties,
197 gtk_container_add_with_properties, gtk_container_child_set, gtk_container_child_get, gtk_container_child_get_valist, gtk_container_child_get_property)
198
199
200 _WRAP_SIGNAL(void add(Widget* widget), "add")
201
202 //We use the optional custom_c_callback parameter with _WRAP_SIGNAL() here,
203 //so that we can write special code to check for deleted child widget parameters:
204 _WRAP_SIGNAL(void remove(Widget* widget), "remove", custom_c_callback)
205
206 _WRAP_SIGNAL(void check_resize(), "check_resize")
207 _WRAP_SIGNAL(void set_focus_child(Widget* widget), "set_focus_child")
208
209 void show_all_children(bool recursive = true);
210
211 protected:
212 _CTOR_DEFAULT()
213
214 /** Implements child_type().
215 *
216 * The default implementation returns G_TYPE_NONE
217 */
218 _WRAP_VFUNC(GType child_type() const, child_type)
219
220 /** Invokes a callback on all children of the container.
221 *
222 * The callback may optionally be invoked also on children that are considered
223 * "internal" (implementation details of the container). "Internal" children
224 * generally weren't added by the user of the container, but were added by the
225 * container implementation itself.
226 *
227 * Most applications should use foreach(), rather than forall().
228 *
229 * @param include_internals
230 * @param callback A callback.
231 * @param callback_data Callback user data
232 */
233 _WRAP_VFUNC(void forall(gboolean include_internals, GtkCallback callback, gpointer callback_data), forall)
234
235 //TODO: Return a ustring instead when we can break ABI.
236 /** Returns the composite name of a child widget.
237 *
238 * Composite widgets are children of the container that are considered
239 * "internal" (implementation details of the container). "Internal" children
240 * generally weren't added by the user of the container, but were added by
241 * the container implementation itself.
242 *
243 * The caller is responsible for freeing the returned string.
244 *
245 * @param child The child widget.
246 * @returns The composite name of the child widget.
247 */
248 _WRAP_VFUNC(char* composite_name(GtkWidget* child), composite_name)
249
250 /** Sets a child property for this container and its child.
251 *
252 * Child properties are object properties that are not specific to either the
253 * container or the contained widget, but rather to their relation. Typical
254 * examples of child properties are the position or pack-type of a widget
255 * which is contained in a Gtk::Box.
256 *
257 * @param child The child property.
258 * @param property_id The ID of the child property to set.
259 * @param value The new value for the child property.
260 * @param pspec
261 */
262 _WRAP_VFUNC(void set_child_property(GtkWidget* child, guint property_id, const GValue* value, GParamSpec* pspec), set_child_property)
263
264 /** Returns a child property for this container and its child.
265 *
266 * Child properties are object properties that are not specific to either the
267 * container or the contained widget, but rather to their relation. Typical
268 * examples of child properties are the position or pack-type of a widget
269 * which is contained in a Gtk::Box.
270 *
271 * @param child The child property.
272 * @param property_id The ID of the child property to get.
273 * @param value A GValue to fill with the child property's value.
274 * @param pspec
275 */
276 _WRAP_VFUNC(void get_child_property(GtkWidget* child, guint property_id, GValue* value, GParamSpec* pspec) const, get_child_property)
277
278 _WRAP_PROPERTY("border_width", guint)
279 _WRAP_PROPERTY("resize_mode", ResizeMode,
280 deprecated "Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.")
281 _WRAP_PROPERTY("child", Widget*, deprecated "Use add() instead.")
282
283 #m4begin
284 dnl// Hook in special code to catch explicit uses of gtk_object_destroy() by
285 dnl// GTK+ code, e.g. when receiving the GDK_DELETE event. For details, look
286 dnl// at Gtk::Widget_Class::dispose_vfunc_callback() in widget.ccg.
287 dnl
288 _PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
289 _SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
290 static void remove_callback_normal(GtkContainer* self, GtkWidget* p0);
291 _POP()
292 #m4end
293 };
294
295 } // namespace Gtk