Merged revisions 6293,6296-6306,6308 via svnmerge from
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / table.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_TABLE_H
4 #define _GTKMM_TABLE_H
5
6
7 #include <glibmm.h>
8
9 /* $Id$ */
10
11 /* Copyright (C) 1998-2002 The gtkmm Development Team
12  *
13  * This library is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU Library General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 of the License, or (at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Library General Public License for more details.
22  *
23  * You should have received a copy of the GNU Library General Public
24  * License along with this library; if not, write to the Free
25  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26  */
27
28 #include <glibmm/helperlist.h>
29 #include <gtkmm/container.h>
30 #include <gtkmm/enums.h>
31 #include <gtk/gtktable.h> /* for GtkTableChild */
32
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 typedef struct _GtkTable GtkTable;
36 typedef struct _GtkTableClass GtkTableClass;
37 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
38
39
40 namespace Gtk
41 { class Table_Class; } // namespace Gtk
42 namespace Gtk
43 {
44
45 class Table;
46
47 namespace Table_Helpers
48 {
49
50 class Child : protected _GtkTableChild
51 {
52 private:
53   Child& operator=(const Child&); //Not implemented.
54   Child(const Child&); //Not implemented.
55
56 public:
57   inline _GtkTableChild* gobj() {return (this);}
58   inline const _GtkTableChild* gobj() const {return (this);}
59
60   Widget* get_widget() const;
61
62   //TODO: Which of the GtkTableChild's fields are public API?
63   //Maybe we should remove some of these get()s or add some set()s.
64   //If get_widget() is the only accessor, then we should probably make
65   //the STL-style Table list contain Widgets instead of Childs.
66
67   guint16 get_left_attach() const;
68   guint16 get_right_attach() const;
69   guint16 get_top_attach() const;
70   guint16 get_bottom_attach() const;
71   guint16 get_xpadding() const;
72   guint16 get_ypadding() const;
73   bool get_xexpand() const;
74   bool get_yexpand() const;
75   bool get_xshrink() const;
76   bool get_yshrink() const;
77   bool get_xfill() const;
78   bool get_yfill() const;
79
80 protected:
81   inline GtkTable* parent()
82     { return (GtkTable*) (gobj()->widget->parent); }
83
84 #ifndef DOXYGEN_SHOULD_SKIP_THIS
85   friend class Dummy_; // silence the compiler (Child has only private ctors)
86 #endif
87 };
88
89
90 class TableList : public Glib::HelperList< Child, Widget, Glib::List_Iterator< Child > >
91 {
92 public:
93   TableList();
94   explicit TableList(GtkTable* gparent);
95   TableList(const TableList& src);
96   virtual ~TableList() {}
97
98   TableList& operator=(const TableList& src);
99
100   typedef Glib::HelperList< Child, Widget,  Glib::List_Iterator< Child > > type_base;
101
102   GtkTable* gparent();
103   const GtkTable* gparent() const;
104
105   virtual GList*& glist() const;      // front of list
106
107   virtual void erase(iterator start, iterator stop);
108   virtual iterator erase(iterator);  //Implented as custom or by LIST_CONTAINER_REMOVE
109   virtual void remove(const_reference); //Implented as custom or by LIST_CONTAINER_REMOVE
110
111   /// This is order n. (use at own risk)
112   reference operator[](size_type l) const;
113
114 protected:
115   //Hide these because its read-only:
116   iterator insert(iterator position, element_type& e);
117
118   inline void pop_front();
119   inline void pop_back();
120
121
122   //The standard iterator, instead of List_Cpp_Iterator,
123   //only works because Child is derived from _GtkTableChild.
124
125   
126 virtual void remove(Widget& w); //Implented as custom or by LIST_CONTAINER_REMOVE
127
128   };
129
130
131 } // namespace Table_Helpers
132
133
134 /** Pack widgets in regular patterns.
135  * @ingroup Widgets
136  * @ingroup Containers
137  * Gtk::Table is one of the primary ways of grouping widgets together.  It
138  * consists of a set of lattice points to to which widgets can be attached.
139  * There are <em>rows</em>&nbsp;+&nbsp;1 lattice points vertically and
140  * <em>columns</em>&nbsp;+&nbsp;1 lattice points horizontally.  Lattice points
141  * start counting from 0.  Lattice points can either be specified to be
142  * <em>homogeneous</em>, meaning equally spaced, or not <em>homogeneous</em>,
143  * meaning each cell should be calculated based on the widgets contained in the
144  * row and column. The <em>homogeneous</em> property defaults to false.
145  *
146  * Widgets can be attached to the table by specifying the top, bottom, left and
147  * right points corresponding to upper, lefthand lattice point and the lower,
148  * righthand lattice point which the widget should span.  Widgets can either be
149  * contained in a cell or may span cells.  A number of options control the
150  * resizing behavior of widgets contained in the table.
151  *
152  * @par Packing options:
153  * There are a number of packing options that can be specified when adding a
154  * widget.  With <tt>Gtk::EXPAND</tt>, the lattice is allowed to grow to fill
155  * space.  With <tt>Gtk::SHRINK</tt>, the lattice is allowed to shrink when
156  * resized.  It is also possible to specify the behaviour of the widgets
157  * allocation within the table.  The flag <tt>Gtk::FILL</tt> declares the
158  * widget should grow to fill lattice.  If this is not set any extra space is
159  * used as padding.  The default is <tt>(Gtk::FILL&nbsp;|&nbsp;Gtk::EXPAND)</tt>.
160  *
161  * @par Table sizing:
162  * The table size is calculated based on the size of the widgets contained
163  * within and the restrictions imposed by specified options.  Padding and
164  * spacing can be used in the table.  Padding is added on either side of a
165  * widget, while spacing is placed between widgets.
166  *
167  * @see Gtk::HBox, Gtk::VBox
168  */
169
170 class Table : public Container
171 {
172   public:
173 #ifndef DOXYGEN_SHOULD_SKIP_THIS
174   typedef Table CppObjectType;
175   typedef Table_Class CppClassType;
176   typedef GtkTable BaseObjectType;
177   typedef GtkTableClass BaseClassType;
178 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
179
180   virtual ~Table();
181
182 #ifndef DOXYGEN_SHOULD_SKIP_THIS
183
184 private:
185   friend class Table_Class;
186   static CppClassType table_class_;
187
188   // noncopyable
189   Table(const Table&);
190   Table& operator=(const Table&);
191
192 protected:
193   explicit Table(const Glib::ConstructParams& construct_params);
194   explicit Table(GtkTable* castitem);
195
196 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
197
198 public:
199 #ifndef DOXYGEN_SHOULD_SKIP_THIS
200   static GType get_type()      G_GNUC_CONST;
201   static GType get_base_type() G_GNUC_CONST;
202 #endif
203
204   ///Provides access to the underlying C GtkObject.
205   GtkTable*       gobj()       { return reinterpret_cast<GtkTable*>(gobject_); }
206
207   ///Provides access to the underlying C GtkObject.
208   const GtkTable* gobj() const { return reinterpret_cast<GtkTable*>(gobject_); }
209
210
211 public:
212   //C++ methods used to invoke GTK+ virtual functions:
213 #ifdef GLIBMM_VFUNCS_ENABLED
214 #endif //GLIBMM_VFUNCS_ENABLED
215
216 protected:
217   //GTK+ Virtual Functions (override these to change behaviour):
218 #ifdef GLIBMM_VFUNCS_ENABLED
219 #endif //GLIBMM_VFUNCS_ENABLED
220
221   //Default Signal Handlers::
222 #ifdef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
223 #endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
224
225
226 private:
227
228   
229 public:
230   explicit Table(guint n_rows = 1, guint n_columns = 1, bool homogeneous = false);
231
232   
233         void attach(Widget& child,
234                     guint left_attach, guint right_attach,
235                     guint top_attach, guint bottom_attach,
236                     AttachOptions xoptions = FILL | EXPAND, AttachOptions yoptions = FILL | EXPAND,
237                     guint xpadding = 0, guint ypadding = 0);
238
239
240   void resize(guint rows, guint columns);
241
242
243   void set_row_spacing(guint row, guint spacing);
244   
245   /** Gets the amount of space between row @a row , and
246    * row @a row  + 1. See set_row_spacing().
247    * @param row A row in the table, 0 indicates the first row.
248    * @return The row spacing.
249    */
250   guint get_row_spacing(guint row) const;
251
252   
253   void set_col_spacing(guint column, guint spacing);
254   
255   /** Gets the amount of space between column @a col , and
256    * column @a col  + 1. See set_col_spacing().
257    * @param column A column in the table, 0 indicates the first column.
258    * @return The column spacing.
259    */
260   guint get_col_spacing(guint column) const;
261
262   
263   void set_row_spacings(guint spacing);
264
265   
266   void set_col_spacings(guint spacing);
267
268   void set_spacings(guint spacing);
269
270   
271   /** Gets the default row spacing for the table. This is
272    * the spacing that will be used for newly added rows.
273    * (See set_row_spacings())
274    * @return Value: the default row spacing.
275    */
276   guint get_default_row_spacing();
277   
278   /** Gets the default column spacing for the table. This is
279    * the spacing that will be used for newly added columns.
280    * (See set_col_spacings())
281    * @return Value: the default column spacing.
282    */
283   guint get_default_col_spacing();
284
285   
286   void set_homogeneous(bool homogeneous = true);
287   
288   /** Returns whether the table cells are all constrained to the same
289    * width and height. (See set_homogenous())
290    * @return <tt>true</tt> if the cells are all constrained to the same size.
291    */
292   bool get_homogeneous() const;
293
294   typedef Table_Helpers::TableList TableList;
295
296
297   TableList& children();
298   const TableList& children() const;
299
300   #ifdef GLIBMM_PROPERTIES_ENABLED
301 /** The number of rows in the table.
302    *
303    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
304    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
305    * the value of the property changes.
306    */
307   Glib::PropertyProxy<guint> property_n_rows() ;
308 #endif //#GLIBMM_PROPERTIES_ENABLED
309
310 #ifdef GLIBMM_PROPERTIES_ENABLED
311 /** The number of rows in the table.
312    *
313    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
314    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
315    * the value of the property changes.
316    */
317   Glib::PropertyProxy_ReadOnly<guint> property_n_rows() const;
318 #endif //#GLIBMM_PROPERTIES_ENABLED
319
320   #ifdef GLIBMM_PROPERTIES_ENABLED
321 /** The number of columns in the table.
322    *
323    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
324    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
325    * the value of the property changes.
326    */
327   Glib::PropertyProxy<guint> property_n_columns() ;
328 #endif //#GLIBMM_PROPERTIES_ENABLED
329
330 #ifdef GLIBMM_PROPERTIES_ENABLED
331 /** The number of columns in the table.
332    *
333    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
334    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
335    * the value of the property changes.
336    */
337   Glib::PropertyProxy_ReadOnly<guint> property_n_columns() const;
338 #endif //#GLIBMM_PROPERTIES_ENABLED
339
340   #ifdef GLIBMM_PROPERTIES_ENABLED
341 /** The amount of space between two consecutive columns.
342    *
343    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
344    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
345    * the value of the property changes.
346    */
347   Glib::PropertyProxy<guint> property_column_spacing() ;
348 #endif //#GLIBMM_PROPERTIES_ENABLED
349
350 #ifdef GLIBMM_PROPERTIES_ENABLED
351 /** The amount of space between two consecutive columns.
352    *
353    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
354    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
355    * the value of the property changes.
356    */
357   Glib::PropertyProxy_ReadOnly<guint> property_column_spacing() const;
358 #endif //#GLIBMM_PROPERTIES_ENABLED
359
360   #ifdef GLIBMM_PROPERTIES_ENABLED
361 /** The amount of space between two consecutive rows.
362    *
363    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
364    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
365    * the value of the property changes.
366    */
367   Glib::PropertyProxy<guint> property_row_spacing() ;
368 #endif //#GLIBMM_PROPERTIES_ENABLED
369
370 #ifdef GLIBMM_PROPERTIES_ENABLED
371 /** The amount of space between two consecutive rows.
372    *
373    * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
374    * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
375    * the value of the property changes.
376    */
377   Glib::PropertyProxy_ReadOnly<guint> property_row_spacing() const;
378 #endif //#GLIBMM_PROPERTIES_ENABLED
379
380
381 protected:
382 #ifndef DOXYGEN_SHOULD_SKIP_THIS
383   mutable TableList children_proxy_;
384 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
385
386
387 };
388
389 } // namespace Gtk
390
391
392 namespace Glib
393 {
394   /** A Glib::wrap() method for this object.
395    * 
396    * @param object The C instance.
397    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
398    * @result A C++ instance that wraps this C instance.
399    *
400    * @relates Gtk::Table
401    */
402   Gtk::Table* wrap(GtkTable* object, bool take_copy = false);
403 } //namespace Glib
404
405
406 #endif /* _GTKMM_TABLE_H */
407