Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
MFXRecentNetworks.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2004-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//
19/****************************************************************************/
20// ===========================================================================
21// included modules
22// ===========================================================================
23#include <config.h>
24
25#include "MFXRecentNetworks.h"
26
27
28// ===========================================================================
29// FOX callback mapping
30// ===========================================================================
31
32FXDEFMAP(MFXRecentNetworks) MFXRecentNetworksMap[] = {
34 FXMAPFUNCS(SEL_UPDATE, FXRecentFiles::ID_FILE_1, FXRecentFiles::ID_FILE_10, MFXRecentNetworks::onUpdFile),
35};
36
37// Object implementation
38FXIMPLEMENT(MFXRecentNetworks, FXRecentFiles, MFXRecentNetworksMap, ARRAYNUMBER(MFXRecentNetworksMap))
39
40// ===========================================================================
41// member method definitions
42// ===========================================================================
43
45 FXRecentFiles() {
46}
47
48
49MFXRecentNetworks::MFXRecentNetworks(FXApp* a, const FXString& gp) :
50 FXRecentFiles(a, gp) {
51}
52
53
54long
55MFXRecentNetworks::onUpdFile(FXObject* obj, FXSelector sel, void*) {
56 // get filename index
57 const FXint which = FXSELID(sel) - ID_FILE_1 + 1;
58 // get filename
59 const FXchar* filename;
60 FXchar key[20];
61 sprintf(key, "FILE%d", which);
62 filename = getApp()->reg().readStringEntry(getGroupName().text(), key, NULL);
63 // update myIndexFilenames
64 myIndexFilenames[which] = filename;
65 // check filename
66 if (filename) {
67 FXString string;
68 if (which < 10) {
69 string.format("&%d %s", which, filename);
70 } else {
71 string.format("1&0 %s", filename);
72 }
73 obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SETSTRINGVALUE), (void*)&string);
74 obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);
75 } else {
76 obj->handle(this, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);
77 }
78 return 1;
79}
80
81
82long
83MFXRecentNetworks::onUpdNoFiles(FXObject* obj, FXSelector, void*) {
84 // first disable object
85 obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), NULL);
86 // iterate over myIndexFilenames
87 for (const auto& indexFilename : myIndexFilenames) {
88 // if filename isn't empty, then hide object and stop
89 if (!indexFilename.second.empty()) {
90 obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_HIDE), NULL);
91 return 1;
92 }
93 }
94 //show object
95 obj->handle(obj, FXSEL(SEL_COMMAND, FXWindow::ID_SHOW), NULL);
96 return 1;
97}
FXDEFMAP(MFXRecentNetworks) MFXRecentNetworksMap[]
MFXRecentNetworks.
std::map< FXint, FXString > myIndexFilenames
map with index and strings
MFXRecentNetworks()
default constructor
long onUpdNoFiles(FXObject *, FXSelector, void *)
long onUpdFile(FXObject *, FXSelector, void *)