]> git.mxchange.org Git - flightgear.git/blob - src/GUI/FileDialog.hxx
Remove some debugs
[flightgear.git] / src / GUI / FileDialog.hxx
1 // FileDialog.hxx - abstract inteface for a file open/save dialog
2
3 #ifndef FG_GUI_FILE_DIALOG_HXX
4 #define FG_GUI_FILE_DIALOG_HXX 1
5
6 #include <memory> // for std::auto_ptr
7
8 #include <simgear/misc/strutils.hxx> // for string_list
9 #include <simgear/misc/sg_path.hxx>
10
11 #include <simgear/nasal/cppbind/NasalCallContext.hxx>
12
13 // forward decls
14 class SGPropertyNode;
15
16 class FGFileDialog
17 {
18 public:
19     typedef enum {
20         USE_OPEN_FILE = 0,
21         USE_SAVE_FILE,
22         USE_CHOOSE_DIR
23     } Usage;
24     
25     std::string getTitle() const
26     { return _title; }
27     
28     void setTitle(const std::string& aTitle);
29
30     std::string getButton() const
31     { return _buttonText; }
32     
33     void setButton(const std::string& aText);
34
35     SGPath getDirectory() const
36     { return _initialPath; }
37     
38     void setDirectory(const SGPath& aPath);
39     
40     string_list filterPatterns() const
41     { return _filterPatterns; }
42     
43     void setFilterPatterns(const string_list& patterns);
44     
45     /// for saving
46     std::string getPlaceholder() const
47     { return _placeholder; }
48     
49     void setPlaceholderName(const std::string& aName);
50
51     bool showHidden() const
52     { return _showHidden; }
53     void setShowHidden(bool show);
54     
55     /**
56      * Destructor.
57      */
58     virtual ~FGFileDialog ();
59
60     virtual void exec() = 0;
61     virtual void close() = 0;
62     
63     class Callback
64     {
65       public:
66         virtual ~Callback() { }
67         virtual void onFileDialogDone(FGFileDialog* ins, const SGPath& result) = 0;
68     };
69
70     virtual void setCallback(Callback* aCB);
71
72     void setCallbackFromNasal(const nasal::CallContext& ctx);
73 protected:
74     FGFileDialog(Usage use);
75     
76     const Usage _usage;
77     std::string _title, _buttonText;
78     SGPath _initialPath;
79     string_list _filterPatterns;
80     std::string _placeholder;
81     bool _showHidden;
82     std::auto_ptr<Callback> _callback;
83 };
84
85 #endif // FG_GUI_FILE_DIALOG_HXX