Debian Codegraph @

gtk/src/grid.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 #include <gtkmm/container.h>
18 #include <gtkmm/orientable.h>
19 #include <gtkmm/enums.h>
20
21 _DEFS(gtkmm,gtk)
22 _PINCLUDE(gtkmm/private/container_p.h)
23
24 namespace Gtk
25 {
26
27 /** A container which arranges its child widgets in rows and columns.
28 * It is very similar to Table and Box,
29 * but it consistently uses Widget's margin and expand
30 * properties instead of custom child properties, and it fully supports
31 * height-for-width geometry management.
32 *
33 * Children are added using attach(). They can span multiple
34 * rows or columns. It is also possible to add a child next to an
35 * existing child, using attach_next_to(). The behaviour of
36 * %Grid when several children occupy the same grid cell is undefined.
37 *
38 * %Grid can be used like a Box by just using Gtk::Container::add(),
39 * which will place children next to each other in the direction determined
40 * by the orientation property.
41 *
42 * @ingroup Widgets
43 * @ingroup Containers
44 *
45 * @newin{3,0}
46 */
47 class GTKMM_API Grid
48 : public Container,
49 public Orientable
50 {
51 _CLASS_GTKOBJECT(Grid, GtkGrid, GTK_GRID, Gtk::Container, GtkContainer, , , GTKMM_API)
52 _IMPLEMENTS_INTERFACE(Orientable)
53 public:
54 _CTOR_DEFAULT
55
56 //TODO: Add a Grid(Orientation orientation = ORIENTATION_HORIZONTAL) constructor to match the Paned and Box ones?
57 //Probably not, because a vertical GtkGrid is not very useful. murrayc.
58
59 _WRAP_METHOD(void attach(Widget& child, int left, int top, int width = 1, int height = 1), gtk_grid_attach)
60
61 /** Adds a widget to the grid.
62 *
63 * The widget is placed next to @a sibling, on the side determined by
64 * @a side. The %attach_next_to() without the @a sibling parameter
65 * places the widget in row 0 (for left or right placement) or column 0
66 * (for top or bottom placement), at the end indicated by @a side.
67 *
68 * Attaching widgets labeled [1], [2], [3] without the @a sibling parameter and
69 * @a side == Gtk::POS_LEFT yields a layout of [3][2][1].
70 *
71 * @param child The widget to add.
72 * @param sibling The child of @a grid that @a child will be placed
73 * next to, or omitted to place @a child at the beginning or end.
74 * @param side The side of @a sibling that @a child is positioned next to.
75 * @param width The number of columns that @a child will span.
76 * @param height The number of rows that @a child will span.
77 */
78 _WRAP_METHOD(void attach_next_to(Widget& child, Widget& sibling{?}, PositionType side,
79 int width = 1, int height = 1), gtk_grid_attach_next_to)
80
81 _WRAP_METHOD(Widget* get_child_at(int left, int top), gtk_grid_get_child_at)
82 _WRAP_METHOD(const Widget* get_child_at(int left, int top) const, gtk_grid_get_child_at)
83 _WRAP_METHOD(void insert_row(int position), gtk_grid_insert_row)
84 _WRAP_METHOD(void insert_column(int position), gtk_grid_insert_column)
85 _WRAP_METHOD(void remove_row(int position), gtk_grid_remove_row)
86 _WRAP_METHOD(void remove_column(int position), gtk_grid_remove_column)
87 _WRAP_METHOD(void insert_next_to(Widget& sibling, PositionType side), gtk_grid_insert_next_to)
88
89 _WRAP_METHOD(void set_row_homogeneous(bool homogeneous = true), gtk_grid_set_row_homogeneous)
90 _WRAP_METHOD(bool get_row_homogeneous() const, gtk_grid_get_row_homogeneous)
91 _WRAP_METHOD(void set_row_spacing(guint spacing), gtk_grid_set_row_spacing)
92 _WRAP_METHOD(guint get_row_spacing() const, gtk_grid_get_row_spacing)
93 _WRAP_METHOD(void set_column_homogeneous(bool homogeneous), gtk_grid_set_column_homogeneous)
94 _WRAP_METHOD(bool get_column_homogeneous() const, gtk_grid_get_column_homogeneous)
95 _WRAP_METHOD(void set_column_spacing(guint spacing), gtk_grid_set_column_spacing)
96 _WRAP_METHOD(guint get_column_spacing() const, gtk_grid_get_column_spacing)
97 _WRAP_METHOD(void set_row_baseline_position(int row, BaselinePosition pos), gtk_grid_set_row_baseline_position)
98 _WRAP_METHOD(BaselinePosition get_row_baseline_position(int row) const, gtk_grid_get_row_baseline_position)
99 _WRAP_METHOD(void set_baseline_row(int row), gtk_grid_set_baseline_row)
100 _WRAP_METHOD(int get_baseline_row() const, gtk_grid_get_baseline_row)
101
102 _WRAP_PROPERTY("row-spacing", guint)
103 _WRAP_PROPERTY("column-spacing", guint)
104 _WRAP_PROPERTY("row-homogeneous", bool)
105 _WRAP_PROPERTY("column-homogeneous", bool)
106 _WRAP_PROPERTY("baseline-row", int)
107
108 _WRAP_CHILD_PROPERTY("left-attach", int)
109 _WRAP_CHILD_PROPERTY("top-attach", int)
110 _WRAP_CHILD_PROPERTY("width", int)
111 _WRAP_CHILD_PROPERTY("height", int)
112 };
113
114 } // namespace Gtk