Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TObject.h"
17#include "TGDimension.h"
18#include "TRefCnt.h"
19
20//---- layout hints
21
33 // bits 8-11 used by ETableLayoutHints
34};
35
36class TGFrame;
38class TGLayoutHints;
39class TList;
40class TGFrameElement;
41
42/** \class TGLayoutHints
43 \ingroup guiwidgets
44
45This class describes layout hints used by the layout classes.
46
47*/
48
49
50class TGLayoutHints : public TObject, public TRefCnt {
51
52friend class TGFrameElement;
53friend class TGCompositeFrame;
54
55private:
56 TGFrameElement *fFE; // back pointer to the last frame element
57 TGFrameElement *fPrev; // previous element sharing this layout_hints
58
60
61protected:
62 ULong_t fLayoutHints; // layout hints (combination of ELayoutHints)
63 Int_t fPadtop; // amount of top padding
64 Int_t fPadbottom; // amount of bottom padding
65 Int_t fPadleft; // amount of left padding
66 Int_t fPadright; // amount of right padding
67
69
70public:
72 Int_t padleft = 0, Int_t padright = 0,
73 Int_t padtop = 0, Int_t padbottom = 0):
74 fFE(nullptr), fPrev(nullptr), fLayoutHints(hints), fPadtop(padtop), fPadbottom(padbottom),
75 fPadleft(padleft), fPadright(padright)
76 { SetRefCount(0); }
77
79
80 ~TGLayoutHints() override;
81
83 Int_t GetPadTop() const { return fPadtop; }
84 Int_t GetPadBottom() const { return fPadbottom; }
85 Int_t GetPadLeft() const { return fPadleft; }
86 Int_t GetPadRight() const { return fPadright; }
87
88 virtual void SetLayoutHints(ULong_t lh) { fLayoutHints = lh; }
89 virtual void SetPadTop(Int_t v) { fPadtop = v; }
90 virtual void SetPadBottom(Int_t v) { fPadbottom = v; }
91 virtual void SetPadLeft(Int_t v) { fPadleft = v; }
92 virtual void SetPadRight(Int_t v) { fPadright = v; }
93
94 void Print(Option_t* option = "") const override;
95 void ls(Option_t* option = "") const override { Print(option); }
96
97 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
98
99 ClassDefOverride(TGLayoutHints,0) // Class describing GUI layout hints
100};
101
102// Temporarily public as we need to share this class definition
103// with the frame manager class
104
105class TGFrameElement : public TObject {
106
107private:
110
111public:
112 TGFrame *fFrame; // frame used in layout
113 Int_t fState; // EFrameState defined in TGFrame.h
114 TGLayoutHints *fLayout; // layout hints used in layout
115
116 TGFrameElement() : fFrame(nullptr), fState(0), fLayout(nullptr) { }
118 ~TGFrameElement() override;
119
120 void Print(Option_t* option = "") const override;
121 void ls(Option_t* option = "") const override { Print(option); }
122
123 ClassDefOverride(TGFrameElement, 0); // Base class used in GUI containers
124};
125
126
127/** \class TGLayoutManager
128 \ingroup guiwidgets
129
130Frame layout manager. This is an abstract class.
131
132*/
133
134
135class TGLayoutManager : public TObject {
136protected:
137 Bool_t fModified;// kTRUE if positions of subframes changed after layout
138
139public:
141
142 virtual void Layout() = 0;
143 virtual TGDimension GetDefaultSize() const = 0;
144 virtual void SetDefaultWidth(UInt_t /* w */) {}
145 virtual void SetDefaultHeight(UInt_t /* h */) {}
146 virtual Bool_t IsModified() const { return fModified; }
147 virtual void SetModified(Bool_t flag = kTRUE) { fModified = flag; }
148
149 ClassDefOverride(TGLayoutManager,0) // Layout manager abstract base class
150};
151
152
153/** \class TGVerticalLayout
154 \ingroup guiwidgets
155
156*/
157
158
160
161protected:
162 TGCompositeFrame *fMain; // container frame
163 TList *fList; // list of frames to arrange
164
166 TGLayoutManager(gvl), fMain(gvl.fMain), fList(gvl.fList) { }
168 {if(this!=&gvl) { TGLayoutManager::operator=(gvl);
169 fMain=gvl.fMain; fList=gvl.fList;} return *this;}
170
171public:
173
174 void Layout() override;
175 TGDimension GetDefaultSize() const override;
176 void SavePrimitive(std::ostream &out, Option_t * = "") override;
177
178 ClassDefOverride(TGVerticalLayout,0) // Vertical layout manager
179};
180
181/** \class TGHorizontalLayout
182 \ingroup guiwidgets
183
184*/
185
186
188public:
190
191 void Layout() override;
192 TGDimension GetDefaultSize() const override;
193 void SavePrimitive(std::ostream &out, Option_t * = "") override;
194
195 ClassDefOverride(TGHorizontalLayout,0) // Horizontal layout manager
196};
197
198
199/** \class TGRowLayout
200 \ingroup guiwidgets
201
202The following two layout managers do not make use of TGLayoutHints.
203
204*/
205
206
208public:
209 Int_t fSep; // interval between frames
210
212 TGVerticalLayout(main), fSep(s) { }
213
214 void Layout() override;
215 TGDimension GetDefaultSize() const override;
216 void SavePrimitive(std::ostream &out, Option_t * = "") override;
217
218 ClassDefOverride(TGRowLayout,0) // Row layout manager
219};
220
221/** \class TGColumnLayout
222 \ingroup guiwidgets
223
224The following layout manager do not make use of TGLayoutHints.
225
226*/
227
228
230public:
232
233 void Layout() override;
234 TGDimension GetDefaultSize() const override;
235 void SavePrimitive(std::ostream &out, Option_t * = "") override;
236
237 ClassDefOverride(TGColumnLayout,0) // Column layout manager
238};
239
240
241/** \class TGMatrixLayout
242 \ingroup guiwidgets
243
244This layout managers does not make use of TGLayoutHints.
245
246
247It arranges frames in a matrix-like way.
248This manager provides :
249- a column number (0 means unlimited)
250- a row number (0 means unlimited)
251- horizontal & vertical separators
252
253Notes : If both column and row are fixed values, any remaining
254 frames outside the count won't be managed.
255 Unlimited rows means the frame can expand downward
256 (the default behaviour in most UI).
257 Both unlimited rows and columns is undefined (read: will
258 crash the algorithm ;-).
259 With fixed dimensions, frames are always arranged in rows.
260 That is: 1st frame is at position (0,0), next one is at
261 row(0), column(1) and so on...
262 When specifying one dimension as unlimited (i.e. row=0 or
263 column=0) the frames are arranged according to the direction
264 of the fixed dimension. This layout manager does not make
265 use of TGLayoutHints.
266*/
267
268
270
271private:
274
275protected:
276 TGCompositeFrame *fMain; ///< container frame
277 TList *fList; ///< list of frames to arrange
278
279public:
280 Int_t fSep; ///< interval between frames
281 Int_t fHints; ///< layout hints (currently not used)
282 UInt_t fRows; ///< number of rows
283 UInt_t fColumns; ///< number of columns
284
286
287 void Layout() override;
288 TGDimension GetDefaultSize() const override;
289 void SavePrimitive(std::ostream &out, Option_t * = "") override;
290
291 ClassDefOverride(TGMatrixLayout,0) // Matrix layout manager
292};
293
294
295/** \class TGTileLayout
296 \ingroup guiwidgets
297
298This is a layout manager for the TGListView widget.
299
300*/
301
302
304
305private:
306 TGTileLayout(const TGTileLayout&) = delete;
308
309protected:
310 Int_t fSep; ///< separation between tiles
311 TGCompositeFrame *fMain; ///< container frame
312 TList *fList; ///< list of frames to arrange
313 Bool_t fModified; ///< layout changed
314
315
316public:
318
319 void Layout() override;
320 TGDimension GetDefaultSize() const override;
321 Bool_t IsModified() const override { return fModified; }
322 void SavePrimitive(std::ostream &out, Option_t * = "") override;
323
324 ClassDefOverride(TGTileLayout,0) // Tile layout manager
325};
326
327/** \class TGListLayout
328 \ingroup guiwidgets
329
330This is a layout manager for the TGListView widget.
331
332*/
333
334
336public:
338 TGTileLayout(main, sep) { }
339
340 void Layout() override;
341 TGDimension GetDefaultSize() const override;
342 void SavePrimitive(std::ostream &out, Option_t * = "") override;
343
344 ClassDefOverride(TGListLayout,0) // Layout manager for TGListView widget
345};
346
347/** \class TGListDetailsLayout
348 \ingroup guiwidgets
349
350This is a layout manager for the TGListView widget.
351
352*/
353
354
356private:
357 UInt_t fWidth; // width of listview container
358
359public:
361 TGTileLayout(main, sep), fWidth(w) { }
362
363 void Layout() override;
364 TGDimension GetDefaultSize() const override;
365 void SetDefaultWidth(UInt_t w) override { fWidth = w; }
366 void SavePrimitive(std::ostream &out, Option_t * = "") override;
367
368 ClassDefOverride(TGListDetailsLayout,0) // Layout manager for TGListView details
369};
370
371#endif
int main()
Definition Prototype.cxx:12
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
unsigned long ULong_t
Definition RtypesCore.h:55
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:90
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
ELayoutHints
Definition TGLayout.h:22
@ kLHintsNoHints
Definition TGLayout.h:23
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
The following layout manager do not make use of TGLayoutHints.
Definition TGLayout.h:229
void Layout() override
Make a column layout of all frames in the list.
Definition TGLayout.cxx:566
void SavePrimitive(std::ostream &out, Option_t *="") override
Save column layout manager as a C++ statement(s) on output stream.
TGDimension GetDefaultSize() const override
Return default dimension of the column layout.
Definition TGLayout.cxx:590
TGColumnLayout(TGCompositeFrame *main, Int_t s=0)
Definition TGLayout.h:231
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
TGLayoutHints * fLayout
Definition TGLayout.h:114
TGFrameElement & operator=(const TGFrameElement &)
~TGFrameElement() override
Destructor. Decrease ref. count of fLayout.
Definition TGLayout.cxx:64
void Print(Option_t *option="") const override
Print this frame element.
Definition TGLayout.cxx:71
TGFrameElement(const TGFrameElement &)
void ls(Option_t *option="") const override
The ls function lists the contents of a class on stdout.
Definition TGLayout.h:121
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
TGDimension GetDefaultSize() const override
Return default dimension of the horizontal layout.
Definition TGLayout.cxx:477
void SavePrimitive(std::ostream &out, Option_t *="") override
Save horizontal layout manager as a C++ statement(s) on output stream.
void Layout() override
Make a horizontal layout of all frames in the list.
Definition TGLayout.cxx:352
TGHorizontalLayout(TGCompositeFrame *main)
Definition TGLayout.h:189
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
~TGLayoutHints() override
Destructor.
Definition TGLayout.cxx:100
TGFrameElement * fPrev
Definition TGLayout.h:57
Int_t GetPadRight() const
Definition TGLayout.h:86
void Print(Option_t *option="") const override
Printing.
Definition TGLayout.cxx:123
Int_t fPadtop
Definition TGLayout.h:63
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save layout hints as a C++ statement(s) on output stream out.
Definition TGLayout.cxx:975
Int_t GetPadBottom() const
Definition TGLayout.h:84
TGLayoutHints & operator=(const TGLayoutHints &)=delete
Int_t fPadbottom
Definition TGLayout.h:64
TGLayoutHints(ULong_t hints=kLHintsNormal, Int_t padleft=0, Int_t padright=0, Int_t padtop=0, Int_t padbottom=0)
Definition TGLayout.h:71
ULong_t fLayoutHints
Definition TGLayout.h:62
ULong_t GetLayoutHints() const
Definition TGLayout.h:82
Int_t fPadleft
Definition TGLayout.h:65
virtual void SetPadRight(Int_t v)
Definition TGLayout.h:92
void ls(Option_t *option="") const override
The ls function lists the contents of a class on stdout.
Definition TGLayout.h:95
virtual void SetPadLeft(Int_t v)
Definition TGLayout.h:91
Int_t GetPadTop() const
Definition TGLayout.h:83
TGFrameElement * fFE
Definition TGLayout.h:56
virtual void SetPadTop(Int_t v)
Definition TGLayout.h:89
Int_t GetPadLeft() const
Definition TGLayout.h:85
virtual void SetPadBottom(Int_t v)
Definition TGLayout.h:90
Int_t fPadright
Definition TGLayout.h:66
void UpdateFrameElements(TGLayoutHints *l)
Update layout hints of frame elements.
Definition TGLayout.cxx:107
virtual void SetLayoutHints(ULong_t lh)
Definition TGLayout.h:88
Frame layout manager.
Definition TGLayout.h:135
virtual void SetDefaultWidth(UInt_t)
Definition TGLayout.h:144
virtual Bool_t IsModified() const
Definition TGLayout.h:146
virtual void SetModified(Bool_t flag=kTRUE)
Definition TGLayout.h:147
Bool_t fModified
Definition TGLayout.h:137
virtual TGDimension GetDefaultSize() const =0
virtual void Layout()=0
virtual void SetDefaultHeight(UInt_t)
Definition TGLayout.h:145
This is a layout manager for the TGListView widget.
Definition TGLayout.h:355
TGListDetailsLayout(TGCompositeFrame *main, Int_t sep=0, UInt_t w=0)
Definition TGLayout.h:360
void SetDefaultWidth(UInt_t w) override
Definition TGLayout.h:365
void SavePrimitive(std::ostream &out, Option_t *="") override
Save list details layout manager as a C++ statement(s) on out stream.
void Layout() override
Make a list details layout of all frames in the list.
Definition TGLayout.cxx:917
TGDimension GetDefaultSize() const override
Return default dimension of the list details layout.
Definition TGLayout.cxx:949
This is a layout manager for the TGListView widget.
Definition TGLayout.h:335
void Layout() override
Make a tile layout of all frames in the list.
Definition TGLayout.cxx:825
void SavePrimitive(std::ostream &out, Option_t *="") override
Save list layout manager as a C++ statement(s) on output stream.
TGListLayout(TGCompositeFrame *main, Int_t sep=0)
Definition TGLayout.h:337
TGDimension GetDefaultSize() const override
Return default dimension of the list layout.
Definition TGLayout.cxx:883
This layout managers does not make use of TGLayoutHints.
Definition TGLayout.h:269
TGMatrixLayout & operator=(const TGMatrixLayout &)=delete
UInt_t fRows
number of rows
Definition TGLayout.h:282
void SavePrimitive(std::ostream &out, Option_t *="") override
Save matrix layout manager as a C++ statement(s) on output stream.
Int_t fHints
layout hints (currently not used)
Definition TGLayout.h:281
TGMatrixLayout(const TGMatrixLayout &)=delete
TGCompositeFrame * fMain
container frame
Definition TGLayout.h:276
Int_t fSep
interval between frames
Definition TGLayout.h:280
UInt_t fColumns
number of columns
Definition TGLayout.h:283
void Layout() override
Make a matrix layout of all frames in the list.
Definition TGLayout.cxx:635
TList * fList
list of frames to arrange
Definition TGLayout.h:277
TGDimension GetDefaultSize() const override
Return default dimension of the matrix layout.
Definition TGLayout.cxx:691
The following two layout managers do not make use of TGLayoutHints.
Definition TGLayout.h:207
void SavePrimitive(std::ostream &out, Option_t *="") override
Save row layout manager as a C++ statement(s) on output stream.
Int_t fSep
Definition TGLayout.h:209
TGRowLayout(TGCompositeFrame *main, Int_t s=0)
Definition TGLayout.h:211
TGDimension GetDefaultSize() const override
Return default dimension of the row layout.
Definition TGLayout.cxx:535
void Layout() override
Make a row layout of all frames in the list.
Definition TGLayout.cxx:509
This is a layout manager for the TGListView widget.
Definition TGLayout.h:303
TGDimension GetDefaultSize() const override
Return default dimension of the tile layout.
Definition TGLayout.cxx:790
TList * fList
list of frames to arrange
Definition TGLayout.h:312
Int_t fSep
separation between tiles
Definition TGLayout.h:310
TGCompositeFrame * fMain
container frame
Definition TGLayout.h:311
Bool_t IsModified() const override
Definition TGLayout.h:321
void Layout() override
Make a tile layout of all frames in the list.
Definition TGLayout.cxx:735
Bool_t fModified
layout changed
Definition TGLayout.h:313
void SavePrimitive(std::ostream &out, Option_t *="") override
Save tile layout manager as a C++ statement(s) on output stream.
TGTileLayout(const TGTileLayout &)=delete
TGTileLayout & operator=(const TGTileLayout &)=delete
void Layout() override
Make a vertical layout of all frames in the list.
Definition TGLayout.cxx:189
TGVerticalLayout(const TGVerticalLayout &gvl)
Definition TGLayout.h:165
TGCompositeFrame * fMain
Definition TGLayout.h:162
void SavePrimitive(std::ostream &out, Option_t *="") override
Save vertical layout manager as a C++ statement(s) on output stream.
TGDimension GetDefaultSize() const override
Return default dimension of the vertical layout.
Definition TGLayout.cxx:320
TGVerticalLayout & operator=(const TGVerticalLayout &gvl)
Definition TGLayout.h:167
A doubly linked list.
Definition TList.h:38
Mother of all ROOT objects.
Definition TObject.h:41
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition TObject.h:296
Definitions for TRefCnt, base class for reference counted objects.
Definition TRefCnt.h:27
void SetRefCount(UInt_t r)
Definition TRefCnt.h:39
TLine l
Definition textangle.C:4