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