ROOT
Version v6.34
master
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
21
//////////// auxilary class ///////////////////////////////////////////////////
22
class
GroupBox
:
public
TGGroupFrame
{
23
private
:
24
TGComboBox
*fCombo;
// combo box
25
TGTextEntry
*fEntry;
// text entry
26
27
public
:
28
GroupBox
(
const
TGWindow
*
p
,
const
char
*
name
,
const
char
*title);
29
TGTextEntry
*GetEntry()
const
{
return
fEntry; }
30
TGComboBox
*
GetCombo
()
const
{
return
fCombo; }
31
32
ClassDef
(
GroupBox
, 0)
33
};
34
35
//______________________________________________________________________________
36
GroupBox::GroupBox(
const
TGWindow
*
p
,
const
char
*
name
,
const
char
*title) :
37
TGGroupFrame
(
p
,
name
)
38
{
39
// Group frame containing combobox and text entry.
40
41
TGHorizontalFrame
*
horz
=
new
TGHorizontalFrame
(
this
);
42
AddFrame(
horz
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsCenterY
));
43
TGLabel
*
label
=
new
TGLabel
(
horz
, title);
44
horz
->AddFrame(
label
,
new
TGLayoutHints
(
kLHintsLeft
|
kLHintsCenterY
));
45
46
fCombo =
new
TGComboBox
(
horz
);
47
horz
->AddFrame(fCombo,
new
TGLayoutHints
(
kLHintsRight
|
kLHintsExpandY
,
48
5, 0, 5, 5));
49
fCombo->Resize(100, 20);
50
51
fEntry =
new
TGTextEntry
(
this
);
52
AddFrame(fEntry,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsCenterY
));
53
}
54
55
////////////////////////////////////////////////////////////////////////////////
56
class
TextEntryWindow
{
57
58
protected
:
59
TGMainFrame
*fMain;
// main frame
60
GroupBox
*
fEcho
;
// echo mode (echo, password, no echo)
61
GroupBox
*fAlign;
// alignment (left, right, center)
62
GroupBox
*
fAccess
;
// read-only mode
63
GroupBox
*fBorder;
// border mode
64
65
public
:
66
TextEntryWindow
();
67
virtual
~TextEntryWindow
() {
delete
fMain; }
68
69
ClassDef
(
TextEntryWindow
, 0);
70
};
71
72
73
//______________________________________________________________________________
74
TextEntryWindow::TextEntryWindow()
75
{
76
// Main test window.
77
78
TGComboBox
*
combo
;
79
TGTextEntry
*
entry
;
80
81
fMain =
new
TGMainFrame
(
gClient
->GetRoot(), 10, 10,
kVerticalFrame
);
82
83
// recusively delete all subframes on exit
84
fMain->SetCleanup(
kDeepCleanup
);
85
86
fEcho
=
new
GroupBox
(fMain,
"Echo"
,
"Mode:"
);
87
fMain->AddFrame(
fEcho
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
88
combo
=
fEcho
->GetCombo();
89
entry
=
fEcho
->GetEntry();
90
// add entries
91
combo
->AddEntry(
"Normal"
,
TGTextEntry::kNormal
);
92
combo
->AddEntry(
"Password"
,
TGTextEntry::kPassword
);
93
combo
->AddEntry(
"No Echo"
,
TGTextEntry::kNoEcho
);
94
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetEchoMode(TGTextEntry::EEchoMode)"
);
95
combo
->Select(
TGTextEntry::kNormal
);
96
97
fAlign =
new
GroupBox
(fMain,
"Alignment"
,
"Type:"
);
98
fMain->AddFrame(fAlign,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
99
combo
= fAlign->GetCombo();
100
entry
= fAlign->GetEntry();
101
// add entries
102
combo
->AddEntry(
"Left"
,
kTextLeft
);
103
combo
->AddEntry(
"Centered"
,
kTextCenterX
);
104
combo
->AddEntry(
"Right"
,
kTextRight
);
105
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetAlignment(ETextJustification)"
);
106
combo
->Select(
kTextLeft
);
107
108
fAccess
=
new
GroupBox
(fMain,
"Access"
,
"Read-only:"
);
109
fMain->AddFrame(
fAccess
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
110
combo
=
fAccess
->GetCombo();
111
entry
=
fAccess
->GetEntry();
112
// add entries
113
combo
->AddEntry(
"False"
, 1);
114
combo
->AddEntry(
"True"
, 0);
115
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetEnabled(Int_t)"
);
116
combo
->Select(1);
117
118
fBorder =
new
GroupBox
(fMain,
"Border"
,
"Drawn:"
);
119
fMain->AddFrame(fBorder,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5));
120
combo
= fBorder->GetCombo();
121
entry
= fBorder->GetEntry();
122
// add entries
123
combo
->AddEntry(
"False"
, 0);
124
combo
->AddEntry(
"True"
, 1);
125
combo
->Connect(
"Selected(Int_t)"
,
"TGTextEntry"
,
entry
,
"SetFrameDrawn(Int_t)"
);
126
combo
->Select(1);
127
128
// terminate ROOT session when window is closed
129
fMain->Connect(
"CloseWindow()"
,
"TApplication"
,
gApplication
,
"Terminate()"
);
130
fMain->DontCallClose();
131
132
fMain->MapSubwindows();
133
fMain->Resize();
134
135
// set minimum width, height
136
fMain->SetWMSizeHints(fMain->GetDefaultWidth(), fMain->GetDefaultHeight(),
137
1000, 1000, 0, 0);
138
fMain->SetWindowName(
"Text Entries"
);
139
fMain->MapRaised();
140
}
141
142
143
////////////////////////////////////////////////////////////////////////////////
144
void
textEntries
()
145
{
146
// Main program.
147
148
new
TextEntryWindow
();
149
}
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:156
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: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
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
gui
textEntries.C
ROOT tags/6-34-04 - Reference Guide Generated on Wed Mar 26 2025 04:46:25 (GVA Time) using Doxygen 1.10.0