Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGView.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 30/6/2000
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#ifndef ROOT_TGView
13#define ROOT_TGView
14
15
16#include "TGFrame.h"
17#include "TGWidget.h"
18
19class TGViewFrame;
20class TGHScrollBar;
21class TGVScrollBar;
22
23class TGView : public TGCompositeFrame, public TGWidget {
24
25friend class TGViewFrame;
26
27public:
28 enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
29 enum { kHorizontal = 0, kVertical = 1 };
30
31protected:
32 TGLongPosition fVisible; ///< position of visible region
33 TGLongPosition fMousePos; ///< position of mouse
34 TGLongPosition fScrollVal; ///< scroll value
35 TGDimension fVirtualSize; ///< the current virtual window size
36 TGRectangle fExposedRegion;///< exposed area
37
38 Int_t fScrolling; ///< scrolling direction
39 Atom_t fClipboard; ///< clipboard property
40 UInt_t fXMargin; ///< x margin
41 UInt_t fYMargin; ///< y margin
42 TGViewFrame *fCanvas; ///< frame containing the text
43 TGHScrollBar *fHsb; ///< horizontal scrollbar
44 TGVScrollBar *fVsb; ///< vertical scrollbar
45
46 TGGC fWhiteGC; ///< graphics context used for scrolling
47 ///< generates GraphicsExposure events
48
49 void DoRedraw() override;
50 virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
51 virtual Bool_t ItemLayout() { return kFALSE; }
52
53private:
54 TGView(const TGView&) = delete;
55 TGView& operator=(const TGView&) = delete;
56
57public:
58 TGView(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
59 UInt_t xMargin = 0, UInt_t yMargin = 0,
61 UInt_t sboptions = 0,
62 Pixel_t back = GetWhitePixel());
63
64 ~TGView() override;
65
66 TGViewFrame *GetCanvas() const { return fCanvas; }
67
68 void Clear(Option_t * = "") override;
69 virtual void SetVisibleStart(Int_t newTop, Int_t direction);
70 virtual void ScrollCanvas(Int_t newTop, Int_t direction);
71 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
72 void DrawBorder() override;
73 void Layout() override;
75 virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
76
77 virtual void ScrollToPosition(TGLongPosition newPos);
78 void ScrollUp(Int_t pixels)
80 void ScrollDown(Int_t pixels)
82 void ScrollLeft(Int_t pixels)
84 void ScrollRight(Int_t pixels)
86
87 TGDimension GetDefaultSize() const override { return TGDimension(fWidth, fHeight); }
91
92 TGLongPosition ToVirtual(TGLongPosition coord) const { return coord + fVisible; }
93 TGLongPosition ToPhysical(TGLongPosition coord) const { return coord - fVisible; }
94
97
98 void ChangeBackground(Pixel_t) override;
99 void SetBackgroundColor(Pixel_t) override;
100 void SetBackgroundPixmap(Pixmap_t p) override;
101 virtual void UpdateBackgroundStart();
102
103 const TGGC &GetViewWhiteGC() { return fWhiteGC; }
104
105 ClassDefOverride(TGView,0) // View widget base class
106};
107
108
110private:
111 TGView *fView; // pointer back to the view
112
113 TGViewFrame(const TGViewFrame&) = delete;
115
116public:
117 TGViewFrame(TGView *v, UInt_t w, UInt_t h, UInt_t options = 0,
118 Pixel_t back = GetWhitePixel());
119
123 { return fView->HandleSelectionClear(event); }
125 { return fView->HandleSelection(event); }
127 { return fView->HandleButton(event); }
129 { return fView->HandleExpose(event); }
131 { return fView->HandleCrossing(event); }
133 { return fView->HandleMotion(event); }
135 { return fView->HandleKey(event); }
137 { return fView->HandleDoubleClick(event); }
138
139 ClassDefOverride(TGViewFrame,0) // Frame containing the actual text
140};
141
142#endif
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#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
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 width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
Bool_t HandleKey(Event_t *) override
Definition TGFrame.h:328
Bool_t HandleCrossing(Event_t *) override
Definition TGFrame.h:326
Bool_t HandleSelection(Event_t *) override
Definition TGFrame.h:330
Bool_t HandleDoubleClick(Event_t *) override
Definition TGFrame.h:325
Bool_t HandleMotion(Event_t *) override
Definition TGFrame.h:327
virtual Bool_t HandleSelectionClear(Event_t *)
Definition TGFrame.h:170
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual Bool_t HandleSelectionRequest(Event_t *)
Definition TGFrame.h:169
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,...
Frame layout manager.
Definition TGLayout.h:135
Long_t fX
x position
Definition TGDimension.h:56
Long_t fY
y position
Definition TGDimension.h:57
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
Bool_t HandleButton(Event_t *event) override
Definition TGView.h:126
TGViewFrame & operator=(const TGViewFrame &)=delete
Bool_t HandleSelectionRequest(Event_t *event) override
Definition TGView.h:120
Bool_t HandleCrossing(Event_t *event) override
Definition TGView.h:130
Bool_t HandleMotion(Event_t *event) override
Definition TGView.h:132
Bool_t HandleSelection(Event_t *event) override
Definition TGView.h:124
TGViewFrame(const TGViewFrame &)=delete
Bool_t HandleSelectionClear(Event_t *event) override
Definition TGView.h:122
Bool_t HandleKey(Event_t *event) override
Definition TGView.h:134
TGView * fView
Definition TGView.h:111
Bool_t HandleDoubleClick(Event_t *event) override
Definition TGView.h:136
Bool_t HandleExpose(Event_t *event) override
Definition TGView.h:128
A TGView provides the infrastructure for text viewer and editor widgets.
Definition TGView.h:23
Atom_t fClipboard
clipboard property
Definition TGView.h:39
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Process scrollbar messages.
Definition TGView.cxx:316
TGHScrollBar * fHsb
horizontal scrollbar
Definition TGView.h:43
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGView.h:87
void ScrollLeft(Int_t pixels)
Definition TGView.h:82
virtual Bool_t ItemLayout()
Definition TGView.h:51
void SetBackgroundColor(Pixel_t) override
Set background color of the canvas frame.
Definition TGView.cxx:590
void ScrollRight(Int_t pixels)
Definition TGView.h:84
@ kNoHSB
Definition TGView.h:28
@ kNoVSB
Definition TGView.h:28
void DrawBorder() override
Draw the border of the text edit widget.
Definition TGView.cxx:428
TGDimension fVirtualSize
the current virtual window size
Definition TGView.h:35
TGVScrollBar * fVsb
vertical scrollbar
Definition TGView.h:44
const TGGC & GetViewWhiteGC()
Definition TGView.h:103
TGLongPosition ToPhysical(TGLongPosition coord) const
Definition TGView.h:93
TGLongPosition fMousePos
position of mouse
Definition TGView.h:33
void SetLayoutManager(TGLayoutManager *) override
Set the layout manager for the composite frame.
Definition TGView.h:74
void ScrollUp(Int_t pixels)
Definition TGView.h:78
Bool_t HandleButton(Event_t *event) override
handle button
Definition TGView.cxx:237
TGLongPosition fVisible
position of visible region
Definition TGView.h:32
void ScrollDown(Int_t pixels)
Definition TGView.h:80
virtual void UpdateBackgroundStart()
set some gc values
Definition TGView.cxx:228
TGLongPosition ToVirtual(TGLongPosition coord) const
Definition TGView.h:92
void Layout() override
layout view
Definition TGView.cxx:346
@ kHorizontal
Definition TGView.h:29
@ kVertical
Definition TGView.h:29
TGView(const TGView &)=delete
void ChangeBackground(Pixel_t) override
Change background color of the canvas frame.
Definition TGView.cxx:579
TGViewFrame * GetCanvas() const
Definition TGView.h:66
UInt_t fXMargin
x margin
Definition TGView.h:40
virtual void SetVisibleStart(Int_t newTop, Int_t direction)
Scroll view in specified direction to make newTop the visible location.
Definition TGView.cxx:178
~TGView() override
Delete view.
Definition TGView.cxx:149
Int_t fScrolling
scrolling direction
Definition TGView.h:38
TGLongPosition GetScrollPosition() const
Definition TGView.h:90
void DoRedraw() override
redraw
Definition TGView.cxx:270
TGLongPosition fScrollVal
scroll value
Definition TGView.h:34
TGViewFrame * fCanvas
frame containing the text
Definition TGView.h:42
void SetBackgroundPixmap(Pixmap_t p) override
Set backgound pixmap.
Definition TGView.cxx:600
void Clear(Option_t *="") override
Clear view.
Definition TGView.cxx:161
virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
update a part of view
Definition TGView.cxx:204
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
Definition TGView.cxx:464
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw region.
Definition TGView.cxx:196
TGGC fWhiteGC
graphics context used for scrolling generates GraphicsExposure events
Definition TGView.h:46
virtual void ScrollToPosition(TGLongPosition newPos)
Scroll the canvas to pos.
Definition TGView.cxx:453
UInt_t fYMargin
y margin
Definition TGView.h:41
TGLongPosition GetScrollValue() const
Definition TGView.h:89
TGDimension GetVirtualSize() const
Definition TGView.h:88
TGView & operator=(const TGView &)=delete
TGRectangle fExposedRegion
exposed area
Definition TGView.h:36
Bool_t HandleExpose(Event_t *event) override
Handle expose events.
Definition TGView.cxx:284
The widget base class.
Definition TGWidget.h:43
ROOT GUI Window base class.
Definition TGWindow.h:23
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174