ROOT
Version master
v6.34
v6.32
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
textEntries.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This macro gives an example of how to set/change text entry attributes.
4
/// To run it do either:
5
/// ~~~
6
/// .x textEntries.C
7
/// .x textEntries.C++
8
/// ~~~
9
///
10
/// \macro_code
11
///
12
/// \author Valeriy Onuchin 25/08/2007
13
14
#include <
TGTextEntry.h
>
15
#include <
TGButtonGroup.h
>
16
#include <
TGLabel.h
>
17
#include <
TGComboBox.h
>
18
#include <
TApplication.h
>
19
20
//////////// auxilary class ///////////////////////////////////////////////////
21
class
GroupBox
:
public
TGGroupFrame
{
22
private
:
23
TGComboBox
*fCombo;
// combo box
24
TGTextEntry
*fEntry;
// text entry
25
26
public
:
27
GroupBox
(
const
TGWindow
*
p
,
const
char
*
name
,
const
char
*title);
28
TGTextEntry
*GetEntry()
const
{
return
fEntry; }
29
TGComboBox
*
GetCombo
()
const
{
return
fCombo; }
30
31
ClassDef
(
GroupBox
, 0)
32
};
33
34
//______________________________________________________________________________
35
GroupBox::GroupBox(
const
TGWindow
*
p
,
const
char
*
name
,
const
char
*title) :
TGGroupFrame
(
p
,
name
)
36
{
37
// Group frame containing combobox and text entry.
38
39
TGHorizontalFrame
*
horz
=
new
TGHorizontalFrame
(
this
);
40
AddFrame(
horz
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsCenterY
));
41
TGLabel
*label =
new
TGLabel
(
horz
, title);
42
horz
->AddFrame(label,
new
TGLayoutHints
(
kLHintsLeft
|
kLHintsCenterY
));
43
44
fCombo =
new
TGComboBox
(
horz
);
45
horz
->AddFrame(fCombo,
new
TGLayoutHints
(
kLHintsRight
|
kLHintsExpandY
, 5, 0, 5, 5));
46
fCombo->Resize(100, 20);
47
48
fEntry =
new
TGTextEntry
(
this
);
49
AddFrame(fEntry,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsCenterY
));
50
}
51
52
////////////////////////////////////////////////////////////////////////////////
53
class
TextEntryWindow
{
54
55
protected
:
56
TGMainFrame
*fMain;
// main frame
57
GroupBox
*
fEcho
;
// echo mode (echo, password, no echo)
58
GroupBox
*fAlign;
// alignment (left, right, center)
59
GroupBox
*
fAccess
;
// read-only mode
60
GroupBox
*fBorder;
// border mode
61
62
public
:
63
TextEntryWindow
();
64
virtual
~TextEntryWindow
() {
delete
fMain; }
65
66
ClassDef
(
TextEntryWindow
, 0);
67
};
68
69
//______________________________________________________________________________
70
TextEntryWindow::TextEntryWindow()
71
{
72
// Main test window.
73
74
TGComboBox
*
combo
;
75
TGTextEntry
*
entry
;
76
77
fMain =
new
TGMainFrame
(
gClient
->GetRoot(), 10, 10,
kVerticalFrame
);
78
79
// recusively delete all subframes on exit
80
fMain->SetCleanup(
kDeepCleanup
);
81
82
fEcho
=
new
GroupBox
(fMain,
"Echo"
,
"Mode:"
);
83
fMain->AddFrame(
fEcho
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
84
combo
=
fEcho
->GetCombo();
85
entry
=
fEcho
->GetEntry();
86
// add entries
87
combo
->AddEntry(
"Normal"
,
TGTextEntry::kNormal
);
88
combo
->AddEntry(
"Password"
,
TGTextEntry::kPassword
);
89
combo
->AddEntry(
"No Echo"
,
TGTextEntry::kNoEcho
);
90
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetEchoMode(TGTextEntry::EEchoMode)"
);
91
combo
->Select(
TGTextEntry::kNormal
);
92
93
fAlign =
new
GroupBox
(fMain,
"Alignment"
,
"Type:"
);
94
fMain->AddFrame(fAlign,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
95
combo
= fAlign->GetCombo();
96
entry
= fAlign->GetEntry();
97
// add entries
98
combo
->AddEntry(
"Left"
,
kTextLeft
);
99
combo
->AddEntry(
"Centered"
,
kTextCenterX
);
100
combo
->AddEntry(
"Right"
,
kTextRight
);
101
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetAlignment(ETextJustification)"
);
102
combo
->Select(
kTextLeft
);
103
104
fAccess
=
new
GroupBox
(fMain,
"Access"
,
"Read-only:"
);
105
fMain->AddFrame(
fAccess
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
106
combo
=
fAccess
->GetCombo();
107
entry
=
fAccess
->GetEntry();
108
// add entries
109
combo
->AddEntry(
"False"
, 1);
110
combo
->AddEntry(
"True"
, 0);
111
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetEnabled(Int_t)"
);
112
combo
->Select(1);
113
114
fBorder =
new
GroupBox
(fMain,
"Border"
,
"Drawn:"
);
115
fMain->AddFrame(fBorder,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
116
combo
= fBorder->GetCombo();
117
entry
= fBorder->GetEntry();
118
// add entries
119
combo
->AddEntry(
"False"
, 0);
120
combo
->AddEntry(
"True"
, 1);
121
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetFrameDrawn(Int_t)"
);
122
combo
->Select(1);
123
124
// terminate ROOT session when window is closed
125
fMain->Connect(
"CloseWindow()"
,
"TApplication"
,
gApplication
,
"Terminate()"
);
126
fMain->DontCallClose();
127
128
fMain->MapSubwindows();
129
fMain->Resize();
130
131
// set minimum width, height
132
fMain->SetWMSizeHints(fMain->GetDefaultWidth(), fMain->GetDefaultHeight(), 1000, 1000, 0, 0);
133
fMain->SetWindowName(
"Text Entries"
);
134
fMain->MapRaised();
135
}
136
137
////////////////////////////////////////////////////////////////////////////////
138
void
textEntries
()
139
{
140
// Main program.
141
142
new
TextEntryWindow
();
143
}
kVerticalFrame
@ kVerticalFrame
Definition
GuiTypes.h:381
ClassDef
#define ClassDef(name, id)
Definition
Rtypes.h:342
TApplication.h
gApplication
R__EXTERN TApplication * gApplication
Definition
TApplication.h:170
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TGButtonGroup.h
gClient
#define gClient
Definition
TGClient.h:157
TGComboBox.h
kDeepCleanup
@ kDeepCleanup
Definition
TGFrame.h:42
TGLabel.h
kLHintsRight
@ kLHintsRight
Definition
TGLayout.h:26
kLHintsExpandY
@ kLHintsExpandY
Definition
TGLayout.h:31
kLHintsLeft
@ kLHintsLeft
Definition
TGLayout.h:24
kLHintsCenterY
@ kLHintsCenterY
Definition
TGLayout.h:28
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
TGTextEntry.h
kTextCenterX
@ kTextCenterX
Definition
TGWidget.h:25
kTextLeft
@ kTextLeft
Definition
TGWidget.h:23
kTextRight
@ kTextRight
Definition
TGWidget.h:24
p
winID h TVirtualViewer3D TVirtualGLPainter p
Definition
TGWin32VirtualGLProxy.cxx:51
name
char name[80]
Definition
TGX11.cxx:110
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TGComboBox
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition
TGComboBox.h:47
TGGroupFrame
A composite frame with a border and a title.
Definition
TGFrame.h:524
TGHorizontalFrame
A composite frame that layout their children in horizontal way.
Definition
TGFrame.h:387
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:399
TGTextEntry
A TGTextEntry is a one line text input widget.
Definition
TGTextEntry.h:24
TGTextEntry::kNormal
@ kNormal
Definition
TGTextEntry.h:27
TGTextEntry::kNoEcho
@ kNoEcho
Definition
TGTextEntry.h:27
TGTextEntry::kPassword
@ kPassword
Definition
TGTextEntry.h:27
TGWindow
ROOT GUI Window base class.
Definition
TGWindow.h:23
tutorials
visualisation
gui
textEntries.C
ROOT master - Reference Guide Generated on Wed Apr 2 2025 07:35:45 (GVA Time) using Doxygen 1.10.0