Logo ROOT  
Reference Guide
TContextMenu.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Nenad Buncic 08/02/96
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 #ifndef ROOT_TContextMenu
13 #define ROOT_TContextMenu
14 
15 
16 ////////////////////////////////////////////////////////////////////////////////
17 // //
18 // TContextMenu //
19 // //
20 // This class provides an interface to context sensitive popup menus. //
21 // These menus pop up when the user hits the right mouse button, and //
22 // are destroyed when the menu pops downs. //
23 // //
24 ////////////////////////////////////////////////////////////////////////////////
25 
26 #include "TNamed.h"
27 
28 #ifdef R__LESS_INCLUDES
29 class TContextMenuImp;
30 #else
31 #include "TContextMenuImp.h"
32 #endif
33 
34 class TMethod;
35 class TFunction;
36 class TMethodArg;
37 class TVirtualPad;
38 class TObjArray;
39 class TBrowser;
40 class TToggle;
41 class TClassMenuItem;
42 
43 
44 class TContextMenu : public TNamed {
45 
46 friend class TContextMenuImp;
47 
48 private:
49  TContextMenu(const TContextMenu&) = delete; // TContextMenu can not be copied since we do not know the actual type of the TContextMenuImp (and it can not be 'Cloned')
50  TContextMenu& operator=(const TContextMenu&) = delete; // TContextMenu can not be copied since we do not know the actual type of the TContextMenuImp (and it can not be 'Cloned')
51 
52 protected:
53  TContextMenuImp *fContextMenuImp; //!Context menu system specific implementation
54  TFunction *fSelectedMethod; //selected method
55  TObject *fSelectedObject; //selected object
56  TObject *fCalledObject; //object to call
57  TClassMenuItem *fSelectedMenuItem; //selected class menu item
58  TVirtualPad *fSelectedCanvas; //selected canvas (if exist)
59  TVirtualPad *fSelectedPad; //selected pad (if exist)
60  TBrowser *fBrowser; //selected browser (if exist)
61 
62  virtual void DisplayPopUp(Int_t x, Int_t y);
63 
64 private:
66 
67 public:
68  TContextMenu(const char *name, const char *title = "Context sensitive popup menu");
69  virtual ~TContextMenu();
70 
71  virtual void Action(TObject *object, TMethod *method);
72  virtual void Action(TObject *object, TToggle *toggle);
73  virtual void Action(TClassMenuItem *classmenuitem);
74  void Action(TMethod *method) { Action(fSelectedObject, method); }
75  void Action(TToggle *toggle) { Action(fSelectedObject, toggle); }
76  virtual const char *CreateArgumentTitle(TMethodArg *argument);
77  virtual const char *CreateDialogTitle(TObject *object, TFunction *method);
78  virtual const char *CreatePopupTitle(TObject *object );
79  virtual void Execute(const char *method, const char *params, Int_t *error=nullptr) { TObject::Execute(method, params, error); }
80  virtual void Execute(TMethod *method, TObjArray *params, Int_t *error=nullptr) { TObject::Execute(method, params, error); }
81  virtual void Execute(TObject *object, TFunction *method, const char *params);
82  virtual void Execute(TObject *object, TFunction *method, TObjArray *params);
83  void Execute(const char *params) { Execute(fCalledObject, fSelectedMethod, params); }
84  void Execute(TObjArray *params) { Execute(fCalledObject, fSelectedMethod, params); }
85  virtual TBrowser *GetBrowser() { return fBrowser; }
89  virtual TObject *GetSelectedObject() { return fSelectedObject; }
90  virtual TObject *GetCalledObject() { return fCalledObject; }
92  virtual TVirtualPad *GetSelectedPad() { return fSelectedPad; }
93  virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr); // Create menu from canvas
94  virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b); // Create menu from Browser
95  virtual void SetCanvas(TVirtualPad *c) { fSelectedCanvas = c; }
96  virtual void SetBrowser(TBrowser *b) { fBrowser = b; }
97  virtual void SetMethod(TFunction *m) { fSelectedMethod = m; }
98  virtual void SetCalledObject(TObject *o) { fCalledObject = o; }
100  virtual void SetNameTitle(const char *name, const char *title) { TNamed::SetNameTitle(name, title); }
101  virtual void SetObject(TObject *o) { fSelectedObject = o; }
102  virtual void SetPad(TVirtualPad *p) { fSelectedPad = p; }
103 
104  ClassDef(TContextMenu,0) //Context sensitive popup menu
105 };
106 
107 #endif
c
#define c(i)
Definition: RSha256.hxx:101
TContextMenu::fSelectedMenuItem
TClassMenuItem * fSelectedMenuItem
Definition: TContextMenu.h:57
m
auto * m
Definition: textangle.C:8
TContextMenu::GetSelectedObject
virtual TObject * GetSelectedObject()
Definition: TContextMenu.h:89
TContextMenu::GetSelectedCanvas
virtual TVirtualPad * GetSelectedCanvas()
Definition: TContextMenu.h:87
TContextMenu::fBrowser
TBrowser * fBrowser
Definition: TContextMenu.h:60
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
TObject::Execute
virtual void Execute(const char *method, const char *params, Int_t *error=0)
Execute method on this object with the given parameter string, e.g.
Definition: TObject.cxx:279
TContextMenu::fSelectedPad
TVirtualPad * fSelectedPad
Definition: TContextMenu.h:59
TContextMenuImp
This class provides an interface to GUI independent context sensitive popup menus.
Definition: TContextMenuImp.h:33
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
TNamed::SetNameTitle
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:154
TContextMenu::GetContextMenuImp
virtual TContextMenuImp * GetContextMenuImp()
Definition: TContextMenu.h:86
TContextMenu::~TContextMenu
virtual ~TContextMenu()
Destroy a context menu.
Definition: TContextMenu.cxx:76
TContextMenu::Execute
void Execute(TObjArray *params)
Definition: TContextMenu.h:84
TContextMenu::Execute
virtual void Execute(TMethod *method, TObjArray *params, Int_t *error=nullptr)
Execute method on this object with parameters stored in the TObjArray.
Definition: TContextMenu.h:80
TContextMenu::SetCalledObject
virtual void SetCalledObject(TObject *o)
Definition: TContextMenu.h:98
TContextMenu::Execute
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
Definition: TContextMenu.h:79
TMethodArg
Each ROOT method (see TMethod) has a linked list of its arguments.
Definition: TMethodArg.h:36
TNamed.h
TContextMenu::SetCanvas
virtual void SetCanvas(TVirtualPad *c)
Definition: TContextMenu.h:95
TContextMenu::Popup
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
Popup context menu at given location in canvas c and pad p for selected object.
Definition: TContextMenu.cxx:411
TContextMenu::SetBrowser
virtual void SetBrowser(TBrowser *b)
Definition: TContextMenu.h:96
Int_t
int Int_t
Definition: RtypesCore.h:45
TContextMenu::GetCalledObject
virtual TObject * GetCalledObject()
Definition: TContextMenu.h:90
x
Double_t x[n]
Definition: legend1.C:17
TContextMenu::SetNameTitle
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TContextMenu.h:100
TContextMenu::GetSelectedMethod
virtual TFunction * GetSelectedMethod()
Definition: TContextMenu.h:88
TContextMenu::fSelectedCanvas
TVirtualPad * fSelectedCanvas
Definition: TContextMenu.h:58
b
#define b(i)
Definition: RSha256.hxx:100
TToggle
This class defines toggling facility for both - object's method or variables.
Definition: TToggle.h:47
TContextMenu
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
TContextMenu::GetSelectedMenuItem
virtual TClassMenuItem * GetSelectedMenuItem()
Definition: TContextMenu.h:91
TContextMenu::GetSelectedPad
virtual TVirtualPad * GetSelectedPad()
Definition: TContextMenu.h:92
TClassMenuItem
Describes one element of the context menu associated to a class The menu item may describe.
Definition: TClassMenuItem.h:31
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TContextMenu::SetMethod
virtual void SetMethod(TFunction *m)
Definition: TContextMenu.h:97
TContextMenu::fContextMenuImp
TContextMenuImp * fContextMenuImp
Definition: TContextMenu.h:53
TMethod
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:38
TContextMenu::CreateArgumentTitle
virtual const char * CreateArgumentTitle(TMethodArg *argument)
Create string describing argument (for use in dialog box).
Definition: TContextMenu.cxx:246
TContextMenu::Execute
void Execute(const char *params)
Definition: TContextMenu.h:83
y
Double_t y[n]
Definition: legend1.C:17
TContextMenu::TContextMenu
TContextMenu(const TContextMenu &)=delete
TContextMenu::SetObject
virtual void SetObject(TObject *o)
Definition: TContextMenu.h:101
TContextMenu::Action
void Action(TMethod *method)
Definition: TContextMenu.h:74
TContextMenu::operator=
TContextMenu & operator=(const TContextMenu &)=delete
TContextMenu::CreatePopupTitle
virtual const char * CreatePopupTitle(TObject *object)
Create title for popup menu.
Definition: TContextMenu.cxx:283
TContextMenu::DisplayPopUp
virtual void DisplayPopUp(Int_t x, Int_t y)
Display popup.
Definition: TContextMenu.cxx:310
TContextMenu::SetSelectedMenuItem
virtual void SetSelectedMenuItem(TClassMenuItem *mi)
Definition: TContextMenu.h:99
TVirtualPad
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:51
TContextMenu::Action
void Action(TToggle *toggle)
Definition: TContextMenu.h:75
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TContextMenuImp.h
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TContextMenu::Action
virtual void Action(TObject *object, TMethod *method)
Action to be performed when this menu item is selected.
Definition: TContextMenu.cxx:93
name
char name[80]
Definition: TGX11.cxx:110
TContextMenu::TContextMenu
TContextMenu()
TContextMenu::fSelectedMethod
TFunction * fSelectedMethod
Context menu system specific implementation.
Definition: TContextMenu.h:54
TContextMenu::CreateDialogTitle
virtual const char * CreateDialogTitle(TObject *object, TFunction *method)
Create title for dialog box retrieving argument values.
Definition: TContextMenu.cxx:266
TContextMenu::SetPad
virtual void SetPad(TVirtualPad *p)
Definition: TContextMenu.h:102
TContextMenu::fSelectedObject
TObject * fSelectedObject
Definition: TContextMenu.h:55
TContextMenu::GetBrowser
virtual TBrowser * GetBrowser()
Definition: TContextMenu.h:85
TContextMenu::fCalledObject
TObject * fCalledObject
Definition: TContextMenu.h:56
TFunction
Global functions class (global functions are obtained from CINT).
Definition: TFunction.h:30
int