ROOT logo
// @(#)root/meta:$Id: TClassMenuItem.cxx 26606 2008-12-02 20:36:09Z pcanal $
// Author: Damir Buskulic   23/11/2001

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// Describes one element of the context menu associated to a class      //
// The menu item may describe                                           //
//    - a separator,                                                    //
//    - standard list of methods i.e. the methods defined in            //
//      the described class by a *MENU* in the comment field            //
//      of the header,                                                  //
//    - a method of an external class or a global function              //
//  All the standard methods of the class are described by only         //
//  one item. Since a complete context menu is described by a TList of  //
//  TClassMenuItem elements, it is possible to customize the context    //
//  menu of a class by removing the element "standard methods" and      //
//  replacing it by whatever one wants.                                 //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "TClassMenuItem.h"
#include "TList.h"
#include "TClass.h"


ClassImp(TClassMenuItem)

//______________________________________________________________________________
TClassMenuItem::TClassMenuItem() : TObject()
{
   // Default TClassMenuItem ctor. TClassMenuItems are constructed in TClass
   // with a standard content but may be customized later
   // fType = 0 : external method/function
   // fType = 1 : separator
   // fType = 2 : standard methods list

   fType          = kPopupUserFunction;
   fSelf          = 0;
   fToggle        = 0;
   fCalledObject  = 0;
   fSubMenu       = 0;
   fParent        = 0;
   fSelfObjectPos = -1;
}

//______________________________________________________________________________
TClassMenuItem::TClassMenuItem(Int_t type, TClass *parentcl,
    const char *title, const char *functionname, TObject *obj,
    const char *args, Int_t selfobjposition, Bool_t self) : TObject()
{
   // TClassMenuItem ctor. TClassMenuItems are constructed in TClass
   // with a standard content but may be customized later
   // type = 0 : external method/function
   // type = 1 : separator
   // type = 2 : standard methods list
   // self indicates if the object to be called is the one selected
   // by the popup menu
   // selfobjposition, if non zero, indicates the position in the arguments
   // list of the argument corresponding to the selected (clicked) object.
   // This argument in the calling method should be a TObject*
   // Note: It is the responsability of the caller/creator to add to to the
   // menu list.

   fType          = (EClassMenuItemType) type;
   fSelf          = self;
   fToggle        = 0;
   fTitle         = title;
   fCalledObject  = obj;
   fFunctionName  = functionname;
   fArgs          = args;
   fSubMenu       = 0;
   fParent        = parentcl;
   fSelfObjectPos = selfobjposition;
}

//______________________________________________________________________________
TClassMenuItem::TClassMenuItem(const TClassMenuItem& cmi) :
  TObject(cmi),
  fType(cmi.fType),
  fSelfObjectPos(cmi.fSelfObjectPos),
  fSelf(cmi.fSelf),
  fToggle(cmi.fToggle),
  fTitle(cmi.fTitle),
  fCalledObject(cmi.fCalledObject),
  fFunctionName(cmi.fFunctionName),
  fArgs(cmi.fArgs),
  fSubMenu(cmi.fSubMenu),
  fParent(cmi.fParent)
{ 
   //copy constructor
   // Note: It is the responsability of the caller/creator to add to to the
   // menu list.
}

//______________________________________________________________________________
TClassMenuItem& TClassMenuItem::operator=(const TClassMenuItem& cmi) 
{
   //assignement operator
   // Note: It is the responsability of the caller/creator to add to to the
   // menu list.
   if(this!=&cmi) {
      TObject::operator=(cmi);
      fType=cmi.fType;
      fSelfObjectPos=cmi.fSelfObjectPos;
      fSelf=cmi.fSelf;
      fToggle=cmi.fToggle;
      fTitle=cmi.fTitle;
      fCalledObject=cmi.fCalledObject;
      fFunctionName=cmi.fFunctionName;
      fArgs=cmi.fArgs;
      fSubMenu=cmi.fSubMenu;
      fParent=cmi.fParent;
   } 
   return *this;
}

//______________________________________________________________________________
TClassMenuItem::~TClassMenuItem()
{
   // TClassMenuItem dtor.

   if (fParent) fParent->GetMenuList()->Remove(this);
}
 TClassMenuItem.cxx:1
 TClassMenuItem.cxx:2
 TClassMenuItem.cxx:3
 TClassMenuItem.cxx:4
 TClassMenuItem.cxx:5
 TClassMenuItem.cxx:6
 TClassMenuItem.cxx:7
 TClassMenuItem.cxx:8
 TClassMenuItem.cxx:9
 TClassMenuItem.cxx:10
 TClassMenuItem.cxx:11
 TClassMenuItem.cxx:12
 TClassMenuItem.cxx:13
 TClassMenuItem.cxx:14
 TClassMenuItem.cxx:15
 TClassMenuItem.cxx:16
 TClassMenuItem.cxx:17
 TClassMenuItem.cxx:18
 TClassMenuItem.cxx:19
 TClassMenuItem.cxx:20
 TClassMenuItem.cxx:21
 TClassMenuItem.cxx:22
 TClassMenuItem.cxx:23
 TClassMenuItem.cxx:24
 TClassMenuItem.cxx:25
 TClassMenuItem.cxx:26
 TClassMenuItem.cxx:27
 TClassMenuItem.cxx:28
 TClassMenuItem.cxx:29
 TClassMenuItem.cxx:30
 TClassMenuItem.cxx:31
 TClassMenuItem.cxx:32
 TClassMenuItem.cxx:33
 TClassMenuItem.cxx:34
 TClassMenuItem.cxx:35
 TClassMenuItem.cxx:36
 TClassMenuItem.cxx:37
 TClassMenuItem.cxx:38
 TClassMenuItem.cxx:39
 TClassMenuItem.cxx:40
 TClassMenuItem.cxx:41
 TClassMenuItem.cxx:42
 TClassMenuItem.cxx:43
 TClassMenuItem.cxx:44
 TClassMenuItem.cxx:45
 TClassMenuItem.cxx:46
 TClassMenuItem.cxx:47
 TClassMenuItem.cxx:48
 TClassMenuItem.cxx:49
 TClassMenuItem.cxx:50
 TClassMenuItem.cxx:51
 TClassMenuItem.cxx:52
 TClassMenuItem.cxx:53
 TClassMenuItem.cxx:54
 TClassMenuItem.cxx:55
 TClassMenuItem.cxx:56
 TClassMenuItem.cxx:57
 TClassMenuItem.cxx:58
 TClassMenuItem.cxx:59
 TClassMenuItem.cxx:60
 TClassMenuItem.cxx:61
 TClassMenuItem.cxx:62
 TClassMenuItem.cxx:63
 TClassMenuItem.cxx:64
 TClassMenuItem.cxx:65
 TClassMenuItem.cxx:66
 TClassMenuItem.cxx:67
 TClassMenuItem.cxx:68
 TClassMenuItem.cxx:69
 TClassMenuItem.cxx:70
 TClassMenuItem.cxx:71
 TClassMenuItem.cxx:72
 TClassMenuItem.cxx:73
 TClassMenuItem.cxx:74
 TClassMenuItem.cxx:75
 TClassMenuItem.cxx:76
 TClassMenuItem.cxx:77
 TClassMenuItem.cxx:78
 TClassMenuItem.cxx:79
 TClassMenuItem.cxx:80
 TClassMenuItem.cxx:81
 TClassMenuItem.cxx:82
 TClassMenuItem.cxx:83
 TClassMenuItem.cxx:84
 TClassMenuItem.cxx:85
 TClassMenuItem.cxx:86
 TClassMenuItem.cxx:87
 TClassMenuItem.cxx:88
 TClassMenuItem.cxx:89
 TClassMenuItem.cxx:90
 TClassMenuItem.cxx:91
 TClassMenuItem.cxx:92
 TClassMenuItem.cxx:93
 TClassMenuItem.cxx:94
 TClassMenuItem.cxx:95
 TClassMenuItem.cxx:96
 TClassMenuItem.cxx:97
 TClassMenuItem.cxx:98
 TClassMenuItem.cxx:99
 TClassMenuItem.cxx:100
 TClassMenuItem.cxx:101
 TClassMenuItem.cxx:102
 TClassMenuItem.cxx:103
 TClassMenuItem.cxx:104
 TClassMenuItem.cxx:105
 TClassMenuItem.cxx:106
 TClassMenuItem.cxx:107
 TClassMenuItem.cxx:108
 TClassMenuItem.cxx:109
 TClassMenuItem.cxx:110
 TClassMenuItem.cxx:111
 TClassMenuItem.cxx:112
 TClassMenuItem.cxx:113
 TClassMenuItem.cxx:114
 TClassMenuItem.cxx:115
 TClassMenuItem.cxx:116
 TClassMenuItem.cxx:117
 TClassMenuItem.cxx:118
 TClassMenuItem.cxx:119
 TClassMenuItem.cxx:120
 TClassMenuItem.cxx:121
 TClassMenuItem.cxx:122
 TClassMenuItem.cxx:123
 TClassMenuItem.cxx:124
 TClassMenuItem.cxx:125
 TClassMenuItem.cxx:126
 TClassMenuItem.cxx:127
 TClassMenuItem.cxx:128
 TClassMenuItem.cxx:129
 TClassMenuItem.cxx:130
 TClassMenuItem.cxx:131