library: libGpad #include "TCanvas.h"

# TCanvas

class description - source file - inheritance tree (.pdf)

## class TCanvas : public TPad

| Inheritance Chart:

`TObject`

`TAttLine`

`TAttFill`

`TAttPad`

`TQObject`

<-

`TVirtualPad`

<-

`TPad`

<-

`TCanvas`

<-

`TDialogCanvas`

<-

`TAttFillCanvas` |

`TAttLineCanvas` |

`TAttMarkerCanvas` |

`TAttTextCanvas` |

`TDrawPanelHist` |

`TFitPanel`

<-

`TFitPanelGraph` |

`TInspectCanvas` |

        private:

                       TCanvas(const TCanvas& canvas)
                  void Build()
          virtual void CopyPixmaps()
                  void DrawEventStatus(Int_t event, Int_t x, Int_t y, TObject* selected)
              TCanvas& operator=(const TCanvas& rhs)
                  void RunAutoExec()

        protected:

                  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()
          virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
                  void Init()

        public:

                               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()
                  virtual void Browse(TBrowser* b)
          virtual TVirtualPad* cd(Int_t subpadnumber = 0)
                static TClass* Class()
                  virtual void Clear(Option_t* option = "")
                  virtual void Close(Option_t* option = "")
                  virtual void Closed()
                  virtual void Delete(Option_t* = "")
                          void DisconnectWidget()
                  virtual void Draw(Option_t* option = "")
              virtual TObject* DrawClone(Option_t* option = "") const
              virtual TObject* DrawClonePad()
                  virtual void EditorBar()
                          void EnterLeave(TPad* prevSelPad, TObject* prevSelObj)
                          void FeedbackMode(Bool_t set)
                          void Flush()
                          void ForceUpdate()
                        Bool_t GetAutoExec() const
                 virtual Int_t GetCanvasID() const
                   TCanvasImp* GetCanvasImp() const
                  virtual void GetCanvasPar(Int_t& wtopx, Int_t& wtopy, UInt_t& ww, UInt_t& wh)
                 TContextMenu* GetContextMenu() const
                   const char* GetDISPLAY() const
                         Int_t GetDoubleBuffer() const
                 virtual Int_t GetEvent() const
                 virtual Int_t GetEventX() const
                 virtual Int_t GetEventY() const
               virtual Color_t GetHighLightColor() const
          virtual TVirtualPad* GetPadSave() const
              virtual TObject* GetSelected() const
                     Option_t* GetSelectedOpt() const
          virtual TVirtualPad* GetSelectedPad() const
                         Int_t GetSelectedX() const
                         Int_t GetSelectedY() const
                        Bool_t GetShowEditor() const
                        Bool_t GetShowEventStatus() const
                        Bool_t GetShowToolBar() const
                virtual UInt_t GetWh() const
                        UInt_t GetWindowHeight() const
                         Int_t GetWindowTopX()
                         Int_t GetWindowTopY()
                        UInt_t GetWindowWidth() const
                virtual UInt_t GetWw() const
                        Size_t GetXsizeReal() const
                        Size_t GetXsizeUser() const
                        Size_t GetYsizeReal() const
                        Size_t GetYsizeUser() const
                  virtual void HandleInput(EEventType button, Int_t x, Int_t y)
                        Bool_t HasMenuBar() const
                          void Iconify()
               virtual TClass* IsA() const
                virtual Bool_t IsBatch() const
                virtual Bool_t IsFolder() const
                virtual Bool_t IsRetained() const
                  virtual void ls(Option_t* option = "") const
                   static void MakeDefCanvas()
                          void MoveOpaque(Int_t set = 1)
                virtual Bool_t OpaqueMoving() const
                virtual Bool_t OpaqueResizing() const
                  virtual void Paint(Option_t* option = "")
                 virtual TPad* Pick(Int_t px, Int_t py, TObjLink*& pickobj)
                 virtual TPad* Pick(Int_t px, Int_t py, TObject* prevSelObj)
                  virtual void Picked(TPad* selpad, TObject* selected, Int_t event)
                  virtual void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject* selected)
                          void RaiseWindow()
                  virtual void Resize(Option_t* option = "")
                          void ResizeOpaque(Int_t set = 1)
                  virtual void SavePrimitive(ofstream& out, Option_t* option)
                          void SaveSource(const char* filename = "", Option_t* option = "")
                  virtual void Selected(TVirtualPad* pad, TObject* obj, Int_t event)
                  virtual void SetBatch(Bool_t batch = kTRUE)
                  virtual void SetCanvasSize(UInt_t ww, UInt_t wh)
                  virtual void SetCursor(ECursor cursor)
                  virtual void SetDoubleBuffer(Int_t mode = 1)
                  virtual void SetFixedAspectRatio(Bool_t fixed = kTRUE)
                   static void SetFolder(Bool_t isfolder = kTRUE)
                          void SetHighLightColor(Color_t col)
                          void SetRetained(Bool_t retained = kTRUE)
                  virtual void SetSelected(TObject* obj)
                          void SetSelectedPad(TPad* pad)
                  virtual void SetTitle(const char* title = "")
                          void SetWindowPosition(Int_t x, Int_t y)
                          void SetWindowSize(UInt_t ww, UInt_t wh)
                          void Show()
                  virtual void ShowMembers(TMemberInspector& insp, char* parent)
                  virtual void Size(Float_t xsizeuser = 0, Float_t ysizeuser = 0)
                  virtual void Streamer(TBuffer& b)
                          void StreamerNVirtual(TBuffer& b)
                  virtual void ToggleAutoExec()
                  virtual void ToggleEditor()
                  virtual void ToggleEventStatus()
                  virtual void ToggleToolBar()
                  virtual void Update()
                  virtual void UseCurrentStyle()

### Data Members

        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
                  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* 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 fShowEventStatus  Show event status panel
                 Bool_t fAutoExec         To auto exec the list of pad TExecs
                 Bool_t fMoveOpaque       Move objects in opaque mode
                 Bool_t fResizeOpaque     Resize objects in opaque mode
                 Bool_t fMenuBar          False if no menubar is displayed
          static Bool_t fgIsFolder        Indicates if canvas can be browsed as a folder
                 Bool_t fShowToolBar      Show toolbar
                 Bool_t fShowEditor       Show side frame or old Editor

## Class Description

       A Canvas is an area mapped to a window directly under
       the control of the display manager.
       A ROOT session may have several canvases open at any given time.

       A Canvas may be subdivided into independent graphical areas: the PADs
       A canvas has a default pad which has the name of the canvas itself.
       An example of a Canvas layout is sketched in the picture below.

       ***********************************************************************
       *          Tool Bar menus    for Canvas                               *
       ***********************************************************************
       *                                                                     *
       *  ************************************    *************************  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *              P1                  *    *        P2             *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  *                                  *    *                       *  *
       *  ************************************    *************************  *
       *                                                                     *
       ***********************************************************************

       This canvas contains two pads named P1 and P2.
       Both Canvas, P1 and P2 can be moved, grown, shrinked using the
       normal rules of the Display manager.
       A copy of a real canvas with 4 pads is shown in the picture below.

/* */

      Once objects have been drawn in a canvas, they can be edited/moved
      by pointing directly to them. The cursor shape is changed
      to suggest the type of action that one can do on this object.
      Clicking with the right mouse button on an object pops-up
      a contextmenu with a complete list of actions possible on this object.

      A graphical editor may be started from the canvas "View" menu.
      An interactive HELP is available by clicking on the HELP button
      at the top right of the canvas.

      A canvas may be automatically divided into pads via TPad::Divide.

TCanvas(Bool_t build) : TPad()

     Canvas default constructor.

void Constructor()

     Canvas default constructor

TCanvas(const char *name, Int_t ww, Int_t wh, Int_t winid)

     Create an embedded canvas, i.e. a canvas that is in a TGCanvas widget
     which is placed in a TGFrame. This ctor is only called via the
     TRootEmbeddedCanvas class.

TCanvas(const char *name, const char *title, Int_t form) : TPad()

      Create a new canvas with a predefined size form.
      If form < 0  the menubar is not shown.

      form = 1    700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
      form = 2    500x500 at 20,20
      form = 3    500x500 at 30,30
      form = 4    500x500 at 40,40
      form = 5    500x500 at 50,50

void Constructor(const char *name, const char *title, Int_t form)

      Create a new canvas with a predefined size form.
      If form < 0  the menubar is not shown.

      form = 1    700x500 at 10,10 (set by TStyle::SetCanvasDefH,W,X,Y)
      form = 2    500x500 at 20,20
      form = 3    500x500 at 30,30
      form = 4    500x500 at 40,40
      form = 5    500x500 at 50,50

TCanvas(const char *name, const char *title, Int_t ww, Int_t wh) : TPad()

      Create a new canvas at a random position.

      ww is the canvas size in pixels along X
          (if ww < 0  the menubar is not shown)
      wh is the canvas size in pixels along Y

void Constructor(const char *name, const char *title, Int_t ww, Int_t wh)

      Create a new canvas at a random position.

      ww is the canvas size in pixels along X
          (if ww < 0  the menubar is not shown)
      wh is the canvas size in pixels along Y

TCanvas(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) : TPad()

      Create a new canvas.

      wtopx,wtopy are the pixel coordinates of the top left corner of
      the canvas (if wtopx < 0) the menubar is not shown)
      ww is the canvas size in pixels along X
      wh is the canvas size in pixels along Y

void Constructor(const char *name, const char *title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh)

      Create a new canvas.

      wtopx,wtopy are the pixel coordinates of the top left corner of
      the canvas (if wtopx < 0) the menubar is not shown)
      ww is the canvas size in pixels along X
      wh is the canvas size in pixels along Y

void Init()

     Initialize the TCanvas members. Called by all constructors.

void Build()

     Build a canvas. Called by all constructors.

TCanvas(const TCanvas &) : TPad()

     Intentionally not implemented

~TCanvas()

     Canvas destructor

void Browse(TBrowser *b)

void Destructor()

     Actual canvas destructor.

TVirtualPad* cd(Int_t subpadnumber)

     Set current canvas & pad. Returns the new current pad,
     or 0 in case of failure.
     See TPad::cd() for an explanation of the parameter.

void Clear(Option_t *option)

     Remove all primitives from the canvas.
     If option "D" is specified, direct subpads are cleared but not deleted.
     This option is not recursive, i.e. pads in direct subpads are deleted.

void Closed()

     emit Closed signal

void Close(Option_t *option)

    *-*-*-*-*-*-*-*-*-*-*-*Close canvas*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                    ============
      Delete window/pads data structure

void CopyPixmaps()

    *-*-*-*-*-*-*-*-*Copy the canvas pixmap of the pad to the canvas*-*-*-*-*-*-*
    *-*              ===============================================

void Draw(Option_t *)

      Draw a canvas.
      If a canvas with the name is already on the screen, the canvas is repainted.
      This function is useful when a canvas object has been saved in a Root file.
      One can then do:
         Root > Tfile f("file.root");
         Root > canvas.Draw();

TObject* DrawClone(Option_t *option) const

     Draw a clone of this canvas
     A new canvas is created that is a clone of this canvas

TObject* DrawClonePad()

     Draw a clone of this canvas into the current pad
     In an interactive session, select the destination/current pad
     with the middle mouse button, then point to the canvas area to select
     the canvas context menu item DrawClonePad.
     Note that the original canvas may have subpads.

void DrawEventStatus(Int_t event, Int_t px, Int_t py, TObject *selected)

    *-*-*-*-*-*-*Report name and title of primitive below the cursor*-*-*-*-*-*
    *-*          ===================================================

        This function is called when the option "Event Status"
        in the canvas menu "Options" is selected.

void EditorBar()

       TVirtualPadEditor::GetPadEditor()->LoadEditor();

void EnterLeave(TPad *prevSelPad, TObject *prevSelObj)

     Generate kMouseEnter and kMouseLeave events depending on the previously
     selected object and the currently selected object. Does nothing if the
     selected object does not change.

void ExecuteEvent(Int_t event, Int_t px, Int_t py)

    *-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*
    *-*                  =========================================
      This member function must be implemented to realize the action
      corresponding to the mouse click on the object in the canvas

      Only handle mouse motion events in TCanvas, all other events are
      ignored for the time being

void FeedbackMode(Bool_t set)

    *-*-*-*-*-*-*-*-*Turn rubberband feedback mode on or off*-*-*-*-*-*-*-*-*-*-*
    *-*              =======================================

void Flush()

    *-*-*-*-*-*-*-*-*Flush canvas buffers*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*              ====================

void UseCurrentStyle()

    *-*-*-*-*-*Force a copy of current style for all objects in canvas*-*-*-*-*
    *-*        =======================================================

Int_t GetWindowTopX()

     Returns current top x position of window on screen.

Int_t GetWindowTopY()

     Returns current top y position of window on screen.

void HandleInput(EEventType event, Int_t px, Int_t py)

    *-*-*-*-*-*-*-*-*-*Handle Input Events*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                ===================
      Handle input events, like button up/down in current canvas.

Bool_t IsFolder() const

void ls(Option_t *option) const

    *-*-*-*-*-*-*-*-*-*-*-*-*-*-*List all pads*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                          =============

void MakeDefCanvas()

     Static function to build a default canvas.

void MoveOpaque(Int_t set)

    *-*-*-*-*-*-*-*-*Set option to move objects/pads in a canvas*-*-*-*-*-*-*-*
    *-*              ===========================================

      if set = 1 (default) graphics objects are moved in opaque mode
             = 0 only the outline of objects is drawn when moving them
      The option opaque produces the best effect. It requires however a
      a reasonably fast workstation or response time.

void Paint(Option_t *option)

    *-*-*-*-*-*-*-*-*Paint canvas*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*              ============

TPad* Pick(Int_t px, Int_t py, TObject *prevSelObj)

     Prepare for pick, call TPad::Pick() and when selected object
     is different from previous then emit Picked() signal.

void Picked(TPad *pad, TObject *obj, Int_t event)

     Emit Picked() signal.

void Selected(TVirtualPad *pad, TObject *obj, Int_t event)

     Emit Selected() signal.

void ProcessedEvent(Int_t event, Int_t x, Int_t y, TObject *obj)

     Emit ProcessedEvent() signal.

void Resize(Option_t *)

    *-*-*-*-*-*-*Recompute canvas parameters following a X11 Resize*-*-*-*-*-*-*
    *-*          ==================================================

void RunAutoExec()

     Execute the list of TExecs in the current pad.

void SavePrimitive(ofstream &out, Option_t *option)

     Save primitives in this canvas in C++ macro file with GUI

void SaveSource(const char *filename, Option_t *option)

    *-*-*-*-*-*-*Save primitives in this canvas as a C++ macro file*-*-*-*-*-*
    *-*          ==================================================

void SetBatch(Bool_t batch)

     Toggle batch mode. However, if the canvas is created without a window
     then batch mode always stays set.

void SetCanvasSize(UInt_t ww, UInt_t wh)

     Set Width and Height of canvas to ww and wh respectively
     If ww and/or wh are greater than the current canvas window
     a scroll bar is automatically generated.
     Use this function to zoom in a canvas and naviguate via
     the scroll bars.

void SetCursor(ECursor cursor)

    *-*-*-*-*-*-*-*-*-*-*Set cursor*-*-**-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                  ==========

void SetDoubleBuffer(Int_t mode)

    *-*-*-*-*-*-*-*-*-*-*Set Double Buffer On/Off*-*-**-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                  ========================

void SetFixedAspectRatio(Bool_t fixed)

     Fix canvas aspect ratio to current value if fixed is true.

void SetFolder(Bool_t isfolder)

     if isfolder=kTRUE, the canvas can be browsed like a folder
     by default a canvas is not browsable

void SetSelected(TObject *obj)

void SetTitle(const char *title)

    *-*-*-*-*-*-*-*-*-*-*Set Canvas title*-*-**-*-*-*-*-*-*-*-*-*-*-*-*
    *-*                  ===============

void Size(Float_t xsize, Float_t ysize)

    *-*-*-*-*-*-*Set the canvas scale in centimeters*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*          ===================================
      This information is used by PostScript to set the page size.
      xsize  = size of the canvas in centimeters along X
      ysize  = size of the canvas in centimeters along Y
       if xsize and ysize are not equal to 0, then the scale factors will
       be computed to keep the ratio ysize/xsize independently of the canvas
       size (parts of the physical canvas will be unused).

       if xsize = 0 and ysize is not zero, then xsize will be computed
          to fit to the current canvas scale. If the canvas is resized,
          a new value for xsize will be recomputed. In this case the aspect
          ratio is not preserved.

       if both xsize = 0 and ysize = 0, then the scaling is automatic.
       the largest dimension will be allocated a size of 20 centimeters.

void Streamer(TBuffer &b)

    *-*-*-*-*-*-*-*-*Stream a class object*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
    *-*              =========================================

void ToggleAutoExec()

     Toggle pad auto execution of list of TExecs.

void ToggleEventStatus()

     Toggle event statusbar.

void ToggleToolBar()

     Toggle toolbar.

void ToggleEditor()

     Toggle editor.

void Update()

     Update canvas pad buffers

void DisconnectWidget()

     Used by friend class TCanvasImp.

### Inline Functions

                 TCanvas& operator=(const TCanvas& rhs)
                     void Delete(Option_t* = "")
                     void ForceUpdate()
              const char* GetDISPLAY() const
            TContextMenu* GetContextMenu() const
                    Int_t GetDoubleBuffer() const
                    Int_t GetEvent() const
                    Int_t GetEventX() const
                    Int_t GetEventY() const
                  Color_t GetHighLightColor() const
             TVirtualPad* GetPadSave() const
                 TObject* GetSelected() const
                    Int_t GetSelectedX() const
                    Int_t GetSelectedY() const
                Option_t* GetSelectedOpt() const
             TVirtualPad* GetSelectedPad() const
                   Bool_t GetShowEventStatus() const
                   Bool_t GetShowToolBar() const
                   Bool_t GetShowEditor() const
                   Bool_t GetAutoExec() const
                   Size_t GetXsizeUser() const
                   Size_t GetYsizeUser() const
                   Size_t GetXsizeReal() const
                   Size_t GetYsizeReal() const
                    Int_t GetCanvasID() const
              TCanvasImp* GetCanvasImp() const
                   UInt_t GetWindowWidth() const
                   UInt_t GetWindowHeight() const
                   UInt_t GetWw() const
                   UInt_t GetWh() const
                     void GetCanvasPar(Int_t& wtopx, Int_t& wtopy, UInt_t& ww, UInt_t& wh)
                   Bool_t HasMenuBar() const
                     void Iconify()
                   Bool_t IsBatch() const
                   Bool_t IsRetained() const
                   Bool_t OpaqueMoving() const
                   Bool_t OpaqueResizing() const
                    TPad* Pick(Int_t px, Int_t py, TObject* prevSelObj)
                     void RaiseWindow()
                     void ResizeOpaque(Int_t set = 1)
                     void SetWindowPosition(Int_t x, Int_t y)
                     void SetWindowSize(UInt_t ww, UInt_t wh)
                     void SetHighLightColor(Color_t col)
                     void SetSelectedPad(TPad* pad)
                     void Show()
                     void SetRetained(Bool_t retained = kTRUE)
                  TClass* Class()
                  TClass* IsA() const
                     void ShowMembers(TMemberInspector& insp, char* parent)
                     void StreamerNVirtual(TBuffer& b)

Author: Rene Brun 12/12/94
Last update: root/gpad:$Name: $:$Id: TCanvas.cxx,v 1.90 2005/06/24 12:27:29 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *