ROOT logo
// @(#)root/gui:$Id: TGView.h 23115 2008-04-10 13:35:37Z rdm $
// Author: Fons Rademakers   30/6/2000

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGView
#define ROOT_TGView


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGView                                                               //
//                                                                      //
// A TGView provides the infrastructure for text viewer and editor      //
// widgets. It provides a canvas (TGViewFrame) and (optionally) a       //
// vertical and horizontal scrollbar and methods for marking and        //
// scrolling.                                                           //
//                                                                      //
// The TGView (and derivatives) will generate the following             //
// event messages:                                                      //
// kC_TEXTVIEW, kTXT_ISMARKED, widget id, [true|false]                  //
// kC_TEXTVIEW, kTXT_DATACHANGE, widget id, 0                           //
// kC_TEXTVIEW, kTXT_CLICK2, widget id, position (y << 16) | x)         //
// kC_TEXTVIEW, kTXT_CLICK3, widget id, position (y << 16) | x)         //
// kC_TEXTVIEW, kTXT_F3, widget id, true                                //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGWidget
#include "TGWidget.h"
#endif
#ifndef ROOT_TTimer
#include "TTimer.h"
#endif

class TGViewFrame;
class TGHScrollBar;
class TGVScrollBar;

class TGView : public TGCompositeFrame, public TGWidget {

friend class TGViewFrame;

public:
   enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
   enum { kHorizontal = 0, kVertical = 1 };

protected:
   TGLongPosition    fVisible;      // position of visible region
   TGLongPosition    fMousePos;     // position of mouse
   TGLongPosition    fScrollVal;    // scroll value
   TGDimension       fVirtualSize;  // the current virtual window size
   TGRectangle       fExposedRegion;// exposed area   

   Int_t             fScrolling;    // scrolling direction
   Atom_t            fClipboard;    // clipboard property
   UInt_t            fXMargin;      // x margin
   UInt_t            fYMargin;      // y margin
   TGViewFrame      *fCanvas;       // frame containing the text
   TGHScrollBar     *fHsb;          // horizontal scrollbar
   TGVScrollBar     *fVsb;          // vertical scrollbar

   TGGC              fWhiteGC;      // graphics context used for scrolling
                                    // generates GraphicsExposure events

   virtual void DoRedraw();
   virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
   virtual Bool_t ItemLayout() { return kFALSE; } 

private:
   TGView(const TGView&);              // not implemented
   TGView& operator=(const TGView&);   // not implemented

public:
   TGView(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
          UInt_t xMargin = 0, UInt_t yMargin = 0,
          UInt_t options = kSunkenFrame | kDoubleBorder,
          UInt_t sboptions = 0,
          Pixel_t back = GetWhitePixel());

   virtual ~TGView();

   TGViewFrame   *GetCanvas() const { return fCanvas; }

   virtual void   Clear(Option_t * = "");
   virtual void   SetVisibleStart(Int_t newTop, Int_t direction);
   virtual void   ScrollCanvas(Int_t newTop, Int_t direction);
   virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
   virtual void   DrawBorder();
   virtual void   Layout();
   virtual void   SetLayoutManager(TGLayoutManager*) { }
   virtual void   DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);

   virtual void ScrollToPosition(TGLongPosition newPos);
   void ScrollUp(Int_t pixels)
      { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY + pixels)); }
   void ScrollDown(Int_t pixels)
      { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY - pixels)); }
   void ScrollLeft(Int_t pixels)
      { ScrollToPosition(TGLongPosition(fVisible.fX + pixels, fVisible.fY)); }
   void ScrollRight(Int_t  pixels)
      { ScrollToPosition(TGLongPosition(fVisible.fX - pixels, fVisible.fY)); }

   virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
   TGDimension GetVirtualSize() const { return fVirtualSize; }
   TGLongPosition  GetScrollValue() const { return fScrollVal; }
   TGLongPosition  GetScrollPosition() const { return fVisible; }

   TGLongPosition ToVirtual(TGLongPosition coord)  const { return coord + fVisible; }
   TGLongPosition ToPhysical(TGLongPosition coord) const { return coord - fVisible; }

   virtual Bool_t HandleButton(Event_t *event);
   virtual Bool_t HandleExpose(Event_t *event);

   virtual void   ChangeBackground(Pixel_t);
   virtual void   SetBackgroundColor(Pixel_t);
   virtual void   SetBackgroundPixmap(Pixmap_t p);
   virtual void   UpdateBackgroundStart();

   const TGGC &GetViewWhiteGC() { return fWhiteGC; }

   ClassDef(TGView,0)  // View widget base class
};


class TGViewFrame : public TGCompositeFrame {
private:
   TGView   *fView;  // pointer back to the view

   TGViewFrame(const TGViewFrame&);              // not implemented
   TGViewFrame& operator=(const TGViewFrame&);   // not implemented

public:
   TGViewFrame(TGView *v, UInt_t w, UInt_t h, UInt_t options = 0,
               Pixel_t back = GetWhitePixel());

   Bool_t HandleSelectionRequest(Event_t *event)
            { return fView->HandleSelectionRequest(event); }
   Bool_t HandleSelectionClear(Event_t *event)
            { return fView->HandleSelectionClear(event); }
   Bool_t HandleSelection(Event_t *event)
            { return fView->HandleSelection(event); }
   Bool_t HandleButton(Event_t *event)
            { return fView->HandleButton(event); }
   Bool_t HandleExpose(Event_t *event)
            { return fView->HandleExpose(event); }
   Bool_t HandleCrossing(Event_t *event)
            { return fView->HandleCrossing(event); }
   Bool_t HandleMotion(Event_t *event)
            { return fView->HandleMotion(event); }
   Bool_t HandleKey(Event_t *event)
            { return fView->HandleKey(event); }
   Bool_t HandleDoubleClick(Event_t *event)
            { return fView->HandleDoubleClick(event); }

   ClassDef(TGViewFrame,0)  // Frame containing the actual text
};



#endif
 TGView.h:1
 TGView.h:2
 TGView.h:3
 TGView.h:4
 TGView.h:5
 TGView.h:6
 TGView.h:7
 TGView.h:8
 TGView.h:9
 TGView.h:10
 TGView.h:11
 TGView.h:12
 TGView.h:13
 TGView.h:14
 TGView.h:15
 TGView.h:16
 TGView.h:17
 TGView.h:18
 TGView.h:19
 TGView.h:20
 TGView.h:21
 TGView.h:22
 TGView.h:23
 TGView.h:24
 TGView.h:25
 TGView.h:26
 TGView.h:27
 TGView.h:28
 TGView.h:29
 TGView.h:30
 TGView.h:31
 TGView.h:32
 TGView.h:33
 TGView.h:34
 TGView.h:35
 TGView.h:36
 TGView.h:37
 TGView.h:38
 TGView.h:39
 TGView.h:40
 TGView.h:41
 TGView.h:42
 TGView.h:43
 TGView.h:44
 TGView.h:45
 TGView.h:46
 TGView.h:47
 TGView.h:48
 TGView.h:49
 TGView.h:50
 TGView.h:51
 TGView.h:52
 TGView.h:53
 TGView.h:54
 TGView.h:55
 TGView.h:56
 TGView.h:57
 TGView.h:58
 TGView.h:59
 TGView.h:60
 TGView.h:61
 TGView.h:62
 TGView.h:63
 TGView.h:64
 TGView.h:65
 TGView.h:66
 TGView.h:67
 TGView.h:68
 TGView.h:69
 TGView.h:70
 TGView.h:71
 TGView.h:72
 TGView.h:73
 TGView.h:74
 TGView.h:75
 TGView.h:76
 TGView.h:77
 TGView.h:78
 TGView.h:79
 TGView.h:80
 TGView.h:81
 TGView.h:82
 TGView.h:83
 TGView.h:84
 TGView.h:85
 TGView.h:86
 TGView.h:87
 TGView.h:88
 TGView.h:89
 TGView.h:90
 TGView.h:91
 TGView.h:92
 TGView.h:93
 TGView.h:94
 TGView.h:95
 TGView.h:96
 TGView.h:97
 TGView.h:98
 TGView.h:99
 TGView.h:100
 TGView.h:101
 TGView.h:102
 TGView.h:103
 TGView.h:104
 TGView.h:105
 TGView.h:106
 TGView.h:107
 TGView.h:108
 TGView.h:109
 TGView.h:110
 TGView.h:111
 TGView.h:112
 TGView.h:113
 TGView.h:114
 TGView.h:115
 TGView.h:116
 TGView.h:117
 TGView.h:118
 TGView.h:119
 TGView.h:120
 TGView.h:121
 TGView.h:122
 TGView.h:123
 TGView.h:124
 TGView.h:125
 TGView.h:126
 TGView.h:127
 TGView.h:128
 TGView.h:129
 TGView.h:130
 TGView.h:131
 TGView.h:132
 TGView.h:133
 TGView.h:134
 TGView.h:135
 TGView.h:136
 TGView.h:137
 TGView.h:138
 TGView.h:139
 TGView.h:140
 TGView.h:141
 TGView.h:142
 TGView.h:143
 TGView.h:144
 TGView.h:145
 TGView.h:146
 TGView.h:147
 TGView.h:148
 TGView.h:149
 TGView.h:150
 TGView.h:151
 TGView.h:152
 TGView.h:153
 TGView.h:154
 TGView.h:155
 TGView.h:156
 TGView.h:157
 TGView.h:158
 TGView.h:159
 TGView.h:160
 TGView.h:161
 TGView.h:162
 TGView.h:163
 TGView.h:164
 TGView.h:165
 TGView.h:166
 TGView.h:167
 TGView.h:168
 TGView.h:169
 TGView.h:170