1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Box layouts (à la Qt's QVBoxLayout / QHBoxLayout).
*
* A box does not draw anything itself: it is a positioning helper. You add
* already-created widgets (and nested boxes) to it, then "apply" it over a
* rectangle (or a window). Applying overwrites the x/y/width/height of every
* managed widget so they line up in a vertical or horizontal stack.
*
* Typical use:
*
* gtcaca_box_t *vb = gtcaca_vbox_new();
* gtcaca_box_add(vb, GTCACA_WIDGET(label));
* gtcaca_box_add(vb, GTCACA_WIDGET(entry));
* gtcaca_box_add(vb, GTCACA_WIDGET(button));
* gtcaca_box_apply_window(vb, win); // lay out inside the window
*
* Boxes nest: build an hbox of buttons and gtcaca_box_add_box() it into a vbox.
*
* Sizing model (GTK/Qt-like):
* - By default a widget is placed at its natural size.
* - "expand" lets an item share the leftover space along the box's main axis
* (vertical for a vbox, horizontal for an hbox).
* - "fill" resizes the widget to fill the cell it was given.
* gtcaca_box_add_expand() turns both on, which is what you usually want for a
* widget that should soak up the remaining room (a text view, a list, ...).
*
* Free a box tree with gtcaca_box_free(); it never frees the widgets.
*/
typedef enum gtcaca_box_orientation_t;
/* Cross-axis alignment of items that do not fill the cell. */
typedef enum gtcaca_align_t;
typedef struct _gtcaca_box_t gtcaca_box_t;
/* Constructors. spacing defaults to 1, margin to 1, alignment to START. */
gtcaca_box_t *;
gtcaca_box_t *;
gtcaca_box_t *;
/* Add an already-created widget at its natural size. */
void ;
/* Add a widget that expands to share leftover space and fills its cell. */
void ;
/* Full control: expand = share leftover main-axis space; fill = resize widget
to its cell. */
void ;
/* Nest another box. It spans the full cross axis and takes its natural size
along the main axis (add a stretch if you want it to absorb slack). */
void ;
/* Flexible spacer that pushes neighbours apart (Qt's addStretch). */
void ;
/* Fixed-size empty gap of `size` cells along the main axis. */
void ;
/* Tunables. */
void ;
void ;
void ;
/* Natural size the box would like (includes margins/spacing). */
int ;
int ;
/* Lay the box out over an explicit rectangle. */
void ;
/* Lay the box out inside a window's interior (inside the border). */
void ;
/* Free the box and any nested boxes. Does not touch the widgets. */
void ;
/* _GTCACA_BOX_H_ */