Path: blob/main/src/utils/foxtools/MFXRecentNetworks.cpp
169678 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2004-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 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 FXchar* filename;59FXchar key[20];60sprintf(key, "FILE%d", which);61filename = getApp()->reg().readStringEntry(getGroupName().text(), key, NULL);62// update myIndexFilenames63myIndexFilenames[which] = filename;64// check filename65if (filename) {66FXString string;67if (which < 10) {68string.format("&%d %s", which, filename);69} else {70string.format("1&0 %s", filename);71}72obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE), (void*)&string);73obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);74} else {75obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);76}77return 1;78}798081long82MFXRecentNetworks::onUpdNoFiles(FXObject* obj, FXSelector, void*) {83// first disable object84obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), NULL);85// iterate over myIndexFilenames86for (const auto& indexFilename : myIndexFilenames) {87// if filename isn't empty, then hide object and stop88if (!indexFilename.second.empty()) {89obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);90return 1;91}92}93//show object94obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);95return 1;96}979899