00001 // @(#)root/meta:$Id: TClassMenuItem.cxx 26606 2008-12-02 20:36:09Z pcanal $ 00002 // Author: Damir Buskulic 23/11/2001 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 ////////////////////////////////////////////////////////////////////////// 00013 // // 00014 // Describes one element of the context menu associated to a class // 00015 // The menu item may describe // 00016 // - a separator, // 00017 // - standard list of methods i.e. the methods defined in // 00018 // the described class by a *MENU* in the comment field // 00019 // of the header, // 00020 // - a method of an external class or a global function // 00021 // All the standard methods of the class are described by only // 00022 // one item. Since a complete context menu is described by a TList of // 00023 // TClassMenuItem elements, it is possible to customize the context // 00024 // menu of a class by removing the element "standard methods" and // 00025 // replacing it by whatever one wants. // 00026 // // 00027 ////////////////////////////////////////////////////////////////////////// 00028 00029 #include "TClassMenuItem.h" 00030 #include "TList.h" 00031 #include "TClass.h" 00032 00033 00034 ClassImp(TClassMenuItem) 00035 00036 //______________________________________________________________________________ 00037 TClassMenuItem::TClassMenuItem() : TObject() 00038 { 00039 // Default TClassMenuItem ctor. TClassMenuItems are constructed in TClass 00040 // with a standard content but may be customized later 00041 // fType = 0 : external method/function 00042 // fType = 1 : separator 00043 // fType = 2 : standard methods list 00044 00045 fType = kPopupUserFunction; 00046 fSelf = 0; 00047 fToggle = 0; 00048 fCalledObject = 0; 00049 fSubMenu = 0; 00050 fParent = 0; 00051 fSelfObjectPos = -1; 00052 } 00053 00054 //______________________________________________________________________________ 00055 TClassMenuItem::TClassMenuItem(Int_t type, TClass *parentcl, 00056 const char *title, const char *functionname, TObject *obj, 00057 const char *args, Int_t selfobjposition, Bool_t self) : TObject() 00058 { 00059 // TClassMenuItem ctor. TClassMenuItems are constructed in TClass 00060 // with a standard content but may be customized later 00061 // type = 0 : external method/function 00062 // type = 1 : separator 00063 // type = 2 : standard methods list 00064 // self indicates if the object to be called is the one selected 00065 // by the popup menu 00066 // selfobjposition, if non zero, indicates the position in the arguments 00067 // list of the argument corresponding to the selected (clicked) object. 00068 // This argument in the calling method should be a TObject* 00069 // Note: It is the responsability of the caller/creator to add to to the 00070 // menu list. 00071 00072 fType = (EClassMenuItemType) type; 00073 fSelf = self; 00074 fToggle = 0; 00075 fTitle = title; 00076 fCalledObject = obj; 00077 fFunctionName = functionname; 00078 fArgs = args; 00079 fSubMenu = 0; 00080 fParent = parentcl; 00081 fSelfObjectPos = selfobjposition; 00082 } 00083 00084 //______________________________________________________________________________ 00085 TClassMenuItem::TClassMenuItem(const TClassMenuItem& cmi) : 00086 TObject(cmi), 00087 fType(cmi.fType), 00088 fSelfObjectPos(cmi.fSelfObjectPos), 00089 fSelf(cmi.fSelf), 00090 fToggle(cmi.fToggle), 00091 fTitle(cmi.fTitle), 00092 fCalledObject(cmi.fCalledObject), 00093 fFunctionName(cmi.fFunctionName), 00094 fArgs(cmi.fArgs), 00095 fSubMenu(cmi.fSubMenu), 00096 fParent(cmi.fParent) 00097 { 00098 //copy constructor 00099 // Note: It is the responsability of the caller/creator to add to to the 00100 // menu list. 00101 } 00102 00103 //______________________________________________________________________________ 00104 TClassMenuItem& TClassMenuItem::operator=(const TClassMenuItem& cmi) 00105 { 00106 //assignement operator 00107 // Note: It is the responsability of the caller/creator to add to to the 00108 // menu list. 00109 if(this!=&cmi) { 00110 TObject::operator=(cmi); 00111 fType=cmi.fType; 00112 fSelfObjectPos=cmi.fSelfObjectPos; 00113 fSelf=cmi.fSelf; 00114 fToggle=cmi.fToggle; 00115 fTitle=cmi.fTitle; 00116 fCalledObject=cmi.fCalledObject; 00117 fFunctionName=cmi.fFunctionName; 00118 fArgs=cmi.fArgs; 00119 fSubMenu=cmi.fSubMenu; 00120 fParent=cmi.fParent; 00121 } 00122 return *this; 00123 } 00124 00125 //______________________________________________________________________________ 00126 TClassMenuItem::~TClassMenuItem() 00127 { 00128 // TClassMenuItem dtor. 00129 00130 if (fParent) fParent->GetMenuList()->Remove(this); 00131 }