ROOT
6.18/05
Reference Guide
graf2d
gpadv7
v7
inc
ROOT
RMenuItem.hxx
Go to the documentation of this file.
1
/// \file ROOT/RMenuItem.hxx
2
/// \ingroup Base ROOT7
3
/// \author Sergey Linev
4
/// \date 2017-06-29
5
/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6
/// is welcome!
7
8
/*************************************************************************
9
* Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
10
* All rights reserved. *
11
* *
12
* For the licensing terms see $ROOTSYS/LICENSE. *
13
* For the list of contributors see $ROOTSYS/README/CREDITS. *
14
*************************************************************************/
15
16
#ifndef ROOT7_RMenuItem
17
#define ROOT7_RMenuItem
18
19
#include <string>
20
#include <vector>
21
22
class
TClass
;
23
24
namespace
ROOT
{
25
namespace
Experimental {
26
namespace
Detail {
27
28
/** \class RMenuItem
29
Class contains info for producing menu item on the JS side.
30
*/
31
32
class
RMenuItem
{
33
protected
:
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
37
public
:
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
() {}
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
:
public
RMenuItem
{
61
protected
:
62
bool
fChecked
=
false
;
///< -1 not exists, 0 - off, 1 - on
63
public
:
64
/** Default constructor */
65
RCheckedMenuItem
() =
default
;
66
67
/** Create checked menu item */
68
RCheckedMenuItem
(
const
std::string &
name
,
const
std::string &title,
bool
checked =
false
)
69
:
RMenuItem
(
name
, title),
fChecked
(checked)
70
{
71
}
72
73
/** virtual destructor need for vtable, used when vector of RMenuItem* is stored */
74
virtual
~RCheckedMenuItem
() {}
75
76
/** Set checked state for the item, default is none */
77
void
SetChecked
(
bool
on =
true
) {
fChecked
= on; }
78
79
bool
IsChecked
()
const
{
return
fChecked
; }
80
};
81
82
class
RMenuArgument
{
83
protected
:
84
std::string
fName
;
///< name of call argument
85
std::string
fTitle
;
///< title of call argument
86
std::string
fTypeName
;
///< typename
87
std::string
fDefault
;
///< default value
88
public
:
89
/** Default constructor */
90
RMenuArgument
() =
default
;
91
92
RMenuArgument
(
const
std::string &
name
,
const
std::string &title,
const
std::string &typname,
93
const
std::string &dflt =
""
)
94
:
fName
(
name
),
fTitle
(title),
fTypeName
(typname),
fDefault
(dflt)
95
{
96
}
97
98
void
SetDefault
(
const
std::string &dflt) {
fDefault
= dflt; }
99
};
100
101
class
RArgsMenuItem
:
public
RMenuItem
{
102
protected
:
103
std::vector<RMenuArgument>
fArgs
;
104
105
public
:
106
/** Default constructor */
107
RArgsMenuItem
() =
default
;
108
109
RArgsMenuItem
(
const
std::string &
name
,
const
std::string &title) :
RMenuItem
(
name
, title) {}
110
111
/** virtual destructor need for vtable, used when vector of RMenuItem* is stored */
112
virtual
~RArgsMenuItem
() {}
113
114
void
AddArg
(
const
RMenuArgument
&arg) {
fArgs
.push_back(arg); }
115
};
116
117
}
// namespace Detail
118
119
///////////////////////////////////////////////////////////////////////
120
121
class
RMenuItems
{
122
protected
:
123
std::vector<Detail::RMenuItem *>
fItems
;
///< list of items in the menu
124
public
:
125
/** Default constructor */
126
RMenuItems
() =
default
;
127
128
~RMenuItems
() {
Cleanup
(); }
129
130
void
Add
(
Detail::RMenuItem
*item) {
fItems
.push_back(item); }
131
132
void
AddMenuItem
(
const
std::string &
name
,
const
std::string &title,
const
std::string &exec)
133
{
134
Detail::RMenuItem
*item =
new
Detail::RMenuItem
(
name
, title);
135
item->
SetExec
(exec);
136
Add
(item);
137
}
138
139
void
AddChkMenuItem
(
const
std::string &
name
,
const
std::string &title,
bool
checked,
const
std::string &toggle)
140
{
141
Detail::RCheckedMenuItem
*item =
new
Detail::RCheckedMenuItem
(
name
, title, checked);
142
item->
SetExec
(toggle);
143
Add
(item);
144
}
145
146
unsigned
Size
()
const
{
return
fItems
.size(); }
147
148
void
Cleanup
();
149
150
void
PopulateObjectMenu
(
void
*obj,
TClass
*cl);
151
152
std::string
ProduceJSON
();
153
};
154
155
}
// namespace Experimental
156
}
// namespace ROOT
157
158
#endif
name
char name[80]
Definition:
TGX11.cxx:109
ROOT::Experimental::Detail::RArgsMenuItem
Definition:
RMenuItem.hxx:101
ROOT::Experimental::Detail::RArgsMenuItem::~RArgsMenuItem
virtual ~RArgsMenuItem()
virtual destructor need for vtable, used when vector of RMenuItem* is stored
Definition:
RMenuItem.hxx:112
ROOT::Experimental::Detail::RArgsMenuItem::fArgs
std::vector< RMenuArgument > fArgs
Definition:
RMenuItem.hxx:103
ROOT::Experimental::Detail::RArgsMenuItem::RArgsMenuItem
RArgsMenuItem()=default
Default constructor.
ROOT::Experimental::Detail::RArgsMenuItem::AddArg
void AddArg(const RMenuArgument &arg)
Definition:
RMenuItem.hxx:114
ROOT::Experimental::Detail::RArgsMenuItem::RArgsMenuItem
RArgsMenuItem(const std::string &name, const std::string &title)
Definition:
RMenuItem.hxx:109
ROOT::Experimental::Detail::RCheckedMenuItem
Definition:
RMenuItem.hxx:60
ROOT::Experimental::Detail::RCheckedMenuItem::RCheckedMenuItem
RCheckedMenuItem()=default
Default constructor.
ROOT::Experimental::Detail::RCheckedMenuItem::IsChecked
bool IsChecked() const
Definition:
RMenuItem.hxx:79
ROOT::Experimental::Detail::RCheckedMenuItem::~RCheckedMenuItem
virtual ~RCheckedMenuItem()
virtual destructor need for vtable, used when vector of RMenuItem* is stored
Definition:
RMenuItem.hxx:74
ROOT::Experimental::Detail::RCheckedMenuItem::RCheckedMenuItem
RCheckedMenuItem(const std::string &name, const std::string &title, bool checked=false)
Create checked menu item
Definition:
RMenuItem.hxx:68
ROOT::Experimental::Detail::RCheckedMenuItem::fChecked
bool fChecked
-1 not exists, 0 - off, 1 - on
Definition:
RMenuItem.hxx:62
ROOT::Experimental::Detail::RCheckedMenuItem::SetChecked
void SetChecked(bool on=true)
Set checked state for the item, default is none.
Definition:
RMenuItem.hxx:77
ROOT::Experimental::Detail::RMenuArgument
Definition:
RMenuItem.hxx:82
ROOT::Experimental::Detail::RMenuArgument::RMenuArgument
RMenuArgument()=default
Default constructor.
ROOT::Experimental::Detail::RMenuArgument::fName
std::string fName
name of call argument
Definition:
RMenuItem.hxx:84
ROOT::Experimental::Detail::RMenuArgument::RMenuArgument
RMenuArgument(const std::string &name, const std::string &title, const std::string &typname, const std::string &dflt="")
Definition:
RMenuItem.hxx:92
ROOT::Experimental::Detail::RMenuArgument::SetDefault
void SetDefault(const std::string &dflt)
Definition:
RMenuItem.hxx:98
ROOT::Experimental::Detail::RMenuArgument::fTitle
std::string fTitle
title of call argument
Definition:
RMenuItem.hxx:85
ROOT::Experimental::Detail::RMenuArgument::fTypeName
std::string fTypeName
typename
Definition:
RMenuItem.hxx:86
ROOT::Experimental::Detail::RMenuArgument::fDefault
std::string fDefault
default value
Definition:
RMenuItem.hxx:87
ROOT::Experimental::Detail::RMenuItem
Class contains info for producing menu item on the JS side.
Definition:
RMenuItem.hxx:32
ROOT::Experimental::Detail::RMenuItem::fTitle
std::string fTitle
title of menu item
Definition:
RMenuItem.hxx:35
ROOT::Experimental::Detail::RMenuItem::~RMenuItem
virtual ~RMenuItem()
virtual destructor need for vtable, used when vector of RMenuItem* is stored
Definition:
RMenuItem.hxx:47
ROOT::Experimental::Detail::RMenuItem::RMenuItem
RMenuItem()=default
Default constructor.
ROOT::Experimental::Detail::RMenuItem::GetExec
const std::string & GetExec() const
Returns execution string for the menu item.
Definition:
RMenuItem.hxx:57
ROOT::Experimental::Detail::RMenuItem::SetExec
void SetExec(const std::string &exec)
Set execution string with all required arguments, which will be executed when menu item is selected
Definition:
RMenuItem.hxx:51
ROOT::Experimental::Detail::RMenuItem::fExec
std::string fExec
execute when item is activated
Definition:
RMenuItem.hxx:36
ROOT::Experimental::Detail::RMenuItem::fName
std::string fName
name of the menu item
Definition:
RMenuItem.hxx:34
ROOT::Experimental::Detail::RMenuItem::RMenuItem
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:
RMenuItem.hxx:44
ROOT::Experimental::Detail::RMenuItem::GetName
const std::string & GetName() const
Returns menu item name.
Definition:
RMenuItem.hxx:54
ROOT::Experimental::RMenuItems
Definition:
RMenuItem.hxx:121
ROOT::Experimental::RMenuItems::AddMenuItem
void AddMenuItem(const std::string &name, const std::string &title, const std::string &exec)
Definition:
RMenuItem.hxx:132
ROOT::Experimental::RMenuItems::ProduceJSON
std::string ProduceJSON()
Definition:
RMenuItem.cxx:105
ROOT::Experimental::RMenuItems::Cleanup
void Cleanup()
Definition:
RMenuItem.cxx:27
ROOT::Experimental::RMenuItems::Add
void Add(Detail::RMenuItem *item)
Definition:
RMenuItem.hxx:130
ROOT::Experimental::RMenuItems::AddChkMenuItem
void AddChkMenuItem(const std::string &name, const std::string &title, bool checked, const std::string &toggle)
Definition:
RMenuItem.hxx:139
ROOT::Experimental::RMenuItems::Size
unsigned Size() const
Definition:
RMenuItem.hxx:146
ROOT::Experimental::RMenuItems::fItems
std::vector< Detail::RMenuItem * > fItems
list of items in the menu
Definition:
RMenuItem.hxx:123
ROOT::Experimental::RMenuItems::RMenuItems
RMenuItems()=default
Default constructor.
ROOT::Experimental::RMenuItems::PopulateObjectMenu
void PopulateObjectMenu(void *obj, TClass *cl)
Definition:
RMenuItem.cxx:34
ROOT::Experimental::RMenuItems::~RMenuItems
~RMenuItems()
Definition:
RMenuItem.hxx:128
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition:
TClass.h:75
ROOT
Namespace for new ROOT classes and functions.
Definition:
StringConv.hxx:21