ROOT  6.06/09
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 #ifndef ROOT_TObject
24 #include "TObject.h"
25 #endif
26 #ifndef ROOT_TGDimension
27 #include "TGDimension.h"
28 #endif
29 #ifndef ROOT_TRefCnt
30 #include "TRefCnt.h"
31 #endif
32 
33 //---- layout hints
34 
46  // bits 8-11 used by ETableLayoutHints
47 };
48 
49 class TGFrame;
50 class TGCompositeFrame;
51 class TGLayoutHints;
52 class TList;
53 class TGFrameElement;
54 
55 //////////////////////////////////////////////////////////////////////////
56 // //
57 // TGLayoutHints //
58 // //
59 // This class describes layout hints used by the layout classes. //
60 // //
61 //////////////////////////////////////////////////////////////////////////
62 
63 class TGLayoutHints : public TObject, public TRefCnt {
64 
65 friend class TGFrameElement;
66 friend class TGCompositeFrame;
67 
68 private:
69  TGFrameElement *fFE; // back pointer to the last frame element
70  TGFrameElement *fPrev; // previous element sharing this layout_hints
71 
73 
74 protected:
75  ULong_t fLayoutHints; // layout hints (combination of ELayoutHints)
76  Int_t fPadtop; // amount of top padding
77  Int_t fPadbottom; // amount of bottom padding
78  Int_t fPadleft; // amount of left padding
79  Int_t fPadright; // amount of right padding
80 
82 
83 public:
85  Int_t padleft = 0, Int_t padright = 0,
86  Int_t padtop = 0, Int_t padbottom = 0):
87  fFE(0), fPrev(0), fLayoutHints(hints), fPadtop(padtop), fPadbottom(padbottom),
88  fPadleft(padleft), fPadright(padright)
89  { SetRefCount(0); }
90 
91  TGLayoutHints(const TGLayoutHints &lh);
92 
93  virtual ~TGLayoutHints();
94 
95  ULong_t GetLayoutHints() const { return fLayoutHints; }
96  Int_t GetPadTop() const { return fPadtop; }
97  Int_t GetPadBottom() const { return fPadbottom; }
98  Int_t GetPadLeft() const { return fPadleft; }
99  Int_t GetPadRight() const { return fPadright; }
100 
101  virtual void SetLayoutHints(ULong_t lh) { fLayoutHints = lh; }
102  virtual void SetPadTop(Int_t v) { fPadtop = v; }
103  virtual void SetPadBottom(Int_t v) { fPadbottom = v; }
104  virtual void SetPadLeft(Int_t v) { fPadleft = v; }
105  virtual void SetPadRight(Int_t v) { fPadright = v; }
106 
107  void Print(Option_t* option = "") const;
108  void ls(Option_t* option = "") const { Print(option); }
109 
110  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
111 
112  ClassDef(TGLayoutHints,0) // Class describing GUI layout hints
113 };
114 
115 // Temporarily public as we need to share this class definition
116 // with the frame manager class
117 
118 class TGFrameElement : public TObject {
119 
120 private:
123 
124 public:
125  TGFrame *fFrame; // frame used in layout
126  Int_t fState; // EFrameState defined in TGFrame.h
127  TGLayoutHints *fLayout; // layout hints used in layout
128 
129  TGFrameElement() : fFrame(0), fState(0), fLayout(0) { }
131  ~TGFrameElement();
132 
133  void Print(Option_t* option = "") const;
134  void ls(Option_t* option = "") const { Print(option); }
135 
136  ClassDef(TGFrameElement, 0); // Base class used in GUI containers
137 };
138 
139 
140 //////////////////////////////////////////////////////////////////////////
141 // //
142 // TGLayoutManager //
143 // //
144 // Frame layout manager. This is an abstract class. //
145 // //
146 //////////////////////////////////////////////////////////////////////////
147 
148 class TGLayoutManager : public TObject {
149 protected:
150  Bool_t fModified;// kTRUE if positions of subframes changed after layout
151 
152 public:
153  TGLayoutManager() : fModified(kTRUE) {}
154 
155  virtual void Layout() = 0;
156  virtual TGDimension GetDefaultSize() const = 0;
157  virtual void SetDefaultWidth(UInt_t /* w */) {}
158  virtual void SetDefaultHeight(UInt_t /* h */) {}
159  virtual Bool_t IsModified() const { return fModified; }
160  virtual void SetModified(Bool_t flag = kTRUE) { fModified = flag; }
161 
162  ClassDef(TGLayoutManager,0) // Layout manager abstract base class
163 };
164 
165 
166 //////////////////////////////////////////////////////////////////////////
167 // //
168 // TGVerticalLayout and TGHorizontalLayout managers. //
169 // //
170 //////////////////////////////////////////////////////////////////////////
171 
173 
174 protected:
175  TGCompositeFrame *fMain; // container frame
176  TList *fList; // list of frames to arrange
177 
179  TGLayoutManager(gvl), fMain(gvl.fMain), fList(gvl.fList) { }
181  {if(this!=&gvl) { TGLayoutManager::operator=(gvl);
182  fMain=gvl.fMain; fList=gvl.fList;} return *this;}
183 
184 public:
186 
187  virtual void Layout();
188  virtual TGDimension GetDefaultSize() const;
189  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
190 
191  ClassDef(TGVerticalLayout,0) // Vertical layout manager
192 };
193 
195 public:
197 
198  virtual void Layout();
199  virtual TGDimension GetDefaultSize() const;
200  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
201 
202  ClassDef(TGHorizontalLayout,0) // Horizontal layout manager
203 };
204 
205 
206 //////////////////////////////////////////////////////////////////////////
207 // //
208 // TGRowLayout and TGColumnLayout managers. //
209 // //
210 // The follwing two layout managers do not make use of TGLayoutHints. //
211 // //
212 //////////////////////////////////////////////////////////////////////////
213 
215 public:
216  Int_t fSep; // interval between frames
217 
219  TGVerticalLayout(main), fSep(s) { }
220 
221  virtual void Layout();
222  virtual TGDimension GetDefaultSize() const;
223  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
224 
225  ClassDef(TGRowLayout,0) // Row layout manager
226 };
227 
228 class TGColumnLayout : public TGRowLayout {
229 public:
231 
232  virtual void Layout();
233  virtual TGDimension GetDefaultSize() const;
234  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
235 
236  ClassDef(TGColumnLayout,0) // Column layout manager
237 };
238 
239 
240 //////////////////////////////////////////////////////////////////////////
241 // //
242 // TGMatrixLayout manager. //
243 // //
244 // This layout managers does not make use of TGLayoutHints. //
245 // //
246 //////////////////////////////////////////////////////////////////////////
247 
249 
250 private:
253 
254 protected:
255  TGCompositeFrame *fMain; // container frame
256  TList *fList; // list of frames to arrange
257 
258 public:
259  Int_t fSep; // interval between frames
260  Int_t fHints; // layout hints (currently not used)
261  UInt_t fRows; // number of rows
262  UInt_t fColumns; // number of columns
263 
265 
266  virtual void Layout();
267  virtual TGDimension GetDefaultSize() const;
268  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
269 
270  ClassDef(TGMatrixLayout,0) // Matrix layout manager
271 };
272 
273 
274 //////////////////////////////////////////////////////////////////////////
275 // //
276 // TGTileLayout, TGListLayout and TGListDetailsLayout managers. //
277 // //
278 // This are layout managers for the TGListView widget. //
279 // //
280 //////////////////////////////////////////////////////////////////////////
281 
283 
284 private:
285  TGTileLayout(const TGTileLayout&);
287 
288 protected:
289  Int_t fSep; // separation between tiles
290  TGCompositeFrame *fMain; // container frame
291  TList *fList; // list of frames to arrange
292  Bool_t fModified;// layout changed
293 
294 
295 public:
297 
298  virtual void Layout();
299  virtual TGDimension GetDefaultSize() const;
300  virtual Bool_t IsModified() const { return fModified; }
301  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
302 
303  ClassDef(TGTileLayout,0) // Tile layout manager
304 };
305 
306 class TGListLayout : public TGTileLayout {
307 public:
309  TGTileLayout(main, sep) { }
310 
311  virtual void Layout();
312  virtual TGDimension GetDefaultSize() const;
313  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
314 
315  ClassDef(TGListLayout,0) // Layout manager for TGListView widget
316 };
317 
319 private:
320  UInt_t fWidth; // width of listview container
321 
322 public:
324  TGTileLayout(main, sep), fWidth(w) { }
325 
326  virtual void Layout();
327  virtual TGDimension GetDefaultSize() const;
328  virtual void SetDefaultWidth(UInt_t w) { fWidth = w; }
329  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
330 
331  ClassDef(TGListDetailsLayout,0) // Layout manager for TGListView details
332 };
333 
334 #endif
Int_t GetPadTop() const
Definition: TGLayout.h:96
virtual Bool_t IsModified() const
Definition: TGLayout.h:300
Int_t fSep
Definition: TGLayout.h:216
virtual void SetPadBottom(Int_t v)
Definition: TGLayout.h:103
TList * fList
Definition: TGLayout.h:256
Int_t fPadleft
Definition: TGLayout.h:78
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1103
TGListDetailsLayout(TGCompositeFrame *main, Int_t sep=0, UInt_t w=0)
Definition: TGLayout.h:323
const char Option_t
Definition: RtypesCore.h:62
Int_t GetPadRight() const
Definition: TGLayout.h:99
#define BIT(n)
Definition: Rtypes.h:120
TH1 * h
Definition: legend2.C:5
Definitions for TRefCnt, base class for reference counted objects.
Definition: TRefCnt.h:29
TGMatrixLayout(const TGMatrixLayout &)
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1092
TGCompositeFrame * fMain
Definition: TGLayout.h:255
UInt_t fColumns
Definition: TGLayout.h:262
UInt_t fRows
Definition: TGLayout.h:261
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TGDimension GetDefaultSize() const
Return default dimension of the horizontal layout.
Definition: TGLayout.cxx:507
TGFrameElement & operator=(const TGFrameElement &)
Int_t GetPadLeft() const
Definition: TGLayout.h:98
Int_t fState
Definition: TGLayout.h:126
virtual TGDimension GetDefaultSize() const
Return default dimension of the row layout.
Definition: TGLayout.cxx:565
TGMatrixLayout & operator=(const TGMatrixLayout &)
ULong_t fLayoutHints
Definition: TGLayout.h:75
TGLayoutHints * fLayout
Definition: TGLayout.h:127
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1139
TList * fList
Definition: TGLayout.h:176
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void Layout()
Make a vertical layout of all frames in the list.
Definition: TGLayout.cxx:217
void Print(Option_t *option="") const
Print this frame element.
Definition: TGLayout.cxx:99
TGColumnLayout(TGCompositeFrame *main, Int_t s=0)
Definition: TGLayout.h:230
virtual TGDimension GetDefaultSize() const
Return default dimension of the matrix layout.
Definition: TGLayout.cxx:721
TGVerticalLayout(const TGVerticalLayout &gvl)
Definition: TGLayout.h:178
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TGLayout.h:134
virtual void SetDefaultWidth(UInt_t w)
Definition: TGLayout.h:328
virtual void SetDefaultHeight(UInt_t)
Definition: TGLayout.h:158
virtual TGDimension GetDefaultSize() const =0
TGVerticalLayout & operator=(const TGVerticalLayout &gvl)
Definition: TGLayout.h:180
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TGLayout.h:108
virtual TGDimension GetDefaultSize() const
Return default dimension of the column layout.
Definition: TGLayout.cxx:620
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.cxx:102
TGHorizontalLayout(TGCompositeFrame *main)
Definition: TGLayout.h:196
virtual TGDimension GetDefaultSize() const
Return default dimension of the vertical layout.
Definition: TGLayout.cxx:349
ULong_t GetLayoutHints() const
Definition: TGLayout.h:95
char * out
Definition: TBase64.cxx:29
virtual void Layout()
Make a horizontal layout of all frames in the list.
Definition: TGLayout.cxx:381
virtual void Layout()
Make a row layout of all frames in the list.
Definition: TGLayout.cxx:539
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1128
virtual void SetModified(Bool_t flag=kTRUE)
Definition: TGLayout.h:160
A doubly linked list.
Definition: TList.h:47
virtual void Layout()
Make a column layout of all frames in the list.
Definition: TGLayout.cxx:596
virtual void Layout()
Make a tile layout of all frames in the list.
Definition: TGLayout.cxx:855
Int_t fSep
Definition: TGLayout.h:289
Bool_t fModified
Definition: TGLayout.h:292
virtual void SetPadRight(Int_t v)
Definition: TGLayout.h:105
virtual TGDimension GetDefaultSize() const
Return default dimension of the list details layout.
Definition: TGLayout.cxx:979
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1082
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1073
TList * fList
Definition: TGLayout.h:291
void SetRefCount(UInt_t r)
Definition: TRefCnt.h:41
ROOT::R::TRInterface & r
Definition: Object.C:4
SVector< double, 2 > v
Definition: Dict.h:5
TGLayoutHints(ULong_t hints=kLHintsNormal, Int_t padleft=0, Int_t padright=0, Int_t padtop=0, Int_t padbottom=0)
Definition: TGLayout.h:84
Int_t fPadbottom
Definition: TGLayout.h:77
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1003
void UpdateFrameElements(TGLayoutHints *l)
Update layout hints of frame elements.
Definition: TGLayout.cxx:135
TGCompositeFrame * fMain
Definition: TGLayout.h:175
unsigned int UInt_t
Definition: RtypesCore.h:42
TGFrame * fFrame
Definition: TGLayout.h:125
TLine * l
Definition: textangle.C:4
TGRowLayout(TGCompositeFrame *main, Int_t s=0)
Definition: TGLayout.h:218
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1063
Int_t GetPadBottom() const
Definition: TGLayout.h:97
TGTileLayout & operator=(const TGTileLayout &)
TGFrameElement * fFE
Definition: TGLayout.h:69
TGLayoutHints & operator=(const TGLayoutHints &)
TGCompositeFrame * fMain
Definition: TGLayout.h:290
int main(int argc, char *argv[])
Definition: python64.c:14
virtual void Layout()
Make a tile layout of all frames in the list.
Definition: TGLayout.cxx:765
double f(double x)
virtual void SetLayoutHints(ULong_t lh)
Definition: TGLayout.h:101
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t fHints
Definition: TGLayout.h:260
ELayoutHints
Definition: TGLayout.h:35
virtual TGDimension GetDefaultSize() const
Return default dimension of the list layout.
Definition: TGLayout.cxx:913
virtual ~TGLayoutHints()
Destructor.
Definition: TGLayout.cxx:128
TGTileLayout(const TGTileLayout &)
void Print(Option_t *option="") const
Printing.
Definition: TGLayout.cxx:151
ClassDef(TGFrameElement, 0)
Mother of all ROOT objects.
Definition: TObject.h:58
~TGFrameElement()
Destructor. Decrease ref. count of fLayout.
Definition: TGLayout.cxx:92
virtual void SetPadTop(Int_t v)
Definition: TGLayout.h:102
virtual void Layout()
Make a matrix layout of all frames in the list.
Definition: TGLayout.cxx:665
TGFrameElement * fPrev
Definition: TGLayout.h:70
virtual void Layout()=0
Int_t fPadright
Definition: TGLayout.h:79
virtual Bool_t IsModified() const
Definition: TGLayout.h:159
virtual TGDimension GetDefaultSize() const
Return default dimension of the tile layout.
Definition: TGLayout.cxx:820
virtual void SetPadLeft(Int_t v)
Definition: TGLayout.h:104
Bool_t fModified
Definition: TGLayout.h:150
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGLayout.cxx:1117
const Bool_t kTRUE
Definition: Rtypes.h:91
TGListLayout(TGCompositeFrame *main, Int_t sep=0)
Definition: TGLayout.h:308
Int_t fPadtop
Definition: TGLayout.h:76
virtual void SetDefaultWidth(UInt_t)
Definition: TGLayout.h:157
virtual void Layout()
Make a list details layout of all frames in the list.
Definition: TGLayout.cxx:947