Eclipse SUMO - Simulation of Urban MObility
GUIDialog_AppSettings.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 /****************************************************************************/
19 // The application-settings dialog
20 /****************************************************************************/
21 #include <config.h>
22 
27 #include <gui/GUIGlobals.h>
28 #include "GUIDialog_AppSettings.h"
29 
30 
31 // ===========================================================================
32 // FOX callback mapping
33 // ===========================================================================
34 FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[] = {
36  FXMAPFUNC(SEL_COMMAND, MID_AUTOSTART, GUIDialog_AppSettings::onCmdSelect),
37  FXMAPFUNC(SEL_COMMAND, MID_DEMO, GUIDialog_AppSettings::onCmdSelect),
39  FXMAPFUNC(SEL_COMMAND, MID_LOCATELINKS, GUIDialog_AppSettings::onCmdSelect),
40  FXMAPFUNC(SEL_COMMAND, MID_SETTINGS_OK, GUIDialog_AppSettings::onCmdOk),
42 };
43 
44 FXIMPLEMENT(GUIDialog_AppSettings, FXDialogBox, GUIDialog_AppSettingsMap, ARRAYNUMBER(GUIDialog_AppSettingsMap))
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
51  : FXDialogBox(parent, "Application Settings"),
52  myAppQuitOnEnd(GUIGlobals::gQuitOnEnd),
53  myAppAutoStart(GUIGlobals::gRunAfterLoad),
54  myAppDemo(GUIGlobals::gDemoAutoReload),
55  myAllowTextures(GUITexturesHelper::texturesAllowed()),
56  myLocateLinks(GUIMessageWindow::locateLinksEnabled()) {
57  FXCheckButton* b = nullptr;
58  FXVerticalFrame* f1 = new FXVerticalFrame(this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);
59  b = new FXCheckButton(f1, "Quit on Simulation End", this, MID_QUITONSIMEND);
60  b->setCheck(myAppQuitOnEnd);
61  b = new FXCheckButton(f1, "Autostart Simulation on Load and Reload", this, MID_AUTOSTART);
62  b->setCheck(myAppAutoStart);
63  b = new FXCheckButton(f1, "Reload Simulation after finish (Demo mode)", this, MID_DEMO);
64  b->setCheck(myAppDemo);
65  b = new FXCheckButton(f1, "Locate elements when clicking on messages", this, MID_LOCATELINKS);
66  b->setCheck(myLocateLinks);
67  new FXHorizontalSeparator(f1, SEPARATOR_GROOVE | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X);
68  b = new FXCheckButton(f1, "Allow Textures", this, MID_ALLOWTEXTURES);
69  b->setCheck(myAllowTextures);
70  FXHorizontalFrame* f2 = new FXHorizontalFrame(f1, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH, 0, 0, 0, 0, 10, 10, 5, 5);
71  FXButton* initial = new FXButton(f2, "&OK", nullptr, this, MID_SETTINGS_OK, BUTTON_INITIAL | BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
72  new FXButton(f2, "&Cancel", nullptr, this, MID_SETTINGS_CANCEL, BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_CENTER_X, 0, 0, 0, 0, 30, 30, 4, 4);
73  initial->setFocus();
75 }
76 
77 
79 
80 
81 long
82 GUIDialog_AppSettings::onCmdOk(FXObject*, FXSelector, void*) {
89  destroy();
90  return 1;
91 }
92 
93 
94 long
95 GUIDialog_AppSettings::onCmdCancel(FXObject*, FXSelector, void*) {
96  destroy();
97  return 1;
98 }
99 
100 
101 long
102 GUIDialog_AppSettings::onCmdSelect(FXObject*, FXSelector sel, void*) {
103  switch (FXSELID(sel)) {
104  case MID_QUITONSIMEND:
106  break;
107  case MID_AUTOSTART:
109  break;
110  case MID_DEMO:
111  myAppDemo = !myAppDemo;
112  break;
113  case MID_LOCATELINKS:
115  break;
116  case MID_ALLOWTEXTURES:
118  break;
119  }
120  return 1;
121 }
122 
123 
124 /****************************************************************************/
@ MID_ALLOWTEXTURES
Allow textures - Option.
Definition: GUIAppEnum.h:507
@ MID_AUTOSTART
Start simulation when loaded - Option.
Definition: GUIAppEnum.h:503
@ MID_QUITONSIMEND
Close simulation at end - Option.
Definition: GUIAppEnum.h:501
@ MID_LOCATELINKS
Locate links in messages - Option.
Definition: GUIAppEnum.h:509
@ MID_SETTINGS_OK
Ok-button was pushed.
Definition: GUIAppEnum.h:491
@ MID_DEMO
Demo mode - Option.
Definition: GUIAppEnum.h:505
@ MID_SETTINGS_CANCEL
Cancel-button was pushed.
Definition: GUIAppEnum.h:493
FXDEFMAP(GUIDialog_AppSettings) GUIDialog_AppSettingsMap[]
The dialog to change the application (gui) settings.
bool myAppDemo
Information whether the simulation restarts after ending (demo mode)
bool myAppQuitOnEnd
Information whether the application shall be quit.
long onCmdOk(FXObject *, FXSelector, void *)
Called on OK-button pressure.
bool myAppAutoStart
Information whether the simulation shall start directly after loading.
bool myLocateLinks
Information whether locate links appear in messages.
long onCmdSelect(FXObject *, FXSelector sel, void *)
Called on button change.
long onCmdCancel(FXObject *, FXSelector, void *)
Called on Cancel-button pressure.
bool myAllowTextures
Information whether textures may be used.
static bool gRunAfterLoad
the simulation shall start direct after loading
Definition: GUIGlobals.h:42
static bool gQuitOnEnd
the window shall be closed when the simulation has ended
Definition: GUIGlobals.h:45
static bool gDemoAutoReload
the simulation shall reload when it has ended (demo)
Definition: GUIGlobals.h:48
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
A logging window for the gui.
static void enableLocateLinks(const bool val)
switch locate links on and off
Global storage for textures; manages and draws them.
static void allowTextures(const bool val)
switch texture drawing on and off