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