Logo ROOT  
Reference Guide
No Matches
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 11/01/98
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 *************************************************************************/
12#ifndef ROOT_TGCanvas
13#define ROOT_TGCanvas
16#include "TGFrame.h"
18class TGHScrollBar;
19class TGVScrollBar;
20class TGClient;
21class TGViewPort;
22class TGCanvas;
23class TGFrameElement;
24class TGContainerTimer;
27class TGListView;
28class TGPicture;
29class TGRectangle;
33friend class TGViewPort;
34friend class TGCanvas;
37friend class TGListView;
40 TGViewPort *fViewPort; ///< container viewport
41 TGCanvas *fCanvas; ///< pointer to canvas
42 const TGWindow *fMsgWindow; ///< window handling container messages
43 TGFrameElement *fLastActiveEl; ///< last active item
44 Int_t fXp, fYp; ///< previous pointer position
45 Int_t fX0, fY0; ///< corner of rubber band box
46 Int_t fXf, fYf; ///< other corner of rubber band box
47 Bool_t fDragging; ///< true if in dragging mode
48 Int_t fTotal; ///< total items
49 Int_t fSelected; ///< number of selected items
50 TTimer *fScrollTimer; ///< autoscroll timer
51 Bool_t fOnMouseOver; ///< kTRUE when mouse pointer is over entry
52 Bool_t fLastDir; ///< direction of last search
53 Bool_t fLastCase; ///< case sensitivity of last search
54 Bool_t fLastSubstring; ///< substring search option of last search
55 TString fLastName; ///< the name of object of last search
56 TTimer *fKeyTimer; ///< keyboard timer
57 TString fKeyInput; ///< keyboard input (buffer)
58 Bool_t fKeyTimerActive;///< kTRUE - keyboard timer is active
59 Bool_t fScrolling; ///< kTRUE - when scrolling is ON
62 TGRectangle fExposedRegion; ///< exposed area
64 static TGGC *fgLineGC;
65 static const TGGC &GetLineGC();
67 void DoRedraw() override;
68 virtual void ActivateItem(TGFrameElement* el);
69 virtual void DeActivateItem(TGFrameElement* el);
70 virtual void SearchPattern();
71 virtual void OnAutoScroll();
72 virtual void RepeatSearch();
75 TGContainer(const TGContainer&) = delete;
79 TGContainer(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
80 UInt_t options = kSunkenFrame,
85 ~TGContainer() override;
87 virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
88 virtual void ClearViewPort();
89 virtual void Associate(const TGWindow *w) { fMsgWindow = w; }
90 virtual void AdjustPosition();
91 virtual void SetPagePosition(const TGPosition& pos);
92 virtual void SetPagePosition(Int_t x, Int_t y);
93 virtual void SetPageDimension(const TGDimension& dim);
94 virtual void SetPageDimension(UInt_t w, UInt_t h);
95 void RemoveAll() override;
96 virtual void RemoveItem(TGFrame *item);
97 void Layout() override;
99 TGCanvas *GetCanvas() const { return fCanvas; }
100 const TGWindow *GetMessageWindow() const { return fMsgWindow; }
101 virtual TGPosition GetPagePosition() const;
102 virtual TGDimension GetPageDimension() const;
104 virtual Int_t NumSelected() const { return fSelected; }
105 virtual Int_t NumItems() const { return fTotal; }
106 virtual TGFrameElement *FindFrame(Int_t x,Int_t y, Bool_t exclude=kTRUE);
107 virtual TGFrame *FindFrameByName(const char *name);
108 virtual TGHScrollBar *GetHScrollbar() const;
109 virtual TGVScrollBar *GetVScrollbar() const;
110 virtual void SetHsbPosition(Int_t newPos);
111 virtual void SetVsbPosition(Int_t newPos);
112 virtual void LineUp(Bool_t select = kFALSE);
113 virtual void LineDown(Bool_t select = kFALSE);
114 virtual void LineLeft(Bool_t select = kFALSE);
115 virtual void LineRight(Bool_t select = kFALSE);
116 virtual void PageUp(Bool_t select = kFALSE);
117 virtual void PageDown(Bool_t select = kFALSE);
118 virtual void Home(Bool_t select = kFALSE);
119 virtual void End(Bool_t select = kFALSE);
120 virtual void Search(Bool_t close = kTRUE);
121 virtual void *FindItem(const TString& name,
122 Bool_t direction = kTRUE,
123 Bool_t caseSensitive = kTRUE,
124 Bool_t subString = kFALSE);
126 virtual const TGFrame *GetNextSelected(void **current);
127 virtual TGFrame *GetLastActive() const { return fLastActiveEl ? fLastActiveEl->fFrame : nullptr; }
128 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
130 Bool_t HandleDNDFinished() override { fBdown = kFALSE; return kTRUE; }
131 Bool_t HandleExpose(Event_t *event) override;
132 Bool_t HandleButton(Event_t *event) override;
133 Bool_t HandleDoubleClick(Event_t *event) override;
134 Bool_t HandleMotion(Event_t *event) override;
135 Bool_t HandleKey(Event_t *event) override;
138 virtual void SetDragPixmap(const TGPicture *pic);
140 virtual void SelectAll(); //*SIGNAL*
141 virtual void UnSelectAll(); //*SIGNAL*
142 virtual void InvertSelection(); //*SIGNAL*
143 virtual void ReturnPressed(TGFrame*); //*SIGNAL*
144 virtual void SpacePressed(TGFrame*); //*SIGNAL*
145 virtual void KeyPressed(TGFrame*, UInt_t keysym, UInt_t mask); //*SIGNAL*
146 virtual void OnMouseOver(TGFrame*); //*SIGNAL*
147 virtual void CurrentChanged(Int_t x,Int_t y);//*SIGNAL*
148 virtual void CurrentChanged(TGFrame* f); //*SIGNAL*
149 virtual void Clicked(TGFrame *f, Int_t btn); //*SIGNAL*
150 virtual void DoubleClicked(TGFrame *f, Int_t btn); //*SIGNAL*
151 virtual void DoubleClicked(TGFrame *f, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
152 virtual void Clicked(TGFrame *f, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
154 ClassDefOverride(TGContainer,0) // Canvas container
161 Int_t fX0, fY0; // position of container frame in viewport
162 TGFrame *fContainer; // container frame
165 TGViewPort(const TGViewPort&) = delete;
166 TGViewPort& operator=(const TGViewPort&) = delete;
169 TGViewPort(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
170 UInt_t options = kChildFrame,
173 TGFrame *GetContainer() const { return fContainer; }
174 void SetContainer(TGFrame *f);
176 void DrawBorder() override {}
177 void Layout() override {}
178 TGDimension GetDefaultSize() const override { return TGDimension(fWidth, fHeight); }
180 virtual void SetHPos(Int_t xpos);
181 virtual void SetVPos(Int_t ypos);
182 void SetPos(Int_t xpos, Int_t ypos);
184 Int_t GetHPos() const { return fX0; }
185 Int_t GetVPos() const { return fY0; }
186 Bool_t HandleConfigureNotify(Event_t *event) override;
188 ClassDefOverride(TGViewPort,0) // Viewport through which to look at a container frame
192class TGCanvas : public TGFrame {
195 TGViewPort *fVport; ///< viewport through which we look at contents
196 TGHScrollBar *fHScrollbar; ///< horizontal scrollbar
197 TGVScrollBar *fVScrollbar; ///< vertical scrollbar
198 Int_t fScrolling; ///< flag which scrolling modes are allowed
201 TGCanvas(const TGCanvas&) = delete;
202 TGCanvas& operator=(const TGCanvas&) = delete;
205 enum { kCanvasNoScroll = 0,
209 };
211 TGCanvas(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
214 ~TGCanvas() override;
216 TGFrame *GetContainer() const { return fVport->GetContainer(); }
217 TGViewPort *GetViewPort() const { return fVport; }
221 virtual void AddFrame(TGFrame *f, TGLayoutHints *l = nullptr);
223 void MapSubwindows() override;
224 void DrawBorder() override;
225 void Layout() override;
226 virtual void ClearViewPort();
227 virtual Int_t GetHsbPosition() const;
228 virtual Int_t GetVsbPosition() const;
229 virtual void SetHsbPosition(Int_t newPos);
230 virtual void SetVsbPosition(Int_t newPos);
231 void SetScrolling(Int_t scrolling);
232 Int_t GetScrolling() const { return fScrolling; }
234 TGDimension GetDefaultSize() const override { return TGDimension(fWidth, fHeight); }
235 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
237 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
239 ClassDefOverride(TGCanvas,0) // A canvas with two scrollbars and a viewport
@ kChildFrame
Definition GuiTypes.h:379
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void xpos
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void ypos
char name[80]
Definition TGX11.cxx:110
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:222
~TGCanvas() override
Delete canvas.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a canvas widget as a C++ statement(s) on output stream out.
void DrawBorder() override
Draw canvas border.
TGFrame * GetContainer() const
Definition TGCanvas.h:216
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
TGCanvas & operator=(const TGCanvas &)=delete
virtual void SetHsbPosition(Int_t newPos)
Set position of horizontal scrollbar.
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
TGViewPort * fVport
viewport through which we look at contents
Definition TGCanvas.h:195
Int_t fScrolling
flag which scrolling modes are allowed
Definition TGCanvas.h:198
TGHScrollBar * fHScrollbar
horizontal scrollbar
Definition TGCanvas.h:196
TGVScrollBar * GetVScrollbar() const
Definition TGCanvas.h:219
TGVScrollBar * fVScrollbar
vertical scrollbar
Definition TGCanvas.h:197
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
void MapSubwindows() override
Map all canvas sub windows.
virtual Int_t GetHsbPosition() const
Get position of horizontal scrollbar.
virtual void ClearViewPort()
Clear view port and redraw content.
Int_t GetScrolling() const
Definition TGCanvas.h:232
void SetScrolling(Int_t scrolling)
Set scrolling policy.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Handle message generated by the canvas scrollbars.
@ kCanvasNoScroll
Definition TGCanvas.h:205
@ kCanvasScrollVertical
Definition TGCanvas.h:207
@ kCanvasScrollBoth
Definition TGCanvas.h:208
@ kCanvasScrollHorizontal
Definition TGCanvas.h:206
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Adding a frame to a canvas is actually adding the frame to the viewport container.
TGCanvas(const TGCanvas &)=delete
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGCanvas.h:234
void Layout() override
Create layout for canvas.
TGHScrollBar * GetHScrollbar() const
Definition TGCanvas.h:218
Window client.
Definition TGClient.h:37
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
Manages a content area.
Definition TGCanvas.h:31
TGRectangle fExposedRegion
exposed area
Definition TGCanvas.h:62
virtual void ActivateItem(TGFrameElement *el)
Activate item.
Definition TGCanvas.cxx:701
virtual void Associate(const TGWindow *w)
Definition TGCanvas.h:89
Bool_t fKeyTimerActive
kTRUE - keyboard timer is active
Definition TGCanvas.h:58
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition TGCanvas.cxx:660
Bool_t HandleKey(Event_t *event) override
The key press event handler converts a key press to some line editor action.
TGCanvas * fCanvas
pointer to canvas
Definition TGCanvas.h:41
virtual TGFrame * GetLastActive() const
Definition TGCanvas.h:127
TTimer * fScrollTimer
autoscroll timer
Definition TGCanvas.h:50
virtual void RepeatSearch()
Repeats search.
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click mouse event.
Int_t fYf
other corner of rubber band box
Definition TGCanvas.h:46
virtual void UnSelectAll()
Unselect all items in the container.
Definition TGCanvas.cxx:589
virtual void PageDown(Bool_t select=kFALSE)
Move position one page down.
virtual void LineLeft(Bool_t select=kFALSE)
Move current position one column left.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in container.
Definition TGCanvas.cxx:929
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:891
const TGWindow * fMsgWindow
window handling container messages
Definition TGCanvas.h:42
virtual TGFrameElement * FindFrame(Int_t x, Int_t y, Bool_t exclude=kTRUE)
Find frame located int container at position x,y.
TGContainer & operator=(const TGContainer &)=delete
Int_t fYp
previous pointer position
Definition TGCanvas.h:44
virtual void AdjustPosition()
Move content to position of highlighted/activated frame.
~TGContainer() override
Delete canvas container.
Definition TGCanvas.cxx:406
virtual void OnMouseOver(TGFrame *)
Signal emitted when pointer is over entry.
Definition TGCanvas.cxx:501
virtual void Clicked(TGFrame *f, Int_t btn)
Emit Clicked() signal.
Definition TGCanvas.cxx:510
virtual void InvertSelection()
Invert the selection, all selected items become unselected and vice versa.
Definition TGCanvas.cxx:614
virtual void PageUp(Bool_t select=kFALSE)
Move position one page up.
virtual void LineDown(Bool_t select=kFALSE)
Move one line down.
virtual const TGFrame * GetNextSelected(void **current)
Return the next selected item.
Definition TGCanvas.cxx:681
Bool_t HandleExpose(Event_t *event) override
Handle expose events. Do not use double buffer.
Definition TGCanvas.cxx:903
virtual void Search(Bool_t close=kTRUE)
Invokes search dialog. Looks for item with the entered name.
virtual void LineUp(Bool_t select=kFALSE)
Make current position first line in window by scrolling up.
void Layout() override
Layout container entries.
Definition TGCanvas.cxx:422
Bool_t fLastDir
direction of last search
Definition TGCanvas.h:52
Int_t fY0
corner of rubber band box
Definition TGCanvas.h:45
virtual void Home(Bool_t select=kFALSE)
Move to upper-left corner of container.
Bool_t HandleDNDFinished() override
Definition TGCanvas.h:130
virtual void KeyPressed(TGFrame *, UInt_t keysym, UInt_t mask)
Signal emitted when keyboard key pressed.
Definition TGCanvas.cxx:470
virtual void SetDragPixmap(const TGPicture *pic)
Set drag window pixmaps and hotpoint.
virtual Int_t NumSelected() const
Definition TGCanvas.h:104
const TGPicture * GetObjPicture(TGFrame *f)
Retrieve icons associated with class "name".
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Int_t fXDND
Definition TGCanvas.h:60
TGCanvas * GetCanvas() const
Definition TGCanvas.h:99
virtual void ReturnPressed(TGFrame *)
Signal emitted when Return/Enter key pressed.
Definition TGCanvas.cxx:484
virtual void SearchPattern()
Search for entry which name begins with pattern.
virtual void SetPageDimension(const TGDimension &dim)
Set page dimension.
Definition TGCanvas.cxx:782
virtual void LineRight(Bool_t select=kFALSE)
Move current position one column right.
TGContainer(const TGContainer &)=delete
Int_t fSelected
number of selected items
Definition TGCanvas.h:49
Bool_t fBdown
Definition TGCanvas.h:61
void DoRedraw() override
Redraw content of container in the viewport region.
Definition TGCanvas.cxx:800
virtual void SpacePressed(TGFrame *)
Signal emitted when space key pressed.
Definition TGCanvas.cxx:493
virtual void SetHsbPosition(Int_t newPos)
set new hor. position
Bool_t fScrolling
kTRUE - when scrolling is ON
Definition TGCanvas.h:59
Int_t fX0
Definition TGCanvas.h:45
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition TGCanvas.cxx:751
TString fLastName
the name of object of last search
Definition TGCanvas.h:55
virtual void OnAutoScroll()
Autoscroll while close to & beyond The Wall.
Int_t fXp
Definition TGCanvas.h:44
static const TGGC & GetLineGC()
Get graphics context for line drawing.
static TGGC * fgLineGC
Definition TGCanvas.h:64
Bool_t fDragging
true if in dragging mode
Definition TGCanvas.h:47
virtual void CurrentChanged(Int_t x, Int_t y)
Emit signal when current position changed.
Definition TGCanvas.cxx:434
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a region of container in viewport.
Definition TGCanvas.cxx:819
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a canvas container as a C++ statement(s) on output stream out.
virtual Int_t NumItems() const
Definition TGCanvas.h:105
TGViewPort * fViewPort
container viewport
Definition TGCanvas.h:40
virtual TGVScrollBar * GetVScrollbar() const
returns pointer to vert. scroll bar
virtual TGFrame * FindFrameByName(const char *name)
Find frame by name.
Int_t fYDND
Definition TGCanvas.h:60
virtual void * FindItem(const TString &name, Bool_t direction=kTRUE, Bool_t caseSensitive=kTRUE, Bool_t subString=kFALSE)
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events.
Bool_t fOnMouseOver
kTRUE when mouse pointer is over entry
Definition TGCanvas.h:51
Bool_t fLastCase
case sensitivity of last search
Definition TGCanvas.h:53
Int_t fTotal
total items
Definition TGCanvas.h:48
const TGWindow * GetMessageWindow() const
Definition TGCanvas.h:100
void RemoveAll() override
Remove all items from the container.
Definition TGCanvas.cxx:641
virtual void DoubleClicked(TGFrame *f, Int_t btn)
Emit DoubleClicked() signal.
Definition TGCanvas.cxx:538
virtual TGPosition GetPagePosition() const
Returns page position.
Definition TGCanvas.cxx:737
virtual void End(Bool_t select=kFALSE)
Move to the bottom-right corner of container.
Bool_t fLastSubstring
substring search option of last search
Definition TGCanvas.h:54
virtual void SetPagePosition(const TGPosition &pos)
Set page position.
Definition TGCanvas.cxx:764
virtual TGHScrollBar * GetHScrollbar() const
returns pointer to hor. scroll bar
TGFrameElement * fLastActiveEl
last active item
Definition TGCanvas.h:43
virtual void SelectAll()
Select all items in the container.
Definition TGCanvas.cxx:567
TString fKeyInput
keyboard input (buffer)
Definition TGCanvas.h:57
TTimer * fKeyTimer
keyboard timer
Definition TGCanvas.h:56
virtual void DeActivateItem(TGFrameElement *el)
DeActivate item.
Definition TGCanvas.cxx:724
Int_t fXf
Definition TGCanvas.h:46
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
UInt_t fHeight
frame height
Definition TGFrame.h:88
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
UInt_t fWidth
frame width
Definition TGFrame.h:87
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
The TGHScrollBar will generate the following event messages: kC_HSCROLL, kSB_SLIDERPOS,...
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A list view is a widget that can contain a number of items arranged in a grid or list.
Definition TGListView.h:115
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
Int_t GetHPos() const
Definition TGCanvas.h:184
void DrawBorder() override
Draw frame border.
Definition TGCanvas.h:176
Int_t GetVPos() const
Definition TGCanvas.h:185
void Layout() override
Layout the elements of the composite frame.
Definition TGCanvas.h:177
TGFrame * GetContainer() const
Definition TGCanvas.h:173
TGFrame * fContainer
Definition TGCanvas.h:162
Bool_t HandleConfigureNotify(Event_t *event) override
Handle resize events.
Definition TGCanvas.cxx:292
TGViewPort(const TGViewPort &)=delete
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGCanvas.h:178
Int_t fX0
Definition TGCanvas.h:161
void SetContainer(TGFrame *f)
Add container frame to the viewport.
Definition TGCanvas.cxx:153
virtual void SetHPos(Int_t xpos)
Moves content of container frame in horizontal direction.
Definition TGCanvas.cxx:178
virtual void SetVPos(Int_t ypos)
Moves content of container frame in vertical direction.
Definition TGCanvas.cxx:229
void SetPos(Int_t xpos, Int_t ypos)
Goto new position.
Definition TGCanvas.cxx:281
Int_t fY0
Definition TGCanvas.h:161
TGViewPort & operator=(const TGViewPort &)=delete
ROOT GUI Window base class.
Definition TGWindow.h:23
Basic string class.
Definition TString.h:139
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
TLine l
Definition textangle.C:4