Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEDialog.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2006-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// Custom FXDialogBox used in Netedit that supports internal tests
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
25
26#include "GNEDialogEnum.h"
27
28// ===========================================================================
29// class declarations
30// ===========================================================================
31
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
37
38class GNEDialog : protected FXDialogBox {
39 FXDECLARE_ABSTRACT(GNEDialog)
40
41public:
43 enum class Buttons {
44 OK, // ok button
45 YES_NO, // yes/no buttons
46 YES_NO_CANCEL, // yes/no/cancel buttons
47 ACCEPT, // accept button
48 ACCEPT_CANCEL, // accept/cancel buttons
49 ACCEPT_CANCEL_RESET, // accept/cancel/reset buttons
50 SAVE_DONTSAVE_CANCEL, // save/don't save/cancel buttons
51 RUN_CANCEL_RESET, // run/cancel/reset buttons (used in tools dialogs)
52 RUN_ADVANCED_CANCEL, // run/advanced/cancel buttons (used in tools dialogs)
53 RERUN_BACK_OK, // rerun-abort/back buttons (used in run dialogs)
54 OK_COPY_REPORT // ok, copy trace and report to github
55 };
56
58 enum class OpenType {
59 MODAL, // Modal dialog
60 NON_MODAL // Non-modal dialog
61 };
62
64 enum class ResizeMode {
65 STATIC, // dialog is static (size cannot be edited)
66 RESIZABLE // dialog is resizable (in both directions)
67 };
68
70 enum class Result {
71 ACCEPT, // dialog was closed accepting changes (used in ok, accept, yes buttons)
72 CANCEL, // dialog was closed canceling changes (used in cancel, no buttons)
73 ABORT, // dialog was closed aborting changes (used in abort button)
74 ACCEPT_ALL, // dialog was closed acepting all changes (used in ok, accept, yes buttons)
75 CANCEL_ALL, // dialog was closed canceling all changes (used in cancel, no buttons)
76 };
77
79 GNEDialog(GNEApplicationWindow* applicationWindow,
80 const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,
81 OpenType openType, ResizeMode resizeMode);
82
84 GNEDialog(GNEApplicationWindow* applicationWindow, GNEDialog* parentDialog,
85 const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,
86 OpenType openType, ResizeMode resizeMode);
87
89 GNEDialog(GNEApplicationWindow* applicationWindow,
90 const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,
91 OpenType openType, ResizeMode resizeMode, const int width, const int height);
92
94 GNEDialog(GNEApplicationWindow* applicationWindow, GNEDialog* parentDialog,
95 const std::string& name, GUIIcon titleIcon, DialogType type, Buttons buttons,
96 OpenType openType, ResizeMode resizeMode, const int width, const int height);
97
99 Result getResult() const;
100
103
105 FXVerticalFrame* getContentFrame() const;
106
108 virtual void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) = 0;
109
112
114 virtual long onCmdAccept(FXObject*, FXSelector, void*);
115
117 virtual long onCmdCancel(FXObject*, FXSelector, void*);
118
120 virtual long onCmdAbort(FXObject*, FXSelector, void*);
121
123 virtual long onCmdReset(FXObject*, FXSelector, void*);
124
126 virtual long onCmdRun(FXObject*, FXSelector, void*);
127
129 virtual long onCmdBack(FXObject*, FXSelector, void*);
130
132 virtual long onCmdAdvanced(FXObject*, FXSelector, void*);
133
135 virtual long onCmdCopy(FXObject*, FXSelector, void*);
136
138 virtual long onCmdReport(FXObject*, FXSelector, void*);
139
141 long onKeyPress(FXObject* obj, FXSelector sel, void* ptr);
142
144 long onKeyRelease(FXObject* obj, FXSelector sel, void* ptr);
145
147
148protected:
150 FOX_CONSTRUCTOR(GNEDialog)
151
152
154
157
159 FXVerticalFrame* myContentFrame = nullptr;
160
162 FXButton* myAcceptButton = nullptr;
163
165 FXButton* myCancelButton = nullptr;
166
168 FXButton* myAbortButton = nullptr;
169
171 FXButton* myResetButton = nullptr;
172
174 FXButton* myRunButton = nullptr;
175
177 FXButton* myBackButton = nullptr;
178
180 FXButton* myAdvancedButton = nullptr;
181
183 FXButton* myCopyButton = nullptr;
184
186 FXButton* myReportButton = nullptr;
187
190
193
195 void openDialog(FXWindow* focusableElement = nullptr);
196
199
202
204 long closeDialogAborting();
205
207 void updateTitle(const std::string& newTitle);
208
210 void updateIcon(GUIIcon newIcon);
211
212private:
214 FXButton* myFocusButton = nullptr;
215
218
220 bool myTesting = false;
221
223 void buildDialog(GUIIcon titleIcon, Buttons buttons);
224
226 GNEDialog(const GNEDialog&) = delete;
227
229 GNEDialog& operator=(const GNEDialog& src) = delete;
230};
DialogType
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
virtual long onCmdRun(FXObject *, FXSelector, void *)
called when run button is pressed (must be reimplemented in children depending of Buttons)
void buildDialog(GUIIcon titleIcon, Buttons buttons)
build dialog
FXButton * myFocusButton
focus button, used for focusing the default button when dialog is opened
Definition GNEDialog.h:214
virtual void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)=0
run internal test
OpenType myOpenType
open type
Definition GNEDialog.h:217
bool myTesting
flag to indicate if this dialog is being tested using internal test
Definition GNEDialog.h:220
FXButton * myCopyButton
copy button
Definition GNEDialog.h:183
virtual long onCmdBack(FXObject *, FXSelector, void *)
called when back button is pressed (must be reimplemented in children depending of Buttons)
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:159
FXButton * myAbortButton
abort button
Definition GNEDialog.h:168
long closeDialogAborting()
close dialog aborting the changes
FXButton * myCancelButton
cancel button
Definition GNEDialog.h:165
FXVerticalFrame * getContentFrame() const
get content frame
GNEApplicationWindow * getApplicationWindow() const
get pointer to the application window
Result getResult() const
get result to indicate if this dialog was closed accepting or rejecting changes
FXButton * myAdvancedButton
advanced button
Definition GNEDialog.h:180
GNEApplicationWindow * myApplicationWindow
FOX needs this.
Definition GNEDialog.h:153
FXButton * myResetButton
reset button
Definition GNEDialog.h:171
void updateIcon(GUIIcon newIcon)
update icon
long onKeyRelease(FXObject *obj, FXSelector sel, void *ptr)
called when user releases a key on the dialog
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
Result
list of possible results when closing the dialog
Definition GNEDialog.h:70
FXButton * myAcceptButton
accept button
Definition GNEDialog.h:162
Result myResult
result to indicate if this dialog was closed accepting or rejecting changes
Definition GNEDialog.h:192
long closeDialogAccepting()
close dialog accepting the changes
GNEDialog * myParentDialog
parent dialog used for restoring focus after closing dialog
Definition GNEDialog.h:156
virtual long onCmdAdvanced(FXObject *, FXSelector, void *)
called when advanced button is pressed (must be reimplemented in children depending of Buttons)
OpenType
Open dialog type.
Definition GNEDialog.h:58
DialogType myType
dialog type
Definition GNEDialog.h:189
virtual long onCmdAbort(FXObject *, FXSelector, void *)
called when abort is called either closing dialog or pressing abort button (can be reimplemented in c...
FXButton * myReportButton
report button
Definition GNEDialog.h:186
FXButton * myBackButton
back button
Definition GNEDialog.h:177
long onKeyPress(FXObject *obj, FXSelector sel, void *ptr)
called when user presses a key on the dialog
FXButton * myRunButton
run button
Definition GNEDialog.h:174
virtual long onCmdReport(FXObject *, FXSelector, void *)
called when report button is pressed (must be reimplemented in children depending of Buttons)
virtual long onCmdCopy(FXObject *, FXSelector, void *)
called when copy button is pressed (must be reimplemented in children depending of Buttons)
virtual long onCmdAccept(FXObject *, FXSelector, void *)
called when accept or yes button is pressed (can be reimplemented in children)
long closeDialogCanceling()
close dialog declining the changes
virtual long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed (can be reimplemented in children)
void updateTitle(const std::string &newTitle)
update title
virtual long onCmdReset(FXObject *, FXSelector, void *)
called when reset button is pressed (must be reimplemented in children depending of Buttons)
dialog arguments, used for certain modal dialogs that can not be edited using tab
Definition json.hpp:4471