Logo ROOT   6.10/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 #include "TObject.h"
24 #include "TGDimension.h"
25 #include "TRefCnt.h"
26 
27 //---- layout hints
28 
40  // bits 8-11 used by ETableLayoutHints
41 };
42 
43 class TGFrame;
44 class TGCompositeFrame;
45 class TGLayoutHints;
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:
147  TGLayoutManager() : fModified(kTRUE) {}
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
Int_t fSep
Definition: TGLayout.h:210
virtual void SetPadBottom(Int_t v)
Definition: TGLayout.h:97
TList * fList
Definition: TGLayout.h:250
Int_t fPadleft
Definition: TGLayout.h:72
friend class TGFrameElement
Definition: TGLayout.h:59
TGListDetailsLayout(TGCompositeFrame *main, Int_t sep=0, UInt_t w=0)
Definition: TGLayout.h:317
ULong_t GetLayoutHints() const
Definition: TGLayout.h:89
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:75
TH1 * h
Definition: legend2.C:5
Definitions for TRefCnt, base class for reference counted objects.
Definition: TRefCnt.h:27
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TGLayout.h:102
TGCompositeFrame * fMain
Definition: TGLayout.h:249
UInt_t fColumns
Definition: TGLayout.h:256
UInt_t fRows
Definition: TGLayout.h:255
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t fState
Definition: TGLayout.h:120
ULong_t fLayoutHints
Definition: TGLayout.h:69
TGLayoutHints * fLayout
Definition: TGLayout.h:121
TList * fList
Definition: TGLayout.h:170
#define ClassDef(name, id)
Definition: Rtypes.h:297
TGColumnLayout(TGCompositeFrame *main, Int_t s=0)
Definition: TGLayout.h:224
TGVerticalLayout(const TGVerticalLayout &gvl)
Definition: TGLayout.h:172
virtual void SetDefaultWidth(UInt_t w)
Definition: TGLayout.h:322
virtual void SetDefaultHeight(UInt_t)
Definition: TGLayout.h:152
TGVerticalLayout & operator=(const TGVerticalLayout &gvl)
Definition: TGLayout.h:174
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.h:250
TGHorizontalLayout(TGCompositeFrame *main)
Definition: TGLayout.h:190
virtual void SetModified(Bool_t flag=kTRUE)
Definition: TGLayout.h:154
A doubly linked list.
Definition: TList.h:43
Int_t fSep
Definition: TGLayout.h:283
Bool_t fModified
Definition: TGLayout.h:286
virtual void SetPadRight(Int_t v)
Definition: TGLayout.h:99
TList * fList
Definition: TGLayout.h:285
void SetRefCount(UInt_t r)
Definition: TRefCnt.h:39
void Print(Option_t *option="") const
Printing.
Definition: TGLayout.cxx:151
TRandom2 r(17)
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:78
Int_t fPadbottom
Definition: TGLayout.h:71
void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition: TGLayout.h:128
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
Int_t GetPadLeft() const
Definition: TGLayout.h:92
void UpdateFrameElements(TGLayoutHints *l)
Update layout hints of frame elements.
Definition: TGLayout.cxx:135
TGCompositeFrame * fMain
Definition: TGLayout.h:169
unsigned int UInt_t
Definition: RtypesCore.h:42
TGFrame * fFrame
Definition: TGLayout.h:119
TLine * l
Definition: textangle.C:4
TGRowLayout(TGCompositeFrame *main, Int_t s=0)
Definition: TGLayout.h:212
TGFrameElement * fFE
Definition: TGLayout.h:63
TGLayoutHints & operator=(const TGLayoutHints &)
TGCompositeFrame * fMain
Definition: TGLayout.h:284
double f(double x)
virtual void SetLayoutHints(ULong_t lh)
Definition: TGLayout.h:95
Int_t GetPadRight() const
Definition: TGLayout.h:93
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t fHints
Definition: TGLayout.h:254
ELayoutHints
Definition: TGLayout.h:29
virtual ~TGLayoutHints()
Destructor.
Definition: TGLayout.cxx:128
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void SetPadTop(Int_t v)
Definition: TGLayout.h:96
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)
TGFrameElement * fPrev
Definition: TGLayout.h:64
virtual Bool_t IsModified() const
Definition: TGLayout.h:294
Int_t fPadright
Definition: TGLayout.h:73
Int_t GetPadTop() const
Definition: TGLayout.h:90
virtual Bool_t IsModified() const
Definition: TGLayout.h:153
virtual void SetPadLeft(Int_t v)
Definition: TGLayout.h:98
Bool_t fModified
Definition: TGLayout.h:144
TGListLayout(TGCompositeFrame *main, Int_t sep=0)
Definition: TGLayout.h:302
const Bool_t kTRUE
Definition: RtypesCore.h:91
Int_t fPadtop
Definition: TGLayout.h:70
virtual void SetDefaultWidth(UInt_t)
Definition: TGLayout.h:151
int main(int argc, char **argv)
Int_t GetPadBottom() const
Definition: TGLayout.h:91