File indexing completed on 2025-01-18 10:10:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT7_RFileDialog
0014 #define ROOT7_RFileDialog
0015
0016 #include <ROOT/RWebWindow.hxx>
0017 #include <ROOT/RBrowserData.hxx>
0018
0019 #include <vector>
0020 #include <memory>
0021 #include <stdint.h>
0022
0023 namespace ROOT {
0024
0025 namespace Details {
0026 class RWebWindowPlugin;
0027 }
0028
0029
0030
0031
0032
0033
0034
0035
0036 using RFileDialogCallback_t = std::function<void(const std::string &)>;
0037
0038
0039
0040
0041 class RFileDialog {
0042 friend class Details::RWebWindowPlugin;
0043 public:
0044
0045 enum EDialogTypes {
0046 kOpenFile,
0047 kSaveAs,
0048 kNewFile
0049 };
0050
0051 protected:
0052
0053 EDialogTypes fKind{kOpenFile};
0054 std::string fTitle;
0055 RBrowserData fBrowsable;
0056 bool fCanChangePath{true};
0057
0058 std::shared_ptr<RWebWindow> fWebWindow;
0059
0060 bool fDidSelect{false};
0061 std::string fSelectedFilter;
0062 std::vector<std::string> fNameFilters;
0063 std::string fSelect;
0064 RFileDialogCallback_t fCallback;
0065
0066 static std::string TypeAsString(EDialogTypes kind);
0067
0068 void SendInitMsg(unsigned connid);
0069 void SendChPathMsg(unsigned connid);
0070
0071 void ProcessMsg(unsigned connid, const std::string &arg);
0072
0073 void InvokeCallBack();
0074
0075 std::string GetRegexp(const std::string &name) const;
0076
0077 static std::string Dialog(EDialogTypes kind, const std::string &title, const std::string &fname);
0078
0079 static void SetStartFunc(bool on);
0080
0081 public:
0082
0083 RFileDialog(EDialogTypes kind = kOpenFile, const std::string &title = "", const std::string &fname = "");
0084 virtual ~RFileDialog();
0085
0086 const EDialogTypes &GetType() const { return fKind; }
0087
0088 void SetCallback(RFileDialogCallback_t callback);
0089
0090
0091
0092 void SetNameFilters(const std::vector<std::string> &arr) { fNameFilters = arr; }
0093
0094 const auto &GetNameFilters() const { return fNameFilters; }
0095
0096
0097 void SetCanChangePath(bool on = true) { fCanChangePath = on; }
0098
0099
0100 bool GetCanChangePath() const { return fCanChangePath; }
0101
0102 void SetWorkingPath(const std::string &);
0103 std::string GetWorkingPath() const;
0104
0105 void SetSelectedFilter(const std::string &name);
0106 std::string GetSelectedFilter() const;
0107
0108 void Show(const RWebDisplayArgs &args = "");
0109 void Hide();
0110
0111 bool IsCompleted() const { return fDidSelect; }
0112 const std::string &GetFileName() const { return fSelect; }
0113
0114 static std::string OpenFile(const std::string &title = "", const std::string &fname = "");
0115 static std::string SaveAs(const std::string &title = "", const std::string &fname = "");
0116 static std::string NewFile(const std::string &title = "", const std::string &fname = "");
0117
0118 static std::shared_ptr<RFileDialog> Embed(const std::shared_ptr<RWebWindow> &window, unsigned connid, const std::string &args);
0119
0120 static bool IsMessageToStartDialog(const std::string &msg);
0121
0122 };
0123
0124 }
0125
0126 #endif