Warning, file /include/root/TWebMenuItem.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOT_TWebMenuItem
0012 #define ROOT_TWebMenuItem
0013
0014 #include "TString.h"
0015 #include "TClass.h"
0016
0017 #include <string>
0018 #include <vector>
0019 #include <memory>
0020
0021 class TClass;
0022
0023
0024
0025
0026
0027
0028
0029
0030 class TWebMenuItem {
0031 protected:
0032 std::string fName;
0033 std::string fTitle;
0034 std::string fExec;
0035 std::string fClassName;
0036 public:
0037
0038 TWebMenuItem(const std::string &name, const std::string &title) : fName(name), fTitle(title), fExec(), fClassName() {}
0039 TWebMenuItem(const TWebMenuItem &rhs) : fName(rhs.fName), fTitle(rhs.fTitle), fExec(rhs.fExec), fClassName(rhs.fClassName) {}
0040 virtual ~TWebMenuItem() = default;
0041
0042
0043
0044 void SetExec(const std::string &exec) { fExec = exec; }
0045
0046
0047 void SetClassName(const std::string &clname) { fClassName = clname; }
0048
0049
0050 const std::string &GetName() const { return fName; }
0051
0052
0053 const std::string &GetExec() const { return fExec; }
0054 };
0055
0056
0057
0058 class TWebCheckedMenuItem : public TWebMenuItem {
0059 protected:
0060 bool fChecked{false};
0061 public:
0062
0063 TWebCheckedMenuItem(const std::string &name, const std::string &title, bool checked = false)
0064 : TWebMenuItem(name, title), fChecked(checked)
0065 {
0066 }
0067
0068
0069 ~TWebCheckedMenuItem() override = default;
0070
0071
0072 void SetChecked(bool on = true) { fChecked = on; }
0073
0074 bool IsChecked() const { return fChecked; }
0075 };
0076
0077
0078
0079 class TWebMenuArgument {
0080 protected:
0081 std::string fName;
0082 std::string fTitle;
0083 std::string fTypeName;
0084 std::string fDefault;
0085 public:
0086 TWebMenuArgument() = default;
0087
0088 TWebMenuArgument(const std::string &name, const std::string &title, const std::string &typname,
0089 const std::string &dflt = "")
0090 : fName(name), fTitle(title), fTypeName(typname), fDefault(dflt)
0091 {
0092 }
0093
0094 void SetDefault(const std::string &dflt) { fDefault = dflt; }
0095 };
0096
0097
0098
0099 class TWebArgsMenuItem : public TWebMenuItem {
0100 protected:
0101 std::vector<TWebMenuArgument> fArgs;
0102
0103 public:
0104
0105 TWebArgsMenuItem(const std::string &name, const std::string &title) : TWebMenuItem(name, title) {}
0106
0107
0108 ~TWebArgsMenuItem() override = default;
0109
0110 std::vector<TWebMenuArgument> &GetArgs() { return fArgs; }
0111
0112 };
0113
0114
0115
0116 class TWebMenuItems {
0117 protected:
0118 std::string fId;
0119 std::vector<std::unique_ptr<TWebMenuItem>> fItems;
0120 public:
0121 TWebMenuItems() = default;
0122 TWebMenuItems(const std::string &snapid) : fId(snapid) {}
0123
0124 void Add(TWebMenuItem *item) { fItems.emplace_back(item); }
0125
0126 void AddMenuItem(const std::string &name, const std::string &title, const std::string &exec, TClass *cl = nullptr)
0127 {
0128 TWebMenuItem *item = new TWebMenuItem(name, title);
0129 item->SetExec(exec);
0130 if (cl) item->SetClassName(cl->GetName());
0131 Add(item);
0132 }
0133
0134 void AddChkMenuItem(const std::string &name, const std::string &title, bool checked, const std::string &toggle, TClass *cl = nullptr)
0135 {
0136 TWebCheckedMenuItem *item = new TWebCheckedMenuItem(name, title, checked);
0137 item->SetExec(toggle);
0138 if (cl) item->SetClassName(cl->GetName());
0139 Add(item);
0140 }
0141
0142 std::size_t Size() const { return fItems.size(); }
0143
0144 void PopulateObjectMenu(void *obj, TClass *cl);
0145 };
0146
0147 #endif