ROOT logo
// @(#)root/base:$Id$
// Author: Nenad Buncic   08/02/96

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TContextMenu
#define ROOT_TContextMenu


////////////////////////////////////////////////////////////////////////////////
//                                                                            //
// TContextMenu                                                               //
//                                                                            //
// This class provides an interface to  context sensitive popup menus.        //
// These menus pop up when the user hits  the right mouse button,  and        //
// are destroyed when the menu pops downs.                                    //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TContextMenuImp
#include "TContextMenuImp.h"
#endif

#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

class TMethod;
class TFunction;
class TMethodArg;
class TVirtualPad;
class TObjArray;
class TBrowser;
class TToggle;
class TClassMenuItem;


class TContextMenu : public TNamed {

friend class  TContextMenuImp;

private:
   TContextMenu(const TContextMenu&);            // TContextMenu can not be copied since we do not know the actual type of the TContextMenuImp (and it can not be 'Cloned')
   TContextMenu& operator=(const TContextMenu&); // TContextMenu can not be copied since we do not know the actual type of the TContextMenuImp (and it can not be 'Cloned')
   
protected:
   TContextMenuImp *fContextMenuImp;      //!Context menu system specific implementation
   TFunction       *fSelectedMethod;      //selected method
   TObject         *fSelectedObject;      //selected object
   TObject         *fCalledObject;        //object to call
   TClassMenuItem  *fSelectedMenuItem;    //selected class menu item
   TVirtualPad     *fSelectedCanvas;      //selected canvas (if exist)
   TVirtualPad     *fSelectedPad;         //selected pad (if exist)
   TBrowser        *fBrowser;             //selected browser (if exist)

   virtual void DisplayPopUp(Int_t x, Int_t y)
      { if (fContextMenuImp) fContextMenuImp->DisplayPopup(x, y); }

private:
   TContextMenu();

public:
   TContextMenu(const char *name, const char *title = "Context sensitive popup menu");
   virtual ~TContextMenu();

   virtual void Action(TObject *object, TMethod *method);
   virtual void Action(TObject *object, TToggle *toggle);
   virtual void Action(TClassMenuItem *classmenuitem);
   void Action(TMethod *method) { Action(fSelectedObject, method); }
   void Action(TToggle *toggle) { Action(fSelectedObject, toggle); }
   virtual const char *CreateArgumentTitle(TMethodArg *argument);
   virtual const char *CreateDialogTitle(TObject *object, TFunction *method);
   virtual const char *CreatePopupTitle(TObject *object );
   virtual void Execute(const char *method,  const char *params, Int_t *error=0) { TObject::Execute(method, params, error); }
   virtual void Execute(TMethod *method, TObjArray *params, Int_t *error=0) { TObject::Execute(method, params, error); }
   virtual void Execute(TObject *object, TFunction *method, const char *params);
   virtual void Execute(TObject *object, TFunction *method, TObjArray *params);
   void Execute(const char *params) { Execute(fCalledObject, fSelectedMethod, params); }
   void Execute(TObjArray *params) { Execute(fCalledObject, fSelectedMethod, params); }
   virtual TBrowser *GetBrowser() { return fBrowser; }
   virtual TContextMenuImp *GetContextMenuImp() { return fContextMenuImp; }
   virtual TVirtualPad *GetSelectedCanvas() { return fSelectedCanvas; }
   virtual TFunction *GetSelectedMethod() { return fSelectedMethod; }
   virtual TObject *GetSelectedObject() { return fSelectedObject; }
   virtual TObject *GetCalledObject() { return fCalledObject; }
   virtual TClassMenuItem *GetSelectedMenuItem() { return fSelectedMenuItem; }
   virtual TVirtualPad *GetSelectedPad() { return fSelectedPad; }
   virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0); // Create menu from canvas
   virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b);  // Create menu from Browser
   virtual void SetCanvas(TVirtualPad *c) { fSelectedCanvas = c; }
   virtual void SetBrowser(TBrowser *b) { fBrowser = b; }
   virtual void SetMethod(TFunction *m) { fSelectedMethod = m; }
   virtual void SetCalledObject(TObject *o) { fCalledObject = o; }
   virtual void SetSelectedMenuItem(TClassMenuItem *mi) { fSelectedMenuItem = mi; }
   virtual void SetNameTitle(const char *name, const char *title) { TNamed::SetNameTitle(name, title); }
   virtual void SetObject(TObject *o) { fSelectedObject = o; }
   virtual void SetPad(TVirtualPad *p) { fSelectedPad = p; }

   ClassDef(TContextMenu,0)  //Context sensitive popup menu
};

#endif
 TContextMenu.h:1
 TContextMenu.h:2
 TContextMenu.h:3
 TContextMenu.h:4
 TContextMenu.h:5
 TContextMenu.h:6
 TContextMenu.h:7
 TContextMenu.h:8
 TContextMenu.h:9
 TContextMenu.h:10
 TContextMenu.h:11
 TContextMenu.h:12
 TContextMenu.h:13
 TContextMenu.h:14
 TContextMenu.h:15
 TContextMenu.h:16
 TContextMenu.h:17
 TContextMenu.h:18
 TContextMenu.h:19
 TContextMenu.h:20
 TContextMenu.h:21
 TContextMenu.h:22
 TContextMenu.h:23
 TContextMenu.h:24
 TContextMenu.h:25
 TContextMenu.h:26
 TContextMenu.h:27
 TContextMenu.h:28
 TContextMenu.h:29
 TContextMenu.h:30
 TContextMenu.h:31
 TContextMenu.h:32
 TContextMenu.h:33
 TContextMenu.h:34
 TContextMenu.h:35
 TContextMenu.h:36
 TContextMenu.h:37
 TContextMenu.h:38
 TContextMenu.h:39
 TContextMenu.h:40
 TContextMenu.h:41
 TContextMenu.h:42
 TContextMenu.h:43
 TContextMenu.h:44
 TContextMenu.h:45
 TContextMenu.h:46
 TContextMenu.h:47
 TContextMenu.h:48
 TContextMenu.h:49
 TContextMenu.h:50
 TContextMenu.h:51
 TContextMenu.h:52
 TContextMenu.h:53
 TContextMenu.h:54
 TContextMenu.h:55
 TContextMenu.h:56
 TContextMenu.h:57
 TContextMenu.h:58
 TContextMenu.h:59
 TContextMenu.h:60
 TContextMenu.h:61
 TContextMenu.h:62
 TContextMenu.h:63
 TContextMenu.h:64
 TContextMenu.h:65
 TContextMenu.h:66
 TContextMenu.h:67
 TContextMenu.h:68
 TContextMenu.h:69
 TContextMenu.h:70
 TContextMenu.h:71
 TContextMenu.h:72
 TContextMenu.h:73
 TContextMenu.h:74
 TContextMenu.h:75
 TContextMenu.h:76
 TContextMenu.h:77
 TContextMenu.h:78
 TContextMenu.h:79
 TContextMenu.h:80
 TContextMenu.h:81
 TContextMenu.h:82
 TContextMenu.h:83
 TContextMenu.h:84
 TContextMenu.h:85
 TContextMenu.h:86
 TContextMenu.h:87
 TContextMenu.h:88
 TContextMenu.h:89
 TContextMenu.h:90
 TContextMenu.h:91
 TContextMenu.h:92
 TContextMenu.h:93
 TContextMenu.h:94
 TContextMenu.h:95
 TContextMenu.h:96
 TContextMenu.h:97
 TContextMenu.h:98
 TContextMenu.h:99
 TContextMenu.h:100
 TContextMenu.h:101
 TContextMenu.h:102
 TContextMenu.h:103
 TContextMenu.h:104
 TContextMenu.h:105
 TContextMenu.h:106
 TContextMenu.h:107
 TContextMenu.h:108