Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:19

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWStringParameterSetter
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Mon Mar 10 11:22:32 CDT 2008
0011 //
0012 
0013 // system include files
0014 #include "TGLabel.h"
0015 #include "TGTextEntry.h"
0016 
0017 #include <cassert>
0018 #include <iostream>
0019 
0020 // user include files
0021 #include "Fireworks/Core/src/FWStringParameterSetter.h"
0022 
0023 //
0024 // constants, enums and typedefs
0025 //
0026 
0027 //
0028 // static data member definitions
0029 //
0030 
0031 //
0032 // constructors and destructor
0033 //
0034 FWStringParameterSetter::FWStringParameterSetter() : m_param(nullptr), m_widget(nullptr) {}
0035 
0036 // FWStringParameterSetter::FWStringParameterSetter(const FWStringParameterSetter& rhs)
0037 // {
0038 //    // do actual copying here;
0039 // }
0040 
0041 FWStringParameterSetter::~FWStringParameterSetter() {}
0042 
0043 //
0044 // assignment operators
0045 //
0046 // const FWStringParameterSetter& FWStringParameterSetter::operator=(const FWStringParameterSetter& rhs)
0047 // {
0048 //   //An exception safe implementation is
0049 //   FWStringParameterSetter temp(rhs);
0050 //   swap(rhs);
0051 //
0052 //   return *this;
0053 // }
0054 
0055 //
0056 // member functions
0057 //
0058 
0059 void FWStringParameterSetter::attach(FWParameterBase* iParam) {
0060   m_param = dynamic_cast<FWStringParameter*>(iParam);
0061   assert(nullptr != m_param);
0062 }
0063 
0064 TGFrame* FWStringParameterSetter::build(TGFrame* iParent, bool labelBack) {
0065   TGCompositeFrame* frame = new TGHorizontalFrame(iParent, 180, 20, kFixedWidth);
0066 
0067   m_widget = new TGTextEntry(frame, m_param->name().c_str(), 0);
0068   m_widget->SetText(m_param->value().c_str());
0069   m_widget->Connect("ReturnPressed()", "FWStringParameterSetter", this, "doUpdate()");
0070   // label
0071   TGLabel* label = new TGLabel(frame, m_param->name().c_str());
0072   if (labelBack) {
0073     frame->AddFrame(m_widget, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 2, 2, 1, 1));
0074     frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4, 2, 1, 1));
0075   } else {
0076     frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
0077     frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 8, 2, 2));
0078   }
0079   return frame;
0080 }
0081 
0082 void FWStringParameterSetter::doUpdate() {
0083   assert(nullptr != m_param);
0084   assert(nullptr != m_widget);
0085   m_param->set(m_widget->GetText());
0086   update();
0087 }
0088 //
0089 // const member functions
0090 //
0091 
0092 //
0093 // static member functions
0094 //