File indexing completed on 2025-01-18 10:12:03
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGPack
0013 #define ROOT_TGPack
0014
0015 #include "TGFrame.h"
0016 #include "TGLayout.h"
0017
0018 class TGSplitter;
0019
0020
0021 class TGFrameElementPack : public TGFrameElement
0022 {
0023 private:
0024 TGFrameElementPack(const TGFrameElementPack&) = delete;
0025 TGFrameElementPack& operator=(const TGFrameElementPack&) = delete;
0026
0027 public:
0028 Float_t fWeight;
0029 TGFrameElementPack* fSplitFE;
0030
0031 TGFrameElementPack(TGFrame *frame, TGLayoutHints* lh = nullptr, Float_t weight = 1):
0032 TGFrameElement(frame, lh), fWeight(weight), fSplitFE(nullptr) { }
0033
0034 ClassDefOverride(TGFrameElementPack, 0);
0035 };
0036
0037
0038
0039 class TGPack : public TGCompositeFrame
0040 {
0041 private:
0042 TGPack(const TGPack&) = delete;
0043 TGPack& operator=(const TGPack&) = delete;
0044
0045 protected:
0046 Bool_t fVertical;
0047 Bool_t fUseSplitters;
0048 Int_t fSplitterLen;
0049
0050 Int_t fDragOverflow;
0051
0052 Float_t fWeightSum;
0053 Int_t fNVisible;
0054
0055 Int_t GetFrameLength(const TGFrame* f) const { return fVertical ? f->GetHeight() : f->GetWidth(); }
0056 Int_t GetLength() const { return GetFrameLength(this); }
0057 Int_t GetAvailableLength() const;
0058
0059 void SetFrameLength (TGFrame* f, Int_t len);
0060 void SetFramePosition(TGFrame* f, Int_t pos);
0061
0062 void FindFrames(TGFrame* splitter, TGFrameElementPack*& f0, TGFrameElementPack*& f1) const;
0063
0064 void CheckSplitterVisibility();
0065 void ResizeExistingFrames();
0066 void RefitFramesToPack();
0067
0068 void AddFrameInternal(TGFrame *f, TGLayoutHints* l = nullptr, Float_t weight = 1);
0069 void RemoveFrameInternal(TGFrame *f);
0070
0071 public:
0072 TGPack(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0,
0073 Pixel_t back = GetDefaultFrameBackground());
0074 TGPack(TGClient *c, Window_t id, const TGWindow *parent = nullptr);
0075 ~TGPack() override;
0076
0077 virtual void AddFrameWithWeight(TGFrame *f, TGLayoutHints* l, Float_t w);
0078 void AddFrame(TGFrame *f, TGLayoutHints* l = nullptr) override;
0079
0080 virtual void DeleteFrame(TGFrame *f);
0081 void RemoveFrame(TGFrame *f) override;
0082 void ShowFrame(TGFrame *f) override;
0083 void HideFrame(TGFrame *f) override;
0084
0085 using TGCompositeFrame::Resize;
0086 void Resize(UInt_t w = 0, UInt_t h = 0) override;
0087
0088 using TGCompositeFrame::MapSubwindows;
0089 void MapSubwindows() override;
0090
0091 void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0) override;
0092 void Layout() override;
0093
0094 void Dump() const override;
0095
0096 void EqualizeFrames();
0097 void HandleSplitterStart();
0098 void HandleSplitterResize(Int_t delta);
0099
0100
0101
0102 Bool_t GetVertical() const { return fVertical; }
0103 void SetVertical(Bool_t x);
0104
0105
0106 Bool_t GetUseSplitters() const { return fUseSplitters; }
0107 void SetUseSplitters(Bool_t x) { fUseSplitters = x; }
0108
0109 ClassDefOverride(TGPack, 0);
0110 };
0111
0112 #endif