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