ROOT
master
Reference Guide
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
#include <
TGClient.h
>
15
#include <
TGButton.h
>
16
17
class
MyMainFrame :
public
TGMainFrame
{
18
19
private
:
20
TGTextButton
*test, *draw, *help, *ok, *cancel, *exit;
21
22
public
:
23
MyMainFrame(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
);
24
~MyMainFrame()
override
;
25
26
ClassDef
(MyMainFrame, 0)
27
};
28
29
MyMainFrame::MyMainFrame(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
) :
TGMainFrame
(
p
,
w
,
h
)
30
{
31
// Create a container frames containing buttons
32
33
// one button is resized up to the parent width.
34
// Note! this width should be fixed!
35
TGVerticalFrame
*hframe1 =
new
TGVerticalFrame
(
this
, 170, 50,
kFixedWidth
);
36
test =
new
TGTextButton
(hframe1,
"&Test "
);
37
// to take whole space we need to use kLHintsExpandX layout hints
38
hframe1->
AddFrame
(test,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 2, 0, 2, 2));
39
AddFrame(hframe1,
new
TGLayoutHints
(
kLHintsCenterX
, 2, 2, 5, 1));
40
41
// two buttons are resized up to the parent width.
42
// Note! this width should be fixed!
43
TGCompositeFrame
*cframe1 =
new
TGCompositeFrame
(
this
, 170, 20,
kHorizontalFrame
|
kFixedWidth
);
44
draw =
new
TGTextButton
(cframe1,
"&Draw"
);
45
// to share whole parent space we need to use kLHintsExpandX layout hints
46
cframe1->
AddFrame
(draw,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 2, 2, 2, 2));
47
48
// button background will be set to yellow
49
ULong_t
yellow;
50
gClient
->GetColorByName(
"yellow"
, yellow);
51
help =
new
TGTextButton
(cframe1,
"&Help"
);
52
help->ChangeBackground(yellow);
53
cframe1->
AddFrame
(help,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 2, 2, 2, 2));
54
AddFrame(cframe1,
new
TGLayoutHints
(
kLHintsCenterX
, 2, 2, 5, 1));
55
56
// three buttons are resized up to the parent width.
57
// Note! this width should be fixed!
58
TGCompositeFrame
*cframe2 =
new
TGCompositeFrame
(
this
, 170, 20,
kHorizontalFrame
|
kFixedWidth
);
59
ok =
new
TGTextButton
(cframe2,
"OK"
);
60
// to share whole parent space we need to use kLHintsExpandX layout hints
61
cframe2->
AddFrame
(ok,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 3, 2, 2, 2));
62
63
cancel =
new
TGTextButton
(cframe2,
"Cancel "
);
64
cframe2->
AddFrame
(cancel,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 3, 2, 2, 2));
65
66
exit =
new
TGTextButton
(cframe2,
"&Exit "
,
"gApplication->Terminate(0)"
);
67
cframe2->
AddFrame
(exit,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 2, 0, 2, 2));
68
69
AddFrame(cframe2,
new
TGLayoutHints
(
kLHintsCenterX
, 2, 2, 5, 1));
70
71
SetWindowName(
"Buttons' Layout"
);
72
73
// gives min/max window size + a step of x,y incrementing
74
// between the given sizes
75
SetWMSizeHints
(200, 80, 320, 320, 1, 1);
76
MapSubwindows
();
77
// important for layout algorithm
78
Resize(GetDefaultSize());
79
MapWindow();
80
}
81
82
MyMainFrame::~MyMainFrame()
83
{
84
// Clean up all widgets, frames and layouthints that were used
85
Cleanup();
86
}
87
88
void
buttonsLayout()
89
{
90
// Popup the GUI...
91
new
MyMainFrame(
gClient
->GetRoot(), 350, 80);
92
}
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:342
TGButton.h
TGClient.h
gClient
#define gClient
Definition
TGClient.h:157
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
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition
TGFrame.h:287
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition
TGFrame.cxx:1117
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
visualisation
gui
buttonsLayout.C
ROOT master - Reference Guide Generated on Thu Dec 19 2024 09:47:24 (GVA Time) using Doxygen 1.9.8