14 #include <sys/types.h> 18 #include "TApplication.h" 23 #include "TGTextEntry.h" 31 std::vector<std::string>& names,
32 std::vector<std::string>& values)
38 iend = pset.find(
' ',istart);
40 std::string param = pset.substr(istart, iend-istart);
42 size_t ieq = param.find(
':');
43 if (ieq == param.npos) { abort(); }
45 std::string nm = param.substr(0,ieq);
46 std::string
value = param.substr(ieq+1,param.size());
49 values.push_back(value);
51 if (iend==pset.npos)
break;
61 std::vector<std::string>& name,
62 std::vector<std::string>&
value,
63 std::vector<TGTextEntry*>& fT2)
67 fFrame =
new TGGroupFrame(p,
"Parameters", kVerticalFrame);
69 TGLayoutHints* fLH3 =
new TGLayoutHints(kLHintsCenterX|kLHintsExpandX,
72 fML =
new TGMatrixLayout(
fFrame, 0, 2, 2);
76 for (
unsigned int i=0; i<name.size(); ++i) {
78 if((name[i].compare(
"module_label") == 0) ||
79 (name[i].compare(
"module_type") == 0) ||
80 (name[i].compare(
"service_type") == 0))
continue;
84 b =
new TGTextButton(
fFrame,
87 TGButton::GetDefaultGC()(),
88 TGTextButton::GetDefaultFontStruct(),
93 TGTextEntry* t =
new TGTextEntry(
fFrame, value[i].c_str());
101 if (h>30*26) h = 30*26;
105 fFrame->Connect(
"ProcessedEvent(Event_t*)",
"evdb::ParamFrame",
this,
106 "HandleMouseWheel(Event_t*)");
134 if (event->fType != kButtonPress && event->fType != kButtonRelease)
138 if (event->fCode == kButton4 || event->fCode == kButton5) {
140 if (
fCanvas->GetContainer()->GetHeight())
141 page = Int_t(Float_t(
fCanvas->GetViewPort()->GetHeight() *
142 fCanvas->GetViewPort()->GetHeight()) /
143 fCanvas->GetContainer()->GetHeight());
146 if (event->fCode == kButton4) {
148 Int_t newpos =
fCanvas->GetVsbPosition() - page;
149 if (newpos < 0) newpos = 0;
150 fCanvas->SetVsbPosition(newpos);
152 if (event->fCode == kButton5) {
154 Int_t newpos =
fCanvas->GetVsbPosition() + page;
155 fCanvas->SetVsbPosition(newpos);
162 const std::string& module,
163 const std::string&
label,
164 const std::string& pset,
165 std::string* newpset) :
166 TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 4, 4),
175 fLH1 =
new TGLayoutHints(kLHintsLeft|kLHintsExpandX, 2,2,2,2);
176 fLH2 =
new TGLayoutHints(kLHintsRight|kLHintsExpandX, 2,2,2,2);
177 fLH3 =
new TGLayoutHints(kLHintsCenterX|kLHintsExpandX,2,2,2,2);
178 fLH4 =
new TGLayoutHints(kLHintsLeft|kLHintsExpandY, 4,4,4,4);
182 fF1 =
new TGCompositeFrame(
this, w, h, kVerticalFrame);
183 std::ostringstream lbl1;
184 lbl1 <<
"Module " << module <<
" - " <<
label;
186 fL1 =
new TGLabel(
fF1, lbl1.str().c_str());
195 fCanvas =
new TGCanvas(
this, w, h);
204 for(
unsigned int n = 0;
n <
fT2.size(); ++
n){
206 fT2[
n]->Connect(
"ReturnPressed()",
"evdb::ParameterSetEdit",
this,
208 fT2[
n]->Connect(
"TabPressed()",
"evdb::ParameterSetEdit",
this,
219 fF3 =
new TGCompositeFrame(
this, w, 16, kHorizontalFrame);
222 fB3 =
new TGTextButton(
fF3,
" Apply ");
223 fB4 =
new TGTextButton(
fF3,
" Cancel ");
224 fB5 =
new TGTextButton(
fF3,
" Done ");
229 fB3->Connect(
"Clicked()",
"evdb::ParameterSetEdit",
this,
"Apply()");
230 fB4->Connect(
"Clicked()",
"evdb::ParameterSetEdit",
this,
"Cancel()");
231 fB5->Connect(
"Clicked()",
"evdb::ParameterSetEdit",
this,
"Done()");
233 this->Connect(
"CloseWindow()",
"evdb::ParameterSetEdit",
this,
"CloseWindow()");
238 this->MapSubwindows();
256 std::ostringstream pset;
258 for (i=0; i<
fName.size(); ++i) {
259 if(i <
fT2.size() ) values =
fT2[i]->GetText();
260 else values =
fValue[i].c_str();
261 pset <<
fName[i] <<
":" << values <<
" ";
264 (*fResult) = pset.str();
277 for (i=0; i<
fT2.size(); ++i)
delete fT2[i];
295 this->SendCloseMessage();
303 this->SendCloseMessage();
320 Window_t focusId = gVirtualX->GetInputFocus();
322 for(
unsigned int n = 0;
n <
fT2.size(); ++
n){
323 if(
fT2[
n]->GetId() == focusId) focusIdx =
n;
326 if(focusIdx == -1)
return;
330 focusIdx %=
fT2.size();
331 fT2[focusIdx]->SetFocus();
332 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)
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::string value(boost::any const &)
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.