Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

evdb::CfgEdit Class Reference

Dialog window to edit a configuration set. More...

#include <CfgEdit.h>

Inheritance diagram for evdb::CfgEdit:

cfg::ConfigEditor List of all members.

Public Member Functions

 CfgEdit (cfg::Config *cfg, TGMainFrame *mf)
 ~CfgEdit ()
int EditConfig (cfg::Config &cfg)
void Apply ()
void Cancel ()
void Done ()
void CloseWindow ()

Private Member Functions

 RQ_OBJECT ("evdb::CfgEdit")

Private Attributes

TGCompositeFrame * fF1
ParamFramefParam
TGCanvas * fCanvas
TGCompositeFrame * fF3
TGLayoutHints * fLH1
TGLayoutHints * fLH2
TGLayoutHints * fLH3
TGLayoutHints * fLH4
TGLabel * fL1
TGLabel * fL2
TGTextButton * fB3
TGTextButton * fB4
TGTextButton * fB5
std::vector< TGTextEntry * > fT2
std::vector< std::string > fName
std::vector< std::string > fTag
std::vector< std::string > fComment

Detailed Description

Dialog window to edit a configuration set.

Definition at line 55 of file CfgEdit.h.


Constructor & Destructor Documentation

CfgEdit::CfgEdit cfg::Config cfg,
TGMainFrame *  mf
 

Definition at line 147 of file CfgEdit.cxx.

References fB3, fB4, fB5, fCanvas, fComment, fF1, fF3, fL1, fL2, fLH1, fLH2, fLH3, fLH4, fName, fParam, fT2, fTag, evdb::ParamFrame::GetFrame(), evdb::ParamFrame::GetHeight(), cfg::Config::GetName(), cfg::Config::GetSource(), cfg::Config::GetVersion(), and evdb::ParamFrame::SetCanvas().

00147                                                     :
00148   cfg::ConfigEditor(cfg),
00149   TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 4, 4)
00150 {
00151   int h = 600;
00152   int w = 500;
00153   
00154   fLH1 = new TGLayoutHints(kLHintsLeft|kLHintsExpandX,   2,2,2,2);
00155   fLH2 = new TGLayoutHints(kLHintsRight|kLHintsExpandX,  2,2,2,2);
00156   fLH3 = new TGLayoutHints(kLHintsCenterX|kLHintsExpandX,2,2,2,2);
00157   fLH4 = new TGLayoutHints(kLHintsLeft|kLHintsExpandY,   4,4,4,4);
00158 
00159   // Add the heading at the top of the window
00160   h = 0;
00161   fF1 = new TGCompositeFrame(this, w, h, kVerticalFrame);
00162   std::ostringstream lbl1;
00163   lbl1 << "Configuration " << cfg->GetName() << ", " 
00164        << cfg->GetVersion() << " version";
00165   
00166   std::ostringstream lbl2;
00167   lbl2 << "Originally from " << cfg->GetSource();
00168   
00169   fL1 = new TGLabel(fF1, lbl1.str().c_str());
00170   fL2 = new TGLabel(fF1, lbl2.str().c_str());
00171   
00172   fF1->AddFrame(fL1,fLH3);
00173   fF1->AddFrame(fL2,fLH3);
00174 
00175   fL1->SetHeight(26);
00176   fL2->SetHeight(20);
00177   this->AddFrame(fF1);
00178   h = 30;
00179 
00180   // Add the parameter fields and edit boxes
00181   fCanvas = new TGCanvas(this, w, h);
00182   fParam = new ParamFrame(fCanvas->GetViewPort(), cfg, fName, fTag, 
00183                           fComment, fT2);
00184   fParam->SetCanvas(fCanvas);
00185   fCanvas->SetContainer(fParam->GetFrame());
00186   fParam->GetFrame()->SetCleanup(kDeepCleanup);
00187 
00188   h = fParam->GetHeight();
00189   if (h > 600) h = 600;
00190   fCanvas->Resize(w,h);
00191   
00192   this->AddFrame(fCanvas);
00193 
00194   // Button bar across the bottom
00195   fF3 = new TGCompositeFrame(this, w, 24, kHorizontalFrame);
00196   this->AddFrame(fF3);
00197 
00198   fB3 = new TGTextButton(fF3, "Apply");
00199   fB4 = new TGTextButton(fF3, "Cancel");
00200   fB5 = new TGTextButton(fF3, "Done");
00201   fF3->AddFrame(fB3, fLH1);
00202   fF3->AddFrame(fB4, fLH1);
00203   fF3->AddFrame(fB5, fLH1);
00204 
00205   fB3->Connect("Clicked()","evdb::CfgEdit",this,"Apply()");
00206   fB4->Connect("Clicked()","evdb::CfgEdit",this,"Cancel()");
00207   fB5->Connect("Clicked()","evdb::CfgEdit",this,"Done()");
00208 
00209   this->Connect("CloseWindow()","evdb::CfgEdit",this,"CloseWindow()");
00210 
00211   h += 75;
00212 
00213   this->Resize(w+8,h);
00214   this->MapSubwindows();
00215   this->MapWindow();
00216 }

CfgEdit::~CfgEdit  ) 
 

Definition at line 251 of file CfgEdit.cxx.

References fB3, fB4, fB5, fF1, fF3, fL1, fL2, fLH1, fLH2, fLH3, fLH4, and fT2.

00252 {
00253   unsigned int i;
00254   delete fB5;
00255   delete fB4;
00256   delete fB3;
00257   for (i=0; i<fT2.size(); ++i) delete fT2[i];
00258   delete fL2;
00259   delete fL1;
00260   delete fF3;
00261   delete fF1;
00262   delete fLH4;
00263   delete fLH3;
00264   delete fLH2;
00265   delete fLH1;
00266 }


Member Function Documentation

void CfgEdit::Apply  ) 
 

Reimplemented from cfg::ConfigEditor.

Definition at line 289 of file CfgEdit.cxx.

References cfg::ConfigEditor::Edit().

Referenced by Done().

00290 {
00291   this->Edit(); 
00292   IoModule::Instance()->Reload();
00293 }

void CfgEdit::Cancel  ) 
 

Reimplemented from cfg::ConfigEditor.

Definition at line 274 of file CfgEdit.cxx.

00275 {
00276   this->SendCloseMessage(); 
00277 }

void CfgEdit::CloseWindow  ) 
 

Definition at line 270 of file CfgEdit.cxx.

00270 { delete this; }

void CfgEdit::Done  ) 
 

Definition at line 281 of file CfgEdit.cxx.

References Apply().

00282 {
00283   this->Apply();
00284   this->SendCloseMessage();
00285 }

int CfgEdit::EditConfig cfg::Config cfg  )  [virtual]
 

The user edit function. Modify cfg at by some means. Return 1 to apply changes made to cfg, 0 to discard them

Reimplemented from cfg::ConfigEditor.

Definition at line 220 of file CfgEdit.cxx.

References cfg::Config::AdoptParam(), fComment, fName, fT2, fTag, xmli::Stack< T >::Instance(), and xmli::ReadString().

00221 {
00222   unsigned int i;
00223   const char* values;
00224   std::ostringstream xml;
00225   
00226   xml << "<configdoc>\n";
00227   for (i=0; i<fName.size(); ++i) {
00228     values = fT2[i]->GetText();
00229     xml << "<param name=\"" << fName[i] << "\">\n";
00230     xml << "  <" << fTag[i] << "> " << values << " </" << fTag[i] << ">\n";
00231     xml << "  " << fComment[i] << "\n";
00232     xml << "</param>\n";
00233   }
00234   xml << "</configdoc>\n";
00235   
00236   // std::cerr << xml.str();
00237   
00238   // Parse the XML string created above
00239   xmli::ReadString(xml.str().c_str());
00240 
00241   // The string above should create lots of CfgParams, scoop them up
00242   // and alter the configuration
00243   xmli::Stack<cfg::Param>& s = xmli::Stack<cfg::Param>::Instance();
00244   for (; !s.empty(); s.pop()) cfg.AdoptParam(new cfg::Param(s.top()));
00245 
00246   return 1;
00247 }

evdb::CfgEdit::RQ_OBJECT "evdb::CfgEdit"   )  [private]
 


Member Data Documentation

TGTextButton* evdb::CfgEdit::fB3 [private]
 

Definition at line 79 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGTextButton* evdb::CfgEdit::fB4 [private]
 

Definition at line 80 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGTextButton* evdb::CfgEdit::fB5 [private]
 

Definition at line 81 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGCanvas* evdb::CfgEdit::fCanvas [private]
 

Definition at line 71 of file CfgEdit.h.

Referenced by CfgEdit().

std::vector<std::string> evdb::CfgEdit::fComment [private]
 

Definition at line 85 of file CfgEdit.h.

Referenced by CfgEdit(), and EditConfig().

TGCompositeFrame* evdb::CfgEdit::fF1 [private]
 

Definition at line 69 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGCompositeFrame* evdb::CfgEdit::fF3 [private]
 

Definition at line 72 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGLabel* evdb::CfgEdit::fL1 [private]
 

Definition at line 77 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGLabel* evdb::CfgEdit::fL2 [private]
 

Definition at line 78 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGLayoutHints* evdb::CfgEdit::fLH1 [private]
 

Definition at line 73 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGLayoutHints* evdb::CfgEdit::fLH2 [private]
 

Definition at line 74 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGLayoutHints* evdb::CfgEdit::fLH3 [private]
 

Definition at line 75 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

TGLayoutHints* evdb::CfgEdit::fLH4 [private]
 

Definition at line 76 of file CfgEdit.h.

Referenced by CfgEdit(), and ~CfgEdit().

std::vector<std::string> evdb::CfgEdit::fName [private]
 

Definition at line 83 of file CfgEdit.h.

Referenced by CfgEdit(), and EditConfig().

ParamFrame* evdb::CfgEdit::fParam [private]
 

Definition at line 70 of file CfgEdit.h.

Referenced by CfgEdit().

std::vector<TGTextEntry*> evdb::CfgEdit::fT2 [private]
 

Definition at line 82 of file CfgEdit.h.

Referenced by CfgEdit(), EditConfig(), and ~CfgEdit().

std::vector<std::string> evdb::CfgEdit::fTag [private]
 

Definition at line 84 of file CfgEdit.h.

Referenced by CfgEdit(), and EditConfig().


The documentation for this class was generated from the following files:
Generated on Fri Jul 25 02:05:53 2008 for NOvA Offline by doxygen 1.3.5