Logo ROOT  
Reference Guide
RMenuItems.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_RMenuItems
10#define ROOT7_RMenuItems
11
12#include <string>
13#include <vector>
14#include <memory>
15
17
18class TClass;
19
20namespace ROOT {
21namespace Experimental {
22namespace Detail {
23
24/** \class RMenuItem
25\ingroup GpadROOT7
26\brief Base class for menu items, shown on JS side.
27\author Sergey Linev
28\date 2017-06-29
29\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
30*/
31
32class RMenuItem {
33protected:
34 std::string fName; ///< name of the menu item
35 std::string fTitle; ///< title of menu item
36 std::string fExec; ///< execute when item is activated
37public:
38 /** Default constructor */
39 RMenuItem() = default;
40
41 /** Create menu item with the name and title
42 * name used to display item in the object context menu,
43 * title shown as hint info for that item */
44 RMenuItem(const std::string &name, const std::string &title) : fName(name), fTitle(title), fExec() {}
45
46 /** virtual destructor need for vtable, used when vector of RMenuItem* is stored */
47 virtual ~RMenuItem() = default;
48
49 /** Set execution string with all required arguments,
50 * which will be executed when menu item is selected */
51 void SetExec(const std::string &exec) { fExec = exec; }
52
53 /** Returns menu item name */
54 const std::string &GetName() const { return fName; }
55
56 /** Returns execution string for the menu item */
57 const std::string &GetExec() const { return fExec; }
58};
59
60/** \class RCheckedMenuItem
61\ingroup GpadROOT7
62\brief Menu item with check box
63\author Sergey Linev
64\date 2017-06-29
65\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
66*/
67
69protected:
70 bool fChecked = false; ///< state of checkbox
71public:
72 /** Default constructor */
73 RCheckedMenuItem() = default;
74
75 /** Create checked menu item */
76 RCheckedMenuItem(const std::string &name, const std::string &title, bool checked = false)
77 : RMenuItem(name, title), fChecked(checked)
78 {
79 }
80
81 /** virtual destructor need for vtable, used when vector of RMenuItem* is stored */
82 virtual ~RCheckedMenuItem() {}
83
84 /** Set checked state for the item, default is none */
85 void SetChecked(bool on = true) { fChecked = on; }
86
87 bool IsChecked() const { return fChecked; }
88};
89
90/** \class RMenuArgument
91\ingroup GpadROOT7
92\brief Argument description for menu item which should invoke class method
93\author Sergey Linev
94\date 2017-06-29
95\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
96*/
97
99protected:
100 std::string fName; ///< name of call argument
101 std::string fTitle; ///< title of call argument
102 std::string fTypeName; ///< typename
103 std::string fDefault; ///< default value
104public:
105 /** Default constructor */
106 RMenuArgument() = default;
107
108 RMenuArgument(const std::string &name, const std::string &title, const std::string &typname,
109 const std::string &dflt = "")
110 : fName(name), fTitle(title), fTypeName(typname), fDefault(dflt)
111 {
112 }
113
114 void SetDefault(const std::string &dflt) { fDefault = dflt; }
115};
116
117/** \class RArgsMenuItem
118\ingroup GpadROOT7
119\brief Menu item which requires extra arguments for invoked class method
120\author Sergey Linev
121\date 2017-06-29
122\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
123*/
124
125class RArgsMenuItem : public RMenuItem {
126protected:
127 std::vector<RMenuArgument> fArgs;
128
129public:
130 /** Default constructor */
131 RArgsMenuItem() = default;
132
133 RArgsMenuItem(const std::string &name, const std::string &title) : RMenuItem(name, title) {}
134
135 /** virtual destructor need for vtable, used when vector of RMenuItem* is stored */
136 virtual ~RArgsMenuItem() {}
137
138 void AddArg(const RMenuArgument &arg) { fArgs.emplace_back(arg); }
139};
140
141} // namespace Detail
142
143///////////////////////////////////////////////////////////////////////
144
145/** \class RMenuItems
146\ingroup GpadROOT7
147\brief List of items for object context menu
148\author Sergey Linev
149\date 2017-06-29
150\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
151*/
152
154protected:
155 std::string fId; ///< object identifier
156 std::string fSpecifier; ///<! extra specifier, used only on server
157 std::vector<std::unique_ptr<Detail::RMenuItem>> fItems; ///< list of items in the menu
158public:
159 RMenuItems() = default;
160
161 RMenuItems(const std::string &_id, const std::string &_specifier)
162 {
163 fId = _id;
164 fSpecifier = _specifier;
165 }
166
167 virtual ~RMenuItems();
168
169 const std::string &GetFullId() const { return fId; }
170 const std::string &GetSpecifier() const { return fSpecifier; }
171
172 auto Size() const { return fItems.size(); }
173
174 void Add(std::unique_ptr<Detail::RMenuItem> &&item) { fItems.emplace_back(std::move(item)); }
175
176 void AddMenuItem(const std::string &name, const std::string &title, const std::string &exec)
177 {
178 auto item = std::make_unique<Detail::RMenuItem>(name, title);
179 item->SetExec(exec);
180 Add(std::move(item));
181 }
182
183 void AddChkMenuItem(const std::string &name, const std::string &title, bool checked, const std::string &toggle)
184 {
185 auto item = std::make_unique<Detail::RCheckedMenuItem>(name, title, checked);
186 item->SetExec(toggle);
187 Add(std::move(item));
188 }
189
190 void PopulateObjectMenu(void *obj, TClass *cl);
191};
192
193
194/** \class RDrawableMenuRequest
195\ingroup GpadROOT7
196\brief Request menu items for the drawable object
197\author Sergey Linev
198\date 2020-04-14
199\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
200*/
201
203 std::string menukind;
204 std::string menureqid;
205public:
206 std::unique_ptr<RDrawableReply> Process() override;
207};
208
209
210} // namespace Experimental
211} // namespace ROOT
212
213#endif
char name[80]
Definition: TGX11.cxx:109
Menu item which requires extra arguments for invoked class method.
Definition: RMenuItems.hxx:125
virtual ~RArgsMenuItem()
virtual destructor need for vtable, used when vector of RMenuItem* is stored
Definition: RMenuItems.hxx:136
std::vector< RMenuArgument > fArgs
Definition: RMenuItems.hxx:127
RArgsMenuItem()=default
Default constructor.
void AddArg(const RMenuArgument &arg)
Definition: RMenuItems.hxx:138
RArgsMenuItem(const std::string &name, const std::string &title)
Definition: RMenuItems.hxx:133
RCheckedMenuItem()=default
Default constructor.
virtual ~RCheckedMenuItem()
virtual destructor need for vtable, used when vector of RMenuItem* is stored
Definition: RMenuItems.hxx:82
RCheckedMenuItem(const std::string &name, const std::string &title, bool checked=false)
Create checked menu item
Definition: RMenuItems.hxx:76
void SetChecked(bool on=true)
Set checked state for the item, default is none.
Definition: RMenuItems.hxx:85
Argument description for menu item which should invoke class method.
Definition: RMenuItems.hxx:98
RMenuArgument()=default
Default constructor.
std::string fName
name of call argument
Definition: RMenuItems.hxx:100
RMenuArgument(const std::string &name, const std::string &title, const std::string &typname, const std::string &dflt="")
Definition: RMenuItems.hxx:108
void SetDefault(const std::string &dflt)
Definition: RMenuItems.hxx:114
std::string fTitle
title of call argument
Definition: RMenuItems.hxx:101
Base class for menu items, shown on JS side.
Definition: RMenuItems.hxx:32
std::string fTitle
title of menu item
Definition: RMenuItems.hxx:35
RMenuItem()=default
Default constructor.
const std::string & GetExec() const
Returns execution string for the menu item.
Definition: RMenuItems.hxx:57
void SetExec(const std::string &exec)
Set execution string with all required arguments, which will be executed when menu item is selected
Definition: RMenuItems.hxx:51
std::string fExec
execute when item is activated
Definition: RMenuItems.hxx:36
std::string fName
name of the menu item
Definition: RMenuItems.hxx:34
RMenuItem(const std::string &name, const std::string &title)
Create menu item with the name and title name used to display item in the object context menu,...
Definition: RMenuItems.hxx:44
const std::string & GetName() const
Returns menu item name.
Definition: RMenuItems.hxx:54
virtual ~RMenuItem()=default
virtual destructor need for vtable, used when vector of RMenuItem* is stored
Request menu items for the drawable object.
Definition: RMenuItems.hxx:202
std::unique_ptr< RDrawableReply > Process() override
fill menu items for the drawable
Definition: RMenuItems.cxx:101
Base class for replies on RDrawableRequest.
Base class for requests which can be submitted from the clients.
List of items for object context menu.
Definition: RMenuItems.hxx:153
void AddMenuItem(const std::string &name, const std::string &title, const std::string &exec)
Definition: RMenuItems.hxx:176
RMenuItems(const std::string &_id, const std::string &_specifier)
Definition: RMenuItems.hxx:161
std::string fSpecifier
! extra specifier, used only on server
Definition: RMenuItems.hxx:156
virtual ~RMenuItems()
destructor - pin vtable
void AddChkMenuItem(const std::string &name, const std::string &title, bool checked, const std::string &toggle)
Definition: RMenuItems.hxx:183
std::string fId
object identifier
Definition: RMenuItems.hxx:155
std::vector< std::unique_ptr< Detail::RMenuItem > > fItems
list of items in the menu
Definition: RMenuItems.hxx:157
void Add(std::unique_ptr< Detail::RMenuItem > &&item)
Definition: RMenuItems.hxx:174
const std::string & GetFullId() const
Definition: RMenuItems.hxx:169
void PopulateObjectMenu(void *obj, TClass *cl)
Fill menu for provided object, using MENU as indicator in method comments.
Definition: RMenuItems.cxx:31
const std::string & GetSpecifier() const
Definition: RMenuItems.hxx:170
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
struct void * fTypeName
Definition: cppyy.h:9
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: StringConv.hxx:21