CMS 3D CMS Logo

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 //
12 
13 // system include files
14 #include "TGLabel.h"
15 #include "TGTextEntry.h"
16 
17 #include <cassert>
18 #include <iostream>
19 
20 // user include files
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
34 FWStringParameterSetter::FWStringParameterSetter() : m_param(nullptr), m_widget(nullptr) {}
35 
36 // FWStringParameterSetter::FWStringParameterSetter(const FWStringParameterSetter& rhs)
37 // {
38 // // do actual copying here;
39 // }
40 
42 
43 //
44 // assignment operators
45 //
46 // const FWStringParameterSetter& FWStringParameterSetter::operator=(const FWStringParameterSetter& rhs)
47 // {
48 // //An exception safe implementation is
49 // FWStringParameterSetter temp(rhs);
50 // swap(rhs);
51 //
52 // return *this;
53 // }
54 
55 //
56 // member functions
57 //
58 
60  m_param = dynamic_cast<FWStringParameter*>(iParam);
61  assert(nullptr != m_param);
62 }
63 
64 TGFrame* FWStringParameterSetter::build(TGFrame* iParent, bool labelBack) {
65  TGCompositeFrame* frame = new TGHorizontalFrame(iParent, 180, 20, kFixedWidth);
66 
67  m_widget = new TGTextEntry(frame, m_param->name().c_str(), 0);
68  m_widget->SetText(m_param->value().c_str());
69  m_widget->Connect("ReturnPressed()", "FWStringParameterSetter", this, "doUpdate()");
70  // label
71  TGLabel* label = new TGLabel(frame, m_param->name().c_str());
72  if (labelBack) {
73  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 2, 2, 1, 1));
74  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 4, 2, 1, 1));
75  } else {
76  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
77  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 8, 2, 2));
78  }
79  return frame;
80 }
81 
83  assert(nullptr != m_param);
84  assert(nullptr != m_widget);
85  m_param->set(m_widget->GetText());
86  update();
87 }
88 //
89 // const member functions
90 //
91 
92 //
93 // static member functions
94 //
FWParameterSetterEditorBase * frame() const
assert(be >=bs)
const std::string & name() const
char const * label
void attach(FWParameterBase *) override
TGFrame * build(TGFrame *iParent, bool labelBack=true) override