Logo ROOT  
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#include "TGLayout.h"
93
94
96
97protected:
98 Double_t fX; // x - position of widget
99 Double_t fY; // y - position of widget
100 Double_t fW; // width of widget
101 Double_t fH; // height of widget
102 UInt_t fFlag; // rubber flag
103
104public:
105
110 kLRubberH = BIT(3)
111 };
112
114 UInt_t rubberFlag = kLRubberX | kLRubberY);
115
116 Double_t GetX() const { return fX; };
117 Double_t GetY() const { return fY; };
118 Double_t GetW() const { return fW; };
119 Double_t GetH() const { return fH; };
120 UInt_t GetFlag() const { return fFlag; };
121
122 void SetX(Double_t x) { fX = x; }
123 void SetY(Double_t y) { fY = y; }
124 void SetW(Double_t w) { fW = w; }
125 void SetH(Double_t h) { fH = h; }
126 void SetFlag(UInt_t flag) { fFlag = flag; }
127
128 virtual void SavePrimitive(std::ostream &out, Option_t * = "");
129
130 ClassDef(TGXYLayoutHints,0) // Hits for the X / Y - layout manager
131};
132
133
135
136protected:
137 TList *fList; // list of frames to arrange
138 TGCompositeFrame *fMain; // container frame
139
140 Bool_t fFirst; // flag to determine the first call of Layout()
141 UInt_t fFirstWidth; // original width of the frame fMain
142 UInt_t fFirstHeight; // original height of the fram fMain
143
144 Int_t fTWidth; // text width of a default character "1234567890" / 10
145 Int_t fTHeight; // text height
146
147 TGXYLayout(const TGXYLayout&);
149
150public:
152
153 virtual void Layout();
154 virtual TGDimension GetDefaultSize() const;
155 virtual void SavePrimitive(std::ostream &out, Option_t * = "");
156
157 void NewSize() { fFirst = kTRUE; }
158
159 ClassDef(TGXYLayout,0) // X / Y - layout manager
160};
161
162#endif
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:43
unsigned int UInt_t
Definition: RtypesCore.h:44
bool Bool_t
Definition: RtypesCore.h:61
double Double_t
Definition: RtypesCore.h:57
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
#define BIT(n)
Definition: Rtypes.h:83
Double_t GetX() const
Definition: TGXYLayout.h:116
void SetY(Double_t y)
Definition: TGXYLayout.h:123
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save XY layout hints as a C++ statement(s) on output stream.
Definition: TGXYLayout.cxx:130
void SetFlag(UInt_t flag)
Definition: TGXYLayout.h:126
TGXYLayoutHints(Double_t x, Double_t y, Double_t w, Double_t h, UInt_t rubberFlag=kLRubberX|kLRubberY)
Constructor.
Definition: TGXYLayout.cxx:116
void SetH(Double_t h)
Definition: TGXYLayout.h:125
void SetX(Double_t x)
Definition: TGXYLayout.h:122
Double_t fY
Definition: TGXYLayout.h:99
Double_t GetH() const
Definition: TGXYLayout.h:119
Double_t GetW() const
Definition: TGXYLayout.h:118
Double_t fX
Definition: TGXYLayout.h:98
void SetW(Double_t w)
Definition: TGXYLayout.h:124
Double_t GetY() const
Definition: TGXYLayout.h:117
UInt_t GetFlag() const
Definition: TGXYLayout.h:120
Int_t fTWidth
Definition: TGXYLayout.h:144
TList * fList
Definition: TGXYLayout.h:137
TGXYLayout(const TGXYLayout &)
copy constructor
Definition: TGXYLayout.cxx:191
UInt_t fFirstWidth
Definition: TGXYLayout.h:141
UInt_t fFirstHeight
Definition: TGXYLayout.h:142
TGCompositeFrame * fMain
Definition: TGXYLayout.h:138
TGXYLayout & operator=(const TGXYLayout &)
assignment operator
Definition: TGXYLayout.cxx:206
virtual TGDimension GetDefaultSize() const
Returns the original size of the frame.
Definition: TGXYLayout.cxx:287
Int_t fTHeight
Definition: TGXYLayout.h:145
virtual void Layout()
Recalculates the postion and the size of all widgets.
Definition: TGXYLayout.cxx:224
Bool_t fFirst
Definition: TGXYLayout.h:140
void NewSize()
Definition: TGXYLayout.h:157
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save XY layout manager as a C++ statement(s) on output stream.
Definition: TGXYLayout.cxx:297
A doubly linked list.
Definition: TList.h:44
int main(int argc, char **argv)
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17