guit  0.1
 All Classes Functions Variables Typedefs Enumerations Friends
gfiledialog.hpp
1 //
2 // File Dialog.
3 // Guit GUI Toolkit
4 // Copyright © 2019/2020 Eric Lecolinet. All rights reserved.
5 // http://www.telecom-paris.fr/~elc
6 //
7 
8 #ifndef Guit_FileDialog_hpp
9 #define Guit_FileDialog_hpp
10 #include <gdialog.hpp>
11 namespace guit {
12 
17 class GFileDialog : public GDialog {
18 protected:
19  GFileDialog(GadgetType&, GString const& css_and_title);
20 
21 public:
22  GFileDialog(GString const& css_and_title = "");
23 
24  GFileDialog& clone(GClone const&) override;
25 
27  static GType& Type();
28  GType& type() const override {return Type();}
29 
32  GString pathname() const;
33  GString stringValue() const override {return pathname();}
35 
37  GString basename() const;
38 
40  GString dirname() const;
41 
44  GFileDialog& setDir(GString const& path);
45 
48  GFileDialog& show(bool state = true) override;
49 
53  GFileDialog& alertIf(GBool& test);
54  GFileDialog& alertIf(GExprBool const& test);
55  GFileDialog& alertIf(std::function<bool()> test);
57 
61  GFileDialog& alertFileExist(bool state);
62 
63  GFileDialog& alertFileDontExist(bool state);
64 
66  GChoice& choice() {return *choice_;}
67 
70 protected:
71  gptr<GChoice> choice_;
72  gptr<GBox> list_;
73  gptr<GTextItem> file_, dir_;
74  gprotect<GProp> alertif_;
75  bool alert_file_exist_{}, alert_file_dont_exist_{};
76  void selectEntry(GString fname);
77  void dblClick(bool isdir);
78  void setResult(int result, bool hide) override;
79  void rescan();
81 };
82 
84 GFileDialog& FileDialog(GString const& css_and_title = "");
85 
86 
87 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
88 
89 
90 class GOpenDialog : public GFileDialog {
91 public:
92  GOpenDialog(GString const& css_and_title = "");
93 
94  GOpenDialog& clone(GClone const&) override;
95 
96  using GType = GadgetType_<GOpenDialog,GFileDialog>;
97  static GType& Type();
98  GType& type() const override {return Type();}
99 };
100 
102 GOpenDialog& OpenDialog(GString const& title = "", GString const& directory = "");
103 
104 
105 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
106 
107 
108 class GSaveDialog : public GFileDialog {
109 public:
110  GSaveDialog(GString const& css_and_title = "");
111 
112  GSaveDialog& clone(GClone const&) override;
113 
114  using GType = GadgetType_<GSaveDialog,GFileDialog>;
115  static GType& Type();
116  GType& type() const override {return Type();}
117 };
118 
120 GSaveDialog& SaveDialog(GString const& title = "", GString const& directory = "");
121 
122 
123 }
124 #endif