Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:48

0001 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   11/01/98
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGCanvas
0013 #define ROOT_TGCanvas
0014 
0015 
0016 #include "TGFrame.h"
0017 
0018 class TGHScrollBar;
0019 class TGVScrollBar;
0020 class TGClient;
0021 class TGViewPort;
0022 class TGCanvas;
0023 class TGFrameElement;
0024 class TGContainerTimer;
0025 class TGContainerKeyboardTimer;
0026 class TGContainerScrollTimer;
0027 class TGListView;
0028 class TGPicture;
0029 class TGRectangle;
0030 
0031 class TGContainer : public TGCompositeFrame {
0032 
0033 friend class TGViewPort;
0034 friend class TGCanvas;
0035 friend class TGContainerKeyboardTimer;
0036 friend class TGContainerScrollTimer;
0037 friend class TGListView;
0038 
0039 protected:
0040    TGViewPort        *fViewPort;      ///< container viewport
0041    TGCanvas          *fCanvas;        ///< pointer to canvas
0042    const TGWindow    *fMsgWindow;     ///< window handling container messages
0043    TGFrameElement    *fLastActiveEl;  ///< last active item
0044    Int_t              fXp, fYp;       ///< previous pointer position
0045    Int_t              fX0, fY0;       ///< corner of rubber band box
0046    Int_t              fXf, fYf;       ///< other corner of rubber band box
0047    Bool_t             fDragging;      ///< true if in dragging mode
0048    Int_t              fTotal;         ///< total items
0049    Int_t              fSelected;      ///< number of selected items
0050    TTimer            *fScrollTimer;   ///< autoscroll timer
0051    Bool_t             fOnMouseOver;   ///< kTRUE when mouse pointer is over entry
0052    Bool_t             fLastDir;       ///< direction of last search
0053    Bool_t             fLastCase;      ///< case sensitivity of last search
0054    Bool_t             fLastSubstring; ///< substring search option of last search
0055    TString            fLastName;      ///< the name of object of last search
0056    TTimer            *fKeyTimer;      ///< keyboard timer
0057    TString            fKeyInput;      ///< keyboard input (buffer)
0058    Bool_t             fKeyTimerActive;///< kTRUE - keyboard timer is active
0059    Bool_t             fScrolling;     ///< kTRUE - when scrolling is ON
0060    Int_t              fXDND, fYDND;
0061    Bool_t             fBdown;
0062    TGRectangle        fExposedRegion; ///< exposed area
0063 
0064    static TGGC       *fgLineGC;
0065    static const TGGC &GetLineGC();
0066 
0067    void         DoRedraw() override;
0068    virtual void ActivateItem(TGFrameElement* el);
0069    virtual void DeActivateItem(TGFrameElement* el);
0070    virtual void SearchPattern();
0071    virtual void OnAutoScroll();
0072    virtual void RepeatSearch();
0073 
0074 private:
0075    TGContainer(const TGContainer&) = delete;
0076    TGContainer& operator=(const TGContainer&) = delete;
0077 
0078 public:
0079    TGContainer(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0080                UInt_t options = kSunkenFrame,
0081                Pixel_t back = GetDefaultFrameBackground());
0082    TGContainer(TGCanvas *p,UInt_t options = kSunkenFrame,
0083                Pixel_t back = GetDefaultFrameBackground());
0084 
0085    ~TGContainer() override;
0086 
0087    virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
0088    virtual void ClearViewPort();
0089    virtual void Associate(const TGWindow *w) { fMsgWindow = w; }
0090    virtual void AdjustPosition();
0091    virtual void SetPagePosition(const TGPosition& pos);
0092    virtual void SetPagePosition(Int_t x, Int_t y);
0093    virtual void SetPageDimension(const TGDimension& dim);
0094    virtual void SetPageDimension(UInt_t w, UInt_t h);
0095    void         RemoveAll() override;
0096    virtual void RemoveItem(TGFrame *item);
0097    void         Layout() override;
0098 
0099    TGCanvas         *GetCanvas() const { return fCanvas; }
0100    const TGWindow   *GetMessageWindow() const { return fMsgWindow; }
0101    virtual TGPosition   GetPagePosition() const;
0102    virtual TGDimension  GetPageDimension() const;
0103 
0104    virtual Int_t  NumSelected() const { return fSelected; }
0105    virtual Int_t  NumItems() const { return fTotal; }
0106    virtual TGFrameElement *FindFrame(Int_t x,Int_t y, Bool_t exclude=kTRUE);
0107    virtual TGFrame        *FindFrameByName(const char *name);
0108    virtual TGHScrollBar *GetHScrollbar() const;
0109    virtual TGVScrollBar *GetVScrollbar() const;
0110    virtual void SetHsbPosition(Int_t newPos);
0111    virtual void SetVsbPosition(Int_t newPos);
0112    virtual void LineUp(Bool_t select = kFALSE);
0113    virtual void LineDown(Bool_t select = kFALSE);
0114    virtual void LineLeft(Bool_t select = kFALSE);
0115    virtual void LineRight(Bool_t select = kFALSE);
0116    virtual void PageUp(Bool_t select = kFALSE);
0117    virtual void PageDown(Bool_t select = kFALSE);
0118    virtual void Home(Bool_t select = kFALSE);
0119    virtual void End(Bool_t select = kFALSE);
0120    virtual void Search(Bool_t close = kTRUE);
0121    virtual void *FindItem(const TString& name,
0122                           Bool_t direction = kTRUE,
0123                           Bool_t caseSensitive = kTRUE,
0124                           Bool_t subString = kFALSE);
0125 
0126    virtual const TGFrame *GetNextSelected(void **current);
0127    virtual TGFrame *GetLastActive() const { return fLastActiveEl ? fLastActiveEl->fFrame : nullptr; }
0128    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0129 
0130    Bool_t HandleDNDFinished() override { fBdown = kFALSE; return kTRUE; }
0131    Bool_t HandleExpose(Event_t *event) override;
0132    Bool_t HandleButton(Event_t *event) override;
0133    Bool_t HandleDoubleClick(Event_t *event) override;
0134    Bool_t HandleMotion(Event_t *event) override;
0135    Bool_t HandleKey(Event_t *event) override;
0136 
0137    const TGPicture *GetObjPicture(TGFrame *f);
0138    virtual void SetDragPixmap(const TGPicture *pic);
0139 
0140    virtual void SelectAll();                    //*SIGNAL*
0141    virtual void UnSelectAll();                  //*SIGNAL*
0142    virtual void InvertSelection();              //*SIGNAL*
0143    virtual void ReturnPressed(TGFrame*);        //*SIGNAL*
0144    virtual void SpacePressed(TGFrame*);         //*SIGNAL*
0145    virtual void KeyPressed(TGFrame*, UInt_t keysym, UInt_t mask); //*SIGNAL*
0146    virtual void OnMouseOver(TGFrame*);          //*SIGNAL*
0147    virtual void CurrentChanged(Int_t x,Int_t y);//*SIGNAL*
0148    virtual void CurrentChanged(TGFrame* f);     //*SIGNAL*
0149    virtual void Clicked(TGFrame *f, Int_t btn); //*SIGNAL*
0150    virtual void DoubleClicked(TGFrame *f, Int_t btn);  //*SIGNAL*
0151    virtual void DoubleClicked(TGFrame *f, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
0152    virtual void Clicked(TGFrame *f, Int_t btn, Int_t x, Int_t y);       //*SIGNAL*
0153 
0154    ClassDefOverride(TGContainer,0)  // Canvas container
0155 };
0156 
0157 
0158 class TGViewPort : public TGCompositeFrame {
0159 
0160 protected:
0161    Int_t       fX0, fY0;     // position of container frame in viewport
0162    TGFrame    *fContainer;   // container frame
0163 
0164 private:
0165    TGViewPort(const TGViewPort&) = delete;
0166    TGViewPort& operator=(const TGViewPort&) = delete;
0167 
0168 public:
0169    TGViewPort(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0170               UInt_t options = kChildFrame,
0171               Pixel_t back = GetDefaultFrameBackground());
0172 
0173    TGFrame *GetContainer() const { return fContainer; }
0174    void SetContainer(TGFrame *f);
0175 
0176    void DrawBorder() override {}
0177    void Layout() override {}
0178    TGDimension GetDefaultSize() const override { return TGDimension(fWidth, fHeight); }
0179 
0180    virtual void SetHPos(Int_t xpos);
0181    virtual void SetVPos(Int_t ypos);
0182    void SetPos(Int_t xpos, Int_t ypos);
0183 
0184    Int_t GetHPos() const { return fX0; }
0185    Int_t GetVPos() const { return fY0; }
0186    Bool_t HandleConfigureNotify(Event_t *event) override;
0187 
0188    ClassDefOverride(TGViewPort,0)  // Viewport through which to look at a container frame
0189 };
0190 
0191 
0192 class TGCanvas : public TGFrame {
0193 
0194 protected:
0195    TGViewPort      *fVport;        ///< viewport through which we look at contents
0196    TGHScrollBar    *fHScrollbar;   ///< horizontal scrollbar
0197    TGVScrollBar    *fVScrollbar;   ///< vertical scrollbar
0198    Int_t            fScrolling;    ///< flag which scrolling modes are allowed
0199 
0200 private:
0201    TGCanvas(const TGCanvas&) = delete;
0202    TGCanvas& operator=(const TGCanvas&) = delete;
0203 
0204 public:
0205    enum { kCanvasNoScroll         = 0,
0206           kCanvasScrollHorizontal = BIT(0),
0207           kCanvasScrollVertical   = BIT(1),
0208           kCanvasScrollBoth       = (kCanvasScrollHorizontal | kCanvasScrollVertical)
0209    };
0210 
0211    TGCanvas(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0212             UInt_t options = kSunkenFrame | kDoubleBorder,
0213             Pixel_t back = GetDefaultFrameBackground());
0214    ~TGCanvas() override;
0215 
0216    TGFrame      *GetContainer() const { return fVport->GetContainer(); }
0217    TGViewPort   *GetViewPort() const { return fVport; }
0218    TGHScrollBar *GetHScrollbar() const { return fHScrollbar; }
0219    TGVScrollBar *GetVScrollbar() const { return fVScrollbar; }
0220 
0221    virtual void  AddFrame(TGFrame *f, TGLayoutHints *l = nullptr);
0222    virtual void  SetContainer(TGFrame *f) { fVport->SetContainer(f); }
0223    void          MapSubwindows() override;
0224    void          DrawBorder() override;
0225    void          Layout() override;
0226    virtual void  ClearViewPort();
0227    virtual Int_t GetHsbPosition() const;
0228    virtual Int_t GetVsbPosition() const;
0229    virtual void  SetHsbPosition(Int_t newPos);
0230    virtual void  SetVsbPosition(Int_t newPos);
0231    void          SetScrolling(Int_t scrolling);
0232    Int_t         GetScrolling() const { return fScrolling; }
0233 
0234    TGDimension GetDefaultSize() const override { return TGDimension(fWidth, fHeight); }
0235    Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0236 
0237    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0238 
0239    ClassDefOverride(TGCanvas,0)  // A canvas with two scrollbars and a viewport
0240 };
0241 
0242 
0243 #endif