Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXComboBoxTagProperty.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 tag properties
19/****************************************************************************/
20
22
24
25// ===========================================================================
26// member method definitions
27// ===========================================================================
28
29MFXComboBoxTagProperty::MFXComboBoxTagProperty(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
39MFXComboBoxTagProperty::appendTagItem(const GNETagProperties* tagProperties, FXColor bgColor, void* ptr) {
40 myTagProperties.push_back(tagProperties);
41 return MFXComboBoxIcon::appendIconItem(tagProperties->getSelectorText().c_str(), GUIIconSubSys::getIcon(tagProperties->getGUIIcon()), bgColor, ptr);
42}
43
44
47 return myTagProperties.at(index);
48}
49
50
53 const auto currentIndex = MFXComboBoxIcon::getCurrentItem();
54 if (currentIndex >= 0) {
55 return myTagProperties.at(currentIndex);
56 } else {
57 return nullptr;
58 }
59}
60
61
62bool
64 return std::find(myTagProperties.begin(), myTagProperties.end(), tagProperties) != myTagProperties.end();
65}
66
67
68long
69MFXComboBoxTagProperty::setCurrentItem(const GNETagProperties* tagProperties, FXbool notify) {
70 for (int i = 0; i < (int)myTagProperties.size(); i++) {
71 if (myTagProperties.at(i) == tagProperties) {
72 return MFXComboBoxIcon::setCurrentItem(i, notify);
73 }
74 }
75 fxerror("%s::setItem: index out of range.\n", getClassName());
76 return 0;
77}
78
79
80void
const std::string & getSelectorText() const
get field string (by default tag in string format)
GUIIcon getGUIIcon() const
get GUI icon associated to this tag property
const GNEAttributeProperties * at(int index) const
get attribute value
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
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
const GNETagProperties * getCurrentTagProperty() const
get current tag property
std::vector< const GNETagProperties * > myTagProperties
vector with tag properties
long setCurrentItem(const GNETagProperties *tagProperties, FXbool notify=FALSE)
Set the current item.
FXint appendTagItem(const GNETagProperties *tagProperties, FXColor bgColor=FXRGB(255, 255, 255), void *ptr=nullptr)
append item
void clearItems()
Remove all items from the list.
bool hasTagProperty(const GNETagProperties *tagProperties) const
check if the comboBox has the given tag property
MFXComboBoxTagProperty(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 GNETagProperties * getTagProperties(FXint index) const
get tag properties
MFXStaticToolTip (based on FXToolTip)