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_CLOSE, // 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, const std::string& name,
80 GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType,
81 ResizeMode resizeMode);
82
84 GNEDialog(GNEApplicationWindow* applicationWindow, const std::string& name,
85 GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType,
86 ResizeMode resizeMode, const int width, const int height);
87
89 Result getResult() const;
90
93
95 FXVerticalFrame* getContentFrame() const;
96
98 virtual void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) = 0;
99
102
104 virtual long onCmdAccept(FXObject*, FXSelector, void*);
105
107 virtual long onCmdCancel(FXObject*, FXSelector, void*);
108
110 virtual long onCmdAbort(FXObject*, FXSelector, void*);
111
113 virtual long onCmdReset(FXObject*, FXSelector, void*);
114
116 virtual long onCmdRun(FXObject*, FXSelector, void*);
117
119 virtual long onCmdBack(FXObject*, FXSelector, void*);
120
122 virtual long onCmdAdvanced(FXObject*, FXSelector, void*);
123
125 virtual long onCmdCopy(FXObject*, FXSelector, void*);
126
128 virtual long onCmdReport(FXObject*, FXSelector, void*);
129
131 long onKeyPress(FXObject* obj, FXSelector sel, void* ptr);
132
134 long onKeyRelease(FXObject* obj, FXSelector sel, void* ptr);
135
137
138protected:
140 FOX_CONSTRUCTOR(GNEDialog)
141
142
144
146 FXVerticalFrame* myContentFrame = nullptr;
147
149 FXButton* myAcceptButton = nullptr;
150
152 FXButton* myCancelButton = nullptr;
153
155 FXButton* myAbortButton = nullptr;
156
158 FXButton* myResetButton = nullptr;
159
161 FXButton* myRunButton = nullptr;
162
164 FXButton* myBackButton = nullptr;
165
167 FXButton* myAdvancedButton = nullptr;
168
170 FXButton* myCopyButton = nullptr;
171
173 FXButton* myReportButton = nullptr;
174
177
180
182 void openDialog(FXWindow* focusableElement = nullptr);
183
186
189
191 long closeDialogAborting();
192
194 void updateTitle(const std::string& newTitle);
195
197 void updateIcon(GUIIcon newIcon);
198
199private:
201 FXButton* myFocusButton = nullptr;
202
205
207 bool myTesting = false;
208
210 void buildDialog(GUIIcon titleIcon, Buttons buttons);
211
213 GNEDialog(const GNEDialog&) = delete;
214
216 GNEDialog& operator=(const GNEDialog& src) = delete;
217};
DialogType
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
The main window of Netedit.
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:201
virtual void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)=0
run internal test
OpenType myOpenType
open type
Definition GNEDialog.h:204
bool myTesting
flag to indicate if this dialog is being tested using internal test
Definition GNEDialog.h:207
FXButton * myCopyButton
copy button
Definition GNEDialog.h:170
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:146
FXButton * myAbortButton
abort button
Definition GNEDialog.h:155
long closeDialogAborting()
close dialog aborting the changes
FXButton * myCancelButton
cancel button
Definition GNEDialog.h:152
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
Definition GNEDialog.cpp:96
FXButton * myAdvancedButton
advanced button
Definition GNEDialog.h:167
GNEApplicationWindow * myApplicationWindow
FOX needs this.
Definition GNEDialog.h:143
FXButton * myResetButton
reset button
Definition GNEDialog.h:158
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:149
Result myResult
result to indicate if this dialog was closed accepting or rejecting changes
Definition GNEDialog.h:179
long closeDialogAccepting()
close dialog accepting the changes
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:176
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:173
FXButton * myBackButton
back button
Definition GNEDialog.h:164
long onKeyPress(FXObject *obj, FXSelector sel, void *ptr)
called when user presses a key on the dialog
FXButton * myRunButton
run button
Definition GNEDialog.h:161
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