File indexing completed on 2025-01-18 10:12:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGView
0013 #define ROOT_TGView
0014
0015
0016 #include "TGFrame.h"
0017 #include "TGWidget.h"
0018
0019 class TGViewFrame;
0020 class TGHScrollBar;
0021 class TGVScrollBar;
0022
0023 class TGView : public TGCompositeFrame, public TGWidget {
0024
0025 friend class TGViewFrame;
0026
0027 public:
0028 enum { kNoHSB = BIT(0), kNoVSB = BIT(1) };
0029 enum { kHorizontal = 0, kVertical = 1 };
0030
0031 protected:
0032 TGLongPosition fVisible;
0033 TGLongPosition fMousePos;
0034 TGLongPosition fScrollVal;
0035 TGDimension fVirtualSize;
0036 TGRectangle fExposedRegion;
0037
0038 Int_t fScrolling;
0039 Atom_t fClipboard;
0040 UInt_t fXMargin;
0041 UInt_t fYMargin;
0042 TGViewFrame *fCanvas;
0043 TGHScrollBar *fHsb;
0044 TGVScrollBar *fVsb;
0045
0046 TGGC fWhiteGC;
0047
0048
0049 void DoRedraw() override;
0050 virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
0051 virtual Bool_t ItemLayout() { return kFALSE; }
0052
0053 private:
0054 TGView(const TGView&) = delete;
0055 TGView& operator=(const TGView&) = delete;
0056
0057 public:
0058 TGView(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
0059 UInt_t xMargin = 0, UInt_t yMargin = 0,
0060 UInt_t options = kSunkenFrame | kDoubleBorder,
0061 UInt_t sboptions = 0,
0062 Pixel_t back = GetWhitePixel());
0063
0064 ~TGView() override;
0065
0066 TGViewFrame *GetCanvas() const { return fCanvas; }
0067
0068 void Clear(Option_t * = "") override;
0069 virtual void SetVisibleStart(Int_t newTop, Int_t direction);
0070 virtual void ScrollCanvas(Int_t newTop, Int_t direction);
0071 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0072 void DrawBorder() override;
0073 void Layout() override;
0074 void SetLayoutManager(TGLayoutManager*) override {}
0075 virtual void DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
0076
0077 virtual void ScrollToPosition(TGLongPosition newPos);
0078 void ScrollUp(Int_t pixels)
0079 { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY + pixels)); }
0080 void ScrollDown(Int_t pixels)
0081 { ScrollToPosition(TGLongPosition(fVisible.fX, fVisible.fY - pixels)); }
0082 void ScrollLeft(Int_t pixels)
0083 { ScrollToPosition(TGLongPosition(fVisible.fX + pixels, fVisible.fY)); }
0084 void ScrollRight(Int_t pixels)
0085 { ScrollToPosition(TGLongPosition(fVisible.fX - pixels, fVisible.fY)); }
0086
0087 TGDimension GetDefaultSize() const override { return TGDimension(fWidth, fHeight); }
0088 TGDimension GetVirtualSize() const { return fVirtualSize; }
0089 TGLongPosition GetScrollValue() const { return fScrollVal; }
0090 TGLongPosition GetScrollPosition() const { return fVisible; }
0091
0092 TGLongPosition ToVirtual(TGLongPosition coord) const { return coord + fVisible; }
0093 TGLongPosition ToPhysical(TGLongPosition coord) const { return coord - fVisible; }
0094
0095 Bool_t HandleButton(Event_t *event) override;
0096 Bool_t HandleExpose(Event_t *event) override;
0097
0098 void ChangeBackground(Pixel_t) override;
0099 void SetBackgroundColor(Pixel_t) override;
0100 void SetBackgroundPixmap(Pixmap_t p) override;
0101 virtual void UpdateBackgroundStart();
0102
0103 const TGGC &GetViewWhiteGC() { return fWhiteGC; }
0104
0105 ClassDefOverride(TGView,0)
0106 };
0107
0108
0109 class TGViewFrame : public TGCompositeFrame {
0110 private:
0111 TGView *fView;
0112
0113 TGViewFrame(const TGViewFrame&) = delete;
0114 TGViewFrame& operator=(const TGViewFrame&) = delete;
0115
0116 public:
0117 TGViewFrame(TGView *v, UInt_t w, UInt_t h, UInt_t options = 0,
0118 Pixel_t back = GetWhitePixel());
0119
0120 Bool_t HandleSelectionRequest(Event_t *event) override
0121 { return fView->HandleSelectionRequest(event); }
0122 Bool_t HandleSelectionClear(Event_t *event) override
0123 { return fView->HandleSelectionClear(event); }
0124 Bool_t HandleSelection(Event_t *event) override
0125 { return fView->HandleSelection(event); }
0126 Bool_t HandleButton(Event_t *event) override
0127 { return fView->HandleButton(event); }
0128 Bool_t HandleExpose(Event_t *event) override
0129 { return fView->HandleExpose(event); }
0130 Bool_t HandleCrossing(Event_t *event) override
0131 { return fView->HandleCrossing(event); }
0132 Bool_t HandleMotion(Event_t *event) override
0133 { return fView->HandleMotion(event); }
0134 Bool_t HandleKey(Event_t *event) override
0135 { return fView->HandleKey(event); }
0136 Bool_t HandleDoubleClick(Event_t *event) override
0137 { return fView->HandleDoubleClick(event); }
0138
0139 ClassDefOverride(TGViewFrame,0)
0140 };
0141
0142 #endif