Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNESaveDialog.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-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// Dialog used for saving elements
19/****************************************************************************/
20#include <config.h>
21
25
26#include "GNESaveDialog.h"
27
28// ===========================================================================
29// method definitions
30// ===========================================================================
31
32GNESaveDialog::GNESaveDialog(GNEApplicationWindow* applicationWindow, const std::string& elementTypes) :
33 GNEDialog(applicationWindow, TLF("Save %", elementTypes), GUIIcon::SAVE, DialogType::SAVE,
34 GNEDialog::Buttons::SAVE_DONTSAVE_CANCEL, OpenType::MODAL, ResizeMode::STATIC) {
35 builder(elementTypes);
36}
37
38
40 const std::string& elementTypes) :
41 GNEDialog(applicationWindow, parentDialog, TLF("Save %", elementTypes), GUIIcon::SAVE, DialogType::SAVE,
42 GNEDialog::Buttons::SAVE_DONTSAVE_CANCEL, OpenType::MODAL, ResizeMode::STATIC) {
43 builder(elementTypes);
44}
45
46
49
50
51void
53 // nothing to do
54}
55
56
57long
58GNESaveDialog::onCmdAccept(FXObject*, FXSelector, void*) {
59 // close dialog accepting
61 // check if return apply to all
62 if (myApplyToAllButton && (myApplyToAllButton->getCheck() == TRUE)) {
64 }
65 return 1;
66}
67
68
69long
70GNESaveDialog::onCmdCancel(FXObject*, FXSelector, void*) {
71 // close dialog accepting
73 // check if return apply to all
74 if (myApplyToAllButton && (myApplyToAllButton->getCheck() == TRUE)) {
76 }
77 return 0;
78}
79
80
81void
82GNESaveDialog::builder(const std::string& elementTypes) {
83 // create dialog layout (obtained from FXMessageBox)
84 auto infoFrame = new FXVerticalFrame(myContentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);
85 // add information label
86 const std::string info = TLF("You have unsaved %.", elementTypes) + std::string("\n") +
87 TL("Do you wish to close and discard all changes?");
88 new FXLabel(infoFrame, info.c_str(), NULL, JUSTIFY_LEFT | ICON_BEFORE_TEXT | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y);
89 // create applyToAll button
90 myApplyToAllButton = new FXCheckButton(infoFrame, TL("Apply to all unsaved elements"), nullptr, 0, GUIDesignCheckButton);
91 // open modal dialog
92 openDialog();
93}
94
95/****************************************************************************/
DialogType
#define GUIDesignCheckButton
checkButton placed in left position
Definition GUIDesigns.h:194
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:159
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
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
OpenType
Open dialog type.
Definition GNEDialog.h:58
long closeDialogCanceling()
close dialog declining the changes
long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed (can be reimplemented in children)
~GNESaveDialog()
Destructor.
FXCheckButton * myApplyToAllButton
apply to all button
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
GNESaveDialog(GNEApplicationWindow *applicationWindow, const std::string &elementTypes)
Constructor.
void builder(const std::string &elementTypes)
builder
long onCmdAccept(FXObject *, FXSelector, void *)
called when accept or yes button is pressed (can be reimplemented in children)
dialog arguments, used for certain modal dialogs that can not be edited using tab