Logo ROOT   master
Reference Guide
TGTableLayout.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Brett Viren 04/15/2001
3 
4 /*************************************************************************
5  * Copyright (C) 2001, Brett Viren *
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_TGTableLayout
13 #define ROOT_TGTableLayout
14 
15 #include "TGLayout.h"
16 
17 
18 // extension of ELayoutHints
24 };
25 
26 
27 //////////////////////////////////////////////////////////////////////////
28 // //
29 // TGTableLayoutHints //
30 // //
31 // This class describes layout hints used by the TGTableLayout class. //
32 // //
33 //////////////////////////////////////////////////////////////////////////
34 
36 
37 private:
38  TGTableLayoutHints(const TGTableLayoutHints&); // Not implemented
39  TGTableLayoutHints& operator=(const TGTableLayoutHints&); // Not implemented
40 
41 protected:
42  UInt_t fAttachLeft; // Column/row division number on which
43  UInt_t fAttachRight; // to attach the frame. Starts at 0
44  UInt_t fAttachTop; // and goes to # columns / # rows
45  UInt_t fAttachBottom; // respectively
46 
47 public:
48  TGTableLayoutHints(UInt_t attach_left, UInt_t attach_right,
49  UInt_t attach_top, UInt_t attach_bottom,
50  ULong_t hints = kLHintsNormal,
51  UInt_t padleft = 0, UInt_t padright = 0,
52  UInt_t padtop = 0, UInt_t padbottom = 0)
53  : TGLayoutHints(hints,padleft,padright,padtop,padbottom),
54  fAttachLeft(attach_left),
55  fAttachRight(attach_right),
56  fAttachTop(attach_top),
57  fAttachBottom(attach_bottom) { }
58  virtual ~TGTableLayoutHints() { }
59 
60  UInt_t GetAttachLeft() const { return fAttachLeft; }
61  UInt_t GetAttachRight() const { return fAttachRight; }
62  UInt_t GetAttachTop() const { return fAttachTop; }
63  UInt_t GetAttachBottom() const { return fAttachBottom; }
64  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
65 
66  ClassDef(TGTableLayoutHints,0) // Class describing GUI table layout hints
67 };
68 
69 
70 //////////////////////////////////////////////////////////////////////////
71 // //
72 // TGTableLayout //
73 // //
74 // A LayoutManager which places child frames in a table. This uses //
75 // TGTableLayoutHints (not TGLayoutHints). See TGTableLayoutHints //
76 // for how to use these. This manager works like TGMatrixLayout with //
77 // the addition that: //
78 // - Child frames can span more than one column/row. //
79 // - Child frames can resize with the frame. //
80 // - Column and row sizes are not fixed nor (optionally) homogeneous. //
81 // - The number of columns and rows must be fully specified. //
82 // //
83 //////////////////////////////////////////////////////////////////////////
84 
86 
87 private:
88  TGTableLayout(const TGTableLayout&); // Not implemented
89  TGTableLayout& operator=(const TGTableLayout&); // Not implemented
90 
91 protected:
92  struct TableData_t {
93  UInt_t fDefSize; // Default size of col/rows
94  UInt_t fRealSize; // Real size of col/rows (eg, if table resize)
100  };
101  TableData_t *fRow; // info about each row
102  TableData_t *fCol; // info about each column
103  TGCompositeFrame *fMain; // container frame
104  TList *fList; // list of frames to arrange
105  Bool_t fHomogeneous; // all cols/rows same size
106 
107  void FindRowColSizes();
108  void FindRowColSizesInit();
112 
113  void SetRowColSizes();
114  void SetRowColSizesInit();
115 
116  void CheckSanity();
117 
118  static void SetRowColResize(UInt_t real_size, UInt_t nthings,
119  TableData_t *thing, Bool_t homogeneous);
120 
121 public:
122  // these are public in TGMatrixLayout ??? Perpetuate it.
123  Int_t fSep; // interval between frames
124  Int_t fHints; // layout hints (currently not used)
125  UInt_t fNrows; // number of rows
126  UInt_t fNcols; // number of columns
127 
129  Bool_t homogeneous = kFALSE, Int_t sep = 0, Int_t hints = 0);
130  virtual ~TGTableLayout();
131 
132  virtual void Layout();
133  virtual TGDimension GetDefaultSize() const; // return sum of all child sizes
134  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
135 
136  ClassDef(TGTableLayout,0) // Table layout manager
137 };
138 
139 #endif
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
UInt_t GetAttachLeft() const
Definition: TGTableLayout.h:60
ETableLayoutHints
Definition: TGTableLayout.h:19
const char Option_t
Definition: RtypesCore.h:64
TGTableLayout & operator=(const TGTableLayout &)
#define BIT(n)
Definition: Rtypes.h:83
UInt_t GetAttachTop() const
Definition: TGTableLayout.h:62
TGTableLayout(const TGTableLayout &)
Bool_t fHomogeneous
TGTableLayoutHints & operator=(const TGTableLayoutHints &)
void FindRowColSizesHomogeneous()
If the table is homogeneous make sure all col/rows are same size as biggest col/row.
TGCompositeFrame * fMain
#define ClassDef(name, id)
Definition: Rtypes.h:322
TableData_t * fRow
int main(int argc, char **argv)
virtual void Layout()
Make a table layout of all frames in the list.
void SetRowColSizesInit()
Initialize rows/cols.
UInt_t GetAttachRight() const
Definition: TGTableLayout.h:61
A doubly linked list.
Definition: TList.h:44
void FindRowColSizesSinglyAttached()
Determine the size of rows/cols needed for singly attached children.
TableData_t * fCol
void FindRowColSizesMultiplyAttached()
Checks any children which span multiple col/rows.
UInt_t GetAttachBottom() const
Definition: TGTableLayout.h:63
unsigned int UInt_t
Definition: RtypesCore.h:44
void CheckSanity()
Sanity check various values.
static void SetRowColResize(UInt_t real_size, UInt_t nthings, TableData_t *thing, Bool_t homogeneous)
If main frame is bigger or smaller than all children, expand/shrink to fill.
TGTableLayoutHints(const TGTableLayoutHints &)
const Bool_t kFALSE
Definition: RtypesCore.h:90
void SetRowColSizes()
This gets the new sizes needed to fit the table to the parent frame.
void FindRowColSizes()
Find the sizes of rows and columns needed to statisfy children's layout policies. ...
virtual ~TGTableLayout()
TGTableLayout constructor.
unsigned long ULong_t
Definition: RtypesCore.h:53
void FindRowColSizesInit()
Initialize values needed to determine the size of rows and columns.
virtual TGDimension GetDefaultSize() const
Return default dimension of the table layout.
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save a primitive as a C++ statement(s) on output stream "out".
TGTableLayoutHints(UInt_t attach_left, UInt_t attach_right, UInt_t attach_top, UInt_t attach_bottom, ULong_t hints=kLHintsNormal, UInt_t padleft=0, UInt_t padright=0, UInt_t padtop=0, UInt_t padbottom=0)
Definition: TGTableLayout.h:48
virtual ~TGTableLayoutHints()
Definition: TGTableLayout.h:58