TCanvas.h

Go to the documentation of this file.
00001 // @(#)root/gpad:$Id: TCanvas.h 29403 2009-07-09 07:17:16Z brun $
00002 // Author: Rene Brun   12/12/94
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TCanvas
00013 #define ROOT_TCanvas
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TCanvas                                                              //
00019 //                                                                      //
00020 // Graphics canvas.                                                     //
00021 //                                                                      //
00022 //////////////////////////////////////////////////////////////////////////
00023 
00024 #ifndef ROOT_TPad
00025 #include "TPad.h"
00026 #endif
00027 
00028 #ifndef ROOT_TAttCanvas
00029 #include "TAttCanvas.h"
00030 #endif
00031 
00032 #ifndef ROOT_TVirtualX
00033 #include "TVirtualX.h"
00034 #endif
00035 
00036 #ifndef ROOT_TString
00037 #include "TString.h"
00038 #endif
00039 
00040 #ifndef ROOT_TCanvasImp
00041 #include "TCanvasImp.h"
00042 #endif
00043 
00044 class TContextMenu;
00045 class TControlBar;
00046 class TBrowser;
00047 
00048 class TCanvas : public TPad {
00049 
00050 friend class TCanvasImp;
00051 friend class TThread;
00052 friend class TInterpreter;
00053 
00054 protected:
00055    TAttCanvas    fCatt;            //Canvas attributes
00056    TString       fDISPLAY;         //Name of destination screen
00057    Size_t        fXsizeUser;       //User specified size of canvas along X in CM
00058    Size_t        fYsizeUser;       //User specified size of canvas along Y in CM
00059    Size_t        fXsizeReal;       //Current size of canvas along X in CM
00060    Size_t        fYsizeReal;       //Current size of canvas along Y in CM
00061    Color_t       fHighLightColor;  //Highlight color of active pad
00062    Int_t         fDoubleBuffer;    //Double buffer flag (0=off, 1=on)
00063    Int_t         fWindowTopX;      //Top X position of window (in pixels)
00064    Int_t         fWindowTopY;      //Top Y position of window (in pixels)
00065    UInt_t        fWindowWidth;     //Width of window (including borders, etc.)
00066    UInt_t        fWindowHeight;    //Height of window (including menubar, borders, etc.)
00067    UInt_t        fCw;              //Width of the canvas along X (pixels)
00068    UInt_t        fCh;              //Height of the canvas along Y (pixels)
00069    Int_t         fEvent;           //!Type of current or last handled event
00070    Int_t         fEventX;          //!Last X mouse position in canvas
00071    Int_t         fEventY;          //!Last Y mouse position in canvas
00072    Int_t         fCanvasID;        //!Canvas identifier
00073    TObject      *fSelected;        //!Currently selected object
00074    TObject      *fClickSelected;   //!Currently click-selected object
00075    Int_t         fSelectedX;       //!X of selected object
00076    Int_t         fSelectedY;       //!Y of selected object
00077    TString       fSelectedOpt;     //!Drawing option of selected object
00078    TPad         *fSelectedPad;     //!Pad containing currently selected object
00079    TPad         *fClickSelectedPad;//!Pad containing currently click-selected object
00080    TPad         *fPadSave;         //!Pointer to saved pad in HandleInput
00081    TCanvasImp   *fCanvasImp;       //!Window system specific canvas implementation
00082    TContextMenu *fContextMenu;     //!Context menu pointer
00083    Bool_t        fBatch;           //!True when in batchmode
00084    Bool_t        fUpdating;        //!True when Updating the canvas
00085    Bool_t        fRetained;        //Retain structure flag
00086    Bool_t        fUseGL;           //!True when rendering is with GL
00087    //
00088    TVirtualPadPainter *fPainter;   //!Canvas (pad) painter.
00089 
00090    static Bool_t fgIsFolder;       //Indicates if canvas can be browsed as a folder
00091 
00092 private:
00093    TCanvas(const TCanvas &canvas);  // cannot copy canvas, use TObject::Clone()
00094    TCanvas &operator=(const TCanvas &rhs);  // idem
00095    void     Build();
00096    void     CopyPixmaps();
00097    void     DrawEventStatus(Int_t event, Int_t x, Int_t y, TObject *selected);
00098    void     RunAutoExec();
00099 
00100    //Initialize PadPainter.
00101    void     CreatePainter();
00102 
00103 protected:
00104    virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
00105    //-- used by friend TThread class
00106    void Init();
00107 
00108 public:
00109    // TCanvas status bits
00110    enum {
00111       kShowEventStatus  = BIT(15),
00112       kAutoExec         = BIT(16),
00113       kMenuBar          = BIT(17),
00114       kShowToolBar      = BIT(18),
00115       kShowEditor       = BIT(19),
00116       kMoveOpaque       = BIT(20),
00117       kResizeOpaque     = BIT(21),
00118       kIsGrayscale      = BIT(22),
00119       kShowToolTips     = BIT(23)
00120    };
00121 
00122    TCanvas(Bool_t build=kTRUE);
00123    TCanvas(const char *name, const char *title="", Int_t form=1);
00124    TCanvas(const char *name, const char *title, Int_t ww, Int_t wh);
00125    TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy,
00126            Int_t ww, Int_t wh);
00127    TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid);
00128    virtual ~TCanvas();
00129    
00130    //-- used by friend TThread class
00131    void Constructor();
00132    void Constructor(const char *name, const char *title, Int_t form);
00133    void Constructor(const char *name, const char *title, Int_t ww, Int_t wh);
00134    void Constructor(const char *name, const char *title,
00135            Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
00136    void Destructor();
00137 
00138    TVirtualPad      *cd(Int_t subpadnumber=0);
00139    virtual void      Browse(TBrowser *b);
00140    void              Clear(Option_t *option="");
00141    void              Close(Option_t *option="");
00142    virtual void      Delete(Option_t * = "") { MayNotUse("Delete()"); }
00143    void              DisconnectWidget();  // used by TCanvasImp
00144    virtual void      Draw(Option_t *option="");
00145    virtual TObject  *DrawClone(Option_t *option="") const; // *MENU*
00146    virtual TObject  *DrawClonePad(); // *MENU*
00147    virtual void      EditorBar();
00148    void              EmbedInto(Int_t winid, Int_t ww, Int_t wh);
00149    void              EnterLeave(TPad *prevSelPad, TObject *prevSelObj);
00150    void              FeedbackMode(Bool_t set);
00151    void              Flush();
00152    void              UseCurrentStyle(); // *MENU*
00153    void              ForceUpdate() { fCanvasImp->ForceUpdate(); }
00154    const char       *GetDISPLAY() const {return fDISPLAY.Data();}
00155    TContextMenu     *GetContextMenu() const {return fContextMenu;};
00156    Int_t             GetDoubleBuffer() const {return fDoubleBuffer;}
00157    Int_t             GetEvent() const { return fEvent; }
00158    Int_t             GetEventX() const { return fEventX; }
00159    Int_t             GetEventY() const { return fEventY; }
00160    Color_t           GetHighLightColor() const { return fHighLightColor; }
00161    TVirtualPad      *GetPadSave() const { return fPadSave; }
00162    void              ClearPadSave() { fPadSave = 0; }
00163    TObject          *GetSelected() const {return fSelected;}
00164    TObject          *GetClickSelected() const {return fClickSelected;}
00165    Int_t             GetSelectedX() const {return fSelectedX;}
00166    Int_t             GetSelectedY() const {return fSelectedY;}
00167    Option_t         *GetSelectedOpt() const {return fSelectedOpt.Data();}
00168    TVirtualPad      *GetSelectedPad() const { return fSelectedPad; }
00169    TVirtualPad      *GetClickSelectedPad() const { return fClickSelectedPad; }
00170    Bool_t            GetShowEventStatus() const { return TestBit(kShowEventStatus); }
00171    Bool_t            GetShowToolBar() const { return TestBit(kShowToolBar); }
00172    Bool_t            GetShowEditor() const { return TestBit(kShowEditor); }
00173    Bool_t            GetShowToolTips() const { return TestBit(kShowToolTips); }
00174    Bool_t            GetAutoExec() const { return TestBit(kAutoExec); }
00175    Size_t            GetXsizeUser() const {return fXsizeUser;}
00176    Size_t            GetYsizeUser() const {return fYsizeUser;}
00177    Size_t            GetXsizeReal() const {return fXsizeReal;}
00178    Size_t            GetYsizeReal() const {return fYsizeReal;}
00179    Int_t             GetCanvasID() const {return fCanvasID;}
00180    TCanvasImp       *GetCanvasImp() const {return fCanvasImp;}
00181    Int_t             GetWindowTopX();
00182    Int_t             GetWindowTopY();
00183    UInt_t            GetWindowWidth() const { return fWindowWidth; }
00184    UInt_t            GetWindowHeight() const { return fWindowHeight; }
00185    UInt_t            GetWw() const { return fCw; }
00186    UInt_t            GetWh() const { return fCh; }
00187    virtual void      GetCanvasPar(Int_t &wtopx, Int_t &wtopy, UInt_t &ww, UInt_t &wh)
00188                      {wtopx=GetWindowTopX(); wtopy=fWindowTopY; ww=fWindowWidth; wh=fWindowHeight;}
00189    virtual void      HandleInput(EEventType button, Int_t x, Int_t y);
00190    Bool_t            HasMenuBar() const { return TestBit(kMenuBar); }
00191    void              Iconify() { fCanvasImp->Iconify(); }
00192    Bool_t            IsBatch() const { return fBatch; }
00193    Bool_t            IsFolder() const;
00194    Bool_t            IsGrayscale();
00195    Bool_t            IsRetained() const { return fRetained; }
00196    virtual void      ls(Option_t *option="") const;
00197    void              MoveOpaque(Int_t set=1);
00198    Bool_t            OpaqueMoving() const { return TestBit(kMoveOpaque); }
00199    Bool_t            OpaqueResizing() const { return TestBit(kResizeOpaque); }
00200    virtual void      Paint(Option_t *option="");
00201    virtual TPad     *Pick(Int_t px, Int_t py, TObjLink *&pickobj) { return TPad::Pick(px, py, pickobj); }
00202    virtual TPad     *Pick(Int_t px, Int_t py, TObject *prevSelObj);
00203    virtual void      Picked(TPad *selpad, TObject *selected, Int_t event);             // *SIGNAL*
00204    virtual void      ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected); // *SIGNAL*
00205    virtual void      Selected(TVirtualPad *pad, TObject *obj, Int_t event);            // *SIGNAL*
00206    virtual void      Cleared(TVirtualPad *pad);                                        // *SIGNAL*
00207    virtual void      Closed();                                                         // *SIGNAL*
00208    void              RaiseWindow() { fCanvasImp->RaiseWindow(); }
00209    virtual void      Resize(Option_t *option="");
00210    void              ResizeOpaque(Int_t set=1);
00211    void              SaveSource(const char *filename="", Option_t *option="");
00212    void              SavePrimitive(ostream &out, Option_t *option = "");
00213    virtual void      SetCursor(ECursor cursor);
00214    virtual void      SetDoubleBuffer(Int_t mode=1);
00215    virtual void      SetFixedAspectRatio(Bool_t fixed = kTRUE);  // *TOGGLE*
00216    void              SetGrayscale(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsGrayscale
00217    void              SetWindowPosition(Int_t x, Int_t y) { fCanvasImp->SetWindowPosition(x, y); }
00218    void              SetWindowSize(UInt_t ww, UInt_t wh) { fCanvasImp->SetWindowSize(ww, wh); }
00219    void              SetCanvasSize(UInt_t ww, UInt_t wh); // *MENU*
00220    void              SetHighLightColor(Color_t col) { fHighLightColor = col; }
00221    void              SetSelected(TObject *obj);
00222    void              SetClickSelected(TObject *obj) { fClickSelected = obj; }
00223    void              SetSelectedPad(TPad *pad) { fSelectedPad = pad; }
00224    void              SetClickSelectedPad(TPad *pad) { fClickSelectedPad = pad; }
00225    void              Show() { fCanvasImp->Show(); }
00226    virtual void      Size(Float_t xsizeuser=0, Float_t ysizeuser=0);
00227    void              SetBatch(Bool_t batch=kTRUE);
00228    static  void      SetFolder(Bool_t isfolder=kTRUE);
00229    void              SetPadSave(TPad *pad) {fPadSave = pad;}
00230    void              SetRetained(Bool_t retained=kTRUE) { fRetained=retained;}
00231    void              SetTitle(const char *title="");
00232    virtual void      ToggleEventStatus();
00233    virtual void      ToggleAutoExec();
00234    virtual void      ToggleToolBar();
00235    virtual void      ToggleEditor();
00236    virtual void      ToggleToolTips();
00237    virtual void      Update();
00238    //Still need this.
00239    Bool_t            UseGL() const { return fUseGL; }
00240    void              SetSupportGL(Bool_t support) {fUseGL = support;}
00241    
00242    //Name is GetPainter, not GetPadPainter
00243    //to avoid name hiding and confusion.
00244    //GetPadPainter and GetPainter are non-virtual (no need, in fact).
00245    TVirtualPadPainter *GetCanvasPainter();
00246    
00247    static TCanvas   *MakeDefCanvas();
00248 
00249    ClassDef(TCanvas,7)  //Graphics canvas
00250 };
00251 
00252 #endif

Generated on Tue Jul 5 14:13:55 2011 for ROOT_528-00b_version by  doxygen 1.5.1