Logo ROOT  
Reference Guide
TRootCanvas.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 15/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 
13 #ifndef ROOT_TRootCanvas
14 #define ROOT_TRootCanvas
15 
16 
17 #include "TCanvasImp.h"
18 #include "TGFrame.h"
19 
20 class TGCanvas;
21 class TGMenuBar;
22 class TGPopupMenu;
23 class TGLayoutHints;
24 class TGStatusBar;
25 class TRootContainer;
26 class TGToolBar;
27 class TGHorizontal3DLine;
28 class TGVertical3DLine;
29 class TVirtualPadEditor;
30 class TGDockableFrame;
31 class TGDNDManager;
32 class TGToolTip;
33 
34 class TRootCanvas : public TGMainFrame, public TCanvasImp {
35 
36 friend class TRootContainer;
37 
38 private:
39  TGCanvas *fCanvasWindow; ///< canvas widget
40  TRootContainer *fCanvasContainer; ///< container in canvas widget
41  TGMenuBar *fMenuBar; ///< menubar
42  TGPopupMenu *fFileMenu; ///< file menu
43  TGPopupMenu *fFileSaveMenu; ///< save cascade submenu
44  TGPopupMenu *fEditMenu; ///< edit menu
45  TGPopupMenu *fEditClearMenu; ///< clear cascade submenu
46  TGPopupMenu *fViewMenu; ///< view menu
47  TGPopupMenu *fViewWithMenu; ///< view with... cascade submenu
48  TGPopupMenu *fOptionMenu; ///< option menu
49  TGPopupMenu *fToolsMenu; ///< tools menu
50  TGPopupMenu *fHelpMenu; ///< help menu
51  TGLayoutHints *fMenuBarLayout; ///< menubar layout hints
52  TGLayoutHints *fMenuBarItemLayout; ///< layout hints for menu in menubar
53  TGLayoutHints *fMenuBarHelpLayout; ///< layout hint for help menu in menubar
54  TGLayoutHints *fCanvasLayout; ///< layout for canvas widget
55  TGStatusBar *fStatusBar; ///< statusbar widget
56  TGLayoutHints *fStatusBarLayout; ///< layout hints for statusbar
57 
58  TGCompositeFrame *fEditorFrame; ///< side frame for current pad editor
59  TGLayoutHints *fEditorLayout; ///< layout for editor frame
60  TGCompositeFrame *fMainFrame; ///< main frame containing canvas and side frame
61  TGLayoutHints *fToolBarLayout; ///< layout for toolbar widget
62  TGToolBar *fToolBar; ///< icon button toolbar
63  TGHorizontal3DLine *fToolBarSep; ///< toolbar separator
64  TGLayoutHints *fMainFrameLayout; ///< layout for main frame
65  TGVertical3DLine *fVertical1; ///< toolbar vertical separator
66  TGVertical3DLine *fVertical2; ///< toolbar vertical separator
67  TGHorizontal3DLine *fHorizontal1; ///< toolbar separator
68  TGLayoutHints *fVertical1Layout; ///< layout hints for separator
69  TGLayoutHints *fVertical2Layout; ///< layout hints for separator
70  TGLayoutHints *fHorizontal1Layout; ///< layout hints for separator
71  TGDockableFrame *fToolDock; ///< dockable frame holding the toolbar
72  TGLayoutHints *fDockLayout; ///< layout hints for dockable frame widget
73  const TGPicture *fIconPic; ///< icon picture
74  TGToolTip *fToolTip; ///< tooltip for object info
75 
76  TVirtualPadEditor *fEditor; ///< pointer to currently loaded pad editor
77  Bool_t fEmbedded; ///< true if embedded in any other frame (e.g. in the browser)
78  Int_t fCanvasID; ///< index in fWindows array of TGX11
79  Bool_t fAutoFit; ///< when true canvas container keeps same size as canvas
80  Int_t fButton; ///< currently pressed button
81 
82  TRootCanvas(const TRootCanvas&) = delete;
83  TRootCanvas& operator=(const TRootCanvas&) = delete;
84 
85  void CreateCanvas(const char *name);
86  void CreateEditor();
87 
95 
98  Int_t xroot, Int_t yroot);
99  Atom_t HandleDNDEnter(Atom_t * typelist);
101 
102 public:
103  TRootCanvas(TCanvas *c = nullptr, const char *name = "ROOT Canvas", UInt_t width = 500, UInt_t height = 300);
104  TRootCanvas(TCanvas *c, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height);
105  virtual ~TRootCanvas();
106 
107  void AdjustSize();
108  void Close();
109  void ForceUpdate() { Layout(); }
110  void FitCanvas();
111  void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
113  UInt_t GetCwidth() const;
114  UInt_t GetCheight() const;
115  void Iconify() { IconifyWindow(); }
116  Int_t InitWindow();
117  void PrintCanvas();
118  void RaiseWindow();
120  void SetWindowSize(UInt_t w, UInt_t h);
121  void SetWindowTitle(const char *newTitle);
122  void SetCanvasSize(UInt_t w, UInt_t h);
123  void SetStatusText(const char *txt = 0, Int_t partidx = 0);
124 
125  void Show() { MapRaised(); }
126  void ShowMenuBar(Bool_t show = kTRUE);
127  void ShowStatusBar(Bool_t show = kTRUE);
128  void ShowEditor(Bool_t show = kTRUE);
129  void ShowToolBar(Bool_t show = kTRUE);
130  void ShowToolTips(Bool_t show = kTRUE);
131 
132  Bool_t HasEditor() const;
133  Bool_t HasMenuBar() const;
134  Bool_t HasStatusBar() const;
135  Bool_t HasToolBar() const;
136  Bool_t HasToolTips() const;
137 
138  void Activated(Int_t id);
139 
140  TGMenuBar *GetMenuBar() const { return fMenuBar; }
142  TGStatusBar *GetStatusBar() const { return fStatusBar; }
143  TGDockableFrame *GetToolDock() const { return fToolDock; }
144 
145  // overridden from TGMainFrame
146  void CloseWindow();
147  Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
148  void ReallyDelete();
149 
150  ClassDef(TRootCanvas,0) //ROOT native GUI version of main window with menubar and drawing area
151 };
152 
153 #endif
TCanvasImp.h
c
#define c(i)
Definition: RSha256.hxx:101
TRootCanvas::SetStatusText
void SetStatusText(const char *txt=0, Int_t partidx=0)
Set text in status bar.
Definition: TRootCanvas.cxx:753
TRootCanvas::HasToolBar
Bool_t HasToolBar() const
Returns kTRUE if the tool bar is shown.
Definition: TRootCanvas.cxx:1677
TRootCanvas::fMenuBar
TGMenuBar * fMenuBar
menubar
Definition: TRootCanvas.h:41
TRootContainer
Definition: TRootCanvas.cxx:229
TRootCanvas::fCanvasID
Int_t fCanvasID
index in fWindows array of TGX11
Definition: TRootCanvas.h:78
TRootCanvas::fToolBar
TGToolBar * fToolBar
icon button toolbar
Definition: TRootCanvas.h:62
TRootCanvas::fStatusBar
TGStatusBar * fStatusBar
statusbar widget
Definition: TRootCanvas.h:55
TRootCanvas::fToolTip
TGToolTip * fToolTip
tooltip for object info
Definition: TRootCanvas.h:74
TRootCanvas::fMainFrameLayout
TGLayoutHints * fMainFrameLayout
layout for main frame
Definition: TRootCanvas.h:64
TRootCanvas::fVertical2Layout
TGLayoutHints * fVertical2Layout
layout hints for separator
Definition: TRootCanvas.h:69
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:100
TRootCanvas::fButton
Int_t fButton
currently pressed button
Definition: TRootCanvas.h:80
TGMainFrame
Defines top level windows that interact with the system Window Manager.
Definition: TGFrame.h:398
TRootCanvas::fEditorFrame
TGCompositeFrame * fEditorFrame
side frame for current pad editor
Definition: TRootCanvas.h:58
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TRootCanvas::ShowToolBar
void ShowToolBar(Bool_t show=kTRUE)
Show or hide toolbar.
Definition: TRootCanvas.cxx:1567
TRootCanvas::HandleContainerCrossing
Bool_t HandleContainerCrossing(Event_t *ev)
Handle enter/leave events. Only leave is activated at the moment.
Definition: TRootCanvas.cxx:1942
TGHorizontal3DLine
A horizontal 3D line is a line that typically separates a toolbar from the menubar.
Definition: TG3DLine.h:18
TRootCanvas::CreateEditor
void CreateEditor()
Create embedded editor.
Definition: TRootCanvas.cxx:1547
TRootCanvas::HasStatusBar
Bool_t HasStatusBar() const
Returns kTRUE if the status bar is shown.
Definition: TRootCanvas.cxx:1669
TRootCanvas::HandleContainerMotion
Bool_t HandleContainerMotion(Event_t *ev)
Handle mouse motion event in the canvas container.
Definition: TRootCanvas.cxx:1908
TRootCanvas::SetWindowTitle
void SetWindowTitle(const char *newTitle)
Change title on window.
Definition: TRootCanvas.cxx:1315
TRootCanvas::HasMenuBar
Bool_t HasMenuBar() const
Returns kTRUE if the menu bar is shown.
Definition: TRootCanvas.cxx:1661
TRootCanvas::fCanvasLayout
TGLayoutHints * fCanvasLayout
layout for canvas widget
Definition: TRootCanvas.h:54
TRootCanvas::fViewMenu
TGPopupMenu * fViewMenu
view menu
Definition: TRootCanvas.h:46
TGToolBar
A toolbar is a composite frame that contains TGPictureButtons.
Definition: TGToolBar.h:33
TRootCanvas::fToolsMenu
TGPopupMenu * fToolsMenu
tools menu
Definition: TRootCanvas.h:49
TRootCanvas::operator=
TRootCanvas & operator=(const TRootCanvas &)=delete
TRootCanvas::GetStatusBar
TGStatusBar * GetStatusBar() const
Definition: TRootCanvas.h:142
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TRootCanvas::fHorizontal1
TGHorizontal3DLine * fHorizontal1
toolbar separator
Definition: TRootCanvas.h:67
Int_t
int Int_t
Definition: RtypesCore.h:45
TRootCanvas::HasToolTips
Bool_t HasToolTips() const
Returns kTRUE if the tooltips are enabled.
Definition: TRootCanvas.cxx:1685
TRootCanvas::fDockLayout
TGLayoutHints * fDockLayout
layout hints for dockable frame widget
Definition: TRootCanvas.h:72
TRootCanvas::ForceUpdate
void ForceUpdate()
Definition: TRootCanvas.h:109
event
Definition: triangle.c:552
x
Double_t x[n]
Definition: legend1.C:17
TRootCanvas::GetWindowGeometry
UInt_t GetWindowGeometry(Int_t &x, Int_t &y, UInt_t &w, UInt_t &h)
Gets the size and position of the window containing the canvas.
Definition: TRootCanvas.cxx:739
TGToolTip
Definition: TGToolTip.h:24
TRootCanvas::AdjustSize
void AdjustSize()
Keep the same canvas size while docking/undocking toolbar.
Definition: TRootCanvas.cxx:1693
TRootCanvas::ProcessMessage
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other command generated by the user.
Definition: TRootCanvas.cxx:761
TGVertical3DLine
A vertical 3D line is a line that can be used to separate groups of widgets.
Definition: TG3DLine.h:33
TRootCanvas::fEditClearMenu
TGPopupMenu * fEditClearMenu
clear cascade submenu
Definition: TRootCanvas.h:45
TRootCanvas::fToolBarSep
TGHorizontal3DLine * fToolBarSep
toolbar separator
Definition: TRootCanvas.h:63
TRootCanvas::fAutoFit
Bool_t fAutoFit
when true canvas container keeps same size as canvas
Definition: TRootCanvas.h:79
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TRootCanvas::ShowMenuBar
void ShowMenuBar(Bool_t show=kTRUE)
Show or hide menubar.
Definition: TRootCanvas.cxx:1433
TRootCanvas::Iconify
void Iconify()
Definition: TRootCanvas.h:115
bool
TRootCanvas::fFileSaveMenu
TGPopupMenu * fFileSaveMenu
save cascade submenu
Definition: TRootCanvas.h:43
TRootCanvas::InitWindow
Int_t InitWindow()
Called by TCanvas ctor to get window indetifier.
Definition: TRootCanvas.cxx:1251
TRootCanvas::fVertical1
TGVertical3DLine * fVertical1
toolbar vertical separator
Definition: TRootCanvas.h:65
TRootCanvas::GetMenuBar
TGMenuBar * GetMenuBar() const
Definition: TRootCanvas.h:140
TRootCanvas::HandleContainerExpose
Bool_t HandleContainerExpose(Event_t *ev)
Handle expose events.
Definition: TRootCanvas.cxx:1930
TRootCanvas
This class creates a main window with menubar, scrollbars and a drawing area.
Definition: TRootCanvas.h:34
TGStatusBar
Provides a StatusBar widget.
Definition: TGStatusBar.h:21
TRootCanvas::fEditMenu
TGPopupMenu * fEditMenu
edit menu
Definition: TRootCanvas.h:44
TRootCanvas::fToolDock
TGDockableFrame * fToolDock
dockable frame holding the toolbar
Definition: TRootCanvas.h:71
TRootCanvas::fMenuBarItemLayout
TGLayoutHints * fMenuBarItemLayout
layout hints for menu in menubar
Definition: TRootCanvas.h:52
TRootCanvas::ShowEditor
void ShowEditor(Bool_t show=kTRUE)
Show or hide side frame.
Definition: TRootCanvas.cxx:1467
TRootCanvas::fHorizontal1Layout
TGLayoutHints * fHorizontal1Layout
layout hints for separator
Definition: TRootCanvas.h:70
TRootCanvas::ReallyDelete
void ReallyDelete()
Really delete the canvas and this GUI.
Definition: TRootCanvas.cxx:688
h
#define h(i)
Definition: RSha256.hxx:106
TRootCanvas::RaiseWindow
void RaiseWindow()
Put canvas window on top of the window stack.
Definition: TRootCanvas.cxx:1307
TRootCanvas::Show
void Show()
Definition: TRootCanvas.h:125
TRootCanvas::HandleDNDPosition
Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action, Int_t xroot, Int_t yroot)
Handle dragging position events.
Definition: TRootCanvas.cxx:2017
Atom_t
Handle_t Atom_t
WM token.
Definition: GuiTypes.h:37
TRootCanvas::fMainFrame
TGCompositeFrame * fMainFrame
main frame containing canvas and side frame
Definition: TRootCanvas.h:60
TRootCanvas::SetWindowPosition
void SetWindowPosition(Int_t x, Int_t y)
Set canvas position (units in pixels).
Definition: TRootCanvas.cxx:1282
TRootCanvas::ShowToolTips
void ShowToolTips(Bool_t show=kTRUE)
Enable or disable tooltip info.
Definition: TRootCanvas.cxx:1642
TGFrame.h
Long_t
long Long_t
Definition: RtypesCore.h:54
TRootCanvas::HandleContainerKey
Bool_t HandleContainerKey(Event_t *ev)
Handle keyboard events in the canvas container.
Definition: TRootCanvas.cxx:1808
TRootCanvas::fVertical1Layout
TGLayoutHints * fVertical1Layout
layout hints for separator
Definition: TRootCanvas.h:68
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
TCanvasImp
ABC describing GUI independent main window (with menubar, scrollbars and a drawing area).
Definition: TCanvasImp.h:30
TGFrame::MapRaised
virtual void MapRaised()
map raised
Definition: TGFrame.h:205
TGDockableFrame
A frame with handles that allow it to be undocked (i.e.
Definition: TGDockableFrame.h:82
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TRootCanvas::fViewWithMenu
TGPopupMenu * fViewWithMenu
view with... cascade submenu
Definition: TRootCanvas.h:47
y
Double_t y[n]
Definition: legend1.C:17
TDNDData
Drag and drop data container.
Definition: TGDNDManager.h:64
TRootCanvas::fEditor
TVirtualPadEditor * fEditor
pointer to currently loaded pad editor
Definition: TRootCanvas.h:76
TRootCanvas::fOptionMenu
TGPopupMenu * fOptionMenu
option menu
Definition: TRootCanvas.h:48
TRootCanvas::CreateCanvas
void CreateCanvas(const char *name)
Create the actual canvas.
Definition: TRootCanvas.cxx:332
unsigned int
TRootCanvas::fCanvasWindow
TGCanvas * fCanvasWindow
canvas widget
Definition: TRootCanvas.h:39
TRootCanvas::HandleDNDDrop
Bool_t HandleDNDDrop(TDNDData *data)
Handle drop events.
Definition: TRootCanvas.cxx:1958
TRootCanvas::HandleContainerButton
Bool_t HandleContainerButton(Event_t *ev)
Handle mouse button events in the canvas container.
Definition: TRootCanvas.cxx:1720
TRootCanvas::Close
void Close()
Called via TCanvasImp interface by TCanvas.
Definition: TRootCanvas.cxx:671
TGDNDManager
Definition: TGDNDManager.h:83
TRootCanvas::SetWindowSize
void SetWindowSize(UInt_t w, UInt_t h)
Set size of canvas (units in pixels).
Definition: TRootCanvas.cxx:1290
TRootCanvas::PrintCanvas
void PrintCanvas()
Print the canvas.
Definition: TRootCanvas.cxx:1342
TRootCanvas::fIconPic
const TGPicture * fIconPic
icon picture
Definition: TRootCanvas.h:73
TRootCanvas::EventInfo
void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
Display a tooltip with infos about the primitive below the cursor.
Definition: TRootCanvas.cxx:1402
TCanvas
The Canvas class.
Definition: TCanvas.h:23
TRootCanvas::fCanvasContainer
TRootContainer * fCanvasContainer
container in canvas widget
Definition: TRootCanvas.h:40
TRootCanvas::HasEditor
Bool_t HasEditor() const
Returns kTRUE if the editor is shown.
Definition: TRootCanvas.cxx:1653
TGWindow::IconifyWindow
virtual void IconifyWindow()
iconify window
Definition: TGWindow.cxx:224
TRootCanvas::HandleDNDLeave
Bool_t HandleDNDLeave()
Handle drag leave events.
Definition: TRootCanvas.cxx:2050
TRootCanvas::fStatusBarLayout
TGLayoutHints * fStatusBarLayout
layout hints for statusbar
Definition: TRootCanvas.h:56
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TRootCanvas::GetCheight
UInt_t GetCheight() const
Return height of canvas container.
Definition: TRootCanvas.cxx:730
TRootCanvas::fHelpMenu
TGPopupMenu * fHelpMenu
help menu
Definition: TRootCanvas.h:50
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGPopupMenu
This class creates a popup menu object.
Definition: TGMenu.h:110
TRootCanvas::FitCanvas
void FitCanvas()
Fit canvas container to current window size.
Definition: TRootCanvas.cxx:1325
Event_t
Event structure.
Definition: GuiTypes.h:174
name
char name[80]
Definition: TGX11.cxx:110
TRootCanvas::fEmbedded
Bool_t fEmbedded
true if embedded in any other frame (e.g. in the browser)
Definition: TRootCanvas.h:77
TRootCanvas::GetMenuBarItemLayout
TGLayoutHints * GetMenuBarItemLayout() const
Definition: TRootCanvas.h:141
TRootCanvas::fMenuBarHelpLayout
TGLayoutHints * fMenuBarHelpLayout
layout hint for help menu in menubar
Definition: TRootCanvas.h:53
TRootCanvas::TRootCanvas
TRootCanvas(const TRootCanvas &)=delete
TRootCanvas::Activated
void Activated(Int_t id)
Slot handling tab switching in the browser, to properly set the canvas and the model to the editor.
Definition: TRootCanvas.cxx:2059
TRootCanvas::fToolBarLayout
TGLayoutHints * fToolBarLayout
layout for toolbar widget
Definition: TRootCanvas.h:61
TRootCanvas::fMenuBarLayout
TGLayoutHints * fMenuBarLayout
menubar layout hints
Definition: TRootCanvas.h:51
TRootCanvas::fVertical2
TGVertical3DLine * fVertical2
toolbar vertical separator
Definition: TRootCanvas.h:66
TGMenuBar
The TGMenu.h header contains all different menu classes.
Definition: TGMenu.h:282
TRootCanvas::SetCanvasSize
void SetCanvasSize(UInt_t w, UInt_t h)
Set size of canvas container. Units in pixels.
Definition: TRootCanvas.cxx:1264
TVirtualPadEditor
Abstract base class used by ROOT graphics editor.
Definition: TVirtualPadEditor.h:27
TRootCanvas::CloseWindow
void CloseWindow()
In case window is closed via WM we get here.
Definition: TRootCanvas.cxx:714
TRootCanvas::fFileMenu
TGPopupMenu * fFileMenu
file menu
Definition: TRootCanvas.h:42
TRootCanvas::~TRootCanvas
virtual ~TRootCanvas()
Delete ROOT basic canvas.
Definition: TRootCanvas.cxx:621
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
TGCanvas
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition: TGCanvas.h:192
TRootCanvas::GetCwidth
UInt_t GetCwidth() const
Return width of canvas container.
Definition: TRootCanvas.cxx:722
TRootCanvas::ShowStatusBar
void ShowStatusBar(Bool_t show=kTRUE)
Show or hide statusbar.
Definition: TRootCanvas.cxx:1442
TGCompositeFrame::Layout
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1257
TRootCanvas::HandleContainerConfigure
Bool_t HandleContainerConfigure(Event_t *ev)
Handle configure (i.e. resize) event.
Definition: TRootCanvas.cxx:1786
TRootCanvas::GetToolDock
TGDockableFrame * GetToolDock() const
Definition: TRootCanvas.h:143
TRootCanvas::HandleDNDEnter
Atom_t HandleDNDEnter(Atom_t *typelist)
Handle drag enter events.
Definition: TRootCanvas.cxx:2033
TRootCanvas::HandleContainerDoubleClick
Bool_t HandleContainerDoubleClick(Event_t *ev)
Handle mouse button double click events in the canvas container.
Definition: TRootCanvas.cxx:1767
int
TRootCanvas::fEditorLayout
TGLayoutHints * fEditorLayout
layout for editor frame
Definition: TRootCanvas.h:59