Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGPack.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGPack
13 #define ROOT_TGPack
14 
15 #include "TGFrame.h"
16 #include "TGLayout.h"
17 
18 class TGSplitter;
19 
20 
21 class TGFrameElementPack : public TGFrameElement
22 {
23 private:
24  TGFrameElementPack(const TGFrameElementPack&); // Not implemented
25  TGFrameElementPack& operator=(const TGFrameElementPack&); // Not implemented
26 
27 public:
28  Float_t fWeight; // relative weight
29  TGFrameElementPack* fSplitFE; //! cached varaible for optimisation
30 
31  TGFrameElementPack(TGFrame *frame, TGLayoutHints* lh = 0, Float_t weight = 1):
32  TGFrameElement(frame, lh), fWeight(weight), fSplitFE(0) { }
33 
34  ClassDef(TGFrameElementPack, 0); // Class used in TGPack.
35 };
36 
37 //==============================================================================
38 
39 class TGPack : public TGCompositeFrame
40 {
41 private:
42  TGPack(const TGPack&); // Not implemented
43  TGPack& operator=(const TGPack&); // Not implemented
44 
45 protected:
46  Bool_t fVertical;
47  Bool_t fUseSplitters;
48  Int_t fSplitterLen;
49 
50  Int_t fDragOverflow; //!
51 
52  Float_t fWeightSum; // total sum of sub frame weights
53  Int_t fNVisible; // number of visible frames
54 
55  Int_t GetFrameLength(const TGFrame* f) const { return fVertical ? f->GetHeight() : f->GetWidth(); }
56  Int_t GetLength() const { return GetFrameLength(this); }
57  Int_t GetAvailableLength() const;
58 
59  void SetFrameLength (TGFrame* f, Int_t len);
60  void SetFramePosition(TGFrame* f, Int_t pos);
61 
62  void FindFrames(TGFrame* splitter, TGFrameElementPack*& f0, TGFrameElementPack*& f1) const;
63 
64  void CheckSplitterVisibility();
65  void ResizeExistingFrames();
66  void RefitFramesToPack();
67 
68  void AddFrameInternal(TGFrame *f, TGLayoutHints* l = 0, Float_t weight = 1);
69  void RemoveFrameInternal(TGFrame *f);
70 
71 
72 public:
73  TGPack(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0,
74  Pixel_t back = GetDefaultFrameBackground());
75  TGPack(TGClient *c, Window_t id, const TGWindow *parent = 0);
76  virtual ~TGPack();
77 
78  virtual void AddFrameWithWeight(TGFrame *f, TGLayoutHints* l, Float_t w);
79  virtual void AddFrame(TGFrame *f, TGLayoutHints* l=0);
80 
81  virtual void DeleteFrame(TGFrame *f);
82  virtual void RemoveFrame(TGFrame *f);
83  virtual void ShowFrame(TGFrame *f);
84  virtual void HideFrame(TGFrame *f);
85 
86  using TGCompositeFrame::Resize;
87  virtual void Resize(UInt_t w = 0, UInt_t h = 0);
88 
89  using TGCompositeFrame::MapSubwindows;
90  virtual void MapSubwindows();
91 
92  virtual void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0);
93  virtual void Layout();
94 
95  virtual void Dump() const;
96 
97  void EqualizeFrames();
98  void HandleSplitterStart();
99  void HandleSplitterResize(Int_t delta);
100 
101  // ----------------------------------------------------------------
102 
103  Bool_t GetVertical() const { return fVertical; }
104  void SetVertical(Bool_t x);
105 
106  // For now assume this is always true. Length of splitter = 4 pixels.
107  Bool_t GetUseSplitters() const { return fUseSplitters; }
108  void SetUseSplitters(Bool_t x) { fUseSplitters = x; }
109 
110  ClassDef(TGPack, 0); // Horizontal or vertical stack of frames.
111 };
112 
113 #endif