-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGroup.hpp
More file actions
313 lines (290 loc) · 13.9 KB
/
Group.hpp
File metadata and controls
313 lines (290 loc) · 13.9 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
//
// AmigaOS MUI C++ wrapper
//
// (c) 2022-2026 TDolphin
//
#pragma once
#include "Area.hpp"
#include "ValueTypes/Group/ActivePage.hpp"
#include "ValueTypes/Group/HorizCenter.hpp"
#include "ValueTypes/Group/VertCenter.hpp"
#undef AddHead
#undef AddTail
#undef Remove
namespace MUI
{
/// @brief Group class manages layout and child objects inside MUI windows.
class Group : public Area
{
public:
explicit Group(Object *pMuiObject)
: Area(pMuiObject)
{
}
Group(const Root &root)
: Area(root.muiObject())
{
}
// instanceOf
const static std::string className;
static inline bool instanceOf(Object *pMuiObject)
{
return MUI::instanceOf(pMuiObject, className.c_str());
}
static inline bool instanceOf(const Root &object)
{
return MUI::instanceOf(object.muiObject(), className.c_str());
}
// is/get/set (attributes), all setters return object reference
/// @brief [ @b MUIA_Group_ActivePage ]
/// @return active page (index).
long getActivePage() const;
#ifdef MUIA_Group_ChildCount
/// @brief [ @b MUIA_Group_ChildCount ] Read number of child objects in this group.
long getChildCount() const;
#endif
/// @brief [ @b MUIA_Group_ChildList ]
/// @return list of child objects.
const struct List *getChildList() const;
#ifdef MUIA_Group_HorizCenter
/// @brief [ @b MUIA_Group_HorizCenter ]
/// @return horizontal center alignment.
enum Group_HorizCenter getHorizCenter() const;
#endif
/// @brief [ @b MUIA_Group_HorizSpacing ]
/// @return Number of pixels inserted between horizontal elements of a group.
long getHorizSpacing() const;
#ifdef MUIA_Group_VertCenter
/// @brief [ @b MUIA_Group_VertCenter ]
/// @return vertical center alignment.
enum Group_VertCenter getVertCenter() const;
#endif
/// @brief [ @b MUIA_Group_VertSpacing ]
/// @return Number of pixels inserted between vertical elements of a group.
long getVertSpacing() const;
/// @brief [ @b MUIA_Group_ActivePage ]
/// Activate given page.
/// @param activePage index of page to activate (unsigned long to prevent pass #define < 0)
Group &setActivePage(const unsigned long activePage);
/// @brief [ @b MUIA_Group_ActivePage ]
/// Activate given page by enum Group_ActivePage.
Group &setActivePage(const enum Group_ActivePage activePage);
/// @brief [ @b MUIA_Group_ActivePage, @b MUIV_Group_ActivePage_First ]
/// Activate first page.
Group &setActivePageFirst();
/// @brief [ @b MUIA_Group_ActivePage, @b MUIV_Group_ActivePage_Last ]
/// Activate last page.
Group &setActivePageLast();
/// @brief [ @b MUIA_Group_ActivePage, @b MUIV_Group_ActivePage_Advance ]
/// Activate next page after current.
Group &setActivePageAdvance();
/// @brief [ @b MUIA_Group_Columns ]
/// Set number of columns in a two dimensional group.
Group &setColumns(const long columns);
#ifdef MUIA_Group_Forward
/// @brief [ @b MUIA_Group_Forward ]
/// Enable/disable forward keyboard focus traversal.
Group &setForward(const bool forward);
#endif
#ifdef MUIA_Group_ForwardDepth
/// @brief [ @b MUIA_Group_ForwardDepth ]
/// Set depth used for forward focus handling.
Group &setForwardDepth(const unsigned long forwardDepth);
#endif
#ifdef MUIA_Group_HorizCenter
/// @brief [ @b MUIA_Group_HorizCenter ]
/// Set horizontal center alignment.
Group &setHorizCenter(const enum Group_HorizCenter horizCenter);
#endif
/// @brief [ @b MUIA_Group_HorizSpacing ]
/// Set number of pixels inserted between horizontal elements.
Group &setHorizSpacing(const long horizSpacing);
#ifdef MUIA_Group_Rows
/// @brief [ @b MUIA_Group_Rows ]
/// Set number of rows in a two dimensional group.
Group &setRows(const long rows);
#endif
#ifdef MUIA_Group_Spacing
/// @brief [ @b MUIA_Group_Spacing ]
/// Set spacing used between children.
Group &setSpacing(const long spacing);
#endif
#ifdef MUIA_Group_VertCenter
/// @brief [ @b MUIA_Group_VertCenter ]
/// Set vertical center alignment.
Group &setVertCenter(const enum Group_VertCenter vertCenter);
#endif
/// @brief [ @b MUIA_Group_VertSpacing ]
/// Set number of pixels inserted between vertical elements.
Group &setVertSpacing(const long vertSpacing);
// methods, some returns object reference
#ifdef MUIM_Group_AddHead
/// @brief [ @b MUIM_Group_AddHead ] Add child object at the beginning of the group child list.
/// @param pChildObject child object to insert, ignored when nullptr
Group &AddHead(const Object *pChildObject);
/// @brief [ @b MUIM_Group_AddHead ] Add child object at the beginning of the group child list.
/// @param child child wrapper to insert, ignored when it wraps a null object
Group &AddHead(const Root &child);
#endif
#ifdef MUIM_Group_AddTail
/// @brief [ @b MUIM_Group_AddTail ] Add child object at the end of the group child list.
/// @param pChildObject child object to insert, ignored when nullptr
Group &AddTail(const Object *pChildObject);
/// @brief [ @b MUIM_Group_AddTail ] Add child object at the end of the group child list.
/// @param child child wrapper to insert, ignored when it wraps a null object
Group &AddTail(const Root &child);
#endif
/// @brief [ @b MUIM_Group_ExitChange ] Leave dynamic child-list modification mode and trigger relayout.
Group &ExitChange();
#ifdef MUIM_Group_ExitChange2
/// @brief [ @b MUIM_Group_ExitChange2 ] Leave dynamic child-list modification mode with flags.
/// @param flags set to 0 to suppress automatic relayout
Group &ExitChange2(const unsigned long flags = 0);
#endif
/// @brief [ @b MUIM_Group_InitChange ] Enter dynamic child-list modification mode.
Group &InitChange();
#ifdef MUIM_Group_MoveMember
/// @brief [ @b MUIM_Group_MoveMember ] Move existing child to a new position in the group.
/// @param pChildObject child object to move
/// @param pos target position (0 first, -1 last, other values per MUIM_Group_MoveMember rules)
Group &MoveMember(const Object *pChildObject, const long pos);
/// @brief [ @b MUIM_Group_MoveMember ] Move existing child to a new position in the group.
/// @param child child wrapper to move
/// @param pos target position (0 first, -1 last, other values per MUIM_Group_MoveMember rules)
Group &MoveMember(const Root &child, const long pos);
#endif
#ifdef MUIM_Group_Remove
/// @brief [ @b MUIM_Group_Remove ] Remove child object from the group child list.
/// @param pChildObject child object to remove, ignored when nullptr
Group &Remove(const Object *pChildObject);
/// @brief [ @b MUIM_Group_Remove ] Remove child object from the group child list.
/// @param child child wrapper to remove, ignored when it wraps a null object
Group &Remove(const Root &child);
#endif
#ifdef MUIM_Group_Reorder
/// @brief [ @b MUIM_Group_Reorder ]
/// Reorder the children of a group.
/// @param after anchor object; nullptr moves objects to front, (Object *)-1 moves to back
/// @param objects null-terminated order source converted internally from vector
Group &Reorder(const Object *after, const std::vector<const Object *> &objects);
/// @brief [ @b MUIM_Group_Reorder ]
/// Reorder the children of a group.
/// @param after anchor object; nullptr moves objects to front, (Object *)-1 moves to back
/// @param objects objects to reorder
Group &Reorder(const Object *after, const std::initializer_list<const Object *> &objects);
/// @brief [ @b MUIM_Group_Reorder, after = 0 ]
/// Reorder the given children to the front of the group child list.
Group &ReorderFront(const std::vector<const Object *> &objects);
/// @brief [ @b MUIM_Group_Reorder, after = 0 ]
/// Reorder the given children to the front of the group child list.
Group &ReorderFront(const std::initializer_list<const Object *> &objects);
/// @brief [ @b MUIM_Group_Reorder, after = -1 ]
/// Reorder the given children to the end of the group child list.
Group &ReorderBack(const std::vector<const Object *> &objects);
/// @brief [ @b MUIM_Group_Reorder, after = -1 ]
/// Reorder the given children to the end of the group child list.
Group &ReorderBack(const std::initializer_list<const Object *> &objects);
#endif
/// @brief [ @b MUIM_Group_Sort ]
/// Sort the children of a group.
/// @param objects full child order (must contain all children)
Group &Sort(const std::vector<const Object *> &objects);
/// @brief [ @b MUIM_Group_Sort ]
/// Sort the children of a group.
/// @param objects full child order (must contain all children)
Group &Sort(const std::initializer_list<const Object *> &objects);
/// @brief [ @b OM_ADDMEMBER ] Add child object to group.
/// @param pChildObject child object to add, ignored when nullptr
Group &AddMember(const Object *pChildObject);
/// @brief [ @b OM_ADDMEMBER ] Add child object to group.
/// @param child child wrapper to add
Group &AddMember(const Root &child);
/// @brief [ @b OM_REMMEMBER ] Remove child object from group.
/// @param pChildObject child object to remove, ignored when nullptr
// After disconnecting an object from Group we must call explicitly DiposeObject() on the disconnected child
// object, otherwise the memory will not be released
Group &RemMember(const Object *pChildObject);
/// @brief [ @b OM_REMMEMBER ] Remove child object from group.
/// @param child child wrapper to remove
// After disconnecting an object from Group we must call explicitly DiposeObject() on the disconnected child
// object, otherwise the memory will not be released
Group &RemMember(const Root &child);
};
template <typename T, typename U> class GroupBuilderTemplate : public AreaBuilderTemplate<T, U>
{
public:
GroupBuilderTemplate(const std::string &uniqueId = MUI::EmptyUniqueId, const std::string &muiClassName = MUIC_Group)
: AreaBuilderTemplate<T, U>(uniqueId, muiClassName)
{
}
/// @brief [ @b MUIA_Group_Horiz, FALSE ] - like macro: @b VGroup
T &vertical();
/// @brief [ @b MUIA_Group_Horiz, TRUE ] - like macro: @b HGroup
T &horizontal();
/// @brief [ @b MUIA_Group_ActivePage ]
T &tagActivePage(const unsigned long activePage);
/// @brief [ @b MUIA_Group_ActivePage ]
T &tagActivePage(const enum Group_ActivePage activePage);
/// @brief [ @b MUIA_Group_Child ]
/// Add child object to group.
/// @param pChildObject pointer to child object; nullptr is ignored by this convenience overload
/// @param condition if false, tag is not added
T &tagChild(const Object *pChildObject, bool condition = true);
/// @brief [ @b MUIA_Group_Child ]
/// Add child object to group.
/// @param child Root wrapper of child object; null wrapped objects are ignored by this convenience overload
/// @param condition if false, tag is not added
T &tagChild(const Root &child, bool condition = true);
/// @brief [ @b MUIA_Group_Child ] Add an explicit nullptr child tag.
/// This preserves the original MUI semantics where a NULL child causes group creation to fail.
/// @param condition if false, tag is not added
T &tagChildNull(bool condition = true);
/// @brief [ @b MUIA_Group_Columns ]
/// Number of columns in a two dimensional group.
T &tagColumns(const long columns);
/// @brief [ @b MUIA_Group_Horiz ]
/// Indicate whether the objects in this group shall be layouted horizontally or vertically.
/// By default is false.
T &tagHoriz(const bool horiz);
#ifdef MUIA_Group_HorizCenter
/// @brief [ @b MUIA_Group_HorizCenter ]
T &tagHorizCenter(const enum Group_HorizCenter horizCenter);
#endif
/// @brief [ @b MUIA_Group_HorizSpacing ]
T &tagHorizSpacing(const long horizSpacing);
#ifdef MUIA_Group_LayoutHook
/// @brief [ @b MUIA_Group_LayoutHook ]
T &tagLayoutHook(const Hook *pLayoutHook);
#endif
/// @brief [ @b MUIA_Group_PageMode ]
/// This attribute makes the current group a page group. Page groups always display only one of their children.
/// Which one can be adjusted with the MUIA_Group_ActivePage attribute.
T &tagPageMode(const bool pageMode = true);
/// @brief [ @b MUIA_Group_Rows ]
T &tagRows(const long rows);
/// @brief [ @b MUIA_Group_SameHeight ]
T &tagSameHeight(const bool sameHeight);
/// @brief [ @b MUIA_Group_SameSize ]
T &tagSameSize(const bool sameSize);
/// @brief [ @b MUIA_Group_SameWidth ]
T &tagSameWidth(const bool sameWidth);
/// @brief [ @b MUIA_Group_Spacing ]
T &tagSpacing(const long spacing);
#ifdef MUIA_Group_VertCenter
/// @brief [ @b MUIA_Group_VertCenter ]
T &tagVertCenter(const enum Group_VertCenter vertCenter);
#endif
/// @brief [ @b MUIA_Group_VertSpacing ]
T &tagVertSpacing(const long vertSpacing);
/// @brief replaces mui macro GroupFrameT
T &groupFrame(const std::string &title);
};
class GroupBuilder : public GroupBuilderTemplate<GroupBuilder, Group>
{
public:
GroupBuilder();
};
}
#define MUI_GROUP_TPP_INCLUDE
#include "Group.tpp"
#undef MUI_GROUP_TPP_INCLUDE