Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/GNESaveDialog.cpp
185787 views
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
/****************************************************************************/
14
/// @file GNESaveDialog.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Oct 2025
17
///
18
// Dialog used for saving elements
19
/****************************************************************************/
20
#include <config.h>
21
22
#include <utils/common/MsgHandler.h>
23
#include <utils/gui/div/GUIDesigns.h>
24
#include <utils/gui/images/GUIIconSubSys.h>
25
26
#include "GNESaveDialog.h"
27
28
// ===========================================================================
29
// method definitions
30
// ===========================================================================
31
32
GNESaveDialog::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
39
GNESaveDialog::GNESaveDialog(GNEApplicationWindow* applicationWindow, GNEDialog* parentDialog,
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
47
GNESaveDialog::~GNESaveDialog() {
48
}
49
50
51
void
52
GNESaveDialog::runInternalTest(const InternalTestStep::DialogArgument* /*dialogArgument*/) {
53
// nothing to do
54
}
55
56
57
long
58
GNESaveDialog::onCmdAccept(FXObject*, FXSelector, void*) {
59
// close dialog accepting
60
closeDialogAccepting();
61
// check if return apply to all
62
if (myApplyToAllButton && (myApplyToAllButton->getCheck() == TRUE)) {
63
myResult = Result::ACCEPT_ALL;
64
}
65
return 1;
66
}
67
68
69
long
70
GNESaveDialog::onCmdCancel(FXObject*, FXSelector, void*) {
71
// close dialog accepting
72
closeDialogCanceling();
73
// check if return apply to all
74
if (myApplyToAllButton && (myApplyToAllButton->getCheck() == TRUE)) {
75
myResult = Result::CANCEL_ALL;
76
}
77
return 0;
78
}
79
80
81
void
82
GNESaveDialog::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
/****************************************************************************/
96
97