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//////////////////////////////////////////////////////////////////////////
17// //
18// TGView //
19// //
20// A TGView provides the infrastructure for text viewer and editor //
21// widgets. It provides a canvas (TGViewFrame) and (optionally) a //
22// vertical and horizontal scrollbar and methods for marking and //
23// scrolling. //
24// //
25// The TGView (and derivatives) will generate the following //
26// event messages: //
27// kC_TEXTVIEW, kTXT_ISMARKED, widget id, [true|false] //
28// kC_TEXTVIEW, kTXT_DATACHANGE, widget id, 0 //
29// kC_TEXTVIEW, kTXT_CLICK2, widget id, position (y << 16) | x) //
30// kC_TEXTVIEW, kTXT_CLICK3, widget id, position (y << 16) | x) //
31// kC_TEXTVIEW, kTXT_F3, widget id, true //
32// //
33//////////////////////////////////////////////////////////////////////////
34
35#include "TGFrame.h"
36#include "TGWidget.h"
37
38class TGViewFrame;
39class TGHScrollBar;
40class TGVScrollBar;
41
42class TGView : public TGCompositeFrame, public TGWidget {
43
44friend class TGViewFrame;
45
46public:
47 enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
48 enum { kHorizontal = 0, kVertical = 1 };
49
50protected:
51 TGLongPosition fVisible; // position of visible region
52 TGLongPosition fMousePos; // position of mouse
53 TGLongPosition fScrollVal; // scroll value
54 TGDimension fVirtualSize; // the current virtual window size
56
57 Int_t fScrolling; // scrolling direction
58 Atom_t fClipboard; // clipboard property
59 UInt_t fXMargin; // x margin
60 UInt_t fYMargin; // y margin
61 TGViewFrame *fCanvas; // frame containing the text
62 TGHScrollBar *fHsb; // horizontal scrollbar
63 TGVScrollBar *fVsb; // vertical scrollbar
64
65 TGGC fWhiteGC; // graphics context used for scrolling
66 // generates GraphicsExposure events
67
68 virtual void DoRedraw();
69 virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
70 virtual Bool_t ItemLayout() { return kFALSE; }
71
72private:
73 TGView(const TGView&) = delete;
74 TGView& operator=(const TGView&) = delete;
75
76public:
77 TGView(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
78 UInt_t xMargin = 0, UInt_t yMargin = 0,
80 UInt_t sboptions = 0,
81 Pixel_t back = GetWhitePixel());
82
83 virtual ~TGView();
84
85 TGViewFrame *GetCanvas() const { return fCanvas; }
86
87 virtual void Clear(Option_t * = "");
88 virtual void SetVisibleStart(Int_t newTop, Int_t direction);
89 virtual void ScrollCanvas(Int_t newTop, Int_t direction);
90 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
91 virtual void DrawBorder();
92 virtual void Layout();
94 virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
95
96 virtual void ScrollToPosition(TGLongPosition newPos);
97 void ScrollUp(Int_t pixels)
99 void ScrollDown(Int_t pixels)
101 void ScrollLeft(Int_t pixels)
103 void ScrollRight(Int_t pixels)
105
110
111 TGLongPosition ToVirtual(TGLongPosition coord) const { return coord + fVisible; }
112 TGLongPosition ToPhysical(TGLongPosition coord) const { return coord - fVisible; }
113
114 virtual Bool_t HandleButton(Event_t *event);
115 virtual Bool_t HandleExpose(Event_t *event);
116
117 virtual void ChangeBackground(Pixel_t);
118 virtual void SetBackgroundColor(Pixel_t);
119 virtual void SetBackgroundPixmap(Pixmap_t p);
120 virtual void UpdateBackgroundStart();
121
122 const TGGC &GetViewWhiteGC() { return fWhiteGC; }
123
124 ClassDef(TGView,0) // View widget base class
125};
126
127
129private:
130 TGView *fView; // pointer back to the view
131
132 TGViewFrame(const TGViewFrame&) = delete;
134
135public:
136 TGViewFrame(TGView *v, UInt_t w, UInt_t h, UInt_t options = 0,
137 Pixel_t back = GetWhitePixel());
138
140 { return fView->HandleSelectionRequest(event); }
142 { return fView->HandleSelectionClear(event); }
144 { return fView->HandleSelection(event); }
146 { return fView->HandleButton(event); }
148 { return fView->HandleExpose(event); }
150 { return fView->HandleCrossing(event); }
152 { return fView->HandleMotion(event); }
154 { return fView->HandleKey(event); }
156 { return fView->HandleDoubleClick(event); }
157
158 ClassDef(TGViewFrame,0) // Frame containing the actual text
159};
160
161
162
163#endif
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#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 char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
#define BIT(n)
Definition Rtypes.h:85
include TDocParser_001 C image html pict1_TDocParser_001 png width
virtual Bool_t HandleCrossing(Event_t *)
Definition TGFrame.h:362
virtual Bool_t HandleSelection(Event_t *)
Definition TGFrame.h:366
virtual Bool_t HandleDoubleClick(Event_t *)
Definition TGFrame.h:361
virtual Bool_t HandleMotion(Event_t *)
Definition TGFrame.h:363
virtual Bool_t HandleKey(Event_t *)
Definition TGFrame.h:364
virtual Bool_t HandleSelectionClear(Event_t *)
Definition TGFrame.h:194
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
UInt_t fHeight
Definition TGFrame.h:112
virtual Bool_t HandleSelectionRequest(Event_t *)
Definition TGFrame.h:193
UInt_t fWidth
Definition TGFrame.h:111
Definition TGGC.h:31
Bool_t HandleDoubleClick(Event_t *event)
Definition TGView.h:155
Bool_t HandleCrossing(Event_t *event)
Definition TGView.h:149
Bool_t HandleSelectionRequest(Event_t *event)
Definition TGView.h:139
Bool_t HandleSelection(Event_t *event)
Definition TGView.h:143
Bool_t HandleKey(Event_t *event)
Definition TGView.h:153
TGViewFrame & operator=(const TGViewFrame &)=delete
Bool_t HandleSelectionClear(Event_t *event)
Definition TGView.h:141
Bool_t HandleButton(Event_t *event)
Definition TGView.h:145
Bool_t HandleMotion(Event_t *event)
Definition TGView.h:151
TGViewFrame(const TGViewFrame &)=delete
Bool_t HandleExpose(Event_t *event)
Definition TGView.h:147
TGView * fView
Definition TGView.h:130
Atom_t fClipboard
Definition TGView.h:58
TGHScrollBar * fHsb
Definition TGView.h:62
virtual ~TGView()
Delete view.
Definition TGView.cxx:147
void ScrollLeft(Int_t pixels)
Definition TGView.h:101
virtual Bool_t ItemLayout()
Definition TGView.h:70
void ScrollRight(Int_t pixels)
Definition TGView.h:103
virtual Bool_t HandleButton(Event_t *event)
handle button
Definition TGView.cxx:235
TGDimension fVirtualSize
Definition TGView.h:54
TGVScrollBar * fVsb
Definition TGView.h:63
const TGGC & GetViewWhiteGC()
Definition TGView.h:122
TGLongPosition ToPhysical(TGLongPosition coord) const
Definition TGView.h:112
virtual void Layout()
layout view
Definition TGView.cxx:344
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process scrollbar messages.
Definition TGView.cxx:314
TGLongPosition fMousePos
Definition TGView.h:52
void ScrollUp(Int_t pixels)
Definition TGView.h:97
TGLongPosition fVisible
Definition TGView.h:51
void ScrollDown(Int_t pixels)
Definition TGView.h:99
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGView.h:106
virtual void UpdateBackgroundStart()
set some gc values
Definition TGView.cxx:226
TGLongPosition ToVirtual(TGLongPosition coord) const
Definition TGView.h:111
virtual void DrawBorder()
Draw the border of the text edit widget.
Definition TGView.cxx:426
TGView(const TGView &)=delete
TGViewFrame * GetCanvas() const
Definition TGView.h:85
UInt_t fXMargin
Definition TGView.h:59
virtual void SetVisibleStart(Int_t newTop, Int_t direction)
Scroll view in specified direction to make newTop the visible location.
Definition TGView.cxx:176
Int_t fScrolling
Definition TGView.h:57
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
Definition TGView.cxx:579
TGLongPosition GetScrollPosition() const
Definition TGView.h:109
TGLongPosition fScrollVal
Definition TGView.h:53
@ kHorizontal
Definition TGView.h:48
@ kVertical
Definition TGView.h:48
virtual void SetLayoutManager(TGLayoutManager *)
Set the layout manager for the composite frame.
Definition TGView.h:93
TGViewFrame * fCanvas
Definition TGView.h:61
virtual void ChangeBackground(Pixel_t)
Change background color of the canvas frame.
Definition TGView.cxx:568
virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
update a part of view
Definition TGView.cxx:202
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
Definition TGView.cxx:462
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw region.
Definition TGView.cxx:194
virtual void DoRedraw()
redraw
Definition TGView.cxx:268
TGGC fWhiteGC
Definition TGView.h:65
virtual Bool_t HandleExpose(Event_t *event)
Handle expose events.
Definition TGView.cxx:282
virtual void ScrollToPosition(TGLongPosition newPos)
Scroll the canvas to pos.
Definition TGView.cxx:451
UInt_t fYMargin
Definition TGView.h:60
TGLongPosition GetScrollValue() const
Definition TGView.h:108
TGDimension GetVirtualSize() const
Definition TGView.h:107
TGView & operator=(const TGView &)=delete
virtual void Clear(Option_t *="")
Clear view.
Definition TGView.cxx:159
TGRectangle fExposedRegion
Definition TGView.h:55
virtual void SetBackgroundPixmap(Pixmap_t p)
Set backgound pixmap.
Definition TGView.cxx:589
@ kNoHSB
Definition TGView.h:47
@ kNoVSB
Definition TGView.h:47
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174