rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / gtkmm2 / gtk / src / container.hg
1 /* $Id: container.hg,v 1.11 2006/04/12 11:11:25 murrayc Exp $ */
2
3 /* Copyright (C) 1998-2002 The gtkmm Development Team
4  *
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.
9  *
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.
14  *
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.
18  */
19  
20 #include <glibmm/listhandle.h>
21 #include <gtkmm/widget.h>
22
23 _DEFS(gtkmm,gtk)
24 _PINCLUDE(gtkmm/private/widget_p.h)
25
26 /** @defgroup Containers Container Widgets
27  * These widgets can be used to group other widgets together.
28  */
29
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 */
33
34
35 namespace Gtk
36 {
37
38 class Adjustment;
39 class Label;
40
41 /** Abstract container class
42  *
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.
47  *
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.
52  *
53  * @ingroup Widgets
54  */
55 class Container : public Widget
56 {
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)
60 public:
61
62 /* Application-level methods */
63
64   _WRAP_METHOD(void set_border_width(guint border_width),
65                gtk_container_set_border_width)
66
67   _WRAP_METHOD(guint get_border_width() const,
68                gtk_container_get_border_width)
69
70   //This is virtual so that we can override it in Gtk::ScrolledWindow:
71  virtual void add(Widget& widget);
72   _IGNORE(gtk_container_add)
73
74   _WRAP_METHOD_DOCS_ONLY(gtk_container_remove)
75   void remove(Widget& widget);
76   _IGNORE(gtk_container_remove)
77
78   _WRAP_METHOD(void set_resize_mode(ResizeMode resize_mode),
79                gtk_container_set_resize_mode)
80
81   _WRAP_METHOD(ResizeMode get_resize_mode() const,
82                gtk_container_get_resize_mode)
83
84   /// Request that contained widgets check their size
85   _WRAP_METHOD(void check_resize(), gtk_container_check_resize)
86
87   /** For instance, 
88    * void on_foreach(Gtk::Widget* widget);
89    */
90   typedef sigc::slot<void, Widget&> ForeachSlot;
91
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.
97    *
98    * For example notebook pages contain a page, a label, and
99    * a menu item.  But this only operates on the pages.
100    */
101   void foreach(const ForeachSlot& slot);
102
103   /// (internal) Operate on contained items (see foreach())
104   //_WRAP_METHOD(void foreach_(GtkCallback callback,gpointer data),gtk_container_foreach)
105
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)
108
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)
111
112   _WRAP_METHOD(void propagate_expose(Widget& child, GdkEventExpose* event),
113                gtk_container_propagate_expose)
114
115   _WRAP_METHOD(void set_focus_chain(const Glib::ListHandle<Widget*>& focusable_widgets),
116                gtk_container_set_focus_chain)
117
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;
123
124   _WRAP_METHOD(void unset_focus_chain(), gtk_container_unset_focus_chain)
125
126
127
128
129 /* Widget-level methods */
130
131   _WRAP_METHOD(void set_reallocate_redraws(bool needs_redraws = true),
132                gtk_container_set_reallocate_redraws)
133
134   /// Sets the focus on a child
135   _WRAP_METHOD(void set_focus_child(Widget& widget),gtk_container_set_focus_child)
136
137   _WRAP_METHOD(void set_focus_vadjustment(Adjustment& adjustment),
138                gtk_container_set_focus_vadjustment)
139
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)
144
145   _WRAP_METHOD(void set_focus_hadjustment(Adjustment& adjustment),
146                gtk_container_set_focus_hadjustment)
147
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)
152
153
154   _WRAP_METHOD(void resize_children(), gtk_container_resize_children)
155   
156   _WRAP_METHOD(GType child_type() const, gtk_container_child_type)
157
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)
161
162
163   _WRAP_SIGNAL(void add(Widget* widget), "add")
164
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)
168
169   _WRAP_SIGNAL(void check_resize(), "check_resize")
170   _WRAP_SIGNAL(void set_focus_child(Widget* widget), "set_focus_child")
171
172   void show_all_children(bool recursive = true); 
173
174 protected:
175   _CTOR_DEFAULT()
176
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)
183
184   _WRAP_PROPERTY("border_width", guint)
185   _WRAP_PROPERTY("resize_mode", ResizeMode)
186   _WRAP_PROPERTY("child", Widget*)
187
188 #m4begin
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.
192 dnl
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);
198   _POP()
199 #m4end
200
201 };
202
203 } // namespace Gtk
204