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// ===========================================================================
27// class declarations
28// ===========================================================================
29
31
32// ===========================================================================
33// class definitions
34// ===========================================================================
35
36class GNEDialog : protected FXDialogBox {
37 FXDECLARE_ABSTRACT(GNEDialog)
38
39public:
41 enum class Buttons {
42 OK, // ok button
43 YES_NO, // yes/no buttons
44 YES_NO_CANCEL, // yes/no/cancel buttons
45 ACCEPT, // accept button
46 ACCEPT_CANCEL, // accept/cancel buttons
47 ACCEPT_CANCEL_RESET, // accept/cancel/reset buttons
48 SAVE_DONTSAVE_CANCEL, // save/don't save/cancel buttons
49 RUN_CANCEL_RESET, // run/cancel/reset buttons (used in tools dialogs)
50 RUN_ADVANCED_CANCEL, // run/advanced/cancel buttons (used in tools dialogs)
51 RERUN_BACK_CLOSE // rerun-abort/back buttons (used in run dialogs)
52 };
53
55 enum class OpenType {
56 MODAL, // Modal dialog
57 NON_MODAL // Non-modal dialog
58 };
59
61 enum class ResizeMode {
62 STATIC, // dialog is static (size cannot be edited)
63 RESIZABLE // dialog is resizable (in both directions)
64 };
65
67 enum class Result {
68 ACCEPT, // dialog was closed accepting changes (used in ok, accept, yes buttons)
69 CANCEL, // dialog was closed canceling changes (used in cancel, no buttons)
70 ABORT, // dialog was closed aborting changes (used in abort button)
71 };
72
74 GNEDialog(GNEApplicationWindow* applicationWindow, const std::string& name,
75 GUIIcon titleIcon, Buttons buttons, OpenType openType,
76 ResizeMode resizeMode);
77
79 GNEDialog(GNEApplicationWindow* applicationWindow, const std::string& name,
80 GUIIcon titleIcon, Buttons buttons, OpenType openType,
81 ResizeMode resizeMode, const int width, const int height);
82
84 Result getResult() const;
85
88
90 FXVerticalFrame* getContentFrame() const;
91
93 virtual void runInternalTest(const InternalTestStep::DialogArgument* dialogArgument) = 0;
94
97
99 virtual long onCmdAccept(FXObject*, FXSelector, void*);
100
102 virtual long onCmdCancel(FXObject*, FXSelector, void*);
103
105 virtual long onCmdAbort(FXObject*, FXSelector, void*);
106
108 virtual long onCmdReset(FXObject*, FXSelector, void*);
109
111 virtual long onCmdRun(FXObject*, FXSelector, void*);
112
114 virtual long onCmdBack(FXObject*, FXSelector, void*);
115
117 virtual long onCmdAdvanced(FXObject*, FXSelector, void*);
118
120 long onKeyPress(FXObject* obj, FXSelector sel, void* ptr);
121
123 long onKeyRelease(FXObject* obj, FXSelector sel, void* ptr);
124
126
127protected:
129 FOX_CONSTRUCTOR(GNEDialog)
130
131
133
135 FXVerticalFrame* myContentFrame = nullptr;
136
138 FXButton* myAcceptButton = nullptr;
139
141 FXButton* myCancelButton = nullptr;
142
144 FXButton* myAbortButton = nullptr;
145
147 FXButton* myResetButton = nullptr;
148
150 FXButton* myRunButton = nullptr;
151
153 FXButton* myBackButton = nullptr;
154
156 FXButton* myAdvancedButton = nullptr;
157
160
162 void openDialog(FXWindow* focusableElement = nullptr);
163
166
169
171 long closeDialogAborting();
172
174 void updateTitle(const std::string& newTitle);
175
177 void updateIcon(GUIIcon newIcon);
178
179private:
181 FXButton* myFocusButton = nullptr;
182
185
187 bool myTesting = false;
188
190 void buildDialog(GUIIcon titleIcon, Buttons buttons);
191
193 GNEDialog(const GNEDialog&) = delete;
194
196 GNEDialog& operator=(const GNEDialog& src) = delete;
197};
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)
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:181
virtual void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)=0
run internal test
OpenType myOpenType
open type
Definition GNEDialog.h:184
bool myTesting
flag to indicate if this dialog is being tested using internal test
Definition GNEDialog.h:187
virtual long onCmdBack(FXObject *, FXSelector, void *)
called when back button is pressed (must be reimplemented in children)
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:135
FXButton * myAbortButton
abort button
Definition GNEDialog.h:144
long closeDialogAborting()
close dialog aborting the changes
FXButton * myCancelButton
cancel button
Definition GNEDialog.h:141
FXVerticalFrame * getContentFrame() const
get content frame
Definition GNEDialog.cpp:99
GNEApplicationWindow * getApplicationWindow() const
get pointer to the application window
Definition GNEDialog.cpp:93
Result getResult() const
get result to indicate if this dialog was closed accepting or rejecting changes
Definition GNEDialog.cpp:87
FXButton * myAdvancedButton
advanced button
Definition GNEDialog.h:156
GNEApplicationWindow * myApplicationWindow
FOX needs this.
Definition GNEDialog.h:132
FXButton * myResetButton
reset button
Definition GNEDialog.h:147
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:67
FXButton * myAcceptButton
accept button
Definition GNEDialog.h:138
Result myResult
result to indicate if this dialog was closed accepting or rejecting changes
Definition GNEDialog.h:159
long closeDialogAccepting()
close dialog accepting the changes
virtual long onCmdAdvanced(FXObject *, FXSelector, void *)
called when advanced button is pressed (must be reimplemented in children)
OpenType
Open dialog type.
Definition GNEDialog.h:55
virtual long onCmdAbort(FXObject *, FXSelector, void *)
called when abort is called either closing dialog or pressing abort button (can be reimplemented in c...
FXButton * myBackButton
back button
Definition GNEDialog.h:153
long onKeyPress(FXObject *obj, FXSelector sel, void *ptr)
called when user presses a key on the dialog
FXButton * myRunButton
run button
Definition GNEDialog.h:150
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)
dialog arguments, used for certain modal dialogs that can not be edited using tab
Definition json.hpp:4471