ROOT logo
// @(#)root/gpad:$Id$
// Author: Rene Brun   12/12/94

/*************************************************************************
 * 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_TCanvas
#define ROOT_TCanvas


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TCanvas                                                              //
//                                                                      //
// Graphics canvas.                                                     //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TPad
#include "TPad.h"
#endif

#ifndef ROOT_TAttCanvas
#include "TAttCanvas.h"
#endif

#ifndef ROOT_TVirtualX
#include "TVirtualX.h"
#endif

#ifndef ROOT_TString
#include "TString.h"
#endif

#ifndef ROOT_TCanvasImp
#include "TCanvasImp.h"
#endif

class TContextMenu;
class TControlBar;
class TBrowser;

class TCanvas : public TPad {

friend class TCanvasImp;
friend class TThread;
friend class TInterpreter;

protected:
   TAttCanvas    fCatt;            //Canvas attributes
   TString       fDISPLAY;         //Name of destination screen
   Size_t        fXsizeUser;       //User specified size of canvas along X in CM
   Size_t        fYsizeUser;       //User specified size of canvas along Y in CM
   Size_t        fXsizeReal;       //Current size of canvas along X in CM
   Size_t        fYsizeReal;       //Current size of canvas along Y in CM
   Color_t       fHighLightColor;  //Highlight color of active pad
   Int_t         fDoubleBuffer;    //Double buffer flag (0=off, 1=on)
   Int_t         fWindowTopX;      //Top X position of window (in pixels)
   Int_t         fWindowTopY;      //Top Y position of window (in pixels)
   UInt_t        fWindowWidth;     //Width of window (including borders, etc.)
   UInt_t        fWindowHeight;    //Height of window (including menubar, borders, etc.)
   UInt_t        fCw;              //Width of the canvas along X (pixels)
   UInt_t        fCh;              //Height of the canvas along Y (pixels)
   Int_t         fEvent;           //!Type of current or last handled event
   Int_t         fEventX;          //!Last X mouse position in canvas
   Int_t         fEventY;          //!Last Y mouse position in canvas
   Int_t         fCanvasID;        //!Canvas identifier
   TObject      *fSelected;        //!Currently selected object
   TObject      *fClickSelected;   //!Currently click-selected object
   Int_t         fSelectedX;       //!X of selected object
   Int_t         fSelectedY;       //!Y of selected object
   TString       fSelectedOpt;     //!Drawing option of selected object
   TPad         *fSelectedPad;     //!Pad containing currently selected object
   TPad         *fClickSelectedPad;//!Pad containing currently click-selected object
   TPad         *fPadSave;         //!Pointer to saved pad in HandleInput
   TCanvasImp   *fCanvasImp;       //!Window system specific canvas implementation
   TContextMenu *fContextMenu;     //!Context menu pointer
   Bool_t        fBatch;           //!True when in batchmode
   Bool_t        fUpdating;        //!True when Updating the canvas
   Bool_t        fRetained;        //Retain structure flag
   Bool_t        fUseGL;           //!True when rendering is with GL
   //
   TVirtualPadPainter *fPainter;   //!Canvas (pad) painter.

   static Bool_t fgIsFolder;       //Indicates if canvas can be browsed as a folder

private:
   TCanvas(const TCanvas &canvas);  // cannot copy canvas, use TObject::Clone()
   TCanvas &operator=(const TCanvas &rhs);  // idem
   void     Build();
   void     CopyPixmaps();
   void     DrawEventStatus(Int_t event, Int_t x, Int_t y, TObject *selected);
   void     RunAutoExec();

   //Initialize PadPainter.
   void     CreatePainter();

protected:
   virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
   //-- used by friend TThread class
   void Init();

public:
   // TCanvas status bits
   enum {
      kShowEventStatus  = BIT(15),
      kAutoExec         = BIT(16),
      kMenuBar          = BIT(17),
      kShowToolBar      = BIT(18),
      kShowEditor       = BIT(19),
      kMoveOpaque       = BIT(20),
      kResizeOpaque     = BIT(21),
      kIsGrayscale      = BIT(22),
      kShowToolTips     = BIT(23)
   };

   TCanvas(Bool_t build=kTRUE);
   TCanvas(const char *name, const char *title="", Int_t form=1);
   TCanvas(const char *name, const char *title, Int_t ww, Int_t wh);
   TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy,
           Int_t ww, Int_t wh);
   TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid);
   virtual ~TCanvas();
   
   //-- used by friend TThread class
   void Constructor();
   void Constructor(const char *name, const char *title, Int_t form);
   void Constructor(const char *name, const char *title, Int_t ww, Int_t wh);
   void Constructor(const char *name, const char *title,
           Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh);
   void Destructor();

   TVirtualPad      *cd(Int_t subpadnumber=0);
   virtual void      Browse(TBrowser *b);
   void              Clear(Option_t *option="");
   void              Close(Option_t *option="");
   virtual void      Delete(Option_t * = "") { MayNotUse("Delete()"); }
   void              DisconnectWidget();  // used by TCanvasImp
   virtual void      Draw(Option_t *option="");
   virtual TObject  *DrawClone(Option_t *option="") const; // *MENU*
   virtual TObject  *DrawClonePad(); // *MENU*
   virtual void      EditorBar();
   void              EmbedInto(Int_t winid, Int_t ww, Int_t wh);
   void              EnterLeave(TPad *prevSelPad, TObject *prevSelObj);
   void              FeedbackMode(Bool_t set);
   void              Flush();
   void              UseCurrentStyle(); // *MENU*
   void              ForceUpdate() { fCanvasImp->ForceUpdate(); }
   const char       *GetDISPLAY() const {return fDISPLAY.Data();}
   TContextMenu     *GetContextMenu() const {return fContextMenu;};
   Int_t             GetDoubleBuffer() const {return fDoubleBuffer;}
   Int_t             GetEvent() const { return fEvent; }
   Int_t             GetEventX() const { return fEventX; }
   Int_t             GetEventY() const { return fEventY; }
   Color_t           GetHighLightColor() const { return fHighLightColor; }
   TVirtualPad      *GetPadSave() const { return fPadSave; }
   void              ClearPadSave() { fPadSave = 0; }
   TObject          *GetSelected() const {return fSelected;}
   TObject          *GetClickSelected() const {return fClickSelected;}
   Int_t             GetSelectedX() const {return fSelectedX;}
   Int_t             GetSelectedY() const {return fSelectedY;}
   Option_t         *GetSelectedOpt() const {return fSelectedOpt.Data();}
   TVirtualPad      *GetSelectedPad() const { return fSelectedPad; }
   TVirtualPad      *GetClickSelectedPad() const { return fClickSelectedPad; }
   Bool_t            GetShowEventStatus() const { return TestBit(kShowEventStatus); }
   Bool_t            GetShowToolBar() const { return TestBit(kShowToolBar); }
   Bool_t            GetShowEditor() const { return TestBit(kShowEditor); }
   Bool_t            GetShowToolTips() const { return TestBit(kShowToolTips); }
   Bool_t            GetAutoExec() const { return TestBit(kAutoExec); }
   Size_t            GetXsizeUser() const {return fXsizeUser;}
   Size_t            GetYsizeUser() const {return fYsizeUser;}
   Size_t            GetXsizeReal() const {return fXsizeReal;}
   Size_t            GetYsizeReal() const {return fYsizeReal;}
   Int_t             GetCanvasID() const {return fCanvasID;}
   TCanvasImp       *GetCanvasImp() const {return fCanvasImp;}
   Int_t             GetWindowTopX();
   Int_t             GetWindowTopY();
   UInt_t            GetWindowWidth() const { return fWindowWidth; }
   UInt_t            GetWindowHeight() const { return fWindowHeight; }
   UInt_t            GetWw() const { return fCw; }
   UInt_t            GetWh() const { return fCh; }
   virtual void      GetCanvasPar(Int_t &wtopx, Int_t &wtopy, UInt_t &ww, UInt_t &wh)
                     {wtopx=GetWindowTopX(); wtopy=fWindowTopY; ww=fWindowWidth; wh=fWindowHeight;}
   virtual void      HandleInput(EEventType button, Int_t x, Int_t y);
   Bool_t            HasMenuBar() const { return TestBit(kMenuBar); }
   void              Iconify() { fCanvasImp->Iconify(); }
   Bool_t            IsBatch() const { return fBatch; }
   Bool_t            IsFolder() const;
   Bool_t            IsGrayscale();
   Bool_t            IsRetained() const { return fRetained; }
   virtual void      ls(Option_t *option="") const;
   void              MoveOpaque(Int_t set=1);
   Bool_t            OpaqueMoving() const { return TestBit(kMoveOpaque); }
   Bool_t            OpaqueResizing() const { return TestBit(kResizeOpaque); }
   virtual void      Paint(Option_t *option="");
   virtual TPad     *Pick(Int_t px, Int_t py, TObjLink *&pickobj) { return TPad::Pick(px, py, pickobj); }
   virtual TPad     *Pick(Int_t px, Int_t py, TObject *prevSelObj);
   virtual void      Picked(TPad *selpad, TObject *selected, Int_t event);             // *SIGNAL*
   virtual void      ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *selected); // *SIGNAL*
   virtual void      Selected(TVirtualPad *pad, TObject *obj, Int_t event);            // *SIGNAL*
   virtual void      Cleared(TVirtualPad *pad);                                        // *SIGNAL*
   virtual void      Closed();                                                         // *SIGNAL*
   void              RaiseWindow() { fCanvasImp->RaiseWindow(); }
   virtual void      Resize(Option_t *option="");
   void              ResizeOpaque(Int_t set=1);
   void              SaveSource(const char *filename="", Option_t *option="");
   void              SavePrimitive(ostream &out, Option_t *option = "");
   virtual void      SetCursor(ECursor cursor);
   virtual void      SetDoubleBuffer(Int_t mode=1);
   virtual void      SetFixedAspectRatio(Bool_t fixed = kTRUE);  // *TOGGLE*
   void              SetGrayscale(Bool_t set = kTRUE); // *TOGGLE* *GETTER=IsGrayscale
   void              SetWindowPosition(Int_t x, Int_t y) { fCanvasImp->SetWindowPosition(x, y); }
   void              SetWindowSize(UInt_t ww, UInt_t wh) { fCanvasImp->SetWindowSize(ww, wh); }
   void              SetCanvasSize(UInt_t ww, UInt_t wh); // *MENU*
   void              SetHighLightColor(Color_t col) { fHighLightColor = col; }
   void              SetSelected(TObject *obj);
   void              SetClickSelected(TObject *obj) { fClickSelected = obj; }
   void              SetSelectedPad(TPad *pad) { fSelectedPad = pad; }
   void              SetClickSelectedPad(TPad *pad) { fClickSelectedPad = pad; }
   void              Show() { fCanvasImp->Show(); }
   virtual void      Size(Float_t xsizeuser=0, Float_t ysizeuser=0);
   void              SetBatch(Bool_t batch=kTRUE);
   static  void      SetFolder(Bool_t isfolder=kTRUE);
   void              SetPadSave(TPad *pad) {fPadSave = pad;}
   void              SetRetained(Bool_t retained=kTRUE) { fRetained=retained;}
   void              SetTitle(const char *title="");
   virtual void      ToggleEventStatus();
   virtual void      ToggleAutoExec();
   virtual void      ToggleToolBar();
   virtual void      ToggleEditor();
   virtual void      ToggleToolTips();
   virtual void      Update();

   //
   Bool_t              UseGL() const { return fUseGL; }
   void                SetSupportGL(Bool_t support) {fUseGL = support;}
   TVirtualPadPainter *GetCanvasPainter();
   void                DeleteCanvasPainter();

   
   static TCanvas   *MakeDefCanvas();
   static Bool_t     SupportAlpha();

   ClassDef(TCanvas,8)  //Graphics canvas
};

#endif
 TCanvas.h:1
 TCanvas.h:2
 TCanvas.h:3
 TCanvas.h:4
 TCanvas.h:5
 TCanvas.h:6
 TCanvas.h:7
 TCanvas.h:8
 TCanvas.h:9
 TCanvas.h:10
 TCanvas.h:11
 TCanvas.h:12
 TCanvas.h:13
 TCanvas.h:14
 TCanvas.h:15
 TCanvas.h:16
 TCanvas.h:17
 TCanvas.h:18
 TCanvas.h:19
 TCanvas.h:20
 TCanvas.h:21
 TCanvas.h:22
 TCanvas.h:23
 TCanvas.h:24
 TCanvas.h:25
 TCanvas.h:26
 TCanvas.h:27
 TCanvas.h:28
 TCanvas.h:29
 TCanvas.h:30
 TCanvas.h:31
 TCanvas.h:32
 TCanvas.h:33
 TCanvas.h:34
 TCanvas.h:35
 TCanvas.h:36
 TCanvas.h:37
 TCanvas.h:38
 TCanvas.h:39
 TCanvas.h:40
 TCanvas.h:41
 TCanvas.h:42
 TCanvas.h:43
 TCanvas.h:44
 TCanvas.h:45
 TCanvas.h:46
 TCanvas.h:47
 TCanvas.h:48
 TCanvas.h:49
 TCanvas.h:50
 TCanvas.h:51
 TCanvas.h:52
 TCanvas.h:53
 TCanvas.h:54
 TCanvas.h:55
 TCanvas.h:56
 TCanvas.h:57
 TCanvas.h:58
 TCanvas.h:59
 TCanvas.h:60
 TCanvas.h:61
 TCanvas.h:62
 TCanvas.h:63
 TCanvas.h:64
 TCanvas.h:65
 TCanvas.h:66
 TCanvas.h:67
 TCanvas.h:68
 TCanvas.h:69
 TCanvas.h:70
 TCanvas.h:71
 TCanvas.h:72
 TCanvas.h:73
 TCanvas.h:74
 TCanvas.h:75
 TCanvas.h:76
 TCanvas.h:77
 TCanvas.h:78
 TCanvas.h:79
 TCanvas.h:80
 TCanvas.h:81
 TCanvas.h:82
 TCanvas.h:83
 TCanvas.h:84
 TCanvas.h:85
 TCanvas.h:86
 TCanvas.h:87
 TCanvas.h:88
 TCanvas.h:89
 TCanvas.h:90
 TCanvas.h:91
 TCanvas.h:92
 TCanvas.h:93
 TCanvas.h:94
 TCanvas.h:95
 TCanvas.h:96
 TCanvas.h:97
 TCanvas.h:98
 TCanvas.h:99
 TCanvas.h:100
 TCanvas.h:101
 TCanvas.h:102
 TCanvas.h:103
 TCanvas.h:104
 TCanvas.h:105
 TCanvas.h:106
 TCanvas.h:107
 TCanvas.h:108
 TCanvas.h:109
 TCanvas.h:110
 TCanvas.h:111
 TCanvas.h:112
 TCanvas.h:113
 TCanvas.h:114
 TCanvas.h:115
 TCanvas.h:116
 TCanvas.h:117
 TCanvas.h:118
 TCanvas.h:119
 TCanvas.h:120
 TCanvas.h:121
 TCanvas.h:122
 TCanvas.h:123
 TCanvas.h:124
 TCanvas.h:125
 TCanvas.h:126
 TCanvas.h:127
 TCanvas.h:128
 TCanvas.h:129
 TCanvas.h:130
 TCanvas.h:131
 TCanvas.h:132
 TCanvas.h:133
 TCanvas.h:134
 TCanvas.h:135
 TCanvas.h:136
 TCanvas.h:137
 TCanvas.h:138
 TCanvas.h:139
 TCanvas.h:140
 TCanvas.h:141
 TCanvas.h:142
 TCanvas.h:143
 TCanvas.h:144
 TCanvas.h:145
 TCanvas.h:146
 TCanvas.h:147
 TCanvas.h:148
 TCanvas.h:149
 TCanvas.h:150
 TCanvas.h:151
 TCanvas.h:152
 TCanvas.h:153
 TCanvas.h:154
 TCanvas.h:155
 TCanvas.h:156
 TCanvas.h:157
 TCanvas.h:158
 TCanvas.h:159
 TCanvas.h:160
 TCanvas.h:161
 TCanvas.h:162
 TCanvas.h:163
 TCanvas.h:164
 TCanvas.h:165
 TCanvas.h:166
 TCanvas.h:167
 TCanvas.h:168
 TCanvas.h:169
 TCanvas.h:170
 TCanvas.h:171
 TCanvas.h:172
 TCanvas.h:173
 TCanvas.h:174
 TCanvas.h:175
 TCanvas.h:176
 TCanvas.h:177
 TCanvas.h:178
 TCanvas.h:179
 TCanvas.h:180
 TCanvas.h:181
 TCanvas.h:182
 TCanvas.h:183
 TCanvas.h:184
 TCanvas.h:185
 TCanvas.h:186
 TCanvas.h:187
 TCanvas.h:188
 TCanvas.h:189
 TCanvas.h:190
 TCanvas.h:191
 TCanvas.h:192
 TCanvas.h:193
 TCanvas.h:194
 TCanvas.h:195
 TCanvas.h:196
 TCanvas.h:197
 TCanvas.h:198
 TCanvas.h:199
 TCanvas.h:200
 TCanvas.h:201
 TCanvas.h:202
 TCanvas.h:203
 TCanvas.h:204
 TCanvas.h:205
 TCanvas.h:206
 TCanvas.h:207
 TCanvas.h:208
 TCanvas.h:209
 TCanvas.h:210
 TCanvas.h:211
 TCanvas.h:212
 TCanvas.h:213
 TCanvas.h:214
 TCanvas.h:215
 TCanvas.h:216
 TCanvas.h:217
 TCanvas.h:218
 TCanvas.h:219
 TCanvas.h:220
 TCanvas.h:221
 TCanvas.h:222
 TCanvas.h:223
 TCanvas.h:224
 TCanvas.h:225
 TCanvas.h:226
 TCanvas.h:227
 TCanvas.h:228
 TCanvas.h:229
 TCanvas.h:230
 TCanvas.h:231
 TCanvas.h:232
 TCanvas.h:233
 TCanvas.h:234
 TCanvas.h:235
 TCanvas.h:236
 TCanvas.h:237
 TCanvas.h:238
 TCanvas.h:239
 TCanvas.h:240
 TCanvas.h:241
 TCanvas.h:242
 TCanvas.h:243
 TCanvas.h:244
 TCanvas.h:245
 TCanvas.h:246
 TCanvas.h:247
 TCanvas.h:248
 TCanvas.h:249
 TCanvas.h:250
 TCanvas.h:251
 TCanvas.h:252