Logo ROOT  
Reference Guide
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-2000, 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#include "TTimer.h"
38
39class TGViewFrame;
40class TGHScrollBar;
41class TGVScrollBar;
42
43class TGView : public TGCompositeFrame, public TGWidget {
44
45friend class TGViewFrame;
46
47public:
48 enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
49 enum { kHorizontal = 0, kVertical = 1 };
50
51protected:
52 TGLongPosition fVisible; // position of visible region
53 TGLongPosition fMousePos; // position of mouse
54 TGLongPosition fScrollVal; // scroll value
55 TGDimension fVirtualSize; // the current virtual window size
57
58 Int_t fScrolling; // scrolling direction
59 Atom_t fClipboard; // clipboard property
60 UInt_t fXMargin; // x margin
61 UInt_t fYMargin; // y margin
62 TGViewFrame *fCanvas; // frame containing the text
63 TGHScrollBar *fHsb; // horizontal scrollbar
64 TGVScrollBar *fVsb; // vertical scrollbar
65
66 TGGC fWhiteGC; // graphics context used for scrolling
67 // generates GraphicsExposure events
68
69 virtual void DoRedraw();
70 virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
71 virtual Bool_t ItemLayout() { return kFALSE; }
72
73private:
74 TGView(const TGView&); // not implemented
75 TGView& operator=(const TGView&); // not implemented
76
77public:
78 TGView(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
79 UInt_t xMargin = 0, UInt_t yMargin = 0,
81 UInt_t sboptions = 0,
82 Pixel_t back = GetWhitePixel());
83
84 virtual ~TGView();
85
86 TGViewFrame *GetCanvas() const { return fCanvas; }
87
88 virtual void Clear(Option_t * = "");
89 virtual void SetVisibleStart(Int_t newTop, Int_t direction);
90 virtual void ScrollCanvas(Int_t newTop, Int_t direction);
91 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
92 virtual void DrawBorder();
93 virtual void Layout();
95 virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
96
97 virtual void ScrollToPosition(TGLongPosition newPos);
98 void ScrollUp(Int_t pixels)
100 void ScrollDown(Int_t pixels)
102 void ScrollLeft(Int_t pixels)
104 void ScrollRight(Int_t pixels)
106
111
112 TGLongPosition ToVirtual(TGLongPosition coord) const { return coord + fVisible; }
113 TGLongPosition ToPhysical(TGLongPosition coord) const { return coord - fVisible; }
114
115 virtual Bool_t HandleButton(Event_t *event);
116 virtual Bool_t HandleExpose(Event_t *event);
117
118 virtual void ChangeBackground(Pixel_t);
119 virtual void SetBackgroundColor(Pixel_t);
120 virtual void SetBackgroundPixmap(Pixmap_t p);
121 virtual void UpdateBackgroundStart();
122
123 const TGGC &GetViewWhiteGC() { return fWhiteGC; }
124
125 ClassDef(TGView,0) // View widget base class
126};
127
128
130private:
131 TGView *fView; // pointer back to the view
132
133 TGViewFrame(const TGViewFrame&); // not implemented
134 TGViewFrame& operator=(const TGViewFrame&); // not implemented
135
136public:
137 TGViewFrame(TGView *v, UInt_t w, UInt_t h, UInt_t options = 0,
138 Pixel_t back = GetWhitePixel());
139
141 { return fView->HandleSelectionRequest(event); }
143 { return fView->HandleSelectionClear(event); }
145 { return fView->HandleSelection(event); }
147 { return fView->HandleButton(event); }
149 { return fView->HandleExpose(event); }
151 { return fView->HandleCrossing(event); }
153 { return fView->HandleMotion(event); }
155 { return fView->HandleKey(event); }
157 { return fView->HandleDoubleClick(event); }
158
159 ClassDef(TGViewFrame,0) // Frame containing the actual text
160};
161
162
163
164#endif
Handle_t Pixmap_t
Definition: GuiTypes.h:29
@ kSunkenFrame
Definition: GuiTypes.h:383
@ kDoubleBorder
Definition: GuiTypes.h:385
Handle_t Atom_t
Definition: GuiTypes.h:36
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:43
unsigned int UInt_t
Definition: RtypesCore.h:44
const Bool_t kFALSE
Definition: RtypesCore.h:90
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define BIT(n)
Definition: Rtypes.h:83
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
virtual Bool_t HandleCrossing(Event_t *)
Definition: TGFrame.h:363
virtual Bool_t HandleSelection(Event_t *)
Definition: TGFrame.h:367
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:362
virtual Bool_t HandleMotion(Event_t *)
Definition: TGFrame.h:364
virtual Bool_t HandleKey(Event_t *)
Definition: TGFrame.h:365
virtual Bool_t HandleSelectionClear(Event_t *)
Definition: TGFrame.h:195
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:693
UInt_t fHeight
Definition: TGFrame.h:113
virtual Bool_t HandleSelectionRequest(Event_t *)
Definition: TGFrame.h:194
UInt_t fWidth
Definition: TGFrame.h:112
Definition: TGGC.h:31
Bool_t HandleDoubleClick(Event_t *event)
Definition: TGView.h:156
Bool_t HandleCrossing(Event_t *event)
Definition: TGView.h:150
Bool_t HandleSelectionRequest(Event_t *event)
Definition: TGView.h:140
Bool_t HandleSelection(Event_t *event)
Definition: TGView.h:144
Bool_t HandleKey(Event_t *event)
Definition: TGView.h:154
Bool_t HandleSelectionClear(Event_t *event)
Definition: TGView.h:142
Bool_t HandleButton(Event_t *event)
Definition: TGView.h:146
Bool_t HandleMotion(Event_t *event)
Definition: TGView.h:152
Bool_t HandleExpose(Event_t *event)
Definition: TGView.h:148
TGViewFrame(const TGViewFrame &)
TGView * fView
Definition: TGView.h:131
TGViewFrame & operator=(const TGViewFrame &)
Definition: TGView.h:43
Atom_t fClipboard
Definition: TGView.h:59
TGHScrollBar * fHsb
Definition: TGView.h:63
virtual ~TGView()
Delete view.
Definition: TGView.cxx:147
void ScrollLeft(Int_t pixels)
Definition: TGView.h:102
virtual Bool_t ItemLayout()
Definition: TGView.h:71
void ScrollRight(Int_t pixels)
Definition: TGView.h:104
virtual Bool_t HandleButton(Event_t *event)
handle button
Definition: TGView.cxx:235
TGDimension fVirtualSize
Definition: TGView.h:55
TGView(const TGView &)
TGVScrollBar * fVsb
Definition: TGView.h:64
const TGGC & GetViewWhiteGC()
Definition: TGView.h:123
TGLongPosition ToPhysical(TGLongPosition coord) const
Definition: TGView.h:113
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:53
void ScrollUp(Int_t pixels)
Definition: TGView.h:98
@ kNoHSB
Definition: TGView.h:48
@ kNoVSB
Definition: TGView.h:48
TGLongPosition fVisible
Definition: TGView.h:52
void ScrollDown(Int_t pixels)
Definition: TGView.h:100
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGView.h:107
virtual void UpdateBackgroundStart()
set some gc values
Definition: TGView.cxx:226
TGLongPosition ToVirtual(TGLongPosition coord) const
Definition: TGView.h:112
virtual void DrawBorder()
Draw the border of the text edit widget.
Definition: TGView.cxx:426
TGView & operator=(const TGView &)
TGViewFrame * GetCanvas() const
Definition: TGView.h:86
UInt_t fXMargin
Definition: TGView.h:60
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:58
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
Definition: TGView.cxx:579
TGLongPosition GetScrollPosition() const
Definition: TGView.h:110
TGLongPosition fScrollVal
Definition: TGView.h:54
virtual void SetLayoutManager(TGLayoutManager *)
Set the layout manager for the composite frame.
Definition: TGView.h:94
TGViewFrame * fCanvas
Definition: TGView.h:62
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:66
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:61
TGLongPosition GetScrollValue() const
Definition: TGView.h:109
TGDimension GetVirtualSize() const
Definition: TGView.h:108
virtual void Clear(Option_t *="")
Clear view.
Definition: TGView.cxx:159
TGRectangle fExposedRegion
Definition: TGView.h:56
virtual void SetBackgroundPixmap(Pixmap_t p)
Set backgound pixmap.
Definition: TGView.cxx:589
@ kHorizontal
Definition: TGView.h:49
@ kVertical
Definition: TGView.h:49
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17