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 
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)
100  void ScrollDown(Int_t pixels)
102  void ScrollLeft(Int_t pixels)
104  void ScrollRight(Int_t pixels)
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
TGViewFrame::HandleKey
Bool_t HandleKey(Event_t *event)
Definition: TGView.h:154
TGViewFrame::TGViewFrame
TGViewFrame(const TGViewFrame &)
TGView::fClipboard
Atom_t fClipboard
Definition: TGView.h:59
TGWindow
Definition: TGWindow.h:31
Pixmap_t
Handle_t Pixmap_t
Definition: GuiTypes.h:29
TGView::kNoHSB
@ kNoHSB
Definition: TGView.h:48
TGVScrollBar
Definition: TGScrollBar.h:183
TGView::fWhiteGC
TGGC fWhiteGC
Definition: TGView.h:66
TGView::fScrolling
Int_t fScrolling
Definition: TGView.h:58
TGDimension
Definition: TGDimension.h:27
TGView::ScrollDown
void ScrollDown(Int_t pixels)
Definition: TGView.h:100
TGView::kVertical
@ kVertical
Definition: TGView.h:49
TGView::~TGView
virtual ~TGView()
Delete view.
Definition: TGView.cxx:147
TGView::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGView.h:107
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGFrame::fWidth
UInt_t fWidth
Definition: TGFrame.h:112
TGFrame::HandleSelectionClear
virtual Bool_t HandleSelectionClear(Event_t *)
Definition: TGFrame.h:195
TGView::HandleExpose
virtual Bool_t HandleExpose(Event_t *event)
Handle expose events.
Definition: TGView.cxx:282
TGViewFrame::HandleSelectionRequest
Bool_t HandleSelectionRequest(Event_t *event)
Definition: TGView.h:140
TGViewFrame::HandleDoubleClick
Bool_t HandleDoubleClick(Event_t *event)
Definition: TGView.h:156
TGView::fScrollVal
TGLongPosition fScrollVal
Definition: TGView.h:54
TGView::fXMargin
UInt_t fXMargin
Definition: TGView.h:60
TGLongPosition::fY
Long_t fY
Definition: TGDimension.h:66
TGCompositeFrame::HandleCrossing
virtual Bool_t HandleCrossing(Event_t *)
Definition: TGFrame.h:363
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGView::SetBackgroundColor
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
Definition: TGView.cxx:579
TGViewFrame::HandleCrossing
Bool_t HandleCrossing(Event_t *event)
Definition: TGView.h:150
TGCompositeFrame::HandleSelection
virtual Bool_t HandleSelection(Event_t *)
Definition: TGFrame.h:367
Int_t
int Int_t
Definition: RtypesCore.h:45
TGWidget
Definition: TGWidget.h:55
TGView::DoRedraw
virtual void DoRedraw()
redraw
Definition: TGView.cxx:268
TGView::ScrollToPosition
virtual void ScrollToPosition(TGLongPosition newPos)
Scroll the canvas to pos.
Definition: TGView.cxx:451
TGView::fVsb
TGVScrollBar * fVsb
Definition: TGView.h:64
x
Double_t x[n]
Definition: legend1.C:17
TGView::fExposedRegion
TGRectangle fExposedRegion
Definition: TGView.h:56
TGViewFrame::operator=
TGViewFrame & operator=(const TGViewFrame &)
TTimer.h
TGFrame::HandleSelectionRequest
virtual Bool_t HandleSelectionRequest(Event_t *)
Definition: TGFrame.h:194
TGView::SetLayoutManager
virtual void SetLayoutManager(TGLayoutManager *)
Set the layout manager for the composite frame.
Definition: TGView.h:94
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGView::Clear
virtual void Clear(Option_t *="")
Clear view.
Definition: TGView.cxx:159
TGView::GetScrollPosition
TGLongPosition GetScrollPosition() const
Definition: TGView.h:110
TGView::fCanvas
TGViewFrame * fCanvas
Definition: TGView.h:62
kDoubleBorder
@ kDoubleBorder
Definition: GuiTypes.h:385
v
@ v
Definition: rootcling_impl.cxx:3635
TGView::GetScrollValue
TGLongPosition GetScrollValue() const
Definition: TGView.h:109
TGView::HandleButton
virtual Bool_t HandleButton(Event_t *event)
handle button
Definition: TGView.cxx:235
TGView::TGView
TGView(const TGView &)
bool
TGView::GetCanvas
TGViewFrame * GetCanvas() const
Definition: TGView.h:86
TGView::ScrollRight
void ScrollRight(Int_t pixels)
Definition: TGView.h:104
TGView::ItemLayout
virtual Bool_t ItemLayout()
Definition: TGView.h:71
TGView::GetViewWhiteGC
const TGGC & GetViewWhiteGC()
Definition: TGView.h:123
TGViewFrame::HandleSelection
Bool_t HandleSelection(Event_t *event)
Definition: TGView.h:144
TGLayoutManager
Definition: TGLayout.h:142
TGView::ScrollCanvas
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
TGViewFrame::HandleExpose
Bool_t HandleExpose(Event_t *event)
Definition: TGView.h:148
TGRectangle
Definition: TGDimension.h:98
TGView::ScrollLeft
void ScrollLeft(Int_t pixels)
Definition: TGView.h:102
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGCompositeFrame::HandleDoubleClick
virtual Bool_t HandleDoubleClick(Event_t *)
Definition: TGFrame.h:362
kSunkenFrame
@ kSunkenFrame
Definition: GuiTypes.h:383
TGView::ProcessMessage
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process scrollbar messages.
Definition: TGView.cxx:314
TGView::SetBackgroundPixmap
virtual void SetBackgroundPixmap(Pixmap_t p)
Set backgound pixmap.
Definition: TGView.cxx:589
TGView::GetVirtualSize
TGDimension GetVirtualSize() const
Definition: TGView.h:108
h
#define h(i)
Definition: RSha256.hxx:124
TGGC
Definition: TGGC.h:31
TGView::fYMargin
UInt_t fYMargin
Definition: TGView.h:61
TGHScrollBar
Definition: TGScrollBar.h:160
Atom_t
Handle_t Atom_t
Definition: GuiTypes.h:36
TGView::UpdateBackgroundStart
virtual void UpdateBackgroundStart()
set some gc values
Definition: TGView.cxx:226
TGLongPosition::fX
Long_t fX
Definition: TGDimension.h:65
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGView::fVisible
TGLongPosition fVisible
Definition: TGView.h:52
TGFrame.h
Long_t
long Long_t
Definition: RtypesCore.h:54
TGView::kNoVSB
@ kNoVSB
Definition: TGView.h:48
BIT
#define BIT(n)
Definition: Rtypes.h:85
TGView::Layout
virtual void Layout()
layout view
Definition: TGView.cxx:344
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGViewFrame::HandleButton
Bool_t HandleButton(Event_t *event)
Definition: TGView.h:146
y
Double_t y[n]
Definition: legend1.C:17
TGView::ChangeBackground
virtual void ChangeBackground(Pixel_t)
Change background color of the canvas frame.
Definition: TGView.cxx:568
TGCompositeFrame::HandleKey
virtual Bool_t HandleKey(Event_t *)
Definition: TGFrame.h:365
TGViewFrame::HandleMotion
Bool_t HandleMotion(Event_t *event)
Definition: TGView.h:152
TGView::ToPhysical
TGLongPosition ToPhysical(TGLongPosition coord) const
Definition: TGView.h:113
TGView::DrawRegion
virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw region.
Definition: TGView.cxx:194
TGView::DrawBorder
virtual void DrawBorder()
Draw the border of the text edit widget.
Definition: TGView.cxx:426
TGView::fMousePos
TGLongPosition fMousePos
Definition: TGView.h:53
TGWidget.h
TGView::fVirtualSize
TGDimension fVirtualSize
Definition: TGView.h:55
unsigned int
TGView::SetVisibleStart
virtual void SetVisibleStart(Int_t newTop, Int_t direction)
Scroll view in specified direction to make newTop the visible location.
Definition: TGView.cxx:176
TGLongPosition
Definition: TGDimension.h:63
TGViewFrame::HandleSelectionClear
Bool_t HandleSelectionClear(Event_t *event)
Definition: TGView.h:142
TGView::kHorizontal
@ kHorizontal
Definition: TGView.h:49
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
Event_t
Definition: GuiTypes.h:173
TGFrame::GetWhitePixel
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:694
TGView::fHsb
TGHScrollBar * fHsb
Definition: TGView.h:63
TGViewFrame
Definition: TGView.h:129
TGFrame::fHeight
UInt_t fHeight
Definition: TGFrame.h:113
TGViewFrame::fView
TGView * fView
Definition: TGView.h:131
TGView::ScrollUp
void ScrollUp(Int_t pixels)
Definition: TGView.h:98
TGCompositeFrame
Definition: TGFrame.h:324
TGView::UpdateRegion
virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
update a part of view
Definition: TGView.cxx:202
TGView::ToVirtual
TGLongPosition ToVirtual(TGLongPosition coord) const
Definition: TGView.h:112
TGCompositeFrame::HandleMotion
virtual Bool_t HandleMotion(Event_t *)
Definition: TGFrame.h:364
TGView
Definition: TGView.h:43
int
TGView::operator=
TGView & operator=(const TGView &)