Logo ROOT  
Reference Guide
TClassMenuItem.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id$
2// Author: Damir Buskulic 23/11/2001
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TClassMenuItem
13Describes one element of the context menu associated to a class
14The menu item may describe
15 - a separator,
16 - standard list of methods i.e. the methods defined in
17 the described class by a *MENU* in the comment field
18 of the header,
19 - a method of an external class or a global function
20All the standard methods of the class are described by only
21one item. Since a complete context menu is described by a TList of
22TClassMenuItem elements, it is possible to customize the context
23menu of a class by removing the element "standard methods" and
24replacing it by whatever one wants.
25*/
26
27#include "TClassMenuItem.h"
28#include "TList.h"
29#include "TClass.h"
30
31
33
34////////////////////////////////////////////////////////////////////////////////
35/// Default TClassMenuItem ctor. TClassMenuItems are constructed in TClass
36/// with a standard content but may be customized later
37/// - fType = 0 : external method/function
38/// - fType = 1 : separator
39/// - fType = 2 : standard methods list
40
42{
44 fSelf = 0;
45 fToggle = 0;
46 fCalledObject = 0;
47 fSubMenu = 0;
48 fParent = 0;
49 fSelfObjectPos = -1;
50}
51
52////////////////////////////////////////////////////////////////////////////////
53/// TClassMenuItem ctor. TClassMenuItems are constructed in TClass
54/// with a standard content but may be customized later
55/// - type = 0 : external method/function
56/// - type = 1 : separator
57/// - type = 2 : standard methods list
58/// self indicates if the object to be called is the one selected
59/// by the popup menu
60/// selfobjposition, if non zero, indicates the position in the arguments
61/// list of the argument corresponding to the selected (clicked) object.
62/// This argument in the calling method should be a TObject*
63/// Note: It is the responsibility of the caller/creator to add to the
64/// menu list.
65
67 const char *title, const char *functionname, TObject *obj,
68 const char *args, Int_t selfobjposition, Bool_t self) : TObject()
69{
71 fSelf = self;
72 fToggle = 0;
73 fTitle = title;
74 fCalledObject = obj;
75 fFunctionName = functionname;
76 fArgs = args;
77 fSubMenu = 0;
78 fParent = parentcl;
79 fSelfObjectPos = selfobjposition;
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// copy constructor
84///
85/// Note: It is the responsibility of the caller/creator to add to the
86/// menu list.
87
89 TObject(cmi),
90 fType(cmi.fType),
91 fSelfObjectPos(cmi.fSelfObjectPos),
92 fSelf(cmi.fSelf),
93 fToggle(cmi.fToggle),
94 fTitle(cmi.fTitle),
95 fCalledObject(cmi.fCalledObject),
96 fFunctionName(cmi.fFunctionName),
97 fArgs(cmi.fArgs),
98 fSubMenu(cmi.fSubMenu),
99 fParent(cmi.fParent)
100{
101}
102
103////////////////////////////////////////////////////////////////////////////////
104/// assignment operator
105///
106/// Note: It is the responsibility of the caller/creator to add to the
107/// menu list.
108
110{
111 if(this!=&cmi) {
113 fType=cmi.fType;
115 fSelf=cmi.fSelf;
116 fToggle=cmi.fToggle;
117 fTitle=cmi.fTitle;
120 fArgs=cmi.fArgs;
121 fSubMenu=cmi.fSubMenu;
122 fParent=cmi.fParent;
123 }
124 return *this;
125}
126
127////////////////////////////////////////////////////////////////////////////////
128/// TClassMenuItem dtor.
129
131{
132 if (fParent) fParent->GetMenuList()->Remove(this);
133}
int Int_t
Definition: RtypesCore.h:43
bool Bool_t
Definition: RtypesCore.h:61
#define ClassImp(name)
Definition: Rtypes.h:361
int type
Definition: TGX11.cxx:120
Describes one element of the context menu associated to a class The menu item may describe.
TObject * fCalledObject
TClass * fParent
TString fFunctionName
EClassMenuItemType fType
TClassMenuItem()
Default TClassMenuItem ctor.
virtual ~TClassMenuItem()
TClassMenuItem dtor.
TClassMenuItem & operator=(const TClassMenuItem &)
assignment operator
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition: TClass.cxx:4311
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:821
Mother of all ROOT objects.
Definition: TObject.h:37
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.h:283