File indexing completed on 2025-01-18 10:11:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TContextMenu
0013 #define ROOT_TContextMenu
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include "TNamed.h"
0027
0028 #ifdef R__LESS_INCLUDES
0029 class TContextMenuImp;
0030 #else
0031 #include "TContextMenuImp.h"
0032 #endif
0033
0034 class TMethod;
0035 class TFunction;
0036 class TMethodArg;
0037 class TVirtualPad;
0038 class TObjArray;
0039 class TBrowser;
0040 class TToggle;
0041 class TClassMenuItem;
0042
0043
0044 class TContextMenu : public TNamed {
0045
0046 friend class TContextMenuImp;
0047
0048 private:
0049 TContextMenu(const TContextMenu&) = delete;
0050 TContextMenu& operator=(const TContextMenu&) = delete;
0051
0052 protected:
0053 TContextMenuImp *fContextMenuImp;
0054 TFunction *fSelectedMethod;
0055 TObject *fSelectedObject;
0056 TObject *fCalledObject;
0057 TClassMenuItem *fSelectedMenuItem;
0058 TVirtualPad *fSelectedCanvas;
0059 TVirtualPad *fSelectedPad;
0060 TBrowser *fBrowser;
0061
0062 virtual void DisplayPopUp(Int_t x, Int_t y);
0063
0064 private:
0065 TContextMenu();
0066
0067 public:
0068 TContextMenu(const char *name, const char *title = "Context sensitive popup menu");
0069 virtual ~TContextMenu();
0070
0071 virtual void Action(TObject *object, TMethod *method);
0072 virtual void Action(TObject *object, TToggle *toggle);
0073 virtual void Action(TClassMenuItem *classmenuitem);
0074 void Action(TMethod *method) { Action(fSelectedObject, method); }
0075 void Action(TToggle *toggle) { Action(fSelectedObject, toggle); }
0076 virtual const char *CreateArgumentTitle(TMethodArg *argument);
0077 virtual const char *CreateDialogTitle(TObject *object, TFunction *method);
0078 virtual const char *CreatePopupTitle(TObject *object );
0079 void Execute(const char *method, const char *params, Int_t *error=nullptr) override { TObject::Execute(method, params, error); }
0080 void Execute(TMethod *method, TObjArray *params, Int_t *error=nullptr) override { TObject::Execute(method, params, error); }
0081 virtual void Execute(TObject *object, TFunction *method, const char *params);
0082 virtual void Execute(TObject *object, TFunction *method, TObjArray *params);
0083 void Execute(const char *params) { Execute(fCalledObject, fSelectedMethod, params); }
0084 void Execute(TObjArray *params) { Execute(fCalledObject, fSelectedMethod, params); }
0085 virtual TBrowser *GetBrowser() { return fBrowser; }
0086 virtual TContextMenuImp *GetContextMenuImp() { return fContextMenuImp; }
0087 virtual TVirtualPad *GetSelectedCanvas() { return fSelectedCanvas; }
0088 virtual TFunction *GetSelectedMethod() { return fSelectedMethod; }
0089 virtual TObject *GetSelectedObject() { return fSelectedObject; }
0090 virtual TObject *GetCalledObject() { return fCalledObject; }
0091 virtual TClassMenuItem *GetSelectedMenuItem() { return fSelectedMenuItem; }
0092 virtual TVirtualPad *GetSelectedPad() { return fSelectedPad; }
0093 virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr);
0094 virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b);
0095 virtual void SetCanvas(TVirtualPad *c) { fSelectedCanvas = c; }
0096 virtual void SetBrowser(TBrowser *b) { fBrowser = b; }
0097 virtual void SetMethod(TFunction *m) { fSelectedMethod = m; }
0098 virtual void SetCalledObject(TObject *o) { fCalledObject = o; }
0099 virtual void SetSelectedMenuItem(TClassMenuItem *mi) { fSelectedMenuItem = mi; }
0100 void SetNameTitle(const char *name, const char *title) override { TNamed::SetNameTitle(name, title); }
0101 virtual void SetObject(TObject *o) { fSelectedObject = o; }
0102 virtual void SetPad(TVirtualPad *p) { fSelectedPad = p; }
0103
0104 ClassDefOverride(TContextMenu,0)
0105 };
0106
0107 #endif