TGView.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGView.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   30/6/2000
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGView
00013 #define ROOT_TGView
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGView                                                               //
00019 //                                                                      //
00020 // A TGView provides the infrastructure for text viewer and editor      //
00021 // widgets. It provides a canvas (TGViewFrame) and (optionally) a       //
00022 // vertical and horizontal scrollbar and methods for marking and        //
00023 // scrolling.                                                           //
00024 //                                                                      //
00025 // The TGView (and derivatives) will generate the following             //
00026 // event messages:                                                      //
00027 // kC_TEXTVIEW, kTXT_ISMARKED, widget id, [true|false]                  //
00028 // kC_TEXTVIEW, kTXT_DATACHANGE, widget id, 0                           //
00029 // kC_TEXTVIEW, kTXT_CLICK2, widget id, position (y << 16) | x)         //
00030 // kC_TEXTVIEW, kTXT_CLICK3, widget id, position (y << 16) | x)         //
00031 // kC_TEXTVIEW, kTXT_F3, widget id, true                                //
00032 //                                                                      //
00033 //////////////////////////////////////////////////////////////////////////
00034 
00035 #ifndef ROOT_TGFrame
00036 #include "TGFrame.h"
00037 #endif
00038 #ifndef ROOT_TGWidget
00039 #include "TGWidget.h"
00040 #endif
00041 #ifndef ROOT_TTimer
00042 #include "TTimer.h"
00043 #endif
00044 
00045 class TGViewFrame;
00046 class TGHScrollBar;
00047 class TGVScrollBar;
00048 
00049 class TGView : public TGCompositeFrame, public TGWidget {
00050 
00051 friend class TGViewFrame;
00052 
00053 public:
00054    enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
00055    enum { kHorizontal = 0, kVertical = 1 };
00056 
00057 protected:
00058    TGLongPosition    fVisible;      // position of visible region
00059    TGLongPosition    fMousePos;     // position of mouse
00060    TGLongPosition    fScrollVal;    // scroll value
00061    TGDimension       fVirtualSize;  // the current virtual window size
00062    TGRectangle       fExposedRegion;// exposed area   
00063 
00064    Int_t             fScrolling;    // scrolling direction
00065    Atom_t            fClipboard;    // clipboard property
00066    UInt_t            fXMargin;      // x margin
00067    UInt_t            fYMargin;      // y margin
00068    TGViewFrame      *fCanvas;       // frame containing the text
00069    TGHScrollBar     *fHsb;          // horizontal scrollbar
00070    TGVScrollBar     *fVsb;          // vertical scrollbar
00071 
00072    TGGC              fWhiteGC;      // graphics context used for scrolling
00073                                     // generates GraphicsExposure events
00074 
00075    virtual void DoRedraw();
00076    virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
00077    virtual Bool_t ItemLayout() { return kFALSE; } 
00078 
00079 private:
00080    TGView(const TGView&);              // not implemented
00081    TGView& operator=(const TGView&);   // not implemented
00082 
00083 public:
00084    TGView(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
00085           UInt_t xMargin = 0, UInt_t yMargin = 0,
00086           UInt_t options = kSunkenFrame | kDoubleBorder,
00087           UInt_t sboptions = 0,
00088           Pixel_t back = GetWhitePixel());
00089 
00090    virtual ~TGView();
00091 
00092    TGViewFrame   *GetCanvas() const { return fCanvas; }
00093 
00094    virtual void   Clear(Option_t * = "");
00095    virtual void   SetVisibleStart(Int_t newTop, Int_t direction);
00096    virtual void   ScrollCanvas(Int_t newTop, Int_t direction);
00097    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00098    virtual void   DrawBorder();
00099    virtual void   Layout();
00100    virtual void   SetLayoutManager(TGLayoutManager*) { }
00101    virtual void   DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
00102 
00103    virtual void ScrollToPosition(TGLongPosition newPos);
00104    void ScrollUp(Int_t pixels)
00105       { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY + pixels)); }
00106    void ScrollDown(Int_t pixels)
00107       { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY - pixels)); }
00108    void ScrollLeft(Int_t pixels)
00109       { ScrollToPosition(TGLongPosition(fVisible.fX + pixels, fVisible.fY)); }
00110    void ScrollRight(Int_t  pixels)
00111       { ScrollToPosition(TGLongPosition(fVisible.fX - pixels, fVisible.fY)); }
00112 
00113    virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
00114    TGDimension GetVirtualSize() const { return fVirtualSize; }
00115    TGLongPosition  GetScrollValue() const { return fScrollVal; }
00116    TGLongPosition  GetScrollPosition() const { return fVisible; }
00117 
00118    TGLongPosition ToVirtual(TGLongPosition coord)  const { return coord + fVisible; }
00119    TGLongPosition ToPhysical(TGLongPosition coord) const { return coord - fVisible; }
00120 
00121    virtual Bool_t HandleButton(Event_t *event);
00122    virtual Bool_t HandleExpose(Event_t *event);
00123 
00124    virtual void   ChangeBackground(Pixel_t);
00125    virtual void   SetBackgroundColor(Pixel_t);
00126    virtual void   SetBackgroundPixmap(Pixmap_t p);
00127    virtual void   UpdateBackgroundStart();
00128 
00129    const TGGC &GetViewWhiteGC() { return fWhiteGC; }
00130 
00131    ClassDef(TGView,0)  // View widget base class
00132 };
00133 
00134 
00135 class TGViewFrame : public TGCompositeFrame {
00136 private:
00137    TGView   *fView;  // pointer back to the view
00138 
00139    TGViewFrame(const TGViewFrame&);              // not implemented
00140    TGViewFrame& operator=(const TGViewFrame&);   // not implemented
00141 
00142 public:
00143    TGViewFrame(TGView *v, UInt_t w, UInt_t h, UInt_t options = 0,
00144                Pixel_t back = GetWhitePixel());
00145 
00146    Bool_t HandleSelectionRequest(Event_t *event)
00147             { return fView->HandleSelectionRequest(event); }
00148    Bool_t HandleSelectionClear(Event_t *event)
00149             { return fView->HandleSelectionClear(event); }
00150    Bool_t HandleSelection(Event_t *event)
00151             { return fView->HandleSelection(event); }
00152    Bool_t HandleButton(Event_t *event)
00153             { return fView->HandleButton(event); }
00154    Bool_t HandleExpose(Event_t *event)
00155             { return fView->HandleExpose(event); }
00156    Bool_t HandleCrossing(Event_t *event)
00157             { return fView->HandleCrossing(event); }
00158    Bool_t HandleMotion(Event_t *event)
00159             { return fView->HandleMotion(event); }
00160    Bool_t HandleKey(Event_t *event)
00161             { return fView->HandleKey(event); }
00162    Bool_t HandleDoubleClick(Event_t *event)
00163             { return fView->HandleDoubleClick(event); }
00164 
00165    ClassDef(TGViewFrame,0)  // Frame containing the actual text
00166 };
00167 
00168 
00169 
00170 #endif

Generated on Tue Jul 5 14:20:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1