1.10
filedialog.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_FILEDIALOG_H
7#define EGT_FILEDIALOG_H
8
14#include <egt/button.h>
15#include <egt/detail/meta.h>
16#include <egt/dialog.h>
17#include <egt/grid.h>
18#include <egt/label.h>
19#include <egt/list.h>
20#include <egt/popup.h>
21#include <egt/signal.h>
22#include <egt/sizer.h>
23#include <egt/text.h>
24#include <string>
25
26namespace egt
27{
28inline namespace v1
29{
30
41class EGT_API FileDialog : public Dialog
42{
43public:
44
62 explicit FileDialog(const Rect& rect = {}) noexcept;
63
73 explicit FileDialog(const std::string& filepath, const Rect& rect = {}) noexcept;
74
80 explicit FileDialog(Serializer::Properties& props) noexcept
81 : FileDialog(props, false)
82 {
83 }
84
85protected:
86
87 explicit FileDialog(Serializer::Properties& props, bool is_derived) noexcept;
88
89public:
90
96 void show() override;
97
98 void show_centered() override;
99
100 void serialize(Serializer& serializer) const override;
101
102protected:
104 std::shared_ptr<ListBox> m_flist;
105
107 std::string m_filepath;
108
110 bool list_files(const std::string& filepath);
111
113 void list_item_selected(int index);
114
120 virtual void selected(const std::string& fselect) = 0;
121
122private:
123
124 void initialize();
125
126 void deserialize(Serializer::Properties& props);
127};
128
137class EGT_API FileOpenDialog : public FileDialog
138{
139public:
146 explicit FileOpenDialog(const Rect& rect = {}) noexcept;
147
157 explicit FileOpenDialog(const std::string& filepath, const Rect& rect = {}) noexcept;
158
164 explicit FileOpenDialog(Serializer::Properties& props) noexcept
165 : FileOpenDialog(props, false)
166 {
167 }
168
169protected:
170
171 explicit FileOpenDialog(Serializer::Properties& props, bool is_derived) noexcept;
172
173public:
174
180 EGT_NODISCARD std::string selected() const;
181
182protected:
184 std::string m_fselected;
185
191 void selected(const std::string& fselect) override;
192
194};
195
204class EGT_API FileSaveDialog : public FileDialog
205{
206public:
213 explicit FileSaveDialog(const Rect& rect = {}) noexcept;
214
224 explicit FileSaveDialog(const std::string& filepath, const Rect& rect = {}) noexcept;
225
231 explicit FileSaveDialog(Serializer::Properties& props) noexcept
232 : FileSaveDialog(props, false)
233 {
234 }
235
236protected:
237
238 explicit FileSaveDialog(Serializer::Properties& props, bool is_derived) noexcept;
239
240public:
241
247 void show() override;
248
249 void show_centered() override;
250
256 EGT_NODISCARD std::string selected() const;
257
258protected:
259
262
264 std::string m_fsave;
265
271 void selected(const std::string& fselect) override;
272
274};
275
276}
277}
278
279#endif
A dialog is a widget that allows user to make a decision.
Definition dialog.h:38
A FileDialog is a widget that allows user to:
Definition filedialog.h:42
std::string m_filepath
File path of a directory.
Definition filedialog.h:107
void show_centered() override
Show the window centered.
std::shared_ptr< ListBox > m_flist
List Box for file listing.
Definition filedialog.h:104
void list_item_selected(int index)
Get the List Item selected index.
FileDialog(const std::string &filepath, const Rect &rect={}) noexcept
Create a file dialog window.
void serialize(Serializer &serializer) const override
FileDialog(Serializer::Properties &props, bool is_derived) noexcept
void show() override
Show the Widget.
FileDialog(Serializer::Properties &props) noexcept
Create a file dialog window.
Definition filedialog.h:80
FileDialog(const Rect &rect={}) noexcept
Create a file open dialog window and list the contents of current directory.
bool list_files(const std::string &filepath)
List the contents of file path directory.
virtual void selected(const std::string &fselect)=0
File selected.
Signal on_selected
Event signal.
Definition filedialog.h:52
A FileOpenDialog is a widget which inherits from FileDialog and that allows user to:
Definition filedialog.h:138
FileOpenDialog(const Rect &rect={}) noexcept
Create a file open dialog window and list the contents of current directory.
FileOpenDialog(Serializer::Properties &props, bool is_derived) noexcept
void selected(const std::string &fselect) override
File selected.
FileOpenDialog(const std::string &filepath, const Rect &rect={}) noexcept
Create a file open dialog window.
FileOpenDialog(Serializer::Properties &props) noexcept
Create a file open dialog window.
Definition filedialog.h:164
EGT_NODISCARD std::string selected() const
Return file selected in file open dialog window.
std::string m_fselected
File path of a selected file.
Definition filedialog.h:184
A FileSaveDialog is a widget which inherits from FileDialog and that allows user to:
Definition filedialog.h:205
void selected(const std::string &fselect) override
File selected.
FileSaveDialog(const std::string &filepath, const Rect &rect={}) noexcept
Create a file save dialog window.
std::string m_fsave
File path of a file save location.
Definition filedialog.h:264
void show_centered() override
Show the window centered.
FileSaveDialog(Serializer::Properties &props) noexcept
Create a file save dialog window.
Definition filedialog.h:231
void show() override
Show the Widget.
EGT_NODISCARD std::string selected() const
Selected a location for saving a file.
FileSaveDialog(const Rect &rect={}) noexcept
Create a file save dialog window and list the contents of current directory.
FileSaveDialog(Serializer::Properties &props, bool is_derived) noexcept
TextBox m_fsave_box
Input a filename or file path.
Definition filedialog.h:261
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
Input text box.
Definition text.h:134
EGT framework namespace.
Definition animation.h:24