ROOT  6.06/09
Reference Guide
TGXYLayout.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Reiner Rohlfs 24/03/2002
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2002, Rene Brun, Fons Rademakers and Reiner Rohlfs *
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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TGXYLayout //
15 // //
16 // Is a layout manager where the position and the size of each widget //
17 // in the frame are defined by X / Y - coordinates. The coordinates //
18 // for each widget are defined by the TGXYLayoutHints. Therefore it //
19 // is not possible to share a layout hint for several widgets. //
20 // //
21 // The coordinates (X, Y) and the size (W, H) are defined in units //
22 // of the size of a typical character. Also the size of the //
23 // TGCompositeFrame for which a TGXYLayout manager is used has to be //
24 // defined in its constructor in units of the size of a character! //
25 // //
26 // It is not possible to use any other layout hint than the //
27 // TGXYLayoutHints for this layout manager! //
28 // //
29 // The rubberFlag in the constructor of the TGLXYLayoutHints defines //
30 // how the position and the size of a widget is recalculated if the //
31 // size of the frame is increased: //
32 // - kLRubberX: The X - position (left edge) is increased by the same //
33 // factor as the width of the frame increases. //
34 // - kLRubberY: The Y - position (upper edge) is increased by the same //
35 // factor as the height of the frame increases. //
36 // - kLRubberW: The width of the widget is increased by the same //
37 // factor as the width of the frame increases. //
38 // - kLRubberY: The height of the widget is increased by the same //
39 // factor as the height of the frame increases. //
40 // But the size never becomes smaller than defined by the //
41 // TGXYLayoutHints and the X and Y coordinates becomes never smaller //
42 // than defined by the layout hints. //
43 // //
44 // TGXYLayoutHints //
45 // //
46 // This layout hint must be used for the TGXYLouyout manager! //
47 // //
48 // //
49 // Example how to use this layout manager: //
50 // //
51 // TGMyFrame::TGMyFrame() //
52 // : TGMainFrame(gClient->GetRoot(), 30, 12) //
53 // // frame is 30 characters wide and 12 characters high //
54 // { //
55 // SetLayoutManager(new TGXYLayout(this)); //
56 // //
57 // // create a button of size 8 X 1.8 at position 20 / 1 //
58 // TGTextButton * button; //
59 // button = new TGTextButton(this, "&Apply", 1); //
60 // AddFrame(button, new TGXYLayoutHints(20, 1, 8, 1.8)); //
61 // //
62 // // create a listbox of size 18 X 10 at position 1 / 1. //
63 // // The height will increase if the frame height increases //
64 // TGListBox *listBox; //
65 // listBox = new TGListBox(this, 2); //
66 // AddFrame(listBox, new TGXYLayoutHints(1, 1, 18, 10, //
67 // TGXYLayoutHints::kLRubberX | //
68 // TGXYLayoutHints::kLRubberY | //
69 // TGXYLayoutHints::kLRubberH)); //
70 // . //
71 // . //
72 // . //
73 // } //
74 // //
75 // Normaly there is one layout hint per widget. Therefore these //
76 // can be deleted like in the following example in the desctuctor //
77 // of the frame: //
78 // //
79 // TGMyFrame::~TGMyFrame() //
80 // { //
81 // // Destructor, deletes all frames and their layout hints. //
82 // //
83 // // delete all frames and layout hints //
84 // Cleanup(); //
85 // } //
86 // //
87 //////////////////////////////////////////////////////////////////////////
88 
89 #ifndef ROOT_TGXYLayout
90 #define ROOT_TGXYLayout
91 
92 #ifndef ROOT_TGLayout
93 #include "TGLayout.h"
94 #endif
95 
96 
98 
99 protected:
100  Double_t fX; // x - position of widget
101  Double_t fY; // y - position of widget
102  Double_t fW; // width of widget
103  Double_t fH; // height of widget
104  UInt_t fFlag; // rubber flag
105 
106 public:
107 
108  enum ERubberFlag {
113  };
114 
116  UInt_t rubberFlag = kLRubberX | kLRubberY);
117 
118  Double_t GetX() const { return fX; };
119  Double_t GetY() const { return fY; };
120  Double_t GetW() const { return fW; };
121  Double_t GetH() const { return fH; };
122  UInt_t GetFlag() const { return fFlag; };
123 
124  void SetX(Double_t x) { fX = x; }
125  void SetY(Double_t y) { fY = y; }
126  void SetW(Double_t w) { fW = w; }
127  void SetH(Double_t h) { fH = h; }
128  void SetFlag(UInt_t flag) { fFlag = flag; }
129 
130  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
131 
132  ClassDef(TGXYLayoutHints,0) // Hits for the X / Y - layout manager
133 };
134 
135 
136 class TGXYLayout : public TGLayoutManager {
137 
138 protected:
139  TList *fList; // list of frames to arrange
140  TGCompositeFrame *fMain; // container frame
141 
142  Bool_t fFirst; // flag to determine the first call of Layout()
143  UInt_t fFirstWidth; // original width of the frame fMain
144  UInt_t fFirstHeight; // original height of the fram fMain
145 
146  Int_t fTWidth; // text width of a default character "1234567890" / 10
147  Int_t fTHeight; // text height
148 
149  TGXYLayout(const TGXYLayout&);
151 
152 public:
154 
155  virtual void Layout();
156  virtual TGDimension GetDefaultSize() const;
157  virtual void SavePrimitive(std::ostream &out, Option_t * = "");
158 
159  void NewSize() { fFirst = kTRUE; }
160 
161  ClassDef(TGXYLayout,0) // X / Y - layout manager
162 };
163 
164 #endif
void SetX(Double_t x)
Definition: TGXYLayout.h:124
const char Option_t
Definition: RtypesCore.h:62
#define BIT(n)
Definition: Rtypes.h:120
TH1 * h
Definition: legend2.C:5
Double_t GetH() const
Definition: TGXYLayout.h:121
int Int_t
Definition: RtypesCore.h:41
TGXYLayout(const TGXYLayout &)
copy constructor
Definition: TGXYLayout.cxx:190
bool Bool_t
Definition: RtypesCore.h:59
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save XY layout manager as a C++ statement(s) on output stream.
Definition: TGXYLayout.cxx:296
Int_t fTWidth
Definition: TGXYLayout.h:146
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
void NewSize()
Definition: TGXYLayout.h:159
virtual void Layout()
Recalculates the postion and the size of all widgets.
Definition: TGXYLayout.cxx:223
TGXYLayoutHints(Double_t x, Double_t y, Double_t w, Double_t h, UInt_t rubberFlag=kLRubberX|kLRubberY)
TGCompositeFrame * fMain
Definition: TGXYLayout.h:140
char * out
Definition: TBase64.cxx:29
A doubly linked list.
Definition: TList.h:47
void SetH(Double_t h)
Definition: TGXYLayout.h:127
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save XY layout hints as a C++ statement(s) on output stream.
Definition: TGXYLayout.cxx:129
void SetW(Double_t w)
Definition: TGXYLayout.h:126
UInt_t GetFlag() const
Definition: TGXYLayout.h:122
int main(int argc, char *argv[])
Definition: python64.c:14
Double_t GetX() const
Definition: TGXYLayout.h:118
UInt_t fFirstHeight
Definition: TGXYLayout.h:144
double Double_t
Definition: RtypesCore.h:55
UInt_t fFirstWidth
Definition: TGXYLayout.h:143
Double_t y[n]
Definition: legend1.C:17
Int_t fTHeight
Definition: TGXYLayout.h:147
Bool_t fFirst
Definition: TGXYLayout.h:142
void SetFlag(UInt_t flag)
Definition: TGXYLayout.h:128
Double_t GetY() const
Definition: TGXYLayout.h:119
Double_t GetW() const
Definition: TGXYLayout.h:120
TGXYLayout & operator=(const TGXYLayout &)
assignment operator
Definition: TGXYLayout.cxx:205
void SetY(Double_t y)
Definition: TGXYLayout.h:125
const Bool_t kTRUE
Definition: Rtypes.h:91
TList * fList
Definition: TGXYLayout.h:139
virtual TGDimension GetDefaultSize() const
Returns the original size of the frame.
Definition: TGXYLayout.cxx:286