File: container.hg

package info (click to toggle)
gtkmm3.0 3.24.0-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 22,680 kB
  • sloc: xml: 121,333; cpp: 8,531; sh: 4,250; makefile: 262; perl: 236
file content (296 lines) | stat: -rw-r--r-- 12,683 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/* Copyright (C) 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <vector>

#include <gtkmm/widget.h>
#include <gtkmm/childpropertyproxy.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)

/** @defgroup Containers Container Widgets
 * These widgets can be used to group other widgets together.
 */

/* we'll include gtkfeatures because we dont want to include the whole
   gtk/gtk.h - this file is used by almost ALL our widgets, so dependencies
   in minimum - adding things here will increase compile times ALOT */


namespace Gtk
{

class Adjustment;
class Label;

/** Abstract container class
 *
 * This is the abstract container from which all gtk+ widgets which hold
 * other items derive from.  It mainly houses virtual functions
 * used for inserting and removing children.  Containers in gtk+
 * may hold one item or many items depending on the implementation.
 *
 * This interface is used for all single item holding containers.
 * Multi-item containers provide their own unique interface as their
 * items are generally more complex.  The methods of the derived
 * classes should be prefered over these.
 *
 * @ingroup Widgets
 */
class Container : public Widget
{
  _CLASS_GTKOBJECT(Container,GtkContainer,GTK_CONTAINER,Gtk::Widget,GtkWidget)
  _IGNORE(gtk_container_child_set_valist, gtk_container_get_focus_chain)
public:

/* Application-level methods */

  _WRAP_METHOD(void set_border_width(guint border_width),
               gtk_container_set_border_width)

  _WRAP_METHOD(guint get_border_width() const,
               gtk_container_get_border_width)

  //This is virtual so that we can override it in Gtk::ScrolledWindow.
  //TODO: Remove the virtual keyword when we can break ABI,
  //because the override in ScrolledWindow is no longer necessary.
  _WRAP_METHOD_DOCS_ONLY(gtk_container_add)
  virtual void add(Widget& widget);
  _IGNORE(gtk_container_add)

  /** Removes @a widget from the container.
   * @a widget must be inside this container.
   * If @a widget is managed with Gtk::manage(), and you don't want to use @a widget
   * again, then you should delete it, because there will no longer be any parent
   * container to delete it automatically.
   *
   * What's said about ScrolledWindow in the documentation of Bin::remove()
   * applies also to Container::remove().
   *
   * @param widget A current child of the container.
   */
  void remove(Widget& widget);
  _IGNORE(gtk_container_remove)

  _WRAP_METHOD(void set_resize_mode(ResizeMode resize_mode),
               gtk_container_set_resize_mode,
               deprecated "Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.")

  _WRAP_METHOD(ResizeMode get_resize_mode() const,
               gtk_container_get_resize_mode,
               deprecated "Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.")

  /// Request that contained widgets check their size
  _WRAP_METHOD(void check_resize(), gtk_container_check_resize)

  /** A slot to invoke with each child iterated over by foreach() or forall().
   * For instance,<br>
   * void on_foreach(Gtk::Widget& widget);
   */
  typedef sigc::slot<void, Widget&> ForeachSlot;

  /** Operate on contained items.
   *
   * Invokes the @a slot on each non-internal child of the container. See
   * forall() for details on what constitutes an
   * "internal" child.  Most applications should use foreach()
   * rather than forall().
   */
  void foreach(const ForeachSlot& slot);
  _IGNORE(gtk_container_foreach)


  /** Operate on contained items, including internal children.
   *
   * Invokes the @a slot on each child of the container, including children
   * that are considered "internal" (implementation details of the
   * container). "Internal" children generally weren't added by the user
   * of the container, but were added by the container implementation
   * itself.  Most applications should use foreach(),
   * rather than forall().
   *
   * @newin{3,6}
   */
  void forall(const ForeachSlot& slot);
  _IGNORE(gtk_container_forall)

#m4 _CONVERSION(`GList*',`std::vector<Widget*>',`Glib::ListHandler<Widget*>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
  _WRAP_METHOD(std::vector<Widget*> get_children(), gtk_container_get_children)
#m4 _CONVERSION(`GList*',`std::vector<const Widget*>',`Glib::ListHandler<const Widget*>::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
  _WRAP_METHOD(std::vector<const Widget*> get_children() const, gtk_container_get_children)

  _WRAP_METHOD(void propagate_draw(Widget& child, const ::Cairo::RefPtr< ::Cairo::Context>& cr), gtk_container_propagate_draw)

#m4 _CONVERSION(`const std::vector<Widget*>&',`GList*',`Glib::ListHandler<Widget*>::vector_to_list($3).data ()')
  _WRAP_METHOD(void set_focus_chain(const std::vector<Widget*>& focusable_widgets), gtk_container_set_focus_chain,
    deprecated "For overriding focus behavior, use Gtk::Widget::signal_focus().")

#ifndef GTKMM_DISABLE_DEPRECATED
  // gtk_container_get_focus_chain() has been split up into two
  // functions in order to make implicit container conversion possible.
  /** @deprecated For overriding focus behavior, use Gtk::Widget::signal_focus().
   */
  bool has_focus_chain() const;
  /** @deprecated For overriding focus behavior, use Gtk::Widget::signal_focus().
   */
  std::vector<Widget*> get_focus_chain();
  /** @deprecated For overriding focus behavior, use Gtk::Widget::signal_focus().
   */
  std::vector<const Widget*> get_focus_chain() const;
#endif // GTKMM_DISABLE_DEPRECATED

  _WRAP_METHOD(void unset_focus_chain(), gtk_container_unset_focus_chain,
    deprecated "For overriding focus behavior, use Gtk::Widget::signal_focus().")

/* Widget-level methods */

  _WRAP_METHOD(void set_reallocate_redraws(bool needs_redraws = true),
               gtk_container_set_reallocate_redraws,
               deprecated "Call Gtk::Widget::queue_draw() in your Gtk::Widget::signal_size_allocate() handler.")

  /// Sets the focus on a child
  _WRAP_METHOD(void set_focus_child(Widget& widget),gtk_container_set_focus_child)

  _WRAP_METHOD(Widget* get_focus_child(), gtk_container_get_focus_child)
  _WRAP_METHOD(const Widget* get_focus_child() const, gtk_container_get_focus_child, constversion)

  _WRAP_METHOD(void set_focus_vadjustment(const Glib::RefPtr<Adjustment>& adjustment),
               gtk_container_set_focus_vadjustment)

  _WRAP_METHOD(Glib::RefPtr<Adjustment> get_focus_vadjustment(),
               gtk_container_get_focus_vadjustment, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Adjustment> get_focus_vadjustment() const,
               gtk_container_get_focus_vadjustment, refreturn, constversion)

  _WRAP_METHOD(void set_focus_hadjustment(const Glib::RefPtr<Adjustment>& adjustment),
               gtk_container_set_focus_hadjustment)

  _WRAP_METHOD(Glib::RefPtr<Adjustment> get_focus_hadjustment(),
               gtk_container_get_focus_hadjustment, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Adjustment> get_focus_hadjustment() const,
               gtk_container_get_focus_hadjustment, refreturn, constversion)

   /** @deprecated No replacement available.
    */
  _WRAP_METHOD(void resize_children(), gtk_container_resize_children, deprecated "No replacement available.")

  _WRAP_METHOD(GType child_type() const, gtk_container_child_type)

  _WRAP_METHOD(WidgetPath get_path_for_child(const Widget& child) const, gtk_container_get_path_for_child)

  // Ignore functions such as gtk_container_class_install_child_property(),  which I think are for themes, like the GtkWidget style properties.
  _IGNORE(gtk_container_class_install_child_property, gtk_container_class_find_child_property, gtk_container_class_list_child_properties,
          gtk_container_add_with_properties, gtk_container_child_set, gtk_container_child_get, gtk_container_child_get_valist, gtk_container_child_get_property)


  _WRAP_SIGNAL(void add(Widget* widget), "add")

  //We use the optional custom_c_callback parameter with _WRAP_SIGNAL() here,
  //so that we can write special code to check for deleted child widget parameters:
  _WRAP_SIGNAL(void remove(Widget* widget), "remove", custom_c_callback)

  _WRAP_SIGNAL(void check_resize(), "check_resize")
  _WRAP_SIGNAL(void set_focus_child(Widget* widget), "set_focus_child")

  void show_all_children(bool recursive = true);

protected:
  _CTOR_DEFAULT()

  /** Implements child_type().
   *
   * The default implementation returns G_TYPE_NONE
   */
  _WRAP_VFUNC(GType child_type() const, child_type)

  /** Invokes a callback on all children of the container.
   *
   * The callback may optionally be invoked also on children that are considered
   * "internal" (implementation details of the container). "Internal" children
   * generally  weren't added by the user of the container, but were added by the
   * container implementation itself.
   *
   * Most applications should use foreach(), rather than forall().
   *
   * @param include_internals
   * @param callback A callback.
   * @param callback_data Callback user data
   */
  _WRAP_VFUNC(void forall(gboolean include_internals, GtkCallback callback, gpointer callback_data), forall)

  //TODO: Return a ustring instead when we can break ABI.
  /** Returns the composite name of a child widget.
   *
   * Composite widgets are  children of the container that are considered
   * "internal" (implementation details of the container). "Internal" children
   * generally weren't added by the user of the container, but were added by
   * the container implementation itself.
   *
   * The caller is responsible for freeing the returned string.
   *
   * @param child The child widget.
   * @returns The composite name of the child widget.
   */
  _WRAP_VFUNC(char* composite_name(GtkWidget* child), composite_name)

  /** Sets a child property for this container and its child.
   *
   * Child properties are object properties that are not specific to either the
   * container or the contained widget, but rather to their relation. Typical
   * examples of child properties are the position or pack-type of a widget
   * which is contained in a Gtk::Box.
   *
   * @param child The child property.
   * @param property_id The ID of the child property to set.
   * @param value The new value for the child property.
   * @param pspec
   */
  _WRAP_VFUNC(void set_child_property(GtkWidget* child, guint property_id, const GValue* value, GParamSpec* pspec), set_child_property)

  /** Returns a child property for this container and its child.
   *
   * Child  properties are object properties that are not specific to either the
   * container or the contained widget, but rather to their relation. Typical
   * examples of child properties are the position or pack-type of a widget
   * which is contained in a Gtk::Box.
   *
   * @param child The child property.
   * @param property_id The ID of the child property to get.
   * @param value A GValue to fill with the child property's value.
   * @param pspec
   */
  _WRAP_VFUNC(void get_child_property(GtkWidget* child, guint property_id, GValue* value, GParamSpec* pspec) const, get_child_property)

  _WRAP_PROPERTY("border_width", guint)
  _WRAP_PROPERTY("resize_mode", ResizeMode,
    deprecated "Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.")
  _WRAP_PROPERTY("child", Widget*, deprecated "Use add() instead.")

#m4begin
dnl// Hook in special code to catch explicit uses of gtk_object_destroy() by
dnl// GTK+ code, e.g. when receiving the GDK_DELETE event.  For details, look
dnl// at Gtk::Widget_Class::dispose_vfunc_callback() in widget.ccg.
dnl
  _PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
  _SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
    static void remove_callback_normal(GtkContainer* self, GtkWidget* p0);
  _POP()
#m4end
};

} // namespace Gtk