Path: blob/main/src/utils/foxtools/MFXComboBoxAttrProperty.cpp
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2006-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file MFXComboBoxAttrProperty.cpp14/// @author Pablo Alvarez Lopez15/// @date Mar 202516///17// ComboBox icon specific for attr properties18/****************************************************************************/1920#include <netedit/GNEAttributeProperties.h>2122#include "MFXComboBoxAttrProperty.h"2324// ===========================================================================25// member method definitions26// ===========================================================================2728MFXComboBoxAttrProperty::MFXComboBoxAttrProperty(FXComposite* p, MFXStaticToolTip* staticToolTip, const bool canSearch, const int visibleItems,29FXObject* tgt, FXSelector sel, FXuint opts, FXint x, FXint y, FXint w, FXint h, FXint pl, FXint pr, FXint pt, FXint pb) :30MFXComboBoxIcon(p, staticToolTip, canSearch, visibleItems, tgt, sel, opts, x, y, w, h, pl, pr, pt, pb) {31}323334MFXComboBoxAttrProperty::~MFXComboBoxAttrProperty() {}353637FXint38MFXComboBoxAttrProperty::appendAttrItem(const GNEAttributeProperties* attrProperties, FXColor bgColor, void* ptr) {39myAttrProperties.push_back(attrProperties);40return MFXComboBoxIcon::appendIconItem(attrProperties->getAttrStr().c_str(), nullptr, bgColor, ptr);41}424344const GNEAttributeProperties*45MFXComboBoxAttrProperty::getAttrProperties(FXint index) const {46return myAttrProperties.at(index);47}484950const GNEAttributeProperties*51MFXComboBoxAttrProperty::getCurrentAttrProperty() const {52const auto currentIndex = MFXComboBoxIcon::getCurrentItem();53if (currentIndex >= 0) {54return myAttrProperties.at(currentIndex);55} else {56return nullptr;57}58}596061long62MFXComboBoxAttrProperty::setCurrentItem(const GNEAttributeProperties* attributeProperties, FXbool notify) {63for (int i = 0; i < (int)myAttrProperties.size(); i++) {64if (myAttrProperties.at(i) == attributeProperties) {65return MFXComboBoxIcon::setCurrentItem(i, notify);66}67}68fxerror("%s::setItem: index out of range.\n", getClassName());69return 0;70}717273bool74MFXComboBoxAttrProperty::hasAttrProperty(const GNEAttributeProperties* attrProperties) {75return std::find(myAttrProperties.begin(), myAttrProperties.end(), attrProperties) != myAttrProperties.end();76}7778void79MFXComboBoxAttrProperty::clearItems() {80MFXComboBoxIcon::clearItems();81myAttrProperties.clear();82}838485