File indexing completed on 2023-03-17 11:01:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "Fireworks/Core/interface/FWEnumParameterSetter.h"
0017 #include "TGComboBox.h"
0018 #include "TGLabel.h"
0019 #include <cassert>
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 FWEnumParameterSetter::FWEnumParameterSetter() : m_param(nullptr), m_widget(nullptr) {}
0033
0034
0035
0036
0037
0038
0039 FWEnumParameterSetter::~FWEnumParameterSetter() {}
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 void FWEnumParameterSetter::attach(FWParameterBase* iParam) {
0058 m_param = dynamic_cast<FWEnumParameter*>(iParam);
0059 assert(nullptr != m_param);
0060 }
0061
0062 TGFrame* FWEnumParameterSetter::build(TGFrame* iParent, bool labelBack) {
0063 TGCompositeFrame* frame = new TGHorizontalFrame(iParent);
0064
0065 m_widget = new TGComboBox(frame);
0066 std::map<Long_t, std::string>::const_iterator me = m_param->entryMap().begin();
0067 UInt_t max_len = 0;
0068 while (me != m_param->entryMap().end()) {
0069 m_widget->AddEntry(me->second.c_str(), static_cast<Int_t>(me->first));
0070 if (me->second.length() > max_len)
0071 max_len = me->second.length();
0072 ++me;
0073 }
0074 m_widget->Resize(8 * max_len + 20, 20);
0075 m_widget->Select(static_cast<Int_t>(m_param->value()), kFALSE);
0076
0077 m_widget->Connect("Selected(Int_t)", "FWEnumParameterSetter", this, "doUpdate(Int_t)");
0078
0079
0080 TGLabel* label = new TGLabel(frame, m_param->name().c_str());
0081 if (labelBack) {
0082 frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 6, 2, 2));
0083 frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 4, 0, 0));
0084 } else {
0085 frame->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
0086 frame->AddFrame(m_widget, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 8, 2, 2));
0087 }
0088 return frame;
0089 }
0090
0091 void FWEnumParameterSetter::doUpdate(Int_t id) {
0092 assert(nullptr != m_param);
0093 assert(nullptr != m_widget);
0094 m_param->set((Long_t)id);
0095 update();
0096 }
0097
0098 void FWEnumParameterSetter::setEnabled(bool x) { m_widget->SetEnabled(x); }
0099
0100
0101
0102
0103
0104
0105
0106