Logo ROOT  
Reference Guide
TGPack.h
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2021, 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 
22 {
23 private:
26 
27 public:
28  Float_t fWeight; ///< relative weight
29  TGFrameElementPack* fSplitFE; ///<! cached variable for optimisation
30 
31  TGFrameElementPack(TGFrame *frame, TGLayoutHints* lh = nullptr, Float_t weight = 1):
32  TGFrameElement(frame, lh), fWeight(weight), fSplitFE(nullptr) { }
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&) = delete;
43  TGPack& operator=(const TGPack&) = delete;
44 
45 protected:
49 
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 
63 
65  void ResizeExistingFrames();
66  void RefitFramesToPack();
67 
68  void AddFrameInternal(TGFrame *f, TGLayoutHints* l = nullptr, Float_t weight = 1);
70 
71 
72 public:
73  TGPack(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0,
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 
87  virtual void Resize(UInt_t w = 0, UInt_t h = 0);
88 
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.
109 
110  ClassDef(TGPack, 0); // Horizontal or vertical stack of frames.
111 };
112 
113 #endif
c
#define c(i)
Definition: RSha256.hxx:101
l
auto * l
Definition: textangle.C:4
TGPack::DeleteFrame
virtual void DeleteFrame(TGFrame *f)
Remove frame f and refit existing frames to pack size.
Definition: TGPack.cxx:313
TGPack::fUseSplitters
Bool_t fUseSplitters
Definition: TGPack.h:47
TGPack::MapSubwindows
virtual void MapSubwindows()
Virtual method of TGcompositeFrame.
Definition: TGPack.cxx:407
TGPack::fVertical
Bool_t fVertical
Definition: TGPack.h:46
TGPack::SetFrameLength
void SetFrameLength(TGFrame *f, Int_t len)
Set pack-wise length of frame f.
Definition: TGPack.cxx:87
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
f
#define f(i)
Definition: RSha256.hxx:104
TGPack::SetUseSplitters
void SetUseSplitters(Bool_t x)
Definition: TGPack.h:108
TGPack::GetFrameLength
Int_t GetFrameLength(const TGFrame *f) const
Definition: TGPack.h:55
TGFrameElementPack::TGFrameElementPack
TGFrameElementPack(const TGFrameElementPack &)=delete
TGFrameElementPack::operator=
TGFrameElementPack & operator=(const TGFrameElementPack &)=delete
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGLayout.h
TGPack::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame f at the end with default weight.
Definition: TGPack.cxx:275
TGPack::SetFramePosition
void SetFramePosition(TGFrame *f, Int_t pos)
Set pack-wise position of frame f.
Definition: TGPack.cxx:98
TGPack::EqualizeFrames
void EqualizeFrames()
Refit existing frames so that their lengths are equal.
Definition: TGPack.cxx:477
Float_t
float Float_t
Definition: RtypesCore.h:57
TGPack::SetVertical
void SetVertical(Bool_t x)
Sets the vertical flag and reformats the back to new stacking direction.
Definition: TGPack.cxx:569
Int_t
int Int_t
Definition: RtypesCore.h:45
x
Double_t x[n]
Definition: legend1.C:17
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
TGPack::fDragOverflow
Int_t fDragOverflow
!
Definition: TGPack.h:50
TGPack::AddFrameWithWeight
virtual void AddFrameWithWeight(TGFrame *f, TGLayoutHints *l, Float_t w)
Add frame f at the end with given weight.
Definition: TGPack.cxx:265
TGPack::HandleSplitterStart
void HandleSplitterStart()
Called when splitter drag starts.
Definition: TGPack.cxx:498
TGFrame
Definition: TGFrame.h:80
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGPack::GetUseSplitters
Bool_t GetUseSplitters() const
Definition: TGPack.h:107
bool
TGFrameElementPack::fWeight
Float_t fWeight
relative weight
Definition: TGPack.h:28
TGPack::GetAvailableLength
Int_t GetAvailableLength() const
Return length of entire frame without splitters.
Definition: TGPack.cxx:76
TGPack::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the pack.
Definition: TGPack.cxx:432
TGPack::fWeightSum
Float_t fWeightSum
total sum of sub frame weights
Definition: TGPack.h:52
TGPack::HideFrame
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGPack.cxx:378
TGPack::Layout
virtual void Layout()
Reposition the frames so that they fit correctly.
Definition: TGPack.cxx:458
TGPack::fNVisible
Int_t fNVisible
number of visible frames
Definition: TGPack.h:53
TGFrameElementPack::fSplitFE
TGFrameElementPack * fSplitFE
! cached variable for optimisation
Definition: TGPack.h:29
TGPack::MoveResize
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and resize the pack.
Definition: TGPack.cxx:448
h
#define h(i)
Definition: RSha256.hxx:106
TGCompositeFrame::MapSubwindows
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1164
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:605
TGPack
Stack of frames in horizontal (default) or vertical stack.
Definition: TGPack.h:40
TGPack::GetVertical
Bool_t GetVertical() const
Definition: TGPack.h:103
TGFrame.h
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
TGPack::HandleSplitterResize
void HandleSplitterResize(Int_t delta)
Handle resize events from splitters.
Definition: TGPack.cxx:506
Window_t
Handle_t Window_t
Window handle.
Definition: GuiTypes.h:29
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
y
Double_t y[n]
Definition: legend1.C:17
TGPack::CheckSplitterVisibility
void CheckSplitterVisibility()
Check if splitter of first visible frame is hidden.
Definition: TGPack.cxx:110
TGPack::ResizeExistingFrames
void ResizeExistingFrames()
Resize (shrink or expand) existing frames by amount in total.
Definition: TGPack.cxx:138
TGSplitter
A splitter allows the frames left and right or above and below of it to be resized.
Definition: TGSplitter.h:19
TGFrameElementPack::TGFrameElementPack
TGFrameElementPack(TGFrame *frame, TGLayoutHints *lh=nullptr, Float_t weight=1)
Definition: TGPack.h:31
TGPack::RefitFramesToPack
void RefitFramesToPack()
Refit existing frames to pack size.
Definition: TGPack.cxx:185
TGFrameElementPack
Definition: TGPack.h:22
TGPack::RemoveFrameInternal
void RemoveFrameInternal(TGFrame *f)
Remove frame f.
Definition: TGPack.cxx:284
f1
TF1 * f1
Definition: legend1.C:11
TGPack::operator=
TGPack & operator=(const TGPack &)=delete
TGPack::~TGPack
virtual ~TGPack()
Destructor.
Definition: TGPack.cxx:67
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGPack::RemoveFrame
virtual void RemoveFrame(TGFrame *f)
Remove frame f and refit existing frames to pack size.
Definition: TGPack.cxx:324
TGPack::FindFrames
void FindFrames(TGFrame *splitter, TGFrameElementPack *&f0, TGFrameElementPack *&f1) const
Find frames around splitter and return them f0 (previous) and f1 (next).
Definition: TGPack.cxx:201
TGFrameElement
Definition: TGLayout.h:105
TGPack::ShowFrame
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGPack.cxx:350
TGPack::fSplitterLen
Int_t fSplitterLen
Definition: TGPack.h:48
TGPack::GetLength
Int_t GetLength() const
Definition: TGPack.h:56
TGPack::TGPack
TGPack(const TGPack &)=delete
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition: TGFrame.h:287
TGPack::AddFrameInternal
void AddFrameInternal(TGFrame *f, TGLayoutHints *l=nullptr, Float_t weight=1)
Add frame f at the end.
Definition: TGPack.cxx:221
splitter
REAL splitter
Definition: triangle.c:616
TGClient
Window client.
Definition: TGClient.h:37
TGPack::Dump
virtual void Dump() const
Print sub frame info.
Definition: TGPack.cxx:333
int