ROOT
master
Reference Guide
Loading...
Searching...
No Matches
numberEntry.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This macro gives an example of how to create a number entry and how to update a label according to the changed value
4
/// of this number entry. To run it do either:
5
/// ~~~
6
/// .x numberEntry.C
7
/// .x numberEntry.C++
8
/// ~~~
9
///
10
/// \macro_code
11
///
12
/// \author Ilka Antcheva 1/12/2006
13
14
#include <
TApplication.h
>
15
#include <
TGClient.h
>
16
#include <
TGButton.h
>
17
#include <
TGFrame.h
>
18
#include <
TGLayout.h
>
19
#include <
TGWindow.h
>
20
#include <
TGLabel.h
>
21
#include <
TGNumberEntry.h
>
22
#include <
TString.h
>
23
24
class
MyMainFrame :
public
TGMainFrame
{
25
26
private
:
27
TGCompositeFrame
*fHor1;
28
TGTextButton
*fExit;
29
TGGroupFrame
*fGframe;
30
TGNumberEntry
*fNumber;
31
TGLabel
*fLabel;
32
33
public
:
34
MyMainFrame(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
);
35
~MyMainFrame()
override
;
36
void
DoSetlabel();
37
38
ClassDefOverride
(MyMainFrame, 0)
39
};
40
41
MyMainFrame::MyMainFrame(
const
TGWindow
*
p
,
UInt_t
w
,
UInt_t
h
) :
TGMainFrame
(
p
,
w
,
h
)
42
{
43
44
fHor1 =
new
TGHorizontalFrame
(
this
, 60, 20,
kFixedWidth
);
45
fExit =
new
TGTextButton
(fHor1,
"&Exit"
,
"gApplication->Terminate(0)"
);
46
fHor1->AddFrame(fExit,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsLeft
|
kLHintsExpandX
, 4, 4, 4, 4));
47
AddFrame(fHor1,
new
TGLayoutHints
(
kLHintsBottom
|
kLHintsRight
, 2, 2, 5, 1));
48
49
fNumber =
new
TGNumberEntry
(
this
, 0, 9, 999,
TGNumberFormat::kNESInteger
,
TGNumberFormat::kNEANonNegative
,
50
TGNumberFormat::kNELLimitMinMax
, 0, 99999);
51
fNumber->Connect(
"ValueSet(Long_t)"
,
"MyMainFrame"
,
this
,
"DoSetlabel()"
);
52
(fNumber->GetNumberEntry())->Connect(
"ReturnPressed()"
,
"MyMainFrame"
,
this
,
"DoSetlabel()"
);
53
AddFrame(fNumber,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsLeft
, 5, 5, 5, 5));
54
fGframe =
new
TGGroupFrame
(
this
,
"Value"
);
55
fLabel =
new
TGLabel
(fGframe,
"No input."
);
56
fGframe->AddFrame(fLabel,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsLeft
, 5, 5, 5, 5));
57
AddFrame(fGframe,
new
TGLayoutHints
(
kLHintsExpandX
, 2, 2, 1, 1));
58
59
SetCleanup(
kDeepCleanup
);
60
SetWindowName(
"Number Entry"
);
61
MapSubwindows
();
62
Resize(GetDefaultSize());
63
MapWindow();
64
}
65
66
MyMainFrame::~MyMainFrame()
67
{
68
// Destructor.
69
70
Cleanup();
71
}
72
73
void
MyMainFrame::DoSetlabel()
74
{
75
// Slot method connected to the ValueSet(Long_t) signal.
76
// It displays the value set in TGNumberEntry widget.
77
78
fLabel->SetText(
Form
(
"%ld"
, fNumber->GetNumberEntry()->GetIntNumber()));
79
80
// Parent frame Layout() method will redraw the label showing the new value.
81
fGframe->Layout();
82
}
83
84
void
numberEntry
()
85
{
86
new
MyMainFrame(
gClient
->GetRoot(), 50, 50);
87
}
kFixedWidth
@ kFixedWidth
Definition
GuiTypes.h:387
h
#define h(i)
Definition
RSha256.hxx:106
UInt_t
unsigned int UInt_t
Definition
RtypesCore.h:46
ClassDefOverride
#define ClassDefOverride(name, id)
Definition
Rtypes.h:346
TApplication.h
TGButton.h
TGClient.h
gClient
#define gClient
Definition
TGClient.h:157
TGFrame.h
kDeepCleanup
@ kDeepCleanup
Definition
TGFrame.h:42
TGLabel.h
TGLayout.h
kLHintsRight
@ kLHintsRight
Definition
TGLayout.h:26
kLHintsLeft
@ kLHintsLeft
Definition
TGLayout.h:24
kLHintsBottom
@ kLHintsBottom
Definition
TGLayout.h:29
kLHintsTop
@ kLHintsTop
Definition
TGLayout.h:27
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
TGNumberEntry.h
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
TGWindow.h
TString.h
Form
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition
TString.cxx:2489
TGCompositeFrame
The base class for composite widgets (menu bars, list boxes, etc.).
Definition
TGFrame.h:287
TGGroupFrame
A composite frame with a border and a title.
Definition
TGFrame.h:522
TGHorizontalFrame
A composite frame that layout their children in horizontal way.
Definition
TGFrame.h:385
TGLabel
This class handles GUI labels.
Definition
TGLabel.h:24
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
TGNumberEntry
TGNumberEntry is a number entry input widget with up/down buttons.
Definition
TGNumberEntry.h:148
TGNumberFormat::kNEANonNegative
@ kNEANonNegative
Non-negative number.
Definition
TGNumberEntry.h:43
TGNumberFormat::kNESInteger
@ kNESInteger
Style of number entry field.
Definition
TGNumberEntry.h:25
TGNumberFormat::kNELLimitMinMax
@ kNELLimitMinMax
Both lower and upper limits.
Definition
TGNumberEntry.h:51
TGTextButton
Yield an action as soon as it is clicked.
Definition
TGButton.h:142
TGWindow
ROOT GUI Window base class.
Definition
TGWindow.h:23
numberEntry
Definition
numberEntry.py:1
tutorials
visualisation
gui
numberEntry.C
ROOT master - Reference Guide Generated on Thu Dec 19 2024 09:47:24 (GVA Time) using Doxygen 1.9.8