The ZX Ecosystem v5.1.0;_GUI_v3.1.0
Loading...
Searching...
No Matches
ZXDialogsCommon.h
Go to the documentation of this file.
1
2/* **************************************************************************/
20#ifndef ZXDIALOGS_COMMON
21#define ZXDIALOGS_COMMON
22
23#include <filesystem>
27
28
29namespace zxeco
30{
31
32namespace gui
33{
34
35
36/* ****************************************************************************
37
38 Class: MessageDialog
39
40*******************************************************************************/
41
43
44class MessageDialog: public Dialog
45{
46 public:
47
49
50 enum : uint8_t {
51 kOk = 1,
52 kYes = 2,
53 kNo = 4,
54 kCancel = 8,
55 kClose = 16
56 };
57
59 static const uint8_t kOnlyClose = kClose;
60
62 static const uint8_t kOnlyOk = kOk;
63
65 static const uint8_t kYesNo = kYes | kNo;
66
68 static const uint8_t kOkCancel = kOk | kCancel;
69
70
71 MessageDialog(ZXEco & zxe, const std::string & title,
72 const std::string & msg, uint8_t buttons);
74
84 int show(bool center = true, const CharCursor & corner = {0,0},
85 const CharArea & dims = {0,0});
87
90 private:
91
92 int res_;
93};
94
95
96/* ****************************************************************************
97
98 Class: ExplanationDialog
99
100*******************************************************************************/
101
103
106{
107 public:
108
111
112 ExplanationDialog(ZXEco & zxe, const std::string & title,
113 const std::string & expl,
114 const CharArea & explarea,
115 const uint8_t * udgs = nullptr);
117
130 int show(bool center = true, const CharCursor & corner = {0,0},
131 const CharArea & dims = {0,0});
133
136 private:
137
138 int res_;
140 zxeco::Screen totalexpl_;
141};
142
143
144/* ****************************************************************************
145
146 Class: FileDialog
147
148*******************************************************************************/
149
151class FileDialog: public Dialog
152{
153 public:
154
156 enum class Type: uint8_t {
158 kForSaving,
161 };
162
163 FileDialog(ZXEco & zxe, Type t, const std::string & title,
164 const std::filesystem::path & path = std::filesystem::path{},
165 const std::string & custom = "",
166 const std::string & initedit = "",
167 bool automaticoverwrite = false);
169
178 int show(bool center = true, const CharCursor & corner = {0,0},
179 const CharArea & dims = {0,0});
181
188 const std::filesystem::path & lastFile(void) const noexcept
190 { return(lastf_); }
191
192 const std::filesystem::path & lastPath(void) const;
194
195
196 private:
197
198 const Type type_;
199 const bool automaticoverwrite_;
200
201 FileBrowserWidget * pbrowser_;
202 std::string txt_;
203 int res_;
204 std::filesystem::path lastf_;
205};
206
207
208/* ****************************************************************************
209
210 Class: MenuDialog
211
212*******************************************************************************/
213
215class MenuDialog: public Dialog
216{
217 public:
218
219 MenuDialog(ZXEco & zxe, const std::string & title,
220 const Label::Vector & options);
222
223
224 int show(bool center = true, const CharCursor & corner = {0,0},
225 const CharArea & dims = {0,0});
227
230 int show(const CharCursor & context);
232
236 size_t lastOption(void) const noexcept { return(lasto_); }
238
241 const LabelList & listOptions(void) const noexcept { return(ll_); }
243
244 private:
245
246 LabelList ll_;
247 int res_;
248 size_t lasto_;
249};
250
251
252
253} // end namespace gui
254} // end namespace zxeco
255
256#endif
257 // ZXDialogsCommon
259
260
261
Base class for all dialogs.
Definition: ZXDialogsBase.h:42
int show(bool center=true, const CharCursor &corner={0, 0}, const CharArea &dims={0, 0})
Show the dialog and get the file selection.
static const uint8_t kOnlyClose
A combination of buttons with only the CLOSE button.
static const uint8_t kYesNo
A combination of buttons with YES + NO buttons.
int show(bool center=true, const CharCursor &corner={0, 0}, const CharArea &dims={0, 0})
Show the dialog, wait for the user and close it again.
Type
Types of file dialogs.
@ kForLoading
To select a file to load.
@ kForCreating
To select a directory to create.
@ kForSaving
To select a file to save.
@ kForOpening
To select a directory to open.
ExplanationDialog(ZXEco &zxe, const std::string &title, const std::string &expl, const CharArea &explarea, const uint8_t *udgs=nullptr)
Constructor with a certain combination of buttons.
const std::filesystem::path & lastPath(void) const
Return the last path set in the file browser or throw if no browser.
FileDialog(ZXEco &zxe, Type t, const std::string &title, const std::filesystem::path &path=std::filesystem::path{}, const std::string &custom="", const std::string &initedit="", bool automaticoverwrite=false)
Create a dialog for that path.
const LabelList & listOptions(void) const noexcept
Return a reference to the list of options.
MenuDialog(ZXEco &zxe, const std::string &title, const Label::Vector &options)
Create the dialog with those options, that are copied internally.
int show(bool center=true, const CharCursor &corner={0, 0}, const CharArea &dims={0, 0})
Show the dialog and get an option.
size_t lastOption(void) const noexcept
Return the last option selected, or a number >= number of options othrw.
int show(const CharCursor &context)
Show the dialog as a context menu, i.e., auto placing and sizing.
static const uint8_t kOnlyOk
A combination of buttons with only the OK button.
static const uint8_t kOkCancel
A combination of buttons with OK + CANCEL buttons.
MessageDialog(ZXEco &zxe, const std::string &title, const std::string &msg, uint8_t buttons)
Constructor with a certain combination of buttons.
int show(bool center=true, const CharCursor &corner={0, 0}, const CharArea &dims={0, 0})
Show the dialog, get the user choice and close it again.
static const CharArea kAreaNotMessage
Height and width occupied by the entire dialog without message or title.
const std::filesystem::path & lastFile(void) const noexcept
< Return the file selected the last time (or empty if none).
A dialog to provide long, non-editable info.
A dialog to let the user select a file or directory in a filesystem.
A dialog to show a plain ZX-style menu and let the user select one option.
A dialog to provide information and request some simple user interaction.
std::vector< Label > Vector
A vector of labels.
Definition: ZXGUIGeneral.h:183
A list of labels to be displayed vertically, with possible marks on them.
Definition: ZXGUIGeneral.h:231
A possibly scrollable canvas where to write/draw things.
A widget that allows the user to browse files in the filesystem.
Class that provides access to the entire ecosystem: graphics, keyboard, etc.
Definition: ZXEcosystem.h:59
The class that provides the main support for managing the ZX screen.
Definition: ZXScreen.h:89
The main namespace of the library, that spans across all the zx modules.
Definition: ZXChars.h:31