Path: blob/main/src/utils/foxtools/MFXRecentNetworks.cpp
193671 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2004-2026 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 MFXRecentNetworks.cpp14/// @author Pablo Alvarez Lopez15/// @date Feb 202116///17//18/****************************************************************************/19// ===========================================================================20// included modules21// ===========================================================================22#include <config.h>2324#include "MFXRecentNetworks.h"252627// ===========================================================================28// FOX callback mapping29// ===========================================================================3031FXDEFMAP(MFXRecentNetworks) MFXRecentNetworksMap[] = {32FXMAPFUNC(SEL_UPDATE, MFXRecentNetworks::ID_NOFILES, MFXRecentNetworks::onUpdNoFiles),33FXMAPFUNCS(SEL_UPDATE, FXRecentFiles::ID_FILE_1, FXRecentFiles::ID_FILE_10, MFXRecentNetworks::onUpdFile),34};3536// Object implementation37FXIMPLEMENT(MFXRecentNetworks, FXRecentFiles, MFXRecentNetworksMap, ARRAYNUMBER(MFXRecentNetworksMap))3839// ===========================================================================40// member method definitions41// ===========================================================================4243MFXRecentNetworks::MFXRecentNetworks() :44FXRecentFiles() {45}464748MFXRecentNetworks::MFXRecentNetworks(FXApp* a, const FXString& gp) :49FXRecentFiles(a, gp) {50}515253long54MFXRecentNetworks::onUpdFile(FXObject* obj, FXSelector sel, void*) {55// get filename index56const FXint which = FXSELID(sel) - ID_FILE_1 + 1;57// get filename58const FXString key = FXStringFormat("FILE%d", which);59const FXchar* filename = getApp()->reg().readStringEntry(getGroupName().text(), key.text(), NULL);60// update myIndexFilenames61myIndexFilenames[which] = filename;62// check filename63if (filename) {64FXString string;65if (which < 10) {66string.format("&%d %s", which, filename);67} else {68string.format("1&0 %s", filename);69}70obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE), (void*)&string);71obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);72} else {73obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);74}75return 1;76}777879long80MFXRecentNetworks::onUpdNoFiles(FXObject* obj, FXSelector, void*) {81// first disable object82obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), NULL);83// iterate over myIndexFilenames84for (const auto& indexFilename : myIndexFilenames) {85// if filename isn't empty, then hide object and stop86if (!indexFilename.second.empty()) {87obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);88return 1;89}90}91//show object92obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);93return 1;94}959697