Update to 24f58c58bb8d22c0e8e6c5ce43c536c47b719bc6
[gnt.git] / gntbox.h
blobf35c691b55d4dc9cd80262ee14fac11cee5105e6
1 /**
2 * @file gntbox.h Box API
3 * @ingroup gnt
4 */
5 /*
6 * GNT - The GLib Ncurses Toolkit
8 * GNT is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef GNT_BOX_H
28 #define GNT_BOX_H
30 #include "gnt.h"
31 #include "gntwidget.h"
33 #define GNT_TYPE_BOX (gnt_box_get_gtype())
34 #define GNT_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_BOX, GntBox))
35 #define GNT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_BOX, GntBoxClass))
36 #define GNT_IS_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_BOX))
37 #define GNT_IS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_BOX))
38 #define GNT_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_BOX, GntBoxClass))
40 typedef struct _GntBox GntBox;
41 typedef struct _GntBoxClass GntBoxClass;
43 typedef enum
45 /* These for vertical boxes */
46 GNT_ALIGN_LEFT,
47 GNT_ALIGN_RIGHT,
49 GNT_ALIGN_MID,
51 /* These for horizontal boxes */
52 GNT_ALIGN_TOP,
53 GNT_ALIGN_BOTTOM
54 } GntAlignment;
56 struct _GntBox
58 GntWidget parent;
60 gboolean vertical;
61 gboolean homogeneous;
62 gboolean fill;
63 GList *list; /* List of widgets */
65 GntWidget *active;
66 int pad; /* Number of spaces to use between widgets */
67 GntAlignment alignment; /* How are the widgets going to be aligned? */
69 char *title;
70 GList *focus; /* List of widgets to cycle focus (only valid for parent boxes) */
72 void (*gnt_reserved1)(void);
73 void (*gnt_reserved2)(void);
74 void (*gnt_reserved3)(void);
75 void (*gnt_reserved4)(void);
78 struct _GntBoxClass
80 GntWidgetClass parent;
82 void (*gnt_reserved1)(void);
83 void (*gnt_reserved2)(void);
84 void (*gnt_reserved3)(void);
85 void (*gnt_reserved4)(void);
88 G_BEGIN_DECLS
90 /**
91 * The GType for GntBox.
92 * @return The GType.
94 GType gnt_box_get_gtype(void);
96 #define gnt_vbox_new(homo) gnt_box_new(homo, TRUE)
97 #define gnt_hbox_new(homo) gnt_box_new(homo, FALSE)
99 /**
100 * Create a new GntBox.
102 * @param homo If @c TRUE, all the widgets in it will have the same width (or height)
103 * @param vert Whether the widgets in it should be stacked vertically (if @c TRUE)
104 * or horizontally (if @c FALSE).
106 * @return The new GntBox.
108 GntWidget * gnt_box_new(gboolean homo, gboolean vert);
111 * Add a widget in the box.
113 * @param box The box
114 * @param widget The widget to add
116 void gnt_box_add_widget(GntBox *box, GntWidget *widget);
119 * Set a title for the box.
121 * @param box The box
122 * @param title The title to set
124 void gnt_box_set_title(GntBox *box, const char *title);
127 * Set the padding to use between the widgets in the box.
129 * @param box The box
130 * @param pad The padding to use
132 void gnt_box_set_pad(GntBox *box, int pad);
135 * Set whether it's a toplevel box (ie, a window) or not. If a box is toplevel,
136 * then it will show borders, the title (if set) and shadow (if enabled in
137 * @e .gntrc)
139 * @param box The box
140 * @param set @c TRUE if it's a toplevel box, @c FALSE otherwise.
142 void gnt_box_set_toplevel(GntBox *box, gboolean set);
145 * Reposition and refresh the widgets in the box.
147 * @param box The box
149 void gnt_box_sync_children(GntBox *box);
152 * Set the alignment for the widgets in the box.
154 * @param box The box
155 * @param alignment The alignment to use
157 void gnt_box_set_alignment(GntBox *box, GntAlignment alignment);
160 * Remove a widget from the box. Calling this does NOT destroy the removed widget.
162 * @param box The box
163 * @param widget The widget to remove
165 void gnt_box_remove(GntBox *box, GntWidget *widget);
168 * Remove all widgets from the box. This DOES destroy all widgets in the box.
170 * @param box The box
172 void gnt_box_remove_all(GntBox *box);
175 * Readjust the size of each child widget, reposition the child widgets and
176 * recalculate the size of the box.
178 * @param box The box
180 void gnt_box_readjust(GntBox *box);
183 * Set whether the widgets in the box should fill the empty spaces.
185 * @param box The box
186 * @param fill Whether the child widgets should fill the empty space
188 void gnt_box_set_fill(GntBox *box, gboolean fill);
191 * Move the focus from one widget to the other.
193 * @param box The box
194 * @param dir The direction. If it's 1, then the focus is moved forwards, if it's
195 * -1, the focus is moved backwards.
197 void gnt_box_move_focus(GntBox *box, int dir);
200 * Give focus to a specific child widget.
202 * @param box The box
203 * @param widget The child widget to give focus
205 void gnt_box_give_focus_to_child(GntBox *box, GntWidget *widget);
207 G_END_DECLS
209 #endif /* GNT_BOX_H */