Eclipse SUMO - Simulation of Urban MObility
GNEToolDialog.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-2022 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// Abstract dialog for tools
19/****************************************************************************/
20
24
25#include "GNEToolDialog.h"
26
27
28// ===========================================================================
29// FOX callback mapping
30// ===========================================================================
31
32FXDEFMAP(GNEToolDialog) GNEToolDialogMap[] = {
33 FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_RUN, GNEToolDialog::onCmdRun),
35 FXMAPFUNC(SEL_COMMAND, MID_GNE_BUTTON_RESET, GNEToolDialog::onCmdReset),
36};
37
38// Object implementation
39FXIMPLEMENT(GNEToolDialog, FXTopWindow, GNEToolDialogMap, ARRAYNUMBER(GNEToolDialogMap))
40
41// ============================================-===============================
42// member method definitions
43// ===========================================================================
44
45GNEToolDialog::GNEToolDialog(GNEApplicationWindow* GNEApp, const std::string& name, const int dialogWidth, const int dialogHeight) :
46 FXTopWindow(GNEApp->getApp(), name.c_str(), GUIIconSubSys::getIcon(GUIIcon::EMPTY), GUIIconSubSys::getIcon(GUIIcon::EMPTY), GUIDesignDialogBoxExplicit(dialogWidth, dialogHeight)),
47 myGNEApp(GNEApp) {
48 // create main frame
49 FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
50 // build horizontalFrame for content
51 myContentFrame = new FXVerticalFrame(mainFrame, GUIDesignContentsFrame);
52 // create buttons centered
53 FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
54 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
55 new FXButton(buttonsFrame, TL("Run\t\tclose accepting changes"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_BUTTON_RUN, GUIDesignButtonAccept);
56 new FXButton(buttonsFrame, TL("Cancel\t\tclose discarding changes"), GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_BUTTON_CANCEL, GUIDesignButtonCancel);
57 new FXButton(buttonsFrame, TL("Reset\t\treset to previous values"), GUIIconSubSys::getIcon(GUIIcon::RESET), this, MID_GNE_BUTTON_RESET, GUIDesignButtonReset);
58 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
59
60}
61
62
64
65
66void
68 // show dialog
69 show(PLACEMENT_SCREEN);
70 // open as modal dialog (will block all windows until stop() or stopModal() is called)
71 myGNEApp->getApp()->runModalFor(this);
72
73}
74
75
76void
78}
79
80
81bool
83 return FXWindow::shown();
84}
85
86
87void
89 myArguments.push_back(argument);
90}
91
92
93long
94GNEToolDialog::onCmdRun(FXObject*, FXSelector, void*) {
95 // RUN
96
97
98 // stop modal
99 myGNEApp->getApp()->stopModal(this);
100 // hide dialog
101 hide();
102 return 1;
103}
104
105
106long
107GNEToolDialog::onCmdCancel(FXObject*, FXSelector, void*) {
108 // stop modal
109 myGNEApp->getApp()->stopModal(this);
110 // hide dialog
111 hide();
112 return 1;
113}
114
115
116long
117GNEToolDialog::onCmdReset(FXObject*, FXSelector, void*) {
118 // iterate over all arguments and reset values
119 for (const auto& argument : myArguments) {
120 argument->resetValues();
121 }
122 return 1;
123}
124
125
126FXint
128 // create Dialog
129 create();
130 // show in the given position
131 show(placement);
132 // refresh APP
133 getApp()->refresh();
134 // open as modal dialog (will block all windows until stop() or stopModal() is called)
135 return getApp()->runModalFor(this);
136}
137
138/****************************************************************************/
FXDEFMAP(GNEToolDialog) GNEToolDialogMap[]
@ MID_GNE_BUTTON_RUN
run button
Definition: GUIAppEnum.h:1310
@ MID_GNE_BUTTON_CANCEL
cancel button
Definition: GUIAppEnum.h:1296
@ MID_GNE_BUTTON_RESET
reset button
Definition: GUIAppEnum.h:1298
#define GUIDesignDialogBoxExplicit(width, height)
design for dialog box with specift width and height (for example, additional dialogs)
Definition: GUIDesigns.h:596
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:145
#define GUIDesignButtonCancel
Cancel Button.
Definition: GUIDesigns.h:148
#define GUIDesignContentsFrame
design for the main content frame of every frame/dialog
Definition: GUIDesigns.h:388
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:397
#define GUIDesignButtonReset
Reset Button.
Definition: GUIDesigns.h:151
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:394
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent.
Definition: GUIDesigns.h:335
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
#define TL(string)
Definition: MsgHandler.h:282
The main window of the Netedit.
Abstract dialog for tools.
Definition: GNEToolDialog.h:40
void hideToolDialog()
hide window
GNEApplicationWindow * myGNEApp
FOX needs this.
Definition: GNEToolDialog.h:81
long onCmdCancel(FXObject *, FXSelector, void *)
event after press cancel button
long onCmdReset(FXObject *, FXSelector, void *)
event after press reset button
long onCmdRun(FXObject *, FXSelector, void *)
std::vector< GNEToolDialogElements::Argument * > myArguments
list of arguments
Definition: GNEToolDialog.h:91
void openToolDialog()
open window
void addArgument(GNEToolDialogElements::Argument *argument)
add argument
~GNEToolDialog()
destructor
bool shown() const
shown
FXint openAsModalDialog(FXuint placement=PLACEMENT_CURSOR)
execute dialog as modal
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
Definition: json.hpp:4471