ROOT
v6-26
Reference Guide
Loading...
Searching...
No Matches
TWebMenuItem.h
Go to the documentation of this file.
1
// Author: Sergey Linev, GSI 29/06/2017
2
3
/*************************************************************************
4
* Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
5
* All rights reserved. *
6
* *
7
* For the licensing terms see $ROOTSYS/LICENSE. *
8
* For the list of contributors see $ROOTSYS/README/CREDITS. *
9
*************************************************************************/
10
11
#ifndef ROOT_TWebMenuItem
12
#define ROOT_TWebMenuItem
13
14
#include "
TString.h
"
15
#include "
TClass.h
"
16
17
#include <string>
18
#include <vector>
19
#include <memory>
20
21
class
TClass
;
22
23
/** \class TWebMenuItem
24
\ingroup webgui6
25
26
Class contains info for producing menu item on the JS side.
27
28
*/
29
30
class
TWebMenuItem
{
31
protected
:
32
std::string
fName
;
// name of the menu item
33
std::string
fTitle
;
// title of menu item
34
std::string
fExec
;
// execute when item is activated
35
std::string
fClassName
;
// class name
36
public
:
37
38
TWebMenuItem
(
const
std::string &
name
,
const
std::string &title) :
fName
(
name
),
fTitle
(title),
fExec
(),
fClassName
() {}
39
TWebMenuItem
(
const
TWebMenuItem
&rhs) :
fName
(rhs.
fName
),
fTitle
(rhs.
fTitle
),
fExec
(rhs.
fExec
),
fClassName
(rhs.
fClassName
) {}
40
virtual
~TWebMenuItem
() =
default
;
41
42
/** Set execution string with all required arguments,
43
* which will be executed when menu item is selected */
44
void
SetExec
(
const
std::string &exec) {
fExec
= exec; }
45
46
/** Set class name, to which method belons to */
47
void
SetClassName
(
const
std::string &clname) {
fClassName
= clname; }
48
49
/** Returns menu item name */
50
const
std::string &
GetName
()
const
{
return
fName
; }
51
52
/** Returns execution string for the menu item */
53
const
std::string &
GetExec
()
const
{
return
fExec
; }
54
};
55
56
////////////////////////////////////////////////////////////////////////////
57
58
class
TWebCheckedMenuItem
:
public
TWebMenuItem
{
59
protected
:
60
bool
fChecked
{
false
};
///<
61
public
:
62
/** Create checked menu item */
63
TWebCheckedMenuItem
(
const
std::string &
name
,
const
std::string &title,
bool
checked =
false
)
64
:
TWebMenuItem
(
name
, title),
fChecked
(checked)
65
{
66
}
67
68
/** virtual destructor need for vtable, used when vector of TMenuItem* is stored */
69
virtual
~TWebCheckedMenuItem
() =
default
;
70
71
/** Set checked state for the item, default is none */
72
void
SetChecked
(
bool
on =
true
) {
fChecked
= on; }
73
74
bool
IsChecked
()
const
{
return
fChecked
; }
75
};
76
77
////////////////////////////////////////////////////////////////////////////
78
79
class
TWebMenuArgument
{
80
protected
:
81
std::string
fName
;
///< name of call argument
82
std::string
fTitle
;
///< title of call argument
83
std::string
fTypeName
;
///< typename
84
std::string
fDefault
;
///< default value
85
public
:
86
TWebMenuArgument
() =
default
;
87
88
TWebMenuArgument
(
const
std::string &
name
,
const
std::string &title,
const
std::string &typname,
89
const
std::string &dflt =
""
)
90
:
fName
(
name
),
fTitle
(title),
fTypeName
(typname),
fDefault
(dflt)
91
{
92
}
93
94
void
SetDefault
(
const
std::string &dflt) {
fDefault
= dflt; }
95
};
96
97
////////////////////////////////////////////////////////////////////////////
98
99
class
TWebArgsMenuItem
:
public
TWebMenuItem
{
100
protected
:
101
std::vector<TWebMenuArgument>
fArgs
;
102
103
public
:
104
105
TWebArgsMenuItem
(
const
std::string &
name
,
const
std::string &title) :
TWebMenuItem
(
name
, title) {}
106
107
/** virtual destructor need for vtable, used when vector of TMenuItem* is stored */
108
virtual
~TWebArgsMenuItem
() =
default
;
109
110
std::vector<TWebMenuArgument> &
GetArgs
() {
return
fArgs
; }
111
112
};
113
114
///////////////////////////////////////////////////////////////////////
115
116
class
TWebMenuItems
{
117
protected
:
118
std::string
fId
;
///< object identifier
119
std::vector<std::unique_ptr<TWebMenuItem>>
fItems
;
///< list of items in the menu
120
public
:
121
TWebMenuItems
() =
default
;
122
TWebMenuItems
(
const
std::string &snapid) :
fId
(snapid) {}
123
124
void
Add
(
TWebMenuItem
*item) {
fItems
.emplace_back(item); }
125
126
void
AddMenuItem
(
const
std::string &
name
,
const
std::string &title,
const
std::string &exec,
TClass
*cl =
nullptr
)
127
{
128
TWebMenuItem
*item =
new
TWebMenuItem
(
name
, title);
129
item->
SetExec
(exec);
130
if
(cl) item->
SetClassName
(cl->GetName());
131
Add
(item);
132
}
133
134
void
AddChkMenuItem
(
const
std::string &
name
,
const
std::string &title,
bool
checked,
const
std::string &toggle,
TClass
*cl =
nullptr
)
135
{
136
TWebCheckedMenuItem
*item =
new
TWebCheckedMenuItem
(
name
, title, checked);
137
item->
SetExec
(toggle);
138
if
(cl) item->
SetClassName
(cl->GetName());
139
Add
(item);
140
}
141
142
std::size_t
Size
()
const
{
return
fItems
.size(); }
143
144
void
PopulateObjectMenu
(
void
*obj,
TClass
*cl);
145
};
146
147
#endif
TClass.h
name
char name[80]
Definition
TGX11.cxx:110
TString.h
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition
TClass.h:80
TWebArgsMenuItem
Definition
TWebMenuItem.h:99
TWebArgsMenuItem::fArgs
std::vector< TWebMenuArgument > fArgs
Definition
TWebMenuItem.h:101
TWebArgsMenuItem::~TWebArgsMenuItem
virtual ~TWebArgsMenuItem()=default
virtual destructor need for vtable, used when vector of TMenuItem* is stored
TWebArgsMenuItem::GetArgs
std::vector< TWebMenuArgument > & GetArgs()
Definition
TWebMenuItem.h:110
TWebArgsMenuItem::TWebArgsMenuItem
TWebArgsMenuItem(const std::string &name, const std::string &title)
Definition
TWebMenuItem.h:105
TWebCheckedMenuItem
Definition
TWebMenuItem.h:58
TWebCheckedMenuItem::~TWebCheckedMenuItem
virtual ~TWebCheckedMenuItem()=default
virtual destructor need for vtable, used when vector of TMenuItem* is stored
TWebCheckedMenuItem::SetChecked
void SetChecked(bool on=true)
Set checked state for the item, default is none.
Definition
TWebMenuItem.h:72
TWebCheckedMenuItem::TWebCheckedMenuItem
TWebCheckedMenuItem(const std::string &name, const std::string &title, bool checked=false)
Create checked menu item
Definition
TWebMenuItem.h:63
TWebCheckedMenuItem::fChecked
bool fChecked
Definition
TWebMenuItem.h:60
TWebCheckedMenuItem::IsChecked
bool IsChecked() const
Definition
TWebMenuItem.h:74
TWebMenuArgument
Definition
TWebMenuItem.h:79
TWebMenuArgument::SetDefault
void SetDefault(const std::string &dflt)
Definition
TWebMenuItem.h:94
TWebMenuArgument::fTypeName
std::string fTypeName
typename
Definition
TWebMenuItem.h:83
TWebMenuArgument::fName
std::string fName
name of call argument
Definition
TWebMenuItem.h:81
TWebMenuArgument::TWebMenuArgument
TWebMenuArgument()=default
TWebMenuArgument::fTitle
std::string fTitle
title of call argument
Definition
TWebMenuItem.h:82
TWebMenuArgument::TWebMenuArgument
TWebMenuArgument(const std::string &name, const std::string &title, const std::string &typname, const std::string &dflt="")
Definition
TWebMenuItem.h:88
TWebMenuArgument::fDefault
std::string fDefault
default value
Definition
TWebMenuItem.h:84
TWebMenuItem
Class contains info for producing menu item on the JS side.
Definition
TWebMenuItem.h:30
TWebMenuItem::fClassName
std::string fClassName
Definition
TWebMenuItem.h:35
TWebMenuItem::TWebMenuItem
TWebMenuItem(const TWebMenuItem &rhs)
Definition
TWebMenuItem.h:39
TWebMenuItem::fExec
std::string fExec
Definition
TWebMenuItem.h:34
TWebMenuItem::GetExec
const std::string & GetExec() const
Returns execution string for the menu item.
Definition
TWebMenuItem.h:53
TWebMenuItem::TWebMenuItem
TWebMenuItem(const std::string &name, const std::string &title)
Definition
TWebMenuItem.h:38
TWebMenuItem::fName
std::string fName
Definition
TWebMenuItem.h:32
TWebMenuItem::SetExec
void SetExec(const std::string &exec)
Set execution string with all required arguments, which will be executed when menu item is selected
Definition
TWebMenuItem.h:44
TWebMenuItem::fTitle
std::string fTitle
Definition
TWebMenuItem.h:33
TWebMenuItem::~TWebMenuItem
virtual ~TWebMenuItem()=default
TWebMenuItem::SetClassName
void SetClassName(const std::string &clname)
Set class name, to which method belons to
Definition
TWebMenuItem.h:47
TWebMenuItem::GetName
const std::string & GetName() const
Returns menu item name.
Definition
TWebMenuItem.h:50
TWebMenuItems
Definition
TWebMenuItem.h:116
TWebMenuItems::TWebMenuItems
TWebMenuItems(const std::string &snapid)
Definition
TWebMenuItem.h:122
TWebMenuItems::Size
std::size_t Size() const
Definition
TWebMenuItem.h:142
TWebMenuItems::fId
std::string fId
object identifier
Definition
TWebMenuItem.h:118
TWebMenuItems::PopulateObjectMenu
void PopulateObjectMenu(void *obj, TClass *cl)
Definition
TWebMenuItem.cxx:19
TWebMenuItems::AddMenuItem
void AddMenuItem(const std::string &name, const std::string &title, const std::string &exec, TClass *cl=nullptr)
Definition
TWebMenuItem.h:126
TWebMenuItems::AddChkMenuItem
void AddChkMenuItem(const std::string &name, const std::string &title, bool checked, const std::string &toggle, TClass *cl=nullptr)
Definition
TWebMenuItem.h:134
TWebMenuItems::fItems
std::vector< std::unique_ptr< TWebMenuItem > > fItems
list of items in the menu
Definition
TWebMenuItem.h:119
TWebMenuItems::TWebMenuItems
TWebMenuItems()=default
TWebMenuItems::Add
void Add(TWebMenuItem *item)
Definition
TWebMenuItem.h:124
fTypeName
struct void * fTypeName
Definition
cppyy.h:9
gui
webgui6
inc
TWebMenuItem.h
ROOT v6-26 - Reference Guide Generated on Mon Sep 11 2023 21:02:31 (GVA Time) using Doxygen 1.9.8