ROOT
Version v6.32
master
v6.34
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
buttonsLayout.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This macro gives an example of different buttons' layout.
4
/// To run it do either:
5
/// ~~~
6
/// .x buttonsLayout.C
7
/// .x buttonsLayout.C++
8
/// ~~~
9
///
10
/// \macro_code
11
///
12
/// \author Ilka Antcheva 1/12/2006
13
14
15
#include <
TGClient.h
>
16
#include <
TGButton.h
>
17
18
class
MyMainFrame
:
public
TGMainFrame
{
19
20
private
:
21
TGTextButton
*
test
, *
draw
, *help, *ok, *
cancel
, *
exit
;
22
23
public
:
24
MyMainFrame
(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
);
25
~MyMainFrame
()
override
;
26
27
ClassDef
(
MyMainFrame
, 0)
28
};
29
30
31
MyMainFrame::MyMainFrame(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
) :
32
TGMainFrame
(
p
,
w
,
h
)
33
{
34
// Create a container frames containing buttons
35
36
// one button is resized up to the parent width.
37
// Note! this width should be fixed!
38
TGVerticalFrame
*
hframe1
=
new
TGVerticalFrame
(
this
, 170, 50,
kFixedWidth
);
39
test
=
new
TGTextButton
(
hframe1
,
"&Test "
);
40
// to take whole space we need to use kLHintsExpandX layout hints
41
hframe1
->AddFrame(
test
,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
,
42
2, 0, 2, 2));
43
AddFrame(
hframe1
,
new
TGLayoutHints
(
kLHintsCenterX
, 2, 2, 5, 1));
44
45
// two buttons are resized up to the parent width.
46
// Note! this width should be fixed!
47
TGCompositeFrame
*
cframe1
=
new
TGCompositeFrame
(
this
, 170, 20,
48
kHorizontalFrame
|
kFixedWidth
);
49
draw
=
new
TGTextButton
(
cframe1
,
"&Draw"
);
50
// to share whole parent space we need to use kLHintsExpandX layout hints
51
cframe1
->AddFrame(
draw
,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
,
52
2, 2, 2, 2));
53
54
// button background will be set to yellow
55
ULong_t
yellow
;
56
gClient
->GetColorByName(
"yellow"
,
yellow
);
57
help =
new
TGTextButton
(
cframe1
,
"&Help"
);
58
help->ChangeBackground(
yellow
);
59
cframe1
->AddFrame(help,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
,
60
2, 2, 2, 2));
61
AddFrame(
cframe1
,
new
TGLayoutHints
(
kLHintsCenterX
, 2, 2, 5, 1));
62
63
// three buttons are resized up to the parent width.
64
// Note! this width should be fixed!
65
TGCompositeFrame
*
cframe2
=
new
TGCompositeFrame
(
this
, 170, 20,
66
kHorizontalFrame
|
kFixedWidth
);
67
ok =
new
TGTextButton
(
cframe2
,
"OK"
);
68
// to share whole parent space we need to use kLHintsExpandX layout hints
69
cframe2
->AddFrame(ok,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
,
70
3, 2, 2, 2));
71
72
cancel
=
new
TGTextButton
(
cframe2
,
"Cancel "
);
73
cframe2
->AddFrame(
cancel
,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
,
74
3, 2, 2, 2));
75
76
exit
=
new
TGTextButton
(
cframe2
,
"&Exit "
,
"gApplication->Terminate(0)"
);
77
cframe2
->AddFrame(
exit
,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
,
78
2, 0, 2, 2));
79
80
AddFrame(
cframe2
,
new
TGLayoutHints
(
kLHintsCenterX
, 2, 2, 5, 1));
81
82
SetWindowName(
"Buttons' Layout"
);
83
84
// gives min/max window size + a step of x,y incrementing
85
// between the given sizes
86
SetWMSizeHints
(200, 80, 320, 320, 1, 1);
87
MapSubwindows
();
88
// important for layout algorithm
89
Resize(GetDefaultSize());
90
MapWindow();
91
}
92
93
94
MyMainFrame::~MyMainFrame()
95
{
96
// Clean up all widgets, frames and layouthints that were used
97
Cleanup();
98
}
99
100
void
buttonsLayout
()
101
{
102
// Popup the GUI...
103
new
MyMainFrame
(
gClient
->GetRoot(), 350, 80);
104
}
kFixedWidth
@ kFixedWidth
Definition
GuiTypes.h:387
kHorizontalFrame
@ kHorizontalFrame
Definition
GuiTypes.h:382
h
#define h(i)
Definition
RSha256.hxx:106
ULong_t
unsigned long ULong_t
Definition
RtypesCore.h:55
UInt_t
unsigned int UInt_t
Definition
RtypesCore.h:46
ClassDef
#define ClassDef(name, id)
Definition
Rtypes.h:337
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TGButton.h
TGClient.h
gClient
#define gClient
Definition
TGClient.h:156
kLHintsCenterX
@ kLHintsCenterX
Definition
TGLayout.h:25
kLHintsTop
@ kLHintsTop
Definition
TGLayout.h:27
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
w
winID w
Definition
TGWin32VirtualGLProxy.cxx:39
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Definition
TGWin32VirtualXProxy.cxx:94
SetWMSizeHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
Definition
TGWin32VirtualXProxy.cxx:162
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition
TGFrame.h:287
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition
TGLayout.h:50
TGMainFrame
Defines top level windows that interact with the system Window Manager.
Definition
TGFrame.h:397
TGTextButton
Yield an action as soon as it is clicked.
Definition
TGButton.h:142
TGVerticalFrame
A composite frame that layout their children in vertical way.
Definition
TGFrame.h:374
TGWindow
ROOT GUI Window base class.
Definition
TGWindow.h:23
tutorials
gui
buttonsLayout.C
ROOT v6-32 - Reference Guide Generated on Sat Apr 12 2025 15:11:08 (GVA Time) using Doxygen 1.10.0