CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Fireworks/Core/src/FWStringParameterSetter.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWStringParameterSetter
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Mon Mar 10 11:22:32 CDT 2008
00011 // $Id: FWStringParameterSetter.cc,v 1.4 2011/02/15 18:32:34 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include "TGLabel.h"
00016 #include "TGTextEntry.h"
00017 
00018 #include <assert.h>
00019 #include <iostream>
00020 
00021 // user include files
00022 #include "Fireworks/Core/src/FWStringParameterSetter.h"
00023 
00024 //
00025 // constants, enums and typedefs
00026 //
00027 
00028 //
00029 // static data member definitions
00030 //
00031 
00032 //
00033 // constructors and destructor
00034 //
00035 FWStringParameterSetter::FWStringParameterSetter() :
00036    m_param(0),
00037    m_widget(0)
00038 {
00039 }
00040 
00041 // FWStringParameterSetter::FWStringParameterSetter(const FWStringParameterSetter& rhs)
00042 // {
00043 //    // do actual copying here;
00044 // }
00045 
00046 FWStringParameterSetter::~FWStringParameterSetter()
00047 {
00048 }
00049 
00050 //
00051 // assignment operators
00052 //
00053 // const FWStringParameterSetter& FWStringParameterSetter::operator=(const FWStringParameterSetter& rhs)
00054 // {
00055 //   //An exception safe implementation is
00056 //   FWStringParameterSetter temp(rhs);
00057 //   swap(rhs);
00058 //
00059 //   return *this;
00060 // }
00061 
00062 //
00063 // member functions
00064 //
00065 
00066 void
00067 FWStringParameterSetter::attach(FWParameterBase* iParam)
00068 {
00069    m_param = dynamic_cast<FWStringParameter*>(iParam);
00070    assert(0!=m_param);
00071 }
00072 
00073 TGFrame*
00074 FWStringParameterSetter::build(TGFrame* iParent, bool labelBack)
00075 {
00076    TGCompositeFrame* frame = new TGHorizontalFrame(iParent,180,20,kFixedWidth);
00077 
00078    m_widget = new TGTextEntry(frame, m_param->name().c_str(), 0);
00079    m_widget->SetText( m_param->value().c_str() );
00080    m_widget->Connect("ReturnPressed()", "FWStringParameterSetter", this, "doUpdate()");
00081    // label
00082    TGLabel* label = new TGLabel(frame,m_param->name().c_str());
00083    if (labelBack)
00084    {
00085       frame->AddFrame(m_widget, new TGLayoutHints(kLHintsExpandX|kLHintsCenterY,2,2,1,1));
00086       frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY,4,2,1,1) );
00087    }
00088    else
00089    {
00090       frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY) );
00091       frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
00092    }
00093    return frame;
00094 }
00095 
00096 void
00097 FWStringParameterSetter::doUpdate()
00098 {
00099    assert(0!=m_param);
00100    assert(0!=m_widget);
00101    m_param->set(m_widget->GetText());
00102    update();
00103 }
00104 //
00105 // const member functions
00106 //
00107 
00108 //
00109 // static member functions
00110 //