Logo ROOT   6.08/07
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 #ifndef ROOT_TGFrame
36 #include "TGFrame.h"
37 #endif
38 #ifndef ROOT_TGWidget
39 #include "TGWidget.h"
40 #endif
41 #ifndef ROOT_TTimer
42 #include "TTimer.h"
43 #endif
44 
45 class TGViewFrame;
46 class TGHScrollBar;
47 class TGVScrollBar;
48 
49 class TGView : public TGCompositeFrame, public TGWidget {
50 
51 friend class TGViewFrame;
52 
53 public:
54  enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
55  enum { kHorizontal = 0, kVertical = 1 };
56 
57 protected:
58  TGLongPosition fVisible; // position of visible region
59  TGLongPosition fMousePos; // position of mouse
60  TGLongPosition fScrollVal; // scroll value
61  TGDimension fVirtualSize; // the current virtual window size
62  TGRectangle fExposedRegion;// exposed area
63 
64  Int_t fScrolling; // scrolling direction
65  Atom_t fClipboard; // clipboard property
66  UInt_t fXMargin; // x margin
67  UInt_t fYMargin; // y margin
68  TGViewFrame *fCanvas; // frame containing the text
69  TGHScrollBar *fHsb; // horizontal scrollbar
70  TGVScrollBar *fVsb; // vertical scrollbar
71 
72  TGGC fWhiteGC; // graphics context used for scrolling
73  // generates GraphicsExposure events
74 
75  virtual void DoRedraw();
76  virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
77  virtual Bool_t ItemLayout() { return kFALSE; }
78 
79 private:
80  TGView(const TGView&); // not implemented
81  TGView& operator=(const TGView&); // not implemented
82 
83 public:
84  TGView(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
85  UInt_t xMargin = 0, UInt_t yMargin = 0,
86  UInt_t options = kSunkenFrame | kDoubleBorder,
87  UInt_t sboptions = 0,
88  Pixel_t back = GetWhitePixel());
89 
90  virtual ~TGView();
91 
92  TGViewFrame *GetCanvas() const { return fCanvas; }
93 
94  virtual void Clear(Option_t * = "");
95  virtual void SetVisibleStart(Int_t newTop, Int_t direction);
96  virtual void ScrollCanvas(Int_t newTop, Int_t direction);
97  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
98  virtual void DrawBorder();
99  virtual void Layout();
101  virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
102 
103  virtual void ScrollToPosition(TGLongPosition newPos);
104  void ScrollUp(Int_t pixels)
105  { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY + pixels)); }
106  void ScrollDown(Int_t pixels)
107  { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY - pixels)); }
108  void ScrollLeft(Int_t pixels)
109  { ScrollToPosition(TGLongPosition(fVisible.fX + pixels, fVisible.fY)); }
110  void ScrollRight(Int_t pixels)
111  { ScrollToPosition(TGLongPosition(fVisible.fX - pixels, fVisible.fY)); }
112 
113  virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
117 
118  TGLongPosition ToVirtual(TGLongPosition coord) const { return coord + fVisible; }
119  TGLongPosition ToPhysical(TGLongPosition coord) const { return coord - fVisible; }
120 
121  virtual Bool_t HandleButton(Event_t *event);
122  virtual Bool_t HandleExpose(Event_t *event);
123 
124  virtual void ChangeBackground(Pixel_t);
125  virtual void SetBackgroundColor(Pixel_t);
126  virtual void SetBackgroundPixmap(Pixmap_t p);
127  virtual void UpdateBackgroundStart();
128 
129  const TGGC &GetViewWhiteGC() { return fWhiteGC; }
130 
131  ClassDef(TGView,0) // View widget base class
132 };
133 
134 
136 private:
137  TGView *fView; // pointer back to the view
138 
139  TGViewFrame(const TGViewFrame&); // not implemented
140  TGViewFrame& operator=(const TGViewFrame&); // not implemented
141 
142 public:
143  TGViewFrame(TGView *v, UInt_t w, UInt_t h, UInt_t options = 0,
144  Pixel_t back = GetWhitePixel());
145 
147  { return fView->HandleSelectionRequest(event); }
149  { return fView->HandleSelectionClear(event); }
151  { return fView->HandleSelection(event); }
153  { return fView->HandleButton(event); }
155  { return fView->HandleExpose(event); }
157  { return fView->HandleCrossing(event); }
159  { return fView->HandleMotion(event); }
161  { return fView->HandleKey(event); }
163  { return fView->HandleDoubleClick(event); }
164 
165  ClassDef(TGViewFrame,0) // Frame containing the actual text
166 };
167 
168 
169 
170 #endif
TGView * fView
Definition: TGView.h:137
Bool_t HandleDoubleClick(Event_t *event)
Definition: TGView.h:162
Bool_t HandleKey(Event_t *event)
Definition: TGView.h:160
Definition: TGView.h:49
TGLongPosition ToPhysical(TGLongPosition coord) const
Definition: TGView.h:119
virtual void Layout()
layout view
Definition: TGView.cxx:345
virtual Bool_t HandleKey(Event_t *)
Definition: TGFrame.h:403
UInt_t fYMargin
Definition: TGView.h:67
TGDimension fVirtualSize
Definition: TGView.h:61
TGRectangle fExposedRegion
Definition: TGView.h:62
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:400
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:58
#define BIT(n)
Definition: Rtypes.h:120
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
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual void DrawBorder()
Draw the border of the text edit widget.
Definition: TGView.cxx:427
TGHScrollBar * fHsb
Definition: TGView.h:69
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:146
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
UInt_t fXMargin
Definition: TGView.h:66
Handle_t Atom_t
Definition: GuiTypes.h:38
Bool_t HandleCrossing(Event_t *event)
Definition: TGView.h:156
virtual Bool_t HandleSelectionRequest(Event_t *)
Definition: TGFrame.h:232
TGLongPosition fMousePos
Definition: TGView.h:59
TGLongPosition ToVirtual(TGLongPosition coord) const
Definition: TGView.h:118
TGView & operator=(const TGView &)
TGView(const TGView &)
Bool_t HandleSelection(Event_t *event)
Definition: TGView.h:150
SVector< double, 2 > v
Definition: Dict.h:5
TGViewFrame * fCanvas
Definition: TGView.h:68
friend class TGViewFrame
Definition: TGView.h:51
Bool_t HandleButton(Event_t *event)
Definition: TGView.h:152
Bool_t HandleExpose(Event_t *event)
Definition: TGView.h:154
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Bool_t ItemLayout()
Definition: TGView.h:77
const TGGC & GetViewWhiteGC()
Definition: TGView.h:129
Atom_t fClipboard
Definition: TGView.h:65
virtual Bool_t HandleSelectionClear(Event_t *)
Definition: TGFrame.h:233
TGGC fWhiteGC
Definition: TGView.h:72
UInt_t fWidth
Definition: TGFrame.h:150
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
Definition: TGView.cxx:580
virtual Bool_t HandleMotion(Event_t *)
Definition: TGFrame.h:402
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:60
virtual void SetBackgroundPixmap(Pixmap_t p)
Set backgound pixmap.
Definition: TGView.cxx:590
void ScrollUp(Int_t pixels)
Definition: TGView.h:104
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:70
Double_t y[n]
Definition: legend1.C:17
UInt_t fHeight
Definition: TGFrame.h:151
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:115
Bool_t HandleMotion(Event_t *event)
Definition: TGView.h:158
void ScrollRight(Int_t pixels)
Definition: TGView.h:110
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:31
TGLongPosition GetScrollPosition() const
Definition: TGView.h:116
Int_t fScrolling
Definition: TGView.h:64
Bool_t HandleSelectionClear(Event_t *event)
Definition: TGView.h:148
TGViewFrame * GetCanvas() const
Definition: TGView.h:92
virtual void SetLayoutManager(TGLayoutManager *)
Set the layout manager for the composite frame.
Definition: TGView.h:100
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:113
void ScrollDown(Int_t pixels)
Definition: TGView.h:106
void ScrollLeft(Int_t pixels)
Definition: TGView.h:108
Definition: TGGC.h:35
virtual Bool_t HandleCrossing(Event_t *)
Definition: TGFrame.h:401
virtual void UpdateBackgroundStart()
set some gc values
Definition: TGView.cxx:227
virtual Bool_t HandleSelection(Event_t *)
Definition: TGFrame.h:405
TGDimension GetVirtualSize() const
Definition: TGView.h:114