Logo ROOT  
Reference Guide
TGLayout.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 02/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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_TGLayout
13 #define ROOT_TGLayout
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // A number of different layout classes (TGLayoutManager, //
19 // TGVerticalLayout, TGHorizontalLayout, TGLayoutHints, etc.). //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TObject.h"
24 #include "TGDimension.h"
25 #include "TRefCnt.h"
26 
27 //---- layout hints
28 
30  kLHintsNoHints = 0,
31  kLHintsLeft = BIT(0),
32  kLHintsCenterX = BIT(1),
33  kLHintsRight = BIT(2),
34  kLHintsTop = BIT(3),
35  kLHintsCenterY = BIT(4),
40  // bits 8-11 used by ETableLayoutHints
41 };
42 
43 class TGFrame;
46 class TList;
47 class TGFrameElement;
48 
49 //////////////////////////////////////////////////////////////////////////
50 // //
51 // TGLayoutHints //
52 // //
53 // This class describes layout hints used by the layout classes. //
54 // //
55 //////////////////////////////////////////////////////////////////////////
56 
57 class TGLayoutHints : public TObject, public TRefCnt {
58 
59 friend class TGFrameElement;
60 friend class TGCompositeFrame;
61 
62 private:
63  TGFrameElement *fFE; // back pointer to the last frame element
64  TGFrameElement *fPrev; // previous element sharing this layout_hints
65 
67 
68 protected:
69  ULong_t fLayoutHints; // layout hints (combination of ELayoutHints)
70  Int_t fPadtop; // amount of top padding
71  Int_t fPadbottom; // amount of bottom padding
72  Int_t fPadleft; // amount of left padding
73  Int_t fPadright; // amount of right padding
74 
76 
77 public:
79  Int_t padleft = 0, Int_t padright = 0,
80  Int_t padtop = 0, Int_t padbottom = 0):
81  fFE(0), fPrev(0), fLayoutHints(hints), fPadtop(padtop), fPadbottom(padbottom),
82  fPadleft(padleft), fPadright(padright)
83  { SetRefCount(0); }
84 
85  TGLayoutHints(const TGLayoutHints &lh);
86 
87  virtual ~TGLayoutHints();
88 
89  ULong_t GetLayoutHints() const { return fLayoutHints; }
90  Int_t GetPadTop() const { return fPadtop; }
91  Int_t GetPadBottom() const { return fPadbottom; }
92  Int_t GetPadLeft() const { return fPadleft; }
93  Int_t GetPadRight() const { return fPadright; }
94 
95  virtual void SetLayoutHints(ULong_t lh) { fLayoutHints = lh; }
96  virtual void SetPadTop(Int_t v) { fPadtop = v; }
97  virtual void SetPadBottom(Int_t v) { fPadbottom = v; }
98  virtual void SetPadLeft(Int_t v) { fPadleft = v; }
99  virtual void SetPadRight(Int_t v) { fPadright = v; }
100 
101  void Print(Option_t* option = "") const;
102  void ls(Option_t* option = "") const { Print(option); }
103 
104  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
105 
106  ClassDef(TGLayoutHints,0) // Class describing GUI layout hints
107 };
108 
109 // Temporarily public as we need to share this class definition
110 // with the frame manager class
111 
112 class TGFrameElement : public TObject {
113 
114 private:
117 
118 public:
119  TGFrame *fFrame; // frame used in layout
120  Int_t fState; // EFrameState defined in TGFrame.h
121  TGLayoutHints *fLayout; // layout hints used in layout
122 
123  TGFrameElement() : fFrame(0), fState(0), fLayout(0) { }
125  ~TGFrameElement();
126 
127  void Print(Option_t* option = "") const;
128  void ls(Option_t* option = "") const { Print(option); }
129 
130  ClassDef(TGFrameElement, 0); // Base class used in GUI containers
131 };
132 
133 
134 //////////////////////////////////////////////////////////////////////////
135 // //
136 // TGLayoutManager //
137 // //
138 // Frame layout manager. This is an abstract class. //
139 // //
140 //////////////////////////////////////////////////////////////////////////
141 
142 class TGLayoutManager : public TObject {
143 protected:
144  Bool_t fModified;// kTRUE if positions of subframes changed after layout
145 
146 public:
148 
149  virtual void Layout() = 0;
150  virtual TGDimension GetDefaultSize() const = 0;
151  virtual void SetDefaultWidth(UInt_t /* w */) {}
152  virtual void SetDefaultHeight(UInt_t /* h */) {}
153  virtual Bool_t IsModified() const { return fModified; }
154  virtual void SetModified(Bool_t flag = kTRUE) { fModified = flag; }
155 
156  ClassDef(TGLayoutManager,0) // Layout manager abstract base class
157 };
158 
159 
160 //////////////////////////////////////////////////////////////////////////
161 // //
162 // TGVerticalLayout and TGHorizontalLayout managers. //
163 // //
164 //////////////////////////////////////////////////////////////////////////
165 
167 
168 protected:
169  TGCompositeFrame *fMain; // container frame
170  TList *fList; // list of frames to arrange
171 
173  TGLayoutManager(gvl), fMain(gvl.fMain), fList(gvl.fList) { }
175  {if(this!=&gvl) { TGLayoutManager::operator=(gvl);
176  fMain=gvl.fMain; fList=gvl.fList;} return *this;}
177 
178 public:
180 
181  virtual void Layout();
182  virtual TGDimension GetDefaultSize() const;
183  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
184 
185  ClassDef(TGVerticalLayout,0) // Vertical layout manager
186 };
187 
189 public:
191 
192  virtual void Layout();
193  virtual TGDimension GetDefaultSize() const;
194  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
195 
196  ClassDef(TGHorizontalLayout,0) // Horizontal layout manager
197 };
198 
199 
200 //////////////////////////////////////////////////////////////////////////
201 // //
202 // TGRowLayout and TGColumnLayout managers. //
203 // //
204 // The follwing two layout managers do not make use of TGLayoutHints. //
205 // //
206 //////////////////////////////////////////////////////////////////////////
207 
209 public:
210  Int_t fSep; // interval between frames
211 
213  TGVerticalLayout(main), fSep(s) { }
214 
215  virtual void Layout();
216  virtual TGDimension GetDefaultSize() const;
217  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
218 
219  ClassDef(TGRowLayout,0) // Row layout manager
220 };
221 
222 class TGColumnLayout : public TGRowLayout {
223 public:
225 
226  virtual void Layout();
227  virtual TGDimension GetDefaultSize() const;
228  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
229 
230  ClassDef(TGColumnLayout,0) // Column layout manager
231 };
232 
233 
234 //////////////////////////////////////////////////////////////////////////
235 // //
236 // TGMatrixLayout manager. //
237 // //
238 // This layout managers does not make use of TGLayoutHints. //
239 // //
240 //////////////////////////////////////////////////////////////////////////
241 
243 
244 private:
247 
248 protected:
249  TGCompositeFrame *fMain; // container frame
250  TList *fList; // list of frames to arrange
251 
252 public:
253  Int_t fSep; // interval between frames
254  Int_t fHints; // layout hints (currently not used)
255  UInt_t fRows; // number of rows
256  UInt_t fColumns; // number of columns
257 
259 
260  virtual void Layout();
261  virtual TGDimension GetDefaultSize() const;
262  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
263 
264  ClassDef(TGMatrixLayout,0) // Matrix layout manager
265 };
266 
267 
268 //////////////////////////////////////////////////////////////////////////
269 // //
270 // TGTileLayout, TGListLayout and TGListDetailsLayout managers. //
271 // //
272 // This are layout managers for the TGListView widget. //
273 // //
274 //////////////////////////////////////////////////////////////////////////
275 
277 
278 private:
279  TGTileLayout(const TGTileLayout&);
281 
282 protected:
283  Int_t fSep; // separation between tiles
284  TGCompositeFrame *fMain; // container frame
285  TList *fList; // list of frames to arrange
286  Bool_t fModified;// layout changed
287 
288 
289 public:
291 
292  virtual void Layout();
293  virtual TGDimension GetDefaultSize() const;
294  virtual Bool_t IsModified() const { return fModified; }
295  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
296 
297  ClassDef(TGTileLayout,0) // Tile layout manager
298 };
299 
300 class TGListLayout : public TGTileLayout {
301 public:
303  TGTileLayout(main, sep) { }
304 
305  virtual void Layout();
306  virtual TGDimension GetDefaultSize() const;
307  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
308 
309  ClassDef(TGListLayout,0) // Layout manager for TGListView widget
310 };
311 
313 private:
314  UInt_t fWidth; // width of listview container
315 
316 public:
318  TGTileLayout(main, sep), fWidth(w) { }
319 
320  virtual void Layout();
321  virtual TGDimension GetDefaultSize() const;
322  virtual void SetDefaultWidth(UInt_t w) { fWidth = w; }
323  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
324 
325  ClassDef(TGListDetailsLayout,0) // Layout manager for TGListView details
326 };
327 
328 #endif
c
#define c(i)
Definition: RSha256.hxx:119
l
auto * l
Definition: textangle.C:4
TGLayoutHints::SetPadRight
virtual void SetPadRight(Int_t v)
Definition: TGLayout.h:99
TGMatrixLayout::fColumns
UInt_t fColumns
Definition: TGLayout.h:256
TGListLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1129
TGMatrixLayout::operator=
TGMatrixLayout & operator=(const TGMatrixLayout &)
TGListLayout::Layout
virtual void Layout()
Make a tile layout of all frames in the list.
Definition: TGLayout.cxx:856
TGFrameElement::fLayout
TGLayoutHints * fLayout
Definition: TGLayout.h:121
TGColumnLayout::TGColumnLayout
TGColumnLayout(TGCompositeFrame *main, Int_t s=0)
Definition: TGLayout.h:224
kLHintsCenterX
@ kLHintsCenterX
Definition: TGLayout.h:38
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGLayoutManager::SetDefaultHeight
virtual void SetDefaultHeight(UInt_t)
Definition: TGLayout.h:152
f
#define f(i)
Definition: RSha256.hxx:122
TGDimension
Definition: TGDimension.h:27
TRefCnt::SetRefCount
void SetRefCount(UInt_t r)
Definition: TRefCnt.h:45
TGVerticalLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the vertical layout.
Definition: TGLayout.cxx:350
TGMatrixLayout::fMain
TGCompositeFrame * fMain
Definition: TGLayout.h:249
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:40
TGFrameElement::fState
Int_t fState
Definition: TGLayout.h:120
TGMatrixLayout::fList
TList * fList
Definition: TGLayout.h:250
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TGLayoutHints::fFE
TGFrameElement * fFE
Definition: TGLayout.h:63
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TGHorizontalLayout
Definition: TGLayout.h:188
TGTileLayout::fModified
Bool_t fModified
Definition: TGLayout.h:286
TRefCnt.h
TGTileLayout::operator=
TGTileLayout & operator=(const TGTileLayout &)
TGHorizontalLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1074
TGVerticalLayout::Layout
virtual void Layout()
Make a vertical layout of all frames in the list.
Definition: TGLayout.cxx:218
TGLayoutHints::GetPadBottom
Int_t GetPadBottom() const
Definition: TGLayout.h:91
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
TGRowLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the row layout.
Definition: TGLayout.cxx:566
TGDimension.h
TGLayoutHints::UpdateFrameElements
void UpdateFrameElements(TGLayoutHints *l)
Update layout hints of frame elements.
Definition: TGLayout.cxx:136
TGLayoutHints::GetPadLeft
Int_t GetPadLeft() const
Definition: TGLayout.h:92
TGListDetailsLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1140
TGLayoutHints::~TGLayoutHints
virtual ~TGLayoutHints()
Destructor.
Definition: TGLayout.cxx:129
TGListDetailsLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the list details layout.
Definition: TGLayout.cxx:980
TGMatrixLayout::fSep
Int_t fSep
Definition: TGLayout.h:253
TGTileLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the tile layout.
Definition: TGLayout.cxx:821
TGFrame
Definition: TGFrame.h:105
TGTileLayout::fSep
Int_t fSep
Definition: TGLayout.h:283
v
@ v
Definition: rootcling_impl.cxx:3635
TGLayoutHints::fPadleft
Int_t fPadleft
Definition: TGLayout.h:72
TGLayoutManager::IsModified
virtual Bool_t IsModified() const
Definition: TGLayout.h:153
bool
TGVerticalLayout::operator=
TGVerticalLayout & operator=(const TGVerticalLayout &gvl)
Definition: TGLayout.h:174
TGFrameElement::fFrame
TGFrame * fFrame
Definition: TGLayout.h:119
TGLayoutManager
Definition: TGLayout.h:142
TGColumnLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the column layout.
Definition: TGLayout.cxx:621
TGMatrixLayout::fRows
UInt_t fRows
Definition: TGLayout.h:255
TGLayoutHints::GetPadTop
Int_t GetPadTop() const
Definition: TGLayout.h:90
TGVerticalLayout::TGVerticalLayout
TGVerticalLayout(const TGVerticalLayout &gvl)
Definition: TGLayout.h:172
TGLayoutHints::Print
void Print(Option_t *option="") const
Printing.
Definition: TGLayout.cxx:152
TGLayoutManager::SetDefaultWidth
virtual void SetDefaultWidth(UInt_t)
Definition: TGLayout.h:151
TGLayoutManager::TGLayoutManager
TGLayoutManager()
Definition: TGLayout.h:147
TGTileLayout::fList
TList * fList
Definition: TGLayout.h:285
TGFrameElement::ls
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TGLayout.h:128
kLHintsBottom
@ kLHintsBottom
Definition: TGLayout.h:42
TGMatrixLayout
Definition: TGLayout.h:242
TGTileLayout::Layout
virtual void Layout()
Make a tile layout of all frames in the list.
Definition: TGLayout.cxx:766
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGRowLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1083
TGVerticalLayout::fList
TList * fList
Definition: TGLayout.h:170
TGLayoutHints::SetLayoutHints
virtual void SetLayoutHints(ULong_t lh)
Definition: TGLayout.h:95
kLHintsNormal
@ kLHintsNormal
Definition: TGLayout.h:45
TGListDetailsLayout::fWidth
UInt_t fWidth
Definition: TGLayout.h:314
kLHintsCenterY
@ kLHintsCenterY
Definition: TGLayout.h:41
h
#define h(i)
Definition: RSha256.hxx:124
TGLayoutManager::GetDefaultSize
virtual TGDimension GetDefaultSize() const =0
TGLayoutHints::TGLayoutHints
TGLayoutHints(ULong_t hints=kLHintsNormal, Int_t padleft=0, Int_t padright=0, Int_t padtop=0, Int_t padbottom=0)
Definition: TGLayout.h:78
ELayoutHints
ELayoutHints
Definition: TGLayout.h:29
TGFrameElement::operator=
TGFrameElement & operator=(const TGFrameElement &)
TGLayoutHints::SetPadBottom
virtual void SetPadBottom(Int_t v)
Definition: TGLayout.h:97
TGLayoutManager::Layout
virtual void Layout()=0
TGFrameElement::~TGFrameElement
~TGFrameElement()
Destructor. Decrease ref. count of fLayout.
Definition: TGLayout.cxx:93
TGLayoutHints::fPrev
TGFrameElement * fPrev
Definition: TGLayout.h:64
TGColumnLayout::Layout
virtual void Layout()
Make a column layout of all frames in the list.
Definition: TGLayout.cxx:597
main
int main(int argc, char **argv)
Definition: histspeedtest.cxx:752
kLHintsRight
@ kLHintsRight
Definition: TGLayout.h:39
TGLayoutHints
Definition: TGLayout.h:57
TGMatrixLayout::TGMatrixLayout
TGMatrixLayout(const TGMatrixLayout &)
TGLayoutHints::GetPadRight
Int_t GetPadRight() const
Definition: TGLayout.h:93
BIT
#define BIT(n)
Definition: Rtypes.h:85
TGLayoutHints::GetLayoutHints
ULong_t GetLayoutHints() const
Definition: TGLayout.h:89
TGMatrixLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1104
TGLayoutManager::fModified
Bool_t fModified
Definition: TGLayout.h:144
TGColumnLayout
Definition: TGLayout.h:222
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
kLHintsExpandY
@ kLHintsExpandY
Definition: TGLayout.h:44
TGVerticalLayout::fMain
TGCompositeFrame * fMain
Definition: TGLayout.h:169
TGRowLayout::Layout
virtual void Layout()
Make a row layout of all frames in the list.
Definition: TGLayout.cxx:540
TGTileLayout::TGTileLayout
TGTileLayout(const TGTileLayout &)
TGLayoutHints::operator=
TGLayoutHints & operator=(const TGLayoutHints &)
TGLayoutHints::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1004
TGLayoutHints::fPadright
Int_t fPadright
Definition: TGLayout.h:73
TGLayoutHints::ls
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TGLayout.h:102
TGListDetailsLayout::Layout
virtual void Layout()
Make a list details layout of all frames in the list.
Definition: TGLayout.cxx:948
TGFrameElement::TGFrameElement
TGFrameElement()
Definition: TGLayout.h:123
TGTileLayout
Definition: TGLayout.h:276
TGRowLayout::TGRowLayout
TGRowLayout(TGCompositeFrame *main, Int_t s=0)
Definition: TGLayout.h:212
unsigned int
TGLayoutHints::SetPadTop
virtual void SetPadTop(Int_t v)
Definition: TGLayout.h:96
TGFrameElement::Print
void Print(Option_t *option="") const
Print this frame element.
Definition: TGLayout.cxx:100
kLHintsNoHints
@ kLHintsNoHints
Definition: TGLayout.h:36
TGListDetailsLayout::SetDefaultWidth
virtual void SetDefaultWidth(UInt_t w)
Definition: TGLayout.h:322
TGHorizontalLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the horizontal layout.
Definition: TGLayout.cxx:508
TGColumnLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1093
TGListLayout::TGListLayout
TGListLayout(TGCompositeFrame *main, Int_t sep=0)
Definition: TGLayout.h:302
TGVerticalLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1064
TGListDetailsLayout::TGListDetailsLayout
TGListDetailsLayout(TGCompositeFrame *main, Int_t sep=0, UInt_t w=0)
Definition: TGLayout.h:317
TGHorizontalLayout::TGHorizontalLayout
TGHorizontalLayout(TGCompositeFrame *main)
Definition: TGLayout.h:190
TObject::operator=
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.h:268
TObject.h
TGRowLayout
Definition: TGLayout.h:208
TGLayoutManager::SetModified
virtual void SetModified(Bool_t flag=kTRUE)
Definition: TGLayout.h:154
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGVerticalLayout
Definition: TGLayout.h:166
TGLayoutHints::fPadbottom
Int_t fPadbottom
Definition: TGLayout.h:71
TGTileLayout::IsModified
virtual Bool_t IsModified() const
Definition: TGLayout.h:294
TGLayoutHints::fLayoutHints
ULong_t fLayoutHints
Definition: TGLayout.h:69
TGMatrixLayout::Layout
virtual void Layout()
Make a matrix layout of all frames in the list.
Definition: TGLayout.cxx:666
TGFrameElement
Definition: TGLayout.h:112
TGLayoutHints::fPadtop
Int_t fPadtop
Definition: TGLayout.h:70
TRefCnt
Definition: TRefCnt.h:27
TGTileLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1118
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:43
TGRowLayout::fSep
Int_t fSep
Definition: TGLayout.h:210
TGListLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the list layout.
Definition: TGLayout.cxx:914
TGListDetailsLayout
Definition: TGLayout.h:312
TGHorizontalLayout::Layout
virtual void Layout()
Make a horizontal layout of all frames in the list.
Definition: TGLayout.cxx:382
TGMatrixLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default dimension of the matrix layout.
Definition: TGLayout.cxx:722
TGCompositeFrame
Definition: TGFrame.h:324
ROOT::Math::detail::sep
@ sep
Definition: GenVectorIO.h:55
TGTileLayout::fMain
TGCompositeFrame * fMain
Definition: TGLayout.h:284
TGListLayout
Definition: TGLayout.h:300
TGLayoutHints::SetPadLeft
virtual void SetPadLeft(Int_t v)
Definition: TGLayout.h:98
TList
Definition: TList.h:44
int
TGMatrixLayout::fHints
Int_t fHints
Definition: TGLayout.h:254