Logo ROOT   6.10/09
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 
39 class TGViewFrame;
40 class TGHScrollBar;
41 class TGVScrollBar;
42 
43 class TGView : public TGCompositeFrame, public TGWidget {
44 
45 friend class TGViewFrame;
46 
47 public:
48  enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
49  enum { kHorizontal = 0, kVertical = 1 };
50 
51 protected:
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
56  TGRectangle fExposedRegion;// exposed area
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 
73 private:
74  TGView(const TGView&); // not implemented
75  TGView& operator=(const TGView&); // not implemented
76 
77 public:
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,
80  UInt_t options = kSunkenFrame | kDoubleBorder,
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();
94  virtual void SetLayoutManager(TGLayoutManager*) { }
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)
99  { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY + pixels)); }
100  void ScrollDown(Int_t pixels)
101  { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY - pixels)); }
102  void ScrollLeft(Int_t pixels)
103  { ScrollToPosition(TGLongPosition(fVisible.fX + pixels, fVisible.fY)); }
104  void ScrollRight(Int_t pixels)
105  { ScrollToPosition(TGLongPosition(fVisible.fX - pixels, fVisible.fY)); }
106 
107  virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
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 
130 private:
131  TGView *fView; // pointer back to the view
132 
133  TGViewFrame(const TGViewFrame&); // not implemented
134  TGViewFrame& operator=(const TGViewFrame&); // not implemented
135 
136 public:
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
TGView * fView
Definition: TGView.h:131
Bool_t HandleDoubleClick(Event_t *event)
Definition: TGView.h:156
Bool_t HandleKey(Event_t *event)
Definition: TGView.h:154
Definition: TGView.h:43
TGLongPosition ToPhysical(TGLongPosition coord) const
Definition: TGView.h:113
virtual void Layout()
layout view
Definition: TGView.cxx:345
virtual Bool_t HandleKey(Event_t *)
Definition: TGFrame.h:387
UInt_t fYMargin
Definition: TGView.h:61
TGDimension fVirtualSize
Definition: TGView.h:55
TGRectangle fExposedRegion
Definition: TGView.h:56
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:384
virtual void SetVisibleStart(Int_t newTop, Int_t direction)
Scroll view in specified direction to make newTop the visible location.
Definition: TGView.cxx:177
const char Option_t
Definition: RtypesCore.h:62
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw region.
Definition: TGView.cxx:195
TGLongPosition fVisible
Definition: TGView.h:52
#define BIT(n)
Definition: Rtypes.h:75
TH1 * h
Definition: legend2.C:5
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
virtual void ChangeBackground(Pixel_t)
Change background color of the canvas frame.
Definition: TGView.cxx:569
virtual Bool_t HandleButton(Event_t *event)
handle button
Definition: TGView.cxx:236
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void DrawBorder()
Draw the border of the text edit widget.
Definition: TGView.cxx:427
TGHScrollBar * fHsb
Definition: TGView.h:63
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process scrollbar messages.
Definition: TGView.cxx:315
Bool_t HandleSelectionRequest(Event_t *event)
Definition: TGView.h:140
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:297
ULong_t Pixel_t
Definition: GuiTypes.h:39
UInt_t fXMargin
Definition: TGView.h:60
Handle_t Atom_t
Definition: GuiTypes.h:36
Bool_t HandleCrossing(Event_t *event)
Definition: TGView.h:150
virtual Bool_t HandleSelectionRequest(Event_t *)
Definition: TGFrame.h:216
TGLongPosition fMousePos
Definition: TGView.h:53
TGLongPosition ToVirtual(TGLongPosition coord) const
Definition: TGView.h:112
TGView & operator=(const TGView &)
TGView(const TGView &)
Bool_t HandleSelection(Event_t *event)
Definition: TGView.h:144
SVector< double, 2 > v
Definition: Dict.h:5
TGViewFrame * fCanvas
Definition: TGView.h:62
friend class TGViewFrame
Definition: TGView.h:45
Bool_t HandleButton(Event_t *event)
Definition: TGView.h:146
Bool_t HandleExpose(Event_t *event)
Definition: TGView.h:148
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Bool_t ItemLayout()
Definition: TGView.h:71
const TGGC & GetViewWhiteGC()
Definition: TGView.h:123
Atom_t fClipboard
Definition: TGView.h:59
virtual Bool_t HandleSelectionClear(Event_t *)
Definition: TGFrame.h:217
TGGC fWhiteGC
Definition: TGView.h:66
UInt_t fWidth
Definition: TGFrame.h:134
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
Definition: TGView.cxx:580
const Bool_t kFALSE
Definition: RtypesCore.h:92
virtual Bool_t HandleMotion(Event_t *)
Definition: TGFrame.h:386
long Long_t
Definition: RtypesCore.h:50
virtual ~TGView()
Delete view.
Definition: TGView.cxx:148
virtual Bool_t HandleExpose(Event_t *event)
Handle expose events.
Definition: TGView.cxx:283
TGLongPosition fScrollVal
Definition: TGView.h:54
virtual void SetBackgroundPixmap(Pixmap_t p)
Set backgound pixmap.
Definition: TGView.cxx:590
void ScrollUp(Int_t pixels)
Definition: TGView.h:98
virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
update a part of view
Definition: TGView.cxx:203
TGVScrollBar * fVsb
Definition: TGView.h:64
Double_t y[n]
Definition: legend1.C:17
UInt_t fHeight
Definition: TGFrame.h:135
virtual void DoRedraw()
redraw
Definition: TGView.cxx:269
virtual void ScrollToPosition(TGLongPosition newPos)
Scroll the canvas to pos.
Definition: TGView.cxx:452
TGLongPosition GetScrollValue() const
Definition: TGView.h:109
Bool_t HandleMotion(Event_t *event)
Definition: TGView.h:152
void ScrollRight(Int_t pixels)
Definition: TGView.h:104
virtual void ScrollCanvas(Int_t newTop, Int_t direction)
Scroll the canvas to new_top in the kVertical or kHorizontal direction.
Definition: TGView.cxx:463
Handle_t Pixmap_t
Definition: GuiTypes.h:29
TGLongPosition GetScrollPosition() const
Definition: TGView.h:110
Int_t fScrolling
Definition: TGView.h:58
Bool_t HandleSelectionClear(Event_t *event)
Definition: TGView.h:142
TGViewFrame * GetCanvas() const
Definition: TGView.h:86
virtual void SetLayoutManager(TGLayoutManager *)
Set the layout manager for the composite frame.
Definition: TGView.h:94
virtual void Clear(Option_t *="")
Clear view.
Definition: TGView.cxx:160
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGView.h:107
void ScrollDown(Int_t pixels)
Definition: TGView.h:100
void ScrollLeft(Int_t pixels)
Definition: TGView.h:102
Definition: TGGC.h:31
virtual Bool_t HandleCrossing(Event_t *)
Definition: TGFrame.h:385
virtual void UpdateBackgroundStart()
set some gc values
Definition: TGView.cxx:227
virtual Bool_t HandleSelection(Event_t *)
Definition: TGFrame.h:389
TGDimension GetVirtualSize() const
Definition: TGView.h:108