KaliVeda
1.15/7
Toolkit for HIC analysis
KVTextDialog.cpp
1
//Created by KVClassFactory on Thu May 16 11:38:27 2013
2
//Author: gruyer,,,
3
4
#include "KVTextDialog.h"
5
#include "
TGTextEntry.h
"
6
#include "
TGFrame.h
"
7
#include "KVString.h"
8
#include "
TGComboBox.h
"
9
#include "
TGWindow.h
"
10
#include "
TGLabel.h
"
11
#include "
TGButton.h
"
12
#include "
TTimer.h
"
13
#include "
TMath.h
"
14
15
16
ClassImp
(
KVTextDialog
)
17
18
19
21
KVTextDialog
::
KVTextDialog
(const
TGWindow
*
main
, const
Char_t
* question, const
Char_t
* default_value,
TString
* chosen,
Bool_t
* ok, const
char
* unit)
22
{
23
fMain =
new
TGTransientFrame
(
gClient
->GetDefaultRoot(),
main
, 200, 100);
24
fMain->CenterOnParent();
25
fMain->Connect(
"CloseWindow()"
,
"KVDropDownDialog"
,
this
,
"DoClose()"
);
26
fMain->DontCallClose();
// to avoid double deletions.
27
// use hierarchical cleaning
28
fMain->SetCleanup(
kDeepCleanup
);
29
30
fAnswer = chosen;
31
fOK = ok;
32
*fOK =
kFALSE
;
//initialise flag
33
34
// Add a label
35
TGLabel
*
l
=
new
TGLabel
(fMain, question);
36
fMain->AddFrame(
l
,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsCenterX
, 5, 5, 5, 0));
37
TGHorizontalFrame
* hf1 =
new
TGHorizontalFrame
(fMain);
38
39
//Add text Entry
40
fTextEntry =
new
TGTextEntry
(hf1, default_value);
41
fTextEntry->Resize(70, 22);
42
fTextEntry->Connect(
"ReturnPressed()"
,
"KVTextDialog"
,
this
,
"ReadAnswer()"
);
43
hf1->
AddFrame
(fTextEntry,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsLeft
, 5, 5, 5, 5));
44
45
l
=
new
TGLabel
(hf1, unit);
46
hf1->
AddFrame
(
l
,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsRight
, 5, 5, 5, 0));
47
48
fMain->AddFrame(hf1,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsCenterX
, 5, 5, 5, 5));
49
50
fMain->SetWindowName(
"KVTextDialog"
);
51
fMain->SetIconName(
"KVTextDialog"
);
52
53
//--- create the OK, Apply and Cancel buttons
54
55
UInt_t
nb = 0,
width
= 0,
height
= 0;
56
57
TGHorizontalFrame
* hf =
58
new
TGHorizontalFrame
(fMain, 60, 20,
kFixedWidth
);
59
TGLayoutHints
* l1 =
60
new
TGLayoutHints
(
kLHintsCenterY
|
kLHintsExpandX
, 5, 5, 0, 0);
61
62
fOKBut =
new
TGTextButton
(hf,
"&OK"
, 1);
63
hf->
AddFrame
(fOKBut, l1);
64
height
= fOKBut->GetDefaultHeight();
65
width
=
TMath::Max
(
width
, fOKBut->GetDefaultWidth());
66
++nb;
67
fOKBut->Connect(
"Clicked()"
,
"KVTextDialog"
,
this
,
"ReadAnswer()"
);
68
fOKBut->Connect(
"Clicked()"
,
"KVTextDialog"
,
this
,
"DoClose()"
);
69
fTextEntry->Connect(
"ReturnPressed()"
,
"TGTextButton"
, fOKBut,
"Clicked()"
);
70
71
fCancelBut =
new
TGTextButton
(hf,
"&Cancel"
, 3);
72
hf->
AddFrame
(fCancelBut, l1);
73
height
= fCancelBut->GetDefaultHeight();
74
width
=
TMath::Max
(
width
, fCancelBut->GetDefaultWidth());
75
++nb;
76
fCancelBut->Connect(
"Clicked()"
,
"KVTextDialog"
,
this
,
"DoClose()"
);
77
78
// place buttons at the bottom
79
l1 =
new
TGLayoutHints
(
kLHintsBottom
|
kLHintsCenterX
, 0, 0, 5, 5);
80
81
fMain->AddFrame(hf, l1);
82
83
// keep the buttons centered and with the same width
84
hf->
Resize
((
width
+ 20) * nb,
height
);
85
86
// map all widgets and calculate size of dialog
87
fMain->MapSubwindows();
88
89
width
= fMain->GetDefaultWidth();
90
height
= fMain->GetDefaultHeight();
91
92
fMain->Resize(
width
,
height
);
93
94
// position relative to the parent's window
95
fMain->CenterOnParent();
96
97
// make the message box non-resizable
98
fMain->SetWMSize(
width
,
height
);
99
fMain->SetWMSizeHints(
width
,
height
,
width
,
height
, 0, 0);
100
101
fMain->SetMWMHints(
kMWMDecorAll
|
kMWMDecorResizeH
|
kMWMDecorMaximize
|
102
kMWMDecorMinimize
|
kMWMDecorMenu
,
103
kMWMFuncAll
|
kMWMFuncResize
|
kMWMFuncMaximize
|
104
kMWMFuncMinimize
,
kMWMInputModeless
);
105
106
fMain->CenterOnParent();
107
108
fMain->MapWindow();
109
gClient
->WaitFor(fMain);
110
}
111
112
113
116
117
KVTextDialog::~KVTextDialog
()
118
{
119
// Destructor
120
if
(fMain) {
121
delete
fMain;
122
fMain = 0;
123
}
124
}
125
126
127
129
130
void
KVTextDialog::DoClose
()
131
{
132
TTimer::SingleShot
(150,
"KVTextDialog"
,
this
,
"CloseWindow()"
);
133
134
}
135
136
137
138
140
141
void
KVTextDialog::CloseWindow
()
142
{
143
delete
this
;
144
}
145
146
147
151
152
void
KVTextDialog::ReadAnswer
()
153
{
154
//Read text from drop down list and store in "answer" TString.
155
//Set "ok" Bool_t flag to kTRUE
156
*fAnswer = fTextEntry->
GetText
();
157
*fOK =
kTRUE
;
158
}
159
160
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
TGComboBox.h
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
kLHintsRight
kLHintsRight
kLHintsLeft
kLHintsLeft
kLHintsCenterY
kLHintsCenterY
kLHintsCenterX
kLHintsCenterX
kLHintsBottom
kLHintsBottom
kLHintsTop
kLHintsTop
kLHintsExpandX
kLHintsExpandX
TGTextEntry.h
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
TMath.h
TTimer.h
KVTextDialog
Definition:
KVTextDialog.h:19
KVTextDialog::ReadAnswer
void ReadAnswer()
Definition:
KVTextDialog.cpp:152
KVTextDialog::DoClose
void DoClose()
Definition:
KVTextDialog.cpp:130
KVTextDialog::~KVTextDialog
virtual ~KVTextDialog()
Destructor.
Definition:
KVTextDialog.cpp:117
KVTextDialog::CloseWindow
void CloseWindow()
Definition:
KVTextDialog.cpp:141
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
TGFrame::Resize
virtual void Resize(TGDimension size)
TGHorizontalFrame
TGLabel
TGLayoutHints
TGTextButton
TGTextEntry
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
KVTextDialog.cpp
Generated on Wed Sep 16 2026 14:50:47 for KaliVeda by
1.9.1