Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:37

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 ////////////////////////////////////////////////////////////////////////////////
0017 //                                                                            //
0018 // TContextMenu                                                               //
0019 //                                                                            //
0020 // This class provides an interface to  context sensitive popup menus.        //
0021 // These menus pop up when the user hits  the right mouse button,  and        //
0022 // are destroyed when the menu pops downs.                                    //
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;            // TContextMenu can not be copied since we do not know the actual type of the TContextMenuImp (and it can not be 'Cloned')
0050    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')
0051 
0052 protected:
0053    TContextMenuImp *fContextMenuImp;      //!Context menu system specific implementation
0054    TFunction       *fSelectedMethod;      //selected method
0055    TObject         *fSelectedObject;      //selected object
0056    TObject         *fCalledObject;        //object to call
0057    TClassMenuItem  *fSelectedMenuItem;    //selected class menu item
0058    TVirtualPad     *fSelectedCanvas;      //selected canvas (if exist)
0059    TVirtualPad     *fSelectedPad;         //selected pad (if exist)
0060    TBrowser        *fBrowser;             //selected browser (if exist)
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); // Create menu from canvas
0094    virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b);  // Create menu from Browser
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)  //Context sensitive popup menu
0105 };
0106 
0107 #endif