CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWEnumParameterSetter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWEnumParameterSetter
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: matevz
10 // Created: Fri Apr 30 15:17:33 CEST 2010
11 //
12 
13 // system include files
14 
15 // user include files
17 #include "TGComboBox.h"
18 #include "TGLabel.h"
19 #include <cassert>
20 
21 //
22 // constants, enums and typedefs
23 //
24 
25 //
26 // static data member definitions
27 //
28 
29 //
30 // constructors and destructor
31 //
33  m_param(0),
34  m_widget(0)
35 {}
36 
37 // FWEnumParameterSetter::FWEnumParameterSetter(const FWEnumParameterSetter& rhs)
38 // {
39 // // do actual copying here;
40 // }
41 
43 {}
44 
45 //
46 // assignment operators
47 //
48 // const FWEnumParameterSetter& FWEnumParameterSetter::operator=(const FWEnumParameterSetter& rhs)
49 // {
50 // //An exception safe implementation is
51 // FWEnumParameterSetter temp(rhs);
52 // swap(rhs);
53 //
54 // return *this;
55 // }
56 
57 //
58 // member functions
59 //
60 
61 void
63 {
64  m_param = dynamic_cast<FWEnumParameter*>(iParam);
65  assert(0!=m_param);
66 }
67 
68 TGFrame*
69 FWEnumParameterSetter::build(TGFrame* iParent, bool labelBack)
70 {
71  TGCompositeFrame *frame = new TGHorizontalFrame(iParent);
72 
73  m_widget = new TGComboBox(frame);
74  std::map<Long_t, std::string>::const_iterator me = m_param->entryMap().begin();
75  UInt_t max_len = 0;
76  while (me != m_param->entryMap().end())
77  {
78  m_widget->AddEntry(me->second.c_str(), static_cast<Int_t>(me->first));
79  if (me->second.length() > max_len) max_len = me->second.length();
80  ++me;
81  }
82  m_widget->Resize(8*max_len + 20, 20);
83  m_widget->Select(static_cast<Int_t>(m_param->value()), kFALSE);
84 
85  m_widget->Connect("Selected(Int_t)", "FWEnumParameterSetter", this, "doUpdate(Int_t)");
86 
87  // label
88  TGLabel* label = new TGLabel(frame, m_param->name().c_str());
89  if (labelBack)
90  {
91  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,6,2,2));
92  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2, 4, 0, 0));
93  }
94  else
95  {
96  frame->AddFrame(label, new TGLayoutHints(kLHintsLeft|kLHintsCenterY) );
97  frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 2,8,2,2));
98  }
99  return frame;
100 }
101 
102 void
104 {
105  assert(0!=m_param);
106  assert(0!=m_widget);
107  m_param->set((Long_t) id);
108  update();
109 }
110 
111 void
113 {
114  m_widget->SetEnabled(x);
115 }
116 
117 //
118 // const member functions
119 //
120 
121 //
122 // static member functions
123 //
virtual TGFrame * build(TGFrame *iParent, bool labelBack=true)
virtual void setEnabled(bool)
FWParameterSetterEditorBase * frame() const
assert(m_qm.get())
const std::map< Long_t, std::string > & entryMap() const
T x() const
Cartesian x coordinate.
virtual void attach(FWParameterBase *)
const std::string & name() const