TGCanvas.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGCanvas.h 25499 2008-09-22 19:54:46Z bellenot $
00002 // Author: Fons Rademakers   11/01/98
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_TGCanvas
00013 #define ROOT_TGCanvas
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGCanvas and TGViewPort and TGContainer                              //
00019 //                                                                      //
00020 // A TGCanvas is a frame containing two scrollbars (horizontal and      //
00021 // vertical) and a viewport. The viewport acts as the window through    //
00022 // which we look at the contents of the container frame.                //
00023 //                                                                      //
00024 //////////////////////////////////////////////////////////////////////////
00025 
00026 #ifndef ROOT_TGFrame
00027 #include "TGFrame.h"
00028 #endif
00029 
00030 class TGHScrollBar;
00031 class TGVScrollBar;
00032 class TGClient;
00033 class TGViewPort;
00034 class TGCanvas;
00035 class TGFrameElement;
00036 class TGContainerTimer;
00037 class TGContainerKeyboardTimer;
00038 class TGContainerScrollTimer;
00039 class TGListView;
00040 class TGPicture;
00041 class TGRectangle;
00042 
00043 class TGContainer : public TGCompositeFrame {
00044 
00045 friend class TGViewPort;
00046 friend class TGCanvas;
00047 friend class TGContainerKeyboardTimer;
00048 friend class TGContainerScrollTimer;
00049 friend class TGListView;
00050 
00051 protected:
00052    TGViewPort        *fViewPort;      // container viewport
00053    TGCanvas          *fCanvas;        // pointer to canvas
00054    const TGWindow    *fMsgWindow;     // window handling container messages
00055    TGFrameElement    *fLastActiveEl;  // last active item
00056    Int_t              fXp, fYp;       // previous pointer position
00057    Int_t              fX0, fY0;       // corner of rubber band box
00058    Int_t              fXf, fYf;       // other corner of rubber band box
00059    Bool_t             fDragging;      // true if in dragging mode
00060    Int_t              fTotal;         // total items
00061    Int_t              fSelected;      // number of selected items
00062    TTimer            *fScrollTimer;   // autoscroll timer
00063    Bool_t             fOnMouseOver;   // kTRUE when mouse pointer is over entry
00064    Bool_t             fLastDir;       // direction of last search
00065    Bool_t             fLastCase;      // case sensetivity of last search
00066    Bool_t             fLastSubstring; // substring search option of last search
00067    TString            fLastName;      // the name of object of last search
00068    TTimer            *fKeyTimer;      // keyboard timer
00069    TString            fKeyInput;      // keyboard input (buffer)
00070    Bool_t             fKeyTimerActive;// kTRUE - keyboard timer is active
00071    Bool_t             fScrolling;     // kTRUE - when scrolling is ON
00072    Int_t              fXDND, fYDND;
00073    Bool_t             fBdown;
00074    TGRectangle        fExposedRegion; // exposed area
00075 
00076    static TGGC       *fgLineGC;
00077    static const TGGC &GetLineGC();
00078 
00079    virtual void DoRedraw();
00080    virtual void ActivateItem(TGFrameElement* el);
00081    virtual void DeActivateItem(TGFrameElement* el);
00082    virtual void SearchPattern();
00083    virtual void OnAutoScroll();
00084    virtual void RepeatSearch();
00085    
00086 private:
00087    TGContainer(const TGContainer&);               // not implemented
00088    TGContainer& operator=(const TGContainer&);    // not implemented
00089 
00090 public:
00091    TGContainer(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00092                UInt_t options = kSunkenFrame,
00093                Pixel_t back = GetDefaultFrameBackground());
00094    TGContainer(TGCanvas *p,UInt_t options = kSunkenFrame,
00095                Pixel_t back = GetDefaultFrameBackground());
00096 
00097    virtual ~TGContainer();
00098 
00099    virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
00100    virtual void ClearViewPort();
00101    virtual void Associate(const TGWindow *w) { fMsgWindow = w; }
00102    virtual void AdjustPosition();
00103    virtual void SetPagePosition(const TGPosition& pos);
00104    virtual void SetPagePosition(Int_t x, Int_t y);
00105    virtual void SetPageDimension(const TGDimension& dim);
00106    virtual void SetPageDimension(UInt_t w, UInt_t h);
00107    virtual void RemoveAll();
00108    virtual void RemoveItem(TGFrame *item);
00109    virtual void Layout();
00110 
00111    TGCanvas         *GetCanvas() const { return fCanvas; }
00112    const TGWindow   *GetMessageWindow() const { return fMsgWindow; }
00113    virtual TGPosition   GetPagePosition() const;
00114    virtual TGDimension  GetPageDimension() const;
00115 
00116    virtual Int_t  NumSelected() const { return fSelected; }
00117    virtual Int_t  NumItems() const { return fTotal; }
00118    virtual TGFrameElement *FindFrame(Int_t x,Int_t y,Bool_t exclude=kTRUE);
00119    virtual TGFrame        *FindFrameByName(const char *name);
00120    virtual TGHScrollBar *GetHScrollbar() const;
00121    virtual TGVScrollBar *GetVScrollbar() const;
00122    virtual void SetHsbPosition(Int_t newPos);
00123    virtual void SetVsbPosition(Int_t newPos);
00124    virtual void LineUp(Bool_t select = kFALSE);
00125    virtual void LineDown(Bool_t select = kFALSE);
00126    virtual void LineLeft(Bool_t select = kFALSE);
00127    virtual void LineRight(Bool_t select = kFALSE);
00128    virtual void PageUp(Bool_t select = kFALSE);
00129    virtual void PageDown(Bool_t select = kFALSE);
00130    virtual void Home(Bool_t select = kFALSE);
00131    virtual void End(Bool_t select = kFALSE);
00132    virtual void Search(Bool_t close = kTRUE);
00133    virtual void *FindItem(const TString& name,
00134                           Bool_t direction = kTRUE,
00135                           Bool_t caseSensitive = kTRUE,
00136                           Bool_t subString = kFALSE);
00137 
00138    virtual const TGFrame *GetNextSelected(void **current);
00139    virtual TGFrame *GetLastActive() const { return fLastActiveEl ? fLastActiveEl->fFrame : 0; }
00140    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00141 
00142    virtual Bool_t HandleDNDFinished() { fBdown = kFALSE; return kTRUE; }
00143    virtual Bool_t HandleExpose(Event_t *event);
00144    virtual Bool_t HandleButton(Event_t *event);
00145    virtual Bool_t HandleDoubleClick(Event_t *event);
00146    virtual Bool_t HandleMotion(Event_t *event);
00147    virtual Bool_t HandleKey(Event_t *event);
00148 
00149    const TGPicture *GetObjPicture(TGFrame *f);
00150    virtual void SetDragPixmap(const TGPicture *pic);
00151 
00152    virtual void SelectAll();                    //*SIGNAL*
00153    virtual void UnSelectAll();                  //*SIGNAL*
00154    virtual void InvertSelection();              //*SIGNAL*
00155    virtual void ReturnPressed(TGFrame*);        //*SIGNAL*
00156    virtual void SpacePressed(TGFrame*);         //*SIGNAL*
00157    virtual void KeyPressed(TGFrame*, UInt_t keysym, UInt_t mask); //*SIGNAL*
00158    virtual void OnMouseOver(TGFrame*);          //*SIGNAL*
00159    virtual void CurrentChanged(Int_t x,Int_t y);//*SIGNAL*
00160    virtual void CurrentChanged(TGFrame* f);     //*SIGNAL*
00161    virtual void Clicked(TGFrame *f, Int_t btn); //*SIGNAL*
00162    virtual void DoubleClicked(TGFrame *f, Int_t btn);  //*SIGNAL*
00163    virtual void DoubleClicked(TGFrame *f, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
00164    virtual void Clicked(TGFrame *f, Int_t btn, Int_t x, Int_t y);       //*SIGNAL*
00165 
00166    ClassDef(TGContainer,0)  // Canvas container
00167 };
00168 
00169 
00170 class TGViewPort : public TGCompositeFrame {
00171 
00172 protected:
00173    Int_t       fX0, fY0;     // position of container frame in viewport
00174    TGFrame    *fContainer;   // container frame
00175 
00176 private:
00177    TGViewPort(const TGViewPort&);             // not implemented
00178    TGViewPort& operator=(const TGViewPort&);  // not implemented
00179 
00180 public:
00181    TGViewPort(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00182               UInt_t options = kChildFrame,
00183               Pixel_t back = GetDefaultFrameBackground());
00184 
00185    TGFrame *GetContainer() const { return fContainer; }
00186    void SetContainer(TGFrame *f);
00187 
00188    virtual void DrawBorder() { };
00189    virtual void Layout() { }
00190    virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
00191 
00192    virtual void SetHPos(Int_t xpos);
00193    virtual void SetVPos(Int_t ypos);
00194    void SetPos(Int_t xpos, Int_t ypos);
00195 
00196    Int_t GetHPos() const { return fX0; }
00197    Int_t GetVPos() const { return fY0; }
00198    virtual Bool_t HandleConfigureNotify(Event_t *event);
00199 
00200    ClassDef(TGViewPort,0)  // Viewport through which to look at a container frame
00201 };
00202 
00203 
00204 class TGCanvas : public TGFrame {
00205 
00206 protected:
00207    TGViewPort      *fVport;        // viewport through which we look at contents
00208    TGHScrollBar    *fHScrollbar;   // horizontal scrollbar
00209    TGVScrollBar    *fVScrollbar;   // vertical scrollbar
00210    Int_t            fScrolling;    // flag which scrolling modes are allowed
00211 
00212 private:
00213    TGCanvas(const TGCanvas&);              // not implemented
00214    TGCanvas& operator=(const TGCanvas&);   // not implemented
00215 
00216 public:
00217    enum { kCanvasNoScroll         = 0,
00218           kCanvasScrollHorizontal = BIT(0),
00219           kCanvasScrollVertical   = BIT(1),
00220           kCanvasScrollBoth       = (kCanvasScrollHorizontal | kCanvasScrollVertical)
00221    };
00222 
00223    TGCanvas(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
00224             UInt_t options = kSunkenFrame | kDoubleBorder,
00225             Pixel_t back = GetDefaultFrameBackground());
00226    virtual ~TGCanvas();
00227 
00228    TGFrame      *GetContainer() const { return fVport->GetContainer(); }
00229    TGViewPort   *GetViewPort() const { return fVport; }
00230    TGHScrollBar *GetHScrollbar() const { return fHScrollbar; }
00231    TGVScrollBar *GetVScrollbar() const { return fVScrollbar; }
00232 
00233    virtual void  AddFrame(TGFrame *f, TGLayoutHints *l = 0);
00234    virtual void  SetContainer(TGFrame *f) { fVport->SetContainer(f); }
00235    virtual void  MapSubwindows();
00236    virtual void  DrawBorder();
00237    virtual void  Layout();
00238    virtual void  ClearViewPort();
00239    virtual Int_t GetHsbPosition() const;
00240    virtual Int_t GetVsbPosition() const;
00241    virtual void  SetHsbPosition(Int_t newPos);
00242    virtual void  SetVsbPosition(Int_t newPos);
00243    void          SetScrolling(Int_t scrolling);
00244    Int_t         GetScrolling() const { return fScrolling; }
00245 
00246    virtual TGDimension GetDefaultSize() const { return TGDimension(fWidth, fHeight); }
00247    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00248 
00249    virtual void SavePrimitive(ostream &out, Option_t *option = "");
00250 
00251    ClassDef(TGCanvas,0)  // A canvas with two scrollbars and a viewport
00252 };
00253 
00254 
00255 #endif

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