CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWStringParameterSetter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWStringParameterSetter
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Mon Mar 10 11:22:32 CDT 2008
11 // $Id: FWStringParameterSetter.cc,v 1.4 2011/02/15 18:32:34 amraktad Exp $
12 //
13 
14 // system include files
15 #include "TGLabel.h"
16 #include "TGTextEntry.h"
17 
18 #include <assert.h>
19 #include <iostream>
20 
21 // user include files
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
36  m_param(0),
37  m_widget(0)
38 {
39 }
40 
41 // FWStringParameterSetter::FWStringParameterSetter(const FWStringParameterSetter& rhs)
42 // {
43 // // do actual copying here;
44 // }
45 
47 {
48 }
49 
50 //
51 // assignment operators
52 //
53 // const FWStringParameterSetter& FWStringParameterSetter::operator=(const FWStringParameterSetter& rhs)
54 // {
55 // //An exception safe implementation is
56 // FWStringParameterSetter temp(rhs);
57 // swap(rhs);
58 //
59 // return *this;
60 // }
61 
62 //
63 // member functions
64 //
65 
66 void
68 {
69  m_param = dynamic_cast<FWStringParameter*>(iParam);
70  assert(0!=m_param);
71 }
72 
73 TGFrame*
74 FWStringParameterSetter::build(TGFrame* iParent, bool labelBack)
75 {
76  TGCompositeFrame* frame = new TGHorizontalFrame(iParent,180,20,kFixedWidth);
77 
78  m_widget = new TGTextEntry(frame, m_param->name().c_str(), 0);
79  m_widget->SetText( m_param->value().c_str() );
80  m_widget->Connect("ReturnPressed()", "FWStringParameterSetter", this, "doUpdate()");
81  // label
82  TGLabel* label = new TGLabel(frame,m_param->name().c_str());
83  if (labelBack)
84  {
85  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsExpandX|kLHintsCenterY,2,2,1,1));
86  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY,4,2,1,1) );
87  }
88  else
89  {
90  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY) );
91  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
92  }
93  return frame;
94 }
95 
96 void
98 {
99  assert(0!=m_param);
100  assert(0!=m_widget);
101  m_param->set(m_widget->GetText());
102  update();
103 }
104 //
105 // const member functions
106 //
107 
108 //
109 // static member functions
110 //
FWParameterSetterEditorBase * frame() const
virtual void attach(FWParameterBase *)
virtual TGFrame * build(TGFrame *iParent, bool labelBack=true)
const std::string & name() const