Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/foxtools/MFXComboBoxAttrProperty.cpp
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2006-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file MFXComboBoxAttrProperty.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Mar 2025
17
///
18
// ComboBox icon specific for attr properties
19
/****************************************************************************/
20
21
#include <netedit/GNEAttributeProperties.h>
22
23
#include "MFXComboBoxAttrProperty.h"
24
25
// ===========================================================================
26
// member method definitions
27
// ===========================================================================
28
29
MFXComboBoxAttrProperty::MFXComboBoxAttrProperty(FXComposite* p, MFXStaticToolTip* staticToolTip, const bool canSearch, const int visibleItems,
30
FXObject* tgt, FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :
31
MFXComboBoxIcon(p, staticToolTip, canSearch, visibleItems, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {
32
}
33
34
35
MFXComboBoxAttrProperty::~MFXComboBoxAttrProperty() {}
36
37
38
FXint
39
MFXComboBoxAttrProperty::appendAttrItem(const GNEAttributeProperties* attrProperties, FXColor bgColor, void* ptr) {
40
myAttrProperties.push_back(attrProperties);
41
return MFXComboBoxIcon::appendIconItem(attrProperties->getAttrStr().c_str(), nullptr, bgColor, ptr);
42
}
43
44
45
const GNEAttributeProperties*
46
MFXComboBoxAttrProperty::getAttrProperties(FXint index) const {
47
return myAttrProperties.at(index);
48
}
49
50
51
const GNEAttributeProperties*
52
MFXComboBoxAttrProperty::getCurrentAttrProperty() const {
53
const auto currentIndex = MFXComboBoxIcon::getCurrentItem();
54
if (currentIndex >= 0) {
55
return myAttrProperties.at(currentIndex);
56
} else {
57
return nullptr;
58
}
59
}
60
61
62
long
63
MFXComboBoxAttrProperty::setCurrentItem(const GNEAttributeProperties* attributeProperties, FXbool notify) {
64
for (int i = 0; i < (int)myAttrProperties.size(); i++) {
65
if (myAttrProperties.at(i) == attributeProperties) {
66
return MFXComboBoxIcon::setCurrentItem(i, notify);
67
}
68
}
69
fxerror("%s::setItem: index out of range.\n", getClassName());
70
return 0;
71
}
72
73
74
bool
75
MFXComboBoxAttrProperty::hasAttrProperty(const GNEAttributeProperties* attrProperties) {
76
return std::find(myAttrProperties.begin(), myAttrProperties.end(), attrProperties) != myAttrProperties.end();
77
}
78
79
void
80
MFXComboBoxAttrProperty::clearItems() {
81
MFXComboBoxIcon::clearItems();
82
myAttrProperties.clear();
83
}
84
85