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
17// //
18// TGCanvas and TGViewPort and TGContainer //
19// //
20// A TGCanvas is a frame containing two scrollbars (horizontal and //
21// vertical) and a viewport. The viewport acts as the window through //
22// which we look at the contents of the container frame. //
23// //
26#include "TGFrame.h"
28class TGHScrollBar;
29class TGVScrollBar;
30class TGClient;
31class TGViewPort;
32class TGCanvas;
33class TGFrameElement;
34class TGContainerTimer;
35class TGContainerKeyboardTimer;
36class TGContainerScrollTimer;
37class TGListView;
38class TGPicture;
39class TGRectangle;
43friend class TGViewPort;
44friend class TGCanvas;
47friend class TGListView;
50 TGViewPort *fViewPort; // container viewport
51 TGCanvas *fCanvas; // pointer to canvas
52 const TGWindow *fMsgWindow; // window handling container messages
53 TGFrameElement *fLastActiveEl; // last active item
54 Int_t fXp, fYp; // previous pointer position
55 Int_t fX0, fY0; // corner of rubber band box
56 Int_t fXf, fYf; // other corner of rubber band box
57 Bool_t fDragging; // true if in dragging mode
58 Int_t fTotal; // total items
59 Int_t fSelected; // number of selected items
60 TTimer *fScrollTimer; // autoscroll timer
61 Bool_t fOnMouseOver; // kTRUE when mouse pointer is over entry
62 Bool_t fLastDir; // direction of last search
63 Bool_t fLastCase; // case sensetivity of last search
64 Bool_t fLastSubstring; // substring search option of last search
65 TString fLastName; // the name of object of last search
66 TTimer *fKeyTimer; // keyboard timer
67 TString fKeyInput; // keyboard input (buffer)
68 Bool_t fKeyTimerActive;// kTRUE - keyboard timer is active
69 Bool_t fScrolling; // kTRUE - when scrolling is ON
72 TGRectangle fExposedRegion; // exposed area
74 static TGGC *fgLineGC;
75 static const TGGC &GetLineGC();
77 virtual void DoRedraw();
78 virtual void ActivateItem(TGFrameElement* el);
79 virtual void DeActivateItem(TGFrameElement* el);
80 virtual void SearchPattern();
81 virtual void OnAutoScroll();
82 virtual void RepeatSearch();
85 TGContainer(const TGContainer&) = delete;
89 TGContainer(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
90 UInt_t options = kSunkenFrame,
95 virtual ~TGContainer();
97 virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
98 virtual void ClearViewPort();
99 virtual void Associate(const TGWindow *w) { fMsgWindow = w; }
100 virtual void AdjustPosition();
101 virtual void SetPagePosition(const TGPosition& pos);
102 virtual void SetPagePosition(Int_t x, Int_t y);
103 virtual void SetPageDimension(const TGDimension& dim);
104 virtual void SetPageDimension(UInt_t w, UInt_t h);
105 virtual void RemoveAll();
106 virtual void RemoveItem(TGFrame *item);
107 virtual void Layout();
109 TGCanvas *GetCanvas() const { return fCanvas; }
110 const TGWindow *GetMessageWindow() const { return fMsgWindow; }
111 virtual TGPosition GetPagePosition() const;
112 virtual TGDimension GetPageDimension() const;
114 virtual Int_t NumSelected() const { return fSelected; }
115 virtual Int_t NumItems() const { return fTotal; }
116 virtual TGFrameElement *FindFrame(Int_t x,Int_t y,Bool_t exclude=kTRUE);
117 virtual TGFrame *FindFrameByName(const char *name);
118 virtual TGHScrollBar *GetHScrollbar() const;
119 virtual TGVScrollBar *GetVScrollbar() const;
120 virtual void SetHsbPosition(Int_t newPos);
121 virtual void SetVsbPosition(Int_t newPos);
122 virtual void LineUp(Bool_t select = kFALSE);
123 virtual void LineDown(Bool_t select = kFALSE);
124 virtual void LineLeft(Bool_t select = kFALSE);
125 virtual void LineRight(Bool_t select = kFALSE);
126 virtual void PageUp(Bool_t select = kFALSE);
127 virtual void PageDown(Bool_t select = kFALSE);
128 virtual void Home(Bool_t select = kFALSE);
129 virtual void End(Bool_t select = kFALSE);
130 virtual void Search(Bool_t close = kTRUE);
131 virtual void *FindItem(const TString& name,
132 Bool_t direction = kTRUE,
133 Bool_t caseSensitive = kTRUE,
134 Bool_t subString = kFALSE);
136 virtual const TGFrame *GetNextSelected(void **current);
137 virtual TGFrame *GetLastActive() const { return fLastActiveEl ? fLastActiveEl->fFrame : 0; }
138 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
140 virtual Bool_t HandleDNDFinished() { fBdown = kFALSE; return kTRUE; }
141 virtual Bool_t HandleExpose(Event_t *event);
142 virtual Bool_t HandleButton(Event_t *event);
143 virtual Bool_t HandleDoubleClick(Event_t *event);
144 virtual Bool_t HandleMotion(Event_t *event);
145 virtual Bool_t HandleKey(Event_t *event);
148 virtual void SetDragPixmap(const TGPicture *pic);
150 virtual void SelectAll(); //*SIGNAL*
151 virtual void UnSelectAll(); //*SIGNAL*
152 virtual void InvertSelection(); //*SIGNAL*
153 virtual void ReturnPressed(TGFrame*); //*SIGNAL*
154 virtual void SpacePressed(TGFrame*); //*SIGNAL*
155 virtual void KeyPressed(TGFrame*, UInt_t keysym, UInt_t mask); //*SIGNAL*
156 virtual void OnMouseOver(TGFrame*); //*SIGNAL*
157 virtual void CurrentChanged(Int_t x,Int_t y);//*SIGNAL*
158 virtual void CurrentChanged(TGFrame* f); //*SIGNAL*
159 virtual void Clicked(TGFrame *f, Int_t btn); //*SIGNAL*
160 virtual void DoubleClicked(TGFrame *f, Int_t btn); //*SIGNAL*
161 virtual void DoubleClicked(TGFrame *f, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
162 virtual void Clicked(TGFrame *f, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
164 ClassDef(TGContainer,0) // Canvas container
171 Int_t fX0, fY0; // position of container frame in viewport
172 TGFrame *fContainer; // container frame
175 TGViewPort(const TGViewPort&) = delete;
176 TGViewPort& operator=(const TGViewPort&) = delete;
179 TGViewPort(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
180 UInt_t options = kChildFrame,
183 TGFrame *GetContainer() const { return fContainer; }
184 void SetContainer(TGFrame *f);
186 virtual void DrawBorder() { };
187 virtual void Layout() { }
190 virtual void SetHPos(Int_t xpos);
191 virtual void SetVPos(Int_t ypos);
192 void SetPos(Int_t xpos, Int_t ypos);
194 Int_t GetHPos() const { return fX0; }
195 Int_t GetVPos() const { return fY0; }
196 virtual Bool_t HandleConfigureNotify(Event_t *event);
198 ClassDef(TGViewPort,0) // Viewport through which to look at a container frame
202class TGCanvas : public TGFrame {
205 TGViewPort *fVport; // viewport through which we look at contents
206 TGHScrollBar *fHScrollbar; // horizontal scrollbar
207 TGVScrollBar *fVScrollbar; // vertical scrollbar
208 Int_t fScrolling; // flag which scrolling modes are allowed
211 TGCanvas(const TGCanvas&) = delete;
212 TGCanvas& operator=(const TGCanvas&) = delete;
215 enum { kCanvasNoScroll = 0,
219 };
221 TGCanvas(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
224 virtual ~TGCanvas();
226 TGFrame *GetContainer() const { return fVport->GetContainer(); }
227 TGViewPort *GetViewPort() const { return fVport; }
231 virtual void AddFrame(TGFrame *f, TGLayoutHints *l = 0);
233 virtual void MapSubwindows();
234 virtual void DrawBorder();
235 virtual void Layout();
236 virtual void ClearViewPort();
237 virtual Int_t GetHsbPosition() const;
238 virtual Int_t GetVsbPosition() const;
239 virtual void SetHsbPosition(Int_t newPos);
240 virtual void SetVsbPosition(Int_t newPos);
241 void SetScrolling(Int_t scrolling);
242 Int_t GetScrolling() const { return fScrolling; }
245 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
247 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
249 ClassDef(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
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kFALSE
Definition RtypesCore.h:92
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
#define BIT(n)
Definition Rtypes.h:85
char name[80]
Definition TGX11.cxx:110
virtual void SetContainer(TGFrame *f)
Definition TGCanvas.h:232
TGFrame * GetContainer() const
Definition TGCanvas.h:226
virtual void MapSubwindows()
Map all canvas sub windows.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a canvas widget as a C++ statement(s) on output stream out.
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
Definition TGCanvas.h:205
Int_t fScrolling
Definition TGCanvas.h:208
virtual void DrawBorder()
Draw canvas border.
TGHScrollBar * fHScrollbar
Definition TGCanvas.h:206
TGVScrollBar * GetVScrollbar() const
Definition TGCanvas.h:229
TGVScrollBar * fVScrollbar
Definition TGCanvas.h:207
TGViewPort * GetViewPort() const
Definition TGCanvas.h:227
virtual Int_t GetHsbPosition() const
Get position of horizontal scrollbar.
virtual void ClearViewPort()
Clear view port and redraw content.
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGCanvas.h:244
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Adding a frame to a canvas is actually adding the frame to the viewport container.
@ kCanvasNoScroll
Definition TGCanvas.h:215
@ kCanvasScrollVertical
Definition TGCanvas.h:217
@ kCanvasScrollBoth
Definition TGCanvas.h:218
@ kCanvasScrollHorizontal
Definition TGCanvas.h:216
Int_t GetScrolling() const
Definition TGCanvas.h:242
virtual void Layout()
Create layout for canvas.
void SetScrolling(Int_t scrolling)
Set scrolling policy.
TGCanvas(const TGCanvas &)=delete
virtual ~TGCanvas()
Delete canvas.
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle message generated by the canvas scrollbars.
TGHScrollBar * GetHScrollbar() const
Definition TGCanvas.h:228
virtual Bool_t HandleExpose(Event_t *event)
Handle expose events. Do not use double buffer.
Definition TGCanvas.cxx:899
TGRectangle fExposedRegion
Definition TGCanvas.h:72
virtual void ActivateItem(TGFrameElement *el)
Activate item.
Definition TGCanvas.cxx:697
virtual void Associate(const TGWindow *w)
Definition TGCanvas.h:99
Bool_t fKeyTimerActive
Definition TGCanvas.h:68
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition TGCanvas.cxx:656
TGCanvas * fCanvas
Definition TGCanvas.h:51
virtual TGFrame * GetLastActive() const
Definition TGCanvas.h:137
TTimer * fScrollTimer
Definition TGCanvas.h:60
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events.
virtual void RepeatSearch()
Repeats search.
Int_t fYf
Definition TGCanvas.h:56
virtual void UnSelectAll()
Unselect all items in the container.
Definition TGCanvas.cxx:585
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
virtual void PageDown(Bool_t select=kFALSE)
Move position one page down.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in container.
Definition TGCanvas.cxx:925
virtual void LineLeft(Bool_t select=kFALSE)
Move current position one column left.
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:887
const TGWindow * fMsgWindow
Definition TGCanvas.h:52
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
Definition TGCanvas.h:54
virtual void AdjustPosition()
Move content to position of highlighted/activated frame.
virtual void OnMouseOver(TGFrame *)
Signal emitted when pointer is over entry.
Definition TGCanvas.cxx:497
virtual void Clicked(TGFrame *f, Int_t btn)
Emit Clicked() signal.
Definition TGCanvas.cxx:506
virtual void InvertSelection()
Invert the selection, all selected items become unselected and vice versa.
Definition TGCanvas.cxx:610
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:677
virtual void Search(Bool_t close=kTRUE)
Invokes search dialog. Looks for item with the entered name.
virtual ~TGContainer()
Delete canvas container.
Definition TGCanvas.cxx:402
virtual void LineUp(Bool_t select=kFALSE)
Make current position first line in window by scrolling up.
Bool_t fLastDir
Definition TGCanvas.h:62
Int_t fY0
Definition TGCanvas.h:55
virtual void Home(Bool_t select=kFALSE)
Move to upper-left corner of container.
virtual void KeyPressed(TGFrame *, UInt_t keysym, UInt_t mask)
Signal emitted when keyboard key pressed.
Definition TGCanvas.cxx:466
virtual void SetDragPixmap(const TGPicture *pic)
Set drag window pixmaps and hotpoint.
virtual Int_t NumSelected() const
Definition TGCanvas.h:114
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:70
TGCanvas * GetCanvas() const
Definition TGCanvas.h:109
virtual void ReturnPressed(TGFrame *)
Signal emitted when Return/Enter key pressed.
Definition TGCanvas.cxx:480
virtual void SearchPattern()
Search for entry which name begins with pattern.
virtual void SetPageDimension(const TGDimension &dim)
Set page dimension.
Definition TGCanvas.cxx:778
virtual void LineRight(Bool_t select=kFALSE)
Move current position one column right.
TGContainer(const TGContainer &)=delete
Int_t fSelected
Definition TGCanvas.h:59
Bool_t fBdown
Definition TGCanvas.h:71
virtual void SpacePressed(TGFrame *)
Signal emitted when space key pressed.
Definition TGCanvas.cxx:489
virtual void SetHsbPosition(Int_t newPos)
set new hor. position
Bool_t fScrolling
Definition TGCanvas.h:69
virtual void DoRedraw()
Redraw content of container in the viewport region.
Definition TGCanvas.cxx:796
Int_t fX0
Definition TGCanvas.h:55
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition TGCanvas.cxx:747
TString fLastName
Definition TGCanvas.h:65
virtual void Layout()
Layout container entries.
Definition TGCanvas.cxx:418
virtual void OnAutoScroll()
Autoscroll while close to & beyond The Wall.
Int_t fXp
Definition TGCanvas.h:54
static const TGGC & GetLineGC()
Get graphics context for line drawing.
static TGGC * fgLineGC
Definition TGCanvas.h:74
Bool_t fDragging
Definition TGCanvas.h:57
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a canvas container as a C++ statement(s) on output stream out.
virtual void CurrentChanged(Int_t x, Int_t y)
Emit signal when current position changed.
Definition TGCanvas.cxx:430
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:815
virtual void RemoveAll()
Remove all items from the container.
Definition TGCanvas.cxx:637
friend class TGContainerScrollTimer
Definition TGCanvas.h:46
virtual Int_t NumItems() const
Definition TGCanvas.h:115
TGViewPort * fViewPort
Definition TGCanvas.h:50
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:70
friend class TGContainerKeyboardTimer
Definition TGCanvas.h:45
virtual void * FindItem(const TString &name, Bool_t direction=kTRUE, Bool_t caseSensitive=kTRUE, Bool_t subString=kFALSE)
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click mouse event.
Bool_t fOnMouseOver
Definition TGCanvas.h:61
Bool_t fLastCase
Definition TGCanvas.h:63
Int_t fTotal
Definition TGCanvas.h:58
const TGWindow * GetMessageWindow() const
Definition TGCanvas.h:110
virtual void DoubleClicked(TGFrame *f, Int_t btn)
Emit DoubleClicked() signal.
Definition TGCanvas.cxx:534
virtual TGPosition GetPagePosition() const
Returns page position.
Definition TGCanvas.cxx:733
virtual void End(Bool_t select=kFALSE)
Move to the bottom-right corner of container.
Bool_t fLastSubstring
Definition TGCanvas.h:64
virtual void SetPagePosition(const TGPosition &pos)
Set page position.
Definition TGCanvas.cxx:760
virtual Bool_t HandleDNDFinished()
Definition TGCanvas.h:140
virtual TGHScrollBar * GetHScrollbar() const
returns pointer to hor. scroll bar
TGFrameElement * fLastActiveEl
Definition TGCanvas.h:53
virtual void SelectAll()
Select all items in the container.
Definition TGCanvas.cxx:563
TString fKeyInput
Definition TGCanvas.h:67
TTimer * fKeyTimer
Definition TGCanvas.h:66
virtual void DeActivateItem(TGFrameElement *el)
DeActivate item.
Definition TGCanvas.cxx:720
Int_t fXf
Definition TGCanvas.h:56
TGFrame * fFrame
Definition TGLayout.h:119
UInt_t fHeight
Definition TGFrame.h:112
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
UInt_t fWidth
Definition TGFrame.h:111
Definition TGGC.h:31
Int_t GetHPos() const
Definition TGCanvas.h:194
virtual void DrawBorder()
Draw frame border.
Definition TGCanvas.h:186
Int_t GetVPos() const
Definition TGCanvas.h:195
TGFrame * GetContainer() const
Definition TGCanvas.h:183
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGCanvas.h:188
TGFrame * fContainer
Definition TGCanvas.h:172
TGViewPort(const TGViewPort &)=delete
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handle resize events.
Definition TGCanvas.cxx:288
Int_t fX0
Definition TGCanvas.h:171
void SetContainer(TGFrame *f)
Add container frame to the viewport.
Definition TGCanvas.cxx:149
virtual void Layout()
Layout the elements of the composite frame.
Definition TGCanvas.h:187
virtual void SetHPos(Int_t xpos)
Moves content of container frame in horizontal direction.
Definition TGCanvas.cxx:174
virtual void SetVPos(Int_t ypos)
Moves content of container frame in vertical direction.
Definition TGCanvas.cxx:225
void SetPos(Int_t xpos, Int_t ypos)
Goto new position.
Definition TGCanvas.cxx:277
Int_t fY0
Definition TGCanvas.h:171
TGViewPort & operator=(const TGViewPort &)=delete
Basic string class.
Definition TString.h:136
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
auto * l
Definition textangle.C:4