9 #ifndef ROOT7_RMenuItem
10 #define ROOT7_RMenuItem
19 namespace Experimental {
37 RMenuItem() =
default;
42 RMenuItem(
const std::string &name,
const std::string &title) : fName(name), fTitle(title), fExec() {}
45 virtual ~RMenuItem() =
default;
49 void SetExec(
const std::string &exec) { fExec = exec; }
52 const std::string &GetName()
const {
return fName; }
55 const std::string &GetExec()
const {
return fExec; }
66 class RCheckedMenuItem :
public RMenuItem {
68 bool fChecked =
false;
71 RCheckedMenuItem() =
default;
74 RCheckedMenuItem(
const std::string &name,
const std::string &title,
bool checked =
false)
75 : RMenuItem(name, title), fChecked(checked)
80 virtual ~RCheckedMenuItem() {}
83 void SetChecked(
bool on =
true) { fChecked = on; }
85 bool IsChecked()
const {
return fChecked; }
100 std::string fTypeName;
101 std::string fDefault;
104 RMenuArgument() =
default;
106 RMenuArgument(
const std::string &name,
const std::string &title,
const std::string &typname,
107 const std::string &dflt =
"")
108 : fName(name), fTitle(title), fTypeName(typname), fDefault(dflt)
112 void SetDefault(
const std::string &dflt) { fDefault = dflt; }
123 class RArgsMenuItem :
public RMenuItem {
125 std::vector<RMenuArgument> fArgs;
129 RArgsMenuItem() =
default;
131 RArgsMenuItem(
const std::string &name,
const std::string &title) : RMenuItem(name, title) {}
134 virtual ~RArgsMenuItem() {}
136 void AddArg(
const RMenuArgument &arg) { fArgs.emplace_back(arg); }
154 std::vector<std::unique_ptr<Detail::RMenuItem>> fItems;
156 void SetId(
const std::string &
id) { fId = id; }
158 auto Size()
const {
return fItems.size(); }
160 void Add(std::unique_ptr<Detail::RMenuItem> &&item) { fItems.emplace_back(std::move(item)); }
162 void AddMenuItem(
const std::string &name,
const std::string &title,
const std::string &exec)
164 auto item = std::make_unique<Detail::RMenuItem>(name, title);
166 Add(std::move(item));
169 void AddChkMenuItem(
const std::string &name,
const std::string &title,
bool checked,
const std::string &toggle)
171 auto item = std::make_unique<Detail::RCheckedMenuItem>(name, title, checked);
172 item->SetExec(toggle);
173 Add(std::move(item));
176 void PopulateObjectMenu(
void *obj, TClass *cl);