KaliVeda
1.15/6
Toolkit for HIC analysis
KVInputDialog.cpp
1
/*
2
$Id: KVInputDialog.cpp,v 1.6 2007/12/12 11:17:54 franklan Exp $
3
$Revision: 1.6 $
4
$Date: 2007/12/12 11:17:54 $
5
$Author: franklan $
6
*/
7
8
#include "KVInputDialog.h"
9
#include "
TGFrame.h
"
10
#include "
TString.h
"
11
#include "KVTextEntry.h"
12
#include "
TGWindow.h
"
13
#include "
TGLabel.h
"
14
#include "
TGButton.h
"
15
#include "
TTimer.h
"
16
17
23
24
ClassImp
(
KVInputDialog
)
25
KVInputDialog
::
KVInputDialog
(const
TGWindow
*
main
,
26
const
Char_t
* question,
TString
* answer,
27
Bool_t
* ok, const
Char_t
* tooltip)
28
{
29
//Create the dialog box asking a "question" and receiving the "answer"
30
//If you want a default value to appear, put it in 'answer' before opening dialogue
31
//The Bool_t variable will be set to kTRUE if "OK" is pressed (kFALSE otherwise)
32
//Optional argument 'tooltip' will be displayed when mouse held over text entry widget
33
34
fMain =
new
TGTransientFrame
(
gClient
->GetRoot(),
main
, 600, 150);
35
fMain->Connect(
"CloseWindow()"
,
"KVInputDialog"
,
this
,
"DoClose()"
);
36
fMain->DontCallClose();
// to avoid double deletions.
37
// use hierarchical cleaning
38
fMain->SetCleanup(
kDeepCleanup
);
39
40
fAnswer = answer;
41
fOK = ok;
42
*fOK =
kFALSE
;
//initialise flag
43
// Add a label and text input field.
44
45
TGLabel
*
l
=
new
TGLabel
(fMain, question);
46
fTextEntry =
new
KVTextEntry
(fMain, answer->Data());
47
if
(strcmp(tooltip,
""
))
48
fTextEntry->SetToolTipText(tooltip);
49
50
fTextEntry->Resize(
l
->GetDefaultWidth(), fTextEntry->GetDefaultHeight());
51
fMain->AddFrame(
l
,
52
new
TGLayoutHints
(
kLHintsTop
|
kLHintsCenterX
, 5, 5, 5,
53
0));
54
fMain->AddFrame(fTextEntry,
55
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 5, 5, 5,
56
5));
57
58
fMain->SetWindowName(
"KVInputDialog"
);
59
fMain->SetIconName(
"KVInputDialog"
);
60
61
//--- create the OK, Apply and Cancel buttons
62
63
UInt_t
nb = 0,
width
= 0,
height
= 0;
64
65
TGHorizontalFrame
* hf =
66
new
TGHorizontalFrame
(fMain, 60, 20,
kFixedWidth
);
67
TGLayoutHints
* l1 =
68
new
TGLayoutHints
(
kLHintsCenterY
|
kLHintsExpandX
, 5, 5, 0, 0);
69
70
fOKBut =
new
TGTextButton
(hf,
"&OK"
, 1);
71
hf->
AddFrame
(fOKBut, l1);
72
height
= fOKBut->GetDefaultHeight();
73
width
=
TMath::Max
(
width
, fOKBut->GetDefaultWidth());
74
++nb;
75
fOKBut->Connect(
"Clicked()"
,
"KVInputDialog"
,
this
,
"ReadAnswer()"
);
76
fOKBut->Connect(
"Clicked()"
,
"KVInputDialog"
,
this
,
"DoClose()"
);
77
78
fCancelBut =
new
TGTextButton
(hf,
"&Cancel"
, 3);
79
hf->
AddFrame
(fCancelBut, l1);
80
height
= fCancelBut->GetDefaultHeight();
81
width
=
TMath::Max
(
width
, fCancelBut->GetDefaultWidth());
82
++nb;
83
fCancelBut->Connect(
"Clicked()"
,
"KVInputDialog"
,
this
,
"DoClose()"
);
84
85
// place buttons at the bottom
86
l1 =
new
TGLayoutHints
(
kLHintsBottom
|
kLHintsCenterX
, 0, 0, 5, 5);
87
88
fMain->AddFrame(hf, l1);
89
90
// keep the buttons centered and with the same width
91
hf->
Resize
((
width
+ 20) * nb,
height
);
92
93
// map all widgets and calculate size of dialog
94
fMain->MapSubwindows();
95
96
width
= fMain->GetDefaultWidth();
97
height
= fMain->GetDefaultHeight();
98
99
fMain->Resize(
width
,
height
);
100
101
// position relative to the parent's window
102
fMain->CenterOnParent();
103
104
// make the message box non-resizable
105
fMain->SetWMSize(
width
,
height
);
106
fMain->SetWMSizeHints(
width
,
height
,
width
,
height
, 0, 0);
107
108
fMain->SetMWMHints(
kMWMDecorAll
|
kMWMDecorResizeH
|
kMWMDecorMaximize
|
109
kMWMDecorMinimize
|
kMWMDecorMenu
,
110
kMWMFuncAll
|
kMWMFuncResize
|
kMWMFuncMaximize
|
111
kMWMFuncMinimize
,
kMWMInputModeless
);
112
113
fMain->CenterOnParent();
114
fMain->MapWindow();
115
gClient
->WaitFor(fMain);
116
}
117
118
119
120
123
124
KVInputDialog::~KVInputDialog()
125
{
126
//Delete all widgets
127
128
if
(fMain) {
129
delete
fMain;
130
fMain = 0;
131
}
132
}
133
134
135
136
138
139
void
KVInputDialog::DoClose
()
140
{
141
TTimer::SingleShot
(150,
"KVInputDialog"
,
this
,
"CloseWindow()"
);
142
}
143
144
145
146
148
149
void
KVInputDialog::CloseWindow
()
150
{
151
delete
this
;
152
}
153
154
155
159
160
void
KVInputDialog::ReadAnswer
()
161
{
162
//Read text from text entry widget and store in "answer" TString.
163
//Set "ok" Bool_t flag to kTRUE
164
*fAnswer = fTextEntry->
GetText
();
165
*fOK =
kTRUE
;
166
}
167
168
UInt_t
unsigned int UInt_t
kFixedWidth
kFixedWidth
Bool_t
bool Bool_t
Char_t
char Char_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
TGButton.h
gClient
#define gClient
TGFrame.h
kMWMDecorResizeH
kMWMDecorResizeH
kMWMFuncAll
kMWMFuncAll
kMWMFuncResize
kMWMFuncResize
kMWMDecorMaximize
kMWMDecorMaximize
kMWMDecorMinimize
kMWMDecorMinimize
kMWMDecorMenu
kMWMDecorMenu
kMWMDecorAll
kMWMDecorAll
kMWMFuncMaximize
kMWMFuncMaximize
kMWMInputModeless
kMWMInputModeless
kMWMFuncMinimize
kMWMFuncMinimize
kDeepCleanup
kDeepCleanup
TGLabel.h
kLHintsCenterY
kLHintsCenterY
kLHintsCenterX
kLHintsCenterX
kLHintsBottom
kLHintsBottom
kLHintsTop
kLHintsTop
kLHintsExpandX
kLHintsExpandX
width
Option_t Option_t width
height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
TGWindow.h
TString.h
TTimer.h
KVInputDialog
General purpose dialog box asking for some input in the form of a string.
Definition:
KVInputDialog.h:24
KVInputDialog::CloseWindow
void CloseWindow()
Definition:
KVInputDialog.cpp:149
KVInputDialog::DoClose
void DoClose()
Definition:
KVInputDialog.cpp:139
KVInputDialog::ReadAnswer
void ReadAnswer()
Definition:
KVInputDialog.cpp:160
KVTextEntry
TGTextEntry without any limit on the length of the text.
Definition:
KVTextEntry.h:22
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
TGFrame::Resize
virtual void Resize(TGDimension size)
TGHorizontalFrame
TGLabel
TGLayoutHints
TGTextButton
TGTextEntry::GetText
const char * GetText() const
TGTransientFrame
TGWindow
TTimer::SingleShot
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
main
int main(int argc, char **argv)
TMath::Max
Double_t Max(Double_t a, Double_t b)
TString
l
TLine l
ClassImp
ClassImp(TPyArg)
kaliveda.doxygen
src
core
gui
KVInputDialog.cpp
Generated on Wed Aug 5 2026 08:51:16 for KaliVeda by
1.9.1