Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXComboBoxAttrProperty.cpp
Go to the documentation of this file.
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/****************************************************************************/
18// ComboBox icon specific for attr properties
19/****************************************************************************/
20
22
24
25// ===========================================================================
26// member method definitions
27// ===========================================================================
28
29MFXComboBoxAttrProperty::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
36
37
38FXint
39MFXComboBoxAttrProperty::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
47 return myAttrProperties.at(index);
48}
49
50
53 const auto currentIndex = MFXComboBoxIcon::getCurrentItem();
54 if (currentIndex >= 0) {
55 return myAttrProperties.at(currentIndex);
56 } else {
57 return nullptr;
58 }
59}
60
61
62long
63MFXComboBoxAttrProperty::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
74bool
76 return std::find(myAttrProperties.begin(), myAttrProperties.end(), attrProperties) != myAttrProperties.end();
77}
78
79void
const std::string & getAttrStr() const
get XML Attribute in string format (can be updated using alternative name)
void clearItems()
Remove all items from the list.
std::vector< const GNEAttributeProperties * > myAttrProperties
vector with tag properties
bool hasAttrProperty(const GNEAttributeProperties *attrProperties)
check if the given attribute exist in comboBox
FXint appendAttrItem(const GNEAttributeProperties *attrProperties, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append item
long setCurrentItem(const GNEAttributeProperties *attrProperties, FXbool notify=FALSE)
Set the current item.
const GNEAttributeProperties * getCurrentAttrProperty() const
get current attribute property
MFXComboBoxAttrProperty(FXComposite *p, MFXStaticToolTip *staticToolTip, const bool canSearch, const int visibleItems, FXObject *tgt, FXSelector sel, FXuint opts, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
Construct a Combo Box widget with room to display cols columns of text.
const GNEAttributeProperties * getAttrProperties(FXint index) const
get attribute properties
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint getCurrentItem() const
Get the current item's index.
virtual void clearItems()
Remove all items from the list.
FXint appendIconItem(const FXString &text, FXIcon *icon=nullptr, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append icon item in the last position
MFXStaticToolTip (based on FXToolTip)