Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:15:28

0001 // @(#)root/base:$Id$
0002 // Author: Nenad Buncic   08/02/96
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TContextMenu
0013 #define ROOT_TContextMenu
0014 
0015 
0016 #include "TNamed.h"
0017 
0018 #ifdef R__LESS_INCLUDES
0019 class TContextMenuImp;
0020 #else
0021 #include "TContextMenuImp.h"
0022 #endif
0023 
0024 class TMethod;
0025 class TFunction;
0026 class TMethodArg;
0027 class TVirtualPad;
0028 class TObjArray;
0029 class TBrowser;
0030 class TToggle;
0031 class TClassMenuItem;
0032 
0033 
0034 class TContextMenu : public TNamed {
0035 
0036 friend class  TContextMenuImp;
0037 
0038 private:
0039    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')
0040    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')
0041 
0042 protected:
0043    TContextMenuImp *fContextMenuImp;      //!Context menu system specific implementation
0044    TFunction       *fSelectedMethod;      //selected method
0045    TObject         *fSelectedObject;      //selected object
0046    TObject         *fCalledObject;        //object to call
0047    TClassMenuItem  *fSelectedMenuItem;    //selected class menu item
0048    TVirtualPad     *fSelectedCanvas;      //selected canvas (if exist)
0049    TVirtualPad     *fSelectedPad;         //selected pad (if exist)
0050    TBrowser        *fBrowser;             //selected browser (if exist)
0051 
0052    virtual void DisplayPopUp(Int_t x, Int_t y);
0053 
0054 private:
0055    TContextMenu();
0056 
0057 public:
0058    TContextMenu(const char *name, const char *title = "Context sensitive popup menu");
0059    virtual ~TContextMenu();
0060 
0061    virtual void Action(TObject *object, TMethod *method);
0062    virtual void Action(TObject *object, TToggle *toggle);
0063    virtual void Action(TClassMenuItem *classmenuitem);
0064    void Action(TMethod *method) { Action(fSelectedObject, method); }
0065    void Action(TToggle *toggle) { Action(fSelectedObject, toggle); }
0066    virtual const char *CreateArgumentTitle(TMethodArg *argument);
0067    virtual const char *CreateDialogTitle(TObject *object, TFunction *method);
0068    virtual const char *CreatePopupTitle(TObject *object );
0069    void Execute(const char *method,  const char *params, Int_t *error=nullptr) override { TObject::Execute(method, params, error); }
0070    void Execute(TMethod *method, TObjArray *params, Int_t *error=nullptr) override { TObject::Execute(method, params, error); }
0071    virtual void Execute(TObject *object, TFunction *method, const char *params);
0072    virtual void Execute(TObject *object, TFunction *method, TObjArray *params);
0073    void Execute(const char *params) { Execute(fCalledObject, fSelectedMethod, params); }
0074    void Execute(TObjArray *params) { Execute(fCalledObject, fSelectedMethod, params); }
0075    virtual TBrowser *GetBrowser() { return fBrowser; }
0076    virtual TContextMenuImp *GetContextMenuImp() { return fContextMenuImp; }
0077    virtual TVirtualPad *GetSelectedCanvas() { return fSelectedCanvas; }
0078    virtual TFunction *GetSelectedMethod() { return fSelectedMethod; }
0079    virtual TObject *GetSelectedObject() { return fSelectedObject; }
0080    virtual TObject *GetCalledObject() { return fCalledObject; }
0081    virtual TClassMenuItem *GetSelectedMenuItem() { return fSelectedMenuItem; }
0082    virtual TVirtualPad *GetSelectedPad() { return fSelectedPad; }
0083    virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr); // Create menu from canvas
0084    virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b);  // Create menu from Browser
0085    virtual void SetCanvas(TVirtualPad *c) { fSelectedCanvas = c; }
0086    virtual void SetBrowser(TBrowser *b) { fBrowser = b; }
0087    virtual void SetMethod(TFunction *m) { fSelectedMethod = m; }
0088    virtual void SetCalledObject(TObject *o) { fCalledObject = o; }
0089    virtual void SetSelectedMenuItem(TClassMenuItem *mi) { fSelectedMenuItem = mi; }
0090    void SetNameTitle(const char *name, const char *title) override { TNamed::SetNameTitle(name, title); }
0091    virtual void SetObject(TObject *o) { fSelectedObject = o; }
0092    virtual void SetPad(TVirtualPad *p) { fSelectedPad = p; }
0093 
0094    ClassDefOverride(TContextMenu,0)  //Context sensitive popup menu
0095 };
0096 
0097 #endif