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