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 // create dialog layout (obtained from FXMessageBox)
36 auto infoFrame = new FXVerticalFrame(myContentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);
37 // add information label
38 const std::string info = TLF("You have unsaved %.", elementTypes) + std::string("\n") +
39 TL("Do you wish to close and discard all changes?");
40 new FXLabel(infoFrame, info.c_str(), NULL, JUSTIFY_LEFT | ICON_BEFORE_TEXT | LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y);
41 // create applyToAll button
42 myApplyToAllButton = new FXCheckButton(infoFrame, TL("Apply to all unsaved elements"), nullptr, 0, GUIDesignCheckButton);
43 // open modal dialog
44 openDialog();
45}
46
47
50
51
52void
54 // nothing to do
55}
56
57
58long
59GNESaveDialog::onCmdAccept(FXObject*, FXSelector, void*) {
60 // close dialog accepting
62 // check if return apply to all
63 if (myApplyToAllButton && (myApplyToAllButton->getCheck() == TRUE)) {
65 }
66 return 1;
67}
68
69
70long
71GNESaveDialog::onCmdCancel(FXObject*, FXSelector, void*) {
72 // close dialog accepting
74 // check if return apply to all
75 if (myApplyToAllButton && (myApplyToAllButton->getCheck() == TRUE)) {
77 }
78 return 0;
79}
80
81/****************************************************************************/
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
The main window of Netedit.
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:146
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
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
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.
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