File indexing completed on 2025-01-30 10:22:36
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef ROOT7_RMenuItems
0010 #define ROOT7_RMenuItems
0011
0012 #include <string>
0013 #include <vector>
0014 #include <memory>
0015
0016 #include <ROOT/RDrawableRequest.hxx>
0017
0018 #include "TClass.h"
0019
0020 namespace ROOT {
0021 namespace Experimental {
0022 namespace Detail {
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 class RMenuItem {
0033 protected:
0034 std::string fName;
0035 std::string fTitle;
0036 std::string fExec;
0037 std::string fClassName;
0038 public:
0039
0040 RMenuItem() = default;
0041
0042
0043
0044
0045 RMenuItem(const std::string &name, const std::string &title) : fName(name), fTitle(title) {}
0046
0047
0048 virtual ~RMenuItem() = default;
0049
0050
0051
0052 void SetExec(const std::string &exec) { fExec = exec; }
0053
0054
0055 void SetClassName(const std::string &clname) { fClassName = clname; }
0056
0057
0058 const std::string &GetName() const { return fName; }
0059
0060
0061 const std::string &GetExec() const { return fExec; }
0062 };
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 class RCheckedMenuItem : public RMenuItem {
0073 protected:
0074 bool fChecked = false;
0075 public:
0076
0077 RCheckedMenuItem() = default;
0078
0079
0080 RCheckedMenuItem(const std::string &name, const std::string &title, bool checked = false)
0081 : RMenuItem(name, title), fChecked(checked)
0082 {
0083 }
0084
0085
0086 ~RCheckedMenuItem() override {}
0087
0088
0089 void SetChecked(bool on = true) { fChecked = on; }
0090
0091 bool IsChecked() const { return fChecked; }
0092 };
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 class RMenuArgument {
0103 protected:
0104 std::string fName;
0105 std::string fTitle;
0106 std::string fTypeName;
0107 std::string fDefault;
0108 public:
0109
0110 RMenuArgument() = default;
0111
0112 RMenuArgument(const std::string &name, const std::string &title, const std::string &typname,
0113 const std::string &dflt = "")
0114 : fName(name), fTitle(title), fTypeName(typname), fDefault(dflt)
0115 {
0116 }
0117
0118 void SetDefault(const std::string &dflt) { fDefault = dflt; }
0119 };
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129 class RArgsMenuItem : public RMenuItem {
0130 protected:
0131 std::vector<RMenuArgument> fArgs;
0132
0133 public:
0134
0135 RArgsMenuItem() = default;
0136
0137 RArgsMenuItem(const std::string &name, const std::string &title) : RMenuItem(name, title) {}
0138
0139
0140 ~RArgsMenuItem() override {}
0141
0142 void AddArg(const RMenuArgument &arg) { fArgs.emplace_back(arg); }
0143 };
0144
0145 }
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157 class RMenuItems : public RDrawableReply {
0158 protected:
0159 std::string fId;
0160 std::string fSpecifier;
0161 std::vector<std::unique_ptr<Detail::RMenuItem>> fItems;
0162 public:
0163 RMenuItems() = default;
0164
0165 RMenuItems(const std::string &_id, const std::string &_specifier)
0166 {
0167 fId = _id;
0168 fSpecifier = _specifier;
0169 }
0170
0171 ~RMenuItems() override;
0172
0173 const std::string &GetFullId() const { return fId; }
0174 const std::string &GetSpecifier() const { return fSpecifier; }
0175
0176 auto Size() const { return fItems.size(); }
0177
0178 void Add(std::unique_ptr<Detail::RMenuItem> &&item) { fItems.emplace_back(std::move(item)); }
0179
0180 void AddMenuItem(const std::string &name, const std::string &title, const std::string &exec, const TClass *cl = nullptr)
0181 {
0182 auto item = std::make_unique<Detail::RMenuItem>(name, title);
0183 item->SetExec(exec);
0184 if (cl) item->SetClassName(cl->GetName());
0185 Add(std::move(item));
0186 }
0187
0188 void AddChkMenuItem(const std::string &name, const std::string &title, bool checked, const std::string &toggle, const TClass *cl = nullptr)
0189 {
0190 auto item = std::make_unique<Detail::RCheckedMenuItem>(name, title, checked);
0191 item->SetExec(toggle);
0192 if (cl) item->SetClassName(cl->GetName());
0193 Add(std::move(item));
0194 }
0195
0196 void PopulateObjectMenu(void *obj, TClass *cl);
0197 };
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208 class RDrawableMenuRequest : public RDrawableRequest {
0209 std::string menukind;
0210 std::string menureqid;
0211 public:
0212 std::unique_ptr<RDrawableReply> Process() override;
0213 };
0214
0215
0216 }
0217 }
0218
0219 #endif