1 /* $Id: container.hg,v 1.11 2006/04/12 11:11:25 murrayc Exp $ */
3 /* Copyright (C) 1998-2002 The gtkmm Development Team
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <glibmm/listhandle.h>
21 #include <gtkmm/widget.h>
24 _PINCLUDE(gtkmm/private/widget_p.h)
26 /** @defgroup Containers Container Widgets
27 * These widgets can be used to group other widgets together.
30 /* we'll include gtkfeatures because we dont want to include the whole
31 gtk/gtk.h - this file is used by almost ALL our widgets, so dependencies
32 in minimum - adding things here will increase compile times ALOT */
41 /** Abstract container class
43 * This is the abstract container from which all gtk+ widgets which hold
44 * other items derive from. It mainly houses virtual functions
45 * used for inserting and removing children. Containers in gtk+
46 * may hold one item or many items depending on the implementation.
48 * This interface is used for all single item holding containers.
49 * Multi-item containers provide their own unique interface as their
50 * items are generally more complex. The methods of the derived
51 * classes should be prefered over these.
55 class Container : public Widget
57 _CLASS_GTKOBJECT(Container,GtkContainer,GTK_CONTAINER,Gtk::Widget,GtkWidget)
58 _IGNORE(gtk_container_child_set_valist, gtk_container_get_focus_chain,
59 gtk_container_foreach_full, gtk_container_children, gtk_container_border_width)
62 /* Application-level methods */
64 _WRAP_METHOD(void set_border_width(guint border_width),
65 gtk_container_set_border_width)
67 _WRAP_METHOD(guint get_border_width() const,
68 gtk_container_get_border_width)
70 //This is virtual so that we can override it in Gtk::ScrolledWindow:
71 virtual void add(Widget& widget);
72 _IGNORE(gtk_container_add)
74 _WRAP_METHOD_DOCS_ONLY(gtk_container_remove)
75 void remove(Widget& widget);
76 _IGNORE(gtk_container_remove)
78 _WRAP_METHOD(void set_resize_mode(ResizeMode resize_mode),
79 gtk_container_set_resize_mode)
81 _WRAP_METHOD(ResizeMode get_resize_mode() const,
82 gtk_container_get_resize_mode)
84 /// Request that contained widgets check their size
85 _WRAP_METHOD(void check_resize(), gtk_container_check_resize)
88 * void on_foreach(Gtk::Widget* widget);
90 typedef sigc::slot<void, Widget&> ForeachSlot;
92 /** Operate on contained items
93 * This is largely an internal used mainly for things like
94 * creating duplicates of internal lists and other such
95 * operations. The result is lossy as it only gets the
96 * the main child and not its external pieces.
98 * For example notebook pages contain a page, a label, and
99 * a menu item. But this only operates on the pages.
101 void foreach(const ForeachSlot& slot);
103 /// (internal) Operate on contained items (see foreach())
104 //_WRAP_METHOD(void foreach_(GtkCallback callback,gpointer data),gtk_container_foreach)
106 /// (internal) Operate on contained items (see foreach())
107 //_WRAP_METHOD(void foreach_full_(GtkCallback callback,GtkCallbackMarshal marshal, gpointer data,GtkDestroyNotify notify),gtk_container_foreach_full)
109 _WRAP_METHOD(Glib::ListHandle<Widget*> get_children(), gtk_container_get_children)
110 _WRAP_METHOD(Glib::ListHandle<const Widget*> get_children() const, gtk_container_get_children)
112 _WRAP_METHOD(void propagate_expose(Widget& child, GdkEventExpose* event),
113 gtk_container_propagate_expose)
115 _WRAP_METHOD(void set_focus_chain(const Glib::ListHandle<Widget*>& focusable_widgets),
116 gtk_container_set_focus_chain)
118 // gtk_container_get_focus_chain() has been split up into two
119 // functions in order to make implicit container conversion possible.
120 bool has_focus_chain() const;
121 Glib::ListHandle<Widget*> get_focus_chain();
122 Glib::ListHandle<const Widget*> get_focus_chain() const;
124 _WRAP_METHOD(void unset_focus_chain(), gtk_container_unset_focus_chain)
129 /* Widget-level methods */
131 _WRAP_METHOD(void set_reallocate_redraws(bool needs_redraws = true),
132 gtk_container_set_reallocate_redraws)
134 /// Sets the focus on a child
135 _WRAP_METHOD(void set_focus_child(Widget& widget),gtk_container_set_focus_child)
137 _WRAP_METHOD(void set_focus_vadjustment(Adjustment& adjustment),
138 gtk_container_set_focus_vadjustment)
140 _WRAP_METHOD(Adjustment* get_focus_vadjustment(),
141 gtk_container_get_focus_vadjustment)
142 _WRAP_METHOD(const Adjustment* get_focus_vadjustment() const,
143 gtk_container_get_focus_vadjustment, constversion)
145 _WRAP_METHOD(void set_focus_hadjustment(Adjustment& adjustment),
146 gtk_container_set_focus_hadjustment)
148 _WRAP_METHOD(Adjustment* get_focus_hadjustment(),
149 gtk_container_get_focus_hadjustment)
150 _WRAP_METHOD(const Adjustment* get_focus_hadjustment() const,
151 gtk_container_get_focus_hadjustment, constversion)
154 _WRAP_METHOD(void resize_children(), gtk_container_resize_children)
156 _WRAP_METHOD(GType child_type() const, gtk_container_child_type)
158 // Ignore functions such as gtk_container_class_install_child_property(), which I think are for themes, like the GtkWidget style properties.
159 _IGNORE(gtk_container_class_install_child_property, gtk_container_class_find_child_property, gtk_container_class_list_child_properties,
160 gtk_container_add_with_properties, gtk_container_child_set, gtk_container_child_get, gtk_container_child_get_valist, gtk_container_child_get_property)
163 _WRAP_SIGNAL(void add(Widget* widget), "add")
165 //We use the optional custom_c_callback parameter with _WRAP_SIGNAL() here,
166 //so that we can write special code to check for deleted child widget parameters:
167 _WRAP_SIGNAL(void remove(Widget* widget), "remove", custom_c_callback)
169 _WRAP_SIGNAL(void check_resize(), "check_resize")
170 _WRAP_SIGNAL(void set_focus_child(Widget* widget), "set_focus_child")
172 void show_all_children(bool recursive = true);
177 _WRAP_VFUNC(GtkType child_type() const, child_type)
178 _WRAP_VFUNC(void forall(gboolean include_internals, GtkCallback callback, gpointer callback_data), forall)
179 //TODO: What is this?
180 _WRAP_VFUNC(char* composite_name(GtkWidget* child), composite_name)
181 _WRAP_VFUNC(void set_child_property(GtkWidget* child, guint property_id, const GValue* value, GParamSpec* pspec), set_child_property)
182 _WRAP_VFUNC(void get_child_property(GtkWidget* child, guint property_id, GValue* value, GParamSpec* pspec) const, get_child_property)
184 _WRAP_PROPERTY("border_width", guint)
185 _WRAP_PROPERTY("resize_mode", ResizeMode)
186 _WRAP_PROPERTY("child", Widget*)
189 dnl// Hook in special code to catch explicit uses of gtk_object_destroy() by
190 dnl// GTK+ code, e.g. when receiving the GDK_DELETE event. For details, look
191 dnl// at Gtk::Widget_Class::dispose_vfunc_callback() in widget.ccg.
193 _PUSH(SECTION_PCC_CLASS_INIT_DEFAULT_SIGNAL_HANDLERS)
194 reinterpret_cast<GtkObjectClass*>(klass)->destroy = &destroy_callback;
195 _SECTION(SECTION_PH_DEFAULT_SIGNAL_HANDLERS)
196 static void destroy_callback(GtkObject* self);
197 static void remove_callback_normal(GtkContainer* self, GtkWidget* p0);