forked from tdolphin-org/AmigaOS.MUI.cpp.wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPopstring.hpp
More file actions
127 lines (110 loc) · 5.77 KB
/
Popstring.hpp
File metadata and controls
127 lines (110 loc) · 5.77 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
//
// AmigaOS MUI C++ wrapper
//
// (c) 2022-2026 TDolphin
//
#pragma once
#include "Group.hpp"
namespace MUI
{
/// @brief Popstring class is the base class for creating so called popup objects. Usually,
/// a popup consists of a string or text gadget, followed by a little button. Pressing this
/// button brings up a little window with a listview and lets the user choose an entry with the mouse.
class Popstring : public Group
{
public:
explicit Popstring(Object *pMuiObject)
: Group(pMuiObject)
{
}
Popstring(const Root &root)
: Group(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_Popstring_Button ] Specify the button object to be used in the popup.
/// Depending on the type of your popup, you should use an image button with MUII_PopUp,
/// MUII_PopFile or MUII_PopDrawer here.
Object *getButton() const;
/// @brief [ @b MUIA_Popstring_CloseHook ] Whenever the popup receives a MUIM_Popstring_Close
/// method and the popup is currently opened, this hook will be called.
Hook *getCloseHook() const;
/// @brief [ @b MUIA_Popstring_OpenHook ] Whenever the popup receives a MUIM_Popstring_Open
/// method, this hook will be called.
Hook *getOpenHook() const;
/// @brief [ @b MUIA_Popstring_String ] Specify the string object to be used in the popup.
/// This does not necessarily need to be a real string object, using text objects or even
/// complete groups of other objects is perfectly ok.
Object *getString() const;
/// @brief [ @b MUIA_Popstring_Toggle ] Set/Clear the toggle mode for a popstring object.
/// With toggling disabled, the popup button will get disabled whenever the user hits it and
/// the popup opens. With toggling enabled, the popup button always stays enabled and can be
/// used to cancel the popup.
bool isToggle() const;
/// @brief [ @b MUIA_Popstring_CloseHook ] Whenever the popup receives a MUIM_Popstring_Close
/// method and the popup is currently opened, this hook will be called.
Popstring &setCloseHook(const Hook *closeHook);
/// @brief [ @b MUIA_Popstring_OpenHook ] Whenever the popup receives a MUIM_Popstring_Open
/// method, this hook will be called.
Popstring &setOpenHook(const Hook *openHook);
/// @brief [ @b MUIA_Popstring_Toggle ] Set/Clear the toggle mode for a popstring object.
/// With toggling disabled, the popup button will get disabled whenever the user hits it and
/// the popup opens. With toggling enabled, the popup button always stays enabled and can be
/// used to cancel the popup.
Popstring &setToggle(const bool toggle);
// methods, some returns object reference
/// @brief [ @b MUIM_Popstring_Close ] Close the popup. In fact, it only calls the predefined
/// MUIA_Popstring_CloseHook with the supplied success parameter.
/// @param result success parameter passed to the close hook (LONG).
Popstring &Close(long result);
/// @brief [ @b MUIM_Popstring_Open ] Open the popup. In fact, it only calls the predefined
/// MUIA_Popstring_OpenHook and checks its return value. In case of TRUE, the popup button
/// object is disabled as long as MUIA_Popstring_Toggle is unset.
Popstring &Open();
};
template <typename T, typename U> class PopstringBuilderTemplate : public GroupBuilderTemplate<T, U>
{
public:
PopstringBuilderTemplate(const std::string &uniqueId = MUI::EmptyUniqueId, const std::string &muiClassName = MUIC_Popstring)
: GroupBuilderTemplate<T, U>(uniqueId, muiClassName)
{
}
/// @brief [ @b MUIA_Popstring_Button ] Specify the button object to be used in the popup.
/// Depending on the type of your popup, you should use an image button with MUII_PopUp,
/// MUII_PopFile or MUII_PopDrawer here.
T &tagButton(const Object *button);
/// @brief [ @b MUIA_Popstring_CloseHook ] Whenever the popup receives a MUIM_Popstring_Close
/// method and the popup is currently opened, this hook will be called.
T &tagCloseHook(const Hook *closeHook);
/// @brief [ @b MUIA_Popstring_OpenHook ] Whenever the popup receives a MUIM_Popstring_Open
/// method, this hook will be called.
T &tagOpenHook(const Hook *openHook);
/// @brief [ @b MUIA_Popstring_String ] Specify the string object to be used in the popup.
/// This does not necessarily need to be a real string object, using text objects or even
/// complete groups of other objects is perfectly ok.
T &tagString(const Object *string);
/// @brief [ @b MUIA_Popstring_Toggle ] Set/Clear the toggle mode for a popstring object.
/// With toggling disabled, the popup button will get disabled whenever the user hits it and
/// the popup opens. With toggling enabled, the popup button always stays enabled and can be
/// used to cancel the popup.
T &tagToggle(const bool toggle);
};
class PopstringBuilder : public PopstringBuilderTemplate<PopstringBuilder, Popstring>
{
public:
PopstringBuilder();
};
}
#define MUI_POPSTRING_TPP_INCLUDE
#include "Popstring.tpp"
#undef MUI_POPSTRING_TPP_INCLUDE