Logo ROOT   6.08/07
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 {
43  fType = kPopupUserFunction;
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 {
70  fType = (EClassMenuItemType) type;
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),
92  fSelf(cmi.fSelf),
93  fToggle(cmi.fToggle),
94  fTitle(cmi.fTitle),
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 }
Describes one element of the context menu associated to a class The menu item may describe...
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition: TClass.cxx:4106
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TClass * fParent
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.cxx:103
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:675
TObject * fCalledObject
TString fFunctionName
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
PyObject * fType
TClassMenuItem & operator=(const TClassMenuItem &)
assignment operator
#define ClassImp(name)
Definition: Rtypes.h:279
int type
Definition: TGX11.cxx:120
Mother of all ROOT objects.
Definition: TObject.h:37
EClassMenuItemType fType
virtual ~TClassMenuItem()
TClassMenuItem dtor.
TClassMenuItem()
Default TClassMenuItem ctor.