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
13 Describes one element of the context menu associated to a class
14 The 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
20 All the standard methods of the class are described by only
21 one item. Since a complete context menu is described by a TList of
22 TClassMenuItem elements, it is possible to customize the context
23 menu of a class by removing the element "standard methods" and
24 replacing 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) {
112  TObject::operator=(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 }
TClassMenuItem::fType
EClassMenuItemType fType
Definition: TClassMenuItem.h:40
TClassMenuItem::~TClassMenuItem
virtual ~TClassMenuItem()
TClassMenuItem dtor.
Definition: TClassMenuItem.cxx:130
TClassMenuItem::fFunctionName
TString fFunctionName
Definition: TClassMenuItem.h:46
TClassMenuItem::fSelf
Bool_t fSelf
Definition: TClassMenuItem.h:42
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TClassMenuItem::fParent
TClass * fParent
Definition: TClassMenuItem.h:49
TClassMenuItem::fCalledObject
TObject * fCalledObject
Definition: TClassMenuItem.h:45
TClass.h
TList.h
TClassMenuItem::fSubMenu
TList * fSubMenu
Definition: TClassMenuItem.h:48
TClassMenuItem.h
TClassMenuItem::fTitle
TString fTitle
Definition: TClassMenuItem.h:44
TClassMenuItem::fArgs
TString fArgs
Definition: TClassMenuItem.h:47
bool
TClassMenuItem
Describes one element of the context menu associated to a class The menu item may describe.
Definition: TClassMenuItem.h:31
TClassMenuItem::kPopupUserFunction
@ kPopupUserFunction
Definition: TClassMenuItem.h:35
TClassMenuItem::operator=
TClassMenuItem & operator=(const TClassMenuItem &)
assignment operator
Definition: TClassMenuItem.cxx:109
TClass::GetMenuList
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition: TClass.cxx:4246
TClassMenuItem::TClassMenuItem
TClassMenuItem()
Default TClassMenuItem ctor.
Definition: TClassMenuItem.cxx:41
TClassMenuItem::EClassMenuItemType
EClassMenuItemType
Definition: TClassMenuItem.h:34
TObject::operator=
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.h:268
TList::Remove
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:821
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TClassMenuItem::fSelfObjectPos
Int_t fSelfObjectPos
Definition: TClassMenuItem.h:41
type
int type
Definition: TGX11.cxx:121
TClassMenuItem::fToggle
Bool_t fToggle
Definition: TClassMenuItem.h:43
int