Debian Codegraph @

gtk/src/box.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 _DEFS(gtkmm,gtk)
18 _PINCLUDE(gtkmm/private/container_p.h)
19
20 #include <gtkmm/container.h>
21 #include <gtkmm/orientable.h>
22 #include <gtk/gtk.h> /* For _GtkBoxChild */
23
24
25 namespace Gtk
26 {
27
28 /** Packing options for adding child widgets to a Box with pack_start() and pack_end().
29 * @ingroup gtkmmEnums
30 */
31 enum PackOptions
32 {
33 PACK_SHRINK, /**< Space is contracted to the child widget size. */
34 PACK_EXPAND_PADDING, /**< Space is expanded, with extra space filled with padding. */
35 PACK_EXPAND_WIDGET /**< Space is expanded, with extra space filled by increasing the child widget size. */
36 };
37
38 /** The Box widget organizes child widgets into a rectangular area.
39 *
40 * The rectangular area of a Box is organized into either a single row
41 * or a single column of child widgets depending upon the orientation.
42 * Thus, all children of a Box are allocated one dimension in common,
43 * which is the height of a row, or the width of a column.
44 *
45 * Gtk::Box uses a notion of packing. Packing refers to adding widgets with
46 * reference to a particular position in a Gtk::Container. There are two
47 * reference positions: the start and the end of the box. For a vertical Box, the start
48 * is defined as the top of the box and the end is defined as the bottom. For
49 * a horizontal Box the start is defined as the left side and the end is defined as the
50 * right side. Use repeated calls to pack_start() to pack widgets into a
51 * Gtk::Box from start to end. Use pack_end() to add widgets from end to start.
52 * You may intersperse these calls and add widgets from both ends of the same
53 * Gtk::Box. The last widget added with pack_start() will be placed just before
54 * the last widget added with pack_end()
55 *
56 * Because Gtk::Box is a Gtk::Container, you may also use Gtk::Container::add()
57 * to insert widgets, and they will be packed as if with pack_start(). Use
58 * Gtk::Container::remove() to remove widgets.
59 *
60 * Use set_homogeneous() to specify whether or not all children of the Gtk::Box
61 * occupy the same amount of space.
62 *
63 * Use set_spacing() to determine the minimum
64 * space placed between all children in the Gtk::Box. Note that
65 * spacing is added between the children, while
66 * padding added by gtk_box_pack_start() or gtk_box_pack_end() is added
67 * on either side of the widget it belongs to.
68 *
69 * Use reorder_child() to
70 * move a child widget to a different place in the box.
71 *
72 * Use
73 * set_child_packing() to reset the pack options and padding attributes of any
74 * Gtk::Box child. Use query_child_packing() to query these fields.
75 */
76 class GTKMM_API Box
77 : public Container,
78 public Orientable
79 {
80 _CLASS_GTKOBJECT(Box,GtkBox,GTK_BOX,Gtk::Container,GtkContainer,,,GTKMM_API)
81 _IMPLEMENTS_INTERFACE(Orientable)
82 _IGNORE(gtk_box_set_child_packing, gtk_box_query_child_packing)
83 public:
84
85 //Note that we try to use the same default parameter value as the default property value.
86 /** Creates a new box.
87 * @param orientation The box's orientation.
88 * @param spacing Determines the space in pixels between child widgets.
89 */
90 _WRAP_CTOR(Box(Orientation orientation = ORIENTATION_HORIZONTAL, int spacing = 0), gtk_box_new)
91
92 _WRAP_METHOD(void pack_start(Widget& child, bool expand, bool fill, guint padding = 0), gtk_box_pack_start)
93
94 /** Left side insert a widget to a box.
95 * @param child A Widget to be added to box.
96 * @param options Controls how the widget expands to fill space, and how the space around them is used.
97 * @param padding Padding that is added on either side of the widget. This is different to spacing set when the box is created (or with set_spacing()) - spacing is added between objects, and padding is added on either side of an object.
98 */
99 void pack_start(Widget& child, PackOptions options = PACK_EXPAND_WIDGET, guint padding = 0);
100
101 _WRAP_METHOD(void pack_end(Widget& child, bool expand, bool fill, guint padding = 0), gtk_box_pack_end)
102
103 /** Right side insert a widget to a box.
104 * @param child A Widget to be added to box.
105 * @param options Controls how the widget expands to fill space, and how the space around them is used.
106 * @param padding Padding that is added on either side of the widget. This is different to spacing set when the box is created (or with set_spacing()) - spacing is added between objects, and padding is added on either side of an object.
107 */
108 void pack_end(Widget& child, PackOptions options = PACK_EXPAND_WIDGET, guint padding = 0);
109
110 _WRAP_METHOD(void set_homogeneous(bool homogeneous = true), gtk_box_set_homogeneous)
111 _WRAP_METHOD(bool get_homogeneous() const, gtk_box_get_homogeneous)
112
113 _WRAP_METHOD(void set_spacing(int spacing), gtk_box_set_spacing)
114 _WRAP_METHOD(int get_spacing() const, gtk_box_get_spacing)
115
116 _WRAP_METHOD(void set_baseline_position(BaselinePosition position), gtk_box_set_baseline_position)
117 _WRAP_METHOD(BaselinePosition get_baseline_position() const, gtk_box_get_baseline_position)
118
119 _WRAP_METHOD(void reorder_child(Widget& child, int position), gtk_box_reorder_child)
120
121 _WRAP_METHOD(void set_center_widget(Widget& widget), gtk_box_set_center_widget)
122
123 /** Unset the center_widget.
124 * See set_center_widget().
125 */
126 void unset_center_widget();
127 _WRAP_METHOD(Widget* get_center_widget(), gtk_box_get_center_widget) //transfer none
128 _WRAP_METHOD(const Widget* get_center_widget() const, gtk_box_get_center_widget, constversion) //transfer none
129
130 _WRAP_PROPERTY("spacing", int)
131 _WRAP_PROPERTY("homogeneous", bool)
132 _WRAP_PROPERTY("baseline-position", BaselinePosition)
133
134 _WRAP_CHILD_PROPERTY("expand", bool)
135 _WRAP_CHILD_PROPERTY("fill", bool)
136 _WRAP_CHILD_PROPERTY("padding", guint)
137 _WRAP_CHILD_PROPERTY("pack-type", PackType)
138 _WRAP_CHILD_PROPERTY("position", int)
139 };
140
141 } // namespace Gtk
142
143 //Include the deprecated header,
144 //whose classes were previously in this header,
145 //to preserve the "API" of the includes.
146 #include <gtkmm/hvbox.h>