14 #include <sys/types.h> 18 #include "TApplication.h" 23 #include "TGTextEntry.h" 24 #include "TVirtualX.h" 32 std::vector<std::string>& names,
33 std::vector<std::string>&
values)
39 iend = pset.find(
' ',istart);
41 std::string param = pset.substr(istart, iend-istart);
43 size_t ieq = param.find(
':');
44 if (ieq == param.npos) { abort(); }
46 std::string nm = param.substr(0,ieq);
47 std::string
value = param.substr(ieq+1,param.size());
50 values.push_back(value);
52 if (iend==pset.npos)
break;
62 std::vector<std::string>& name,
63 std::vector<std::string>&
value,
64 std::vector<TGTextEntry*>& fT2)
68 fFrame =
new TGGroupFrame(p,
"Parameters", kVerticalFrame);
70 TGLayoutHints* fLH3 =
new TGLayoutHints(kLHintsCenterX|kLHintsExpandX,
73 fML =
new TGMatrixLayout(
fFrame, 0, 2, 2);
77 for (
unsigned int i=0; i<name.size(); ++i) {
79 if((name[i].compare(
"module_label") == 0) ||
80 (name[i].compare(
"module_type") == 0) ||
81 (name[i].compare(
"service_type") == 0))
continue;
85 b =
new TGTextButton(
fFrame,
88 TGButton::GetDefaultGC()(),
89 TGTextButton::GetDefaultFontStruct(),
94 TGTextEntry* t =
new TGTextEntry(
fFrame, value[i].c_str());
102 if (h>30*26) h = 30*26;
106 fFrame->Connect(
"ProcessedEvent(Event_t*)",
"evdb::ParamFrame",
this,
107 "HandleMouseWheel(Event_t*)");
135 if (event->fType != kButtonPress && event->fType != kButtonRelease)
139 if (event->fCode == kButton4 || event->fCode == kButton5) {
141 if (
fCanvas->GetContainer()->GetHeight())
142 page = Int_t(Float_t(
fCanvas->GetViewPort()->GetHeight() *
143 fCanvas->GetViewPort()->GetHeight()) /
144 fCanvas->GetContainer()->GetHeight());
147 if (event->fCode == kButton4) {
149 Int_t newpos =
fCanvas->GetVsbPosition() - page;
150 if (newpos < 0) newpos = 0;
151 fCanvas->SetVsbPosition(newpos);
153 if (event->fCode == kButton5) {
155 Int_t newpos =
fCanvas->GetVsbPosition() + page;
156 fCanvas->SetVsbPosition(newpos);
163 const std::string& module,
164 const std::string& label,
165 const std::string& pset,
166 std::string* newpset) :
167 TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 4, 4),
176 fLH1 =
new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 2,2,2,2);
177 fLH2 =
new TGLayoutHints(kLHintsRight|kLHintsExpandX, 2,2,2,2);
178 fLH3 =
new TGLayoutHints(kLHintsCenterX|kLHintsExpandX,2,2,2,2);
179 fLH4 =
new TGLayoutHints(kLHintsLeft|kLHintsExpandY, 4,4,4,4);
183 fF1 =
new TGCompositeFrame(
this, w, h, kVerticalFrame);
184 std::ostringstream lbl1;
185 lbl1 <<
"Module " << module <<
" - " << label;
187 fL1 =
new TGLabel(
fF1, lbl1.str().c_str());
196 fCanvas =
new TGCanvas(
this, w, h);
205 for(
unsigned int n = 0;
n <
fT2.size(); ++
n){
207 fT2[
n]->Connect(
"ReturnPressed()",
"evdb::ParameterSetEdit",
this,
209 fT2[
n]->Connect(
"TabPressed()",
"evdb::ParameterSetEdit",
this,
220 fF3 =
new TGCompositeFrame(
this, w, 16, kHorizontalFrame);
223 fB3 =
new TGTextButton(
fF3,
" Apply ");
224 fB4 =
new TGTextButton(
fF3,
" Cancel ");
225 fB5 =
new TGTextButton(
fF3,
" Done ");
230 fB3->Connect(
"Clicked()",
"evdb::ParameterSetEdit",
this,
"Apply()");
231 fB4->Connect(
"Clicked()",
"evdb::ParameterSetEdit",
this,
"Cancel()");
232 fB5->Connect(
"Clicked()",
"evdb::ParameterSetEdit",
this,
"Done()");
234 this->Connect(
"CloseWindow()",
"evdb::ParameterSetEdit",
this,
"CloseWindow()");
239 this->MapSubwindows();
257 std::ostringstream pset;
259 for (i=0; i<
fName.size(); ++i) {
260 if(i <
fT2.size() ) values =
fT2[i]->GetText();
261 else values =
fValue[i].c_str();
262 pset <<
fName[i] <<
":" << values <<
" ";
265 (*fResult) = pset.str();
278 for (i=0; i<
fT2.size(); ++i)
delete fT2[i];
296 this->SendCloseMessage();
304 this->SendCloseMessage();
321 Window_t focusId = gVirtualX->GetInputFocus();
323 for(
unsigned int n = 0;
n <
fT2.size(); ++
n){
324 if(
fT2[
n]->GetId() == focusId) focusIdx =
n;
327 if(focusIdx == -1)
return;
331 focusIdx %=
fT2.size();
332 fT2[focusIdx]->SetFocus();
333 fT2[focusIdx]->End();
static void Set(int which)
TGGroupFrame * GetFrame() const
std::vector< TGTextEntry * > fT2
std::vector< std::string > fName
Manage all things related to colors for the event display.
static void parse_pset_string(const std::string &pset, std::vector< std::string > &names, std::vector< std::string > &values)
void SetCanvas(TGCanvas *canvas)
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
ParamFrame(const TGWindow *p, std::vector< std::string > &names, std::vector< std::string > &value, std::vector< TGTextEntry * > &fT2)
Holds information about what action to take next.
std::vector< std::string > fValue
ParameterSetEdit(TGMainFrame *mf, const std::string &module, const std::string &label, const std::string ¶ms, std::string *newpset)
Helper class to setup scroll bars in evdb::ParameterSetEdit.
void HandleMouseWheel(Event_t *event)
Event finding and building.