-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.hpp
103 lines (85 loc) · 2.87 KB
/
Menu.hpp
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
//
// AmigaOS MUI C++ wrapper
//
// (c) 2022-2024 TDolphin
//
#pragma once
#include "Family.hpp"
namespace MUI
{
class Menu : public Family
{
public:
explicit Menu(Object *pMuiObject)
: Family(pMuiObject)
{
}
Menu(const Root &root)
: Family(root.muiObject())
{
}
// instanceOf
const static std::string className;
static inline bool instanceOf(Object *pMuiObject)
{
return MUI::instanceOf(pMuiObject, className.c_str());
}
// is/get/set (attributes), all setters return object reference
/// @brief [ @b MUIA_Menu_Enabled ]
bool isEnabled() const;
/// @brief [ @b MUIA_Menu_Title ]
std::string getTitle() const;
/// @brief [ @b MUIA_Menu_Enabled ]
Menu &setEnabled(const bool enabled);
/// @brief [ @b MUIA_Menu_Title ]
Menu &setTitle(const std::string &title);
// methods, some returns object reference
};
template <typename T, typename U> class MenuBuilderTemplate : public FamilyBuilderTemplate<T, U>
{
public:
MenuBuilderTemplate(const std::string &uniqueId = MUI::EmptyUniqueId, const std::string &muiClassName = MUIC_Menu)
: FamilyBuilderTemplate<T, U>(uniqueId, muiClassName)
{
}
#ifdef MUIA_Menu_CopyStrings
/// @brief [ @b MUIA_Menu_CopyStrings ]
/// Set to true if the title string defined by MUIA_Menu_Title is to be copied. Otherwise the title will be used directly and must
/// remain valid throughout the object's life time. By default is false.
T &tagCopyStrings(const bool copyStrings);
#endif
/// @brief [ @b MUIA_Menu_Enabled ]
T &tagEnabled(const bool enabled);
/// @brief [ @b MUIA_Menu_Title ]
T &tagTitle(const char *title);
/// @brief [ @b MUIA_Menu_Title ]
T &tagTitle(const std::string &title);
};
class MenuBuilder : public MenuBuilderTemplate<MenuBuilder, Menu>
{
public:
MenuBuilder();
};
#ifdef MUIA_Menu_CopyStrings
template <typename T, typename U> inline T &MenuBuilderTemplate<T, U>::tagCopyStrings(const bool copyStrings)
{
this->PushTag(MUIA_Menu_CopyStrings, copyStrings);
return (T &)*this;
}
#endif
template <typename T, typename U> inline T &MenuBuilderTemplate<T, U>::tagEnabled(const bool enabled)
{
this->PushTag(MUIA_Menu_Enabled, enabled);
return (T &)*this;
}
template <typename T, typename U> inline T &MenuBuilderTemplate<T, U>::tagTitle(const char *title)
{
this->PushTag(MUIA_Menu_Title, title);
return (T &)*this;
}
template <typename T, typename U> inline T &MenuBuilderTemplate<T, U>::tagTitle(const std::string &title)
{
this->PushTag(MUIA_Menu_Title, title);
return (T &)*this;
}
}