Logo ROOT   6.19/01
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 "TContextMenuImp.h"
27 
28 #include "TNamed.h"
29 
30 class TMethod;
31 class TFunction;
32 class TMethodArg;
33 class TVirtualPad;
34 class TObjArray;
35 class TBrowser;
36 class TToggle;
37 class TClassMenuItem;
38 
39 
40 class TContextMenu : public TNamed {
41 
42 friend class TContextMenuImp;
43 
44 private:
45  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')
46  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')
47 
48 protected:
49  TContextMenuImp *fContextMenuImp; //!Context menu system specific implementation
50  TFunction *fSelectedMethod; //selected method
51  TObject *fSelectedObject; //selected object
52  TObject *fCalledObject; //object to call
53  TClassMenuItem *fSelectedMenuItem; //selected class menu item
54  TVirtualPad *fSelectedCanvas; //selected canvas (if exist)
55  TVirtualPad *fSelectedPad; //selected pad (if exist)
56  TBrowser *fBrowser; //selected browser (if exist)
57 
58  virtual void DisplayPopUp(Int_t x, Int_t y)
60 
61 private:
62  TContextMenu();
63 
64 public:
65  TContextMenu(const char *name, const char *title = "Context sensitive popup menu");
66  virtual ~TContextMenu();
67 
68  virtual void Action(TObject *object, TMethod *method);
69  virtual void Action(TObject *object, TToggle *toggle);
70  virtual void Action(TClassMenuItem *classmenuitem);
71  void Action(TMethod *method) { Action(fSelectedObject, method); }
72  void Action(TToggle *toggle) { Action(fSelectedObject, toggle); }
73  virtual const char *CreateArgumentTitle(TMethodArg *argument);
74  virtual const char *CreateDialogTitle(TObject *object, TFunction *method);
75  virtual const char *CreatePopupTitle(TObject *object );
76  virtual void Execute(const char *method, const char *params, Int_t *error=nullptr) { TObject::Execute(method, params, error); }
77  virtual void Execute(TMethod *method, TObjArray *params, Int_t *error=nullptr) { TObject::Execute(method, params, error); }
78  virtual void Execute(TObject *object, TFunction *method, const char *params);
79  virtual void Execute(TObject *object, TFunction *method, TObjArray *params);
80  void Execute(const char *params) { Execute(fCalledObject, fSelectedMethod, params); }
81  void Execute(TObjArray *params) { Execute(fCalledObject, fSelectedMethod, params); }
82  virtual TBrowser *GetBrowser() { return fBrowser; }
86  virtual TObject *GetSelectedObject() { return fSelectedObject; }
87  virtual TObject *GetCalledObject() { return fCalledObject; }
89  virtual TVirtualPad *GetSelectedPad() { return fSelectedPad; }
90  virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr); // Create menu from canvas
91  virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b); // Create menu from Browser
92  virtual void SetCanvas(TVirtualPad *c) { fSelectedCanvas = c; }
93  virtual void SetBrowser(TBrowser *b) { fBrowser = b; }
94  virtual void SetMethod(TFunction *m) { fSelectedMethod = m; }
95  virtual void SetCalledObject(TObject *o) { fCalledObject = o; }
97  virtual void SetNameTitle(const char *name, const char *title) { TNamed::SetNameTitle(name, title); }
98  virtual void SetObject(TObject *o) { fSelectedObject = o; }
99  virtual void SetPad(TVirtualPad *p) { fSelectedPad = p; }
100 
101  ClassDef(TContextMenu,0) //Context sensitive popup menu
102 };
103 
104 #endif
Describes one element of the context menu associated to a class The menu item may describe...
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:76
virtual TObject * GetCalledObject()
Definition: TContextMenu.h:87
An array of TObjects.
Definition: TObjArray.h:37
void Execute(const char *params)
Definition: TContextMenu.h:80
virtual TBrowser * GetBrowser()
Definition: TContextMenu.h:82
virtual TVirtualPad * GetSelectedPad()
Definition: TContextMenu.h:89
auto * m
Definition: textangle.C:8
This class defines toggling facility for both - object's method or variables.
Definition: TToggle.h:43
This class provides an interface to GUI independent context sensitive popup menus.
virtual TFunction * GetSelectedMethod()
Definition: TContextMenu.h:85
int Int_t
Definition: RtypesCore.h:41
TVirtualPad * fSelectedPad
Definition: TContextMenu.h:55
TClassMenuItem * fSelectedMenuItem
Definition: TContextMenu.h:53
Each ROOT method (see TMethod) has a linked list of its arguments.
Definition: TMethodArg.h:31
TFunction * fSelectedMethod
Context menu system specific implementation.
Definition: TContextMenu.h:50
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:154
virtual const char * CreateDialogTitle(TObject *object, TFunction *method)
Create title for dialog box retrieving argument values.
virtual void Action(TObject *object, TMethod *method)
Action to be performed when this menu item is selected.
void Action(TToggle *toggle)
Definition: TContextMenu.h:72
TObject * fSelectedObject
Definition: TContextMenu.h:51
Double_t x[n]
Definition: legend1.C:17
virtual void SetCanvas(TVirtualPad *c)
Definition: TContextMenu.h:92
#define ClassDef(name, id)
Definition: Rtypes.h:326
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:77
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void SetCalledObject(TObject *o)
Definition: TContextMenu.h:95
TObject * fCalledObject
Definition: TContextMenu.h:52
TContextMenuImp * fContextMenuImp
Definition: TContextMenu.h:49
virtual void SetBrowser(TBrowser *b)
Definition: TContextMenu.h:93
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
virtual const char * CreateArgumentTitle(TMethodArg *argument)
Create string describing argument (for use in dialog box).
virtual TObject * GetSelectedObject()
Definition: TContextMenu.h:86
TBrowser * fBrowser
Definition: TContextMenu.h:56
virtual void SetObject(TObject *o)
Definition: TContextMenu.h:98
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TContextMenu.h:97
virtual void SetSelectedMenuItem(TClassMenuItem *mi)
Definition: TContextMenu.h:96
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual const char * CreatePopupTitle(TObject *object)
Create title for popup menu.
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:277
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
virtual TVirtualPad * GetSelectedCanvas()
Definition: TContextMenu.h:84
virtual ~TContextMenu()
Destroy a context menu.
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.
virtual TClassMenuItem * GetSelectedMenuItem()
Definition: TContextMenu.h:88
virtual TContextMenuImp * GetContextMenuImp()
Definition: TContextMenu.h:83
Double_t y[n]
Definition: legend1.C:17
virtual void SetPad(TVirtualPad *p)
Definition: TContextMenu.h:99
TVirtualPad * fSelectedCanvas
Definition: TContextMenu.h:54
Mother of all ROOT objects.
Definition: TObject.h:37
Global functions class (global functions are obtained from CINT).
Definition: TFunction.h:28
void Action(TMethod *method)
Definition: TContextMenu.h:71
virtual void DisplayPopUp(Int_t x, Int_t y)
Definition: TContextMenu.h:58
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:38
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
TContextMenu & operator=(const TContextMenu &)=delete
#define c(i)
Definition: RSha256.hxx:101
virtual void DisplayPopup(Int_t x, Int_t y)
char name[80]
Definition: TGX11.cxx:109
virtual void SetMethod(TFunction *m)
Definition: TContextMenu.h:94
void Execute(TObjArray *params)
Definition: TContextMenu.h:81