Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/dialogs/file/GNEFilePathDialog.cpp
169684 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 GNEFilePathDialog.cpp
15
/// @author Pablo Alvarez Lopez
16
/// @date Aug 2025
17
///
18
// A basic dialog for selecting a file path (used in GNEFileSelector)
19
/****************************************************************************/
20
21
#include <netedit/GNEApplicationWindow.h>
22
#include <utils/foxtools/MFXTextFieldIcon.h>
23
#include <utils/gui/div/GUIDesigns.h>
24
25
#include "GNEFilePathDialog.h"
26
27
// ===========================================================================
28
// method definitions
29
// ===========================================================================
30
31
GNEFilePathDialog::GNEFilePathDialog(GNEApplicationWindow* applicationWindow, const std::string& title,
32
const std::string& info, const std::string& originalFilePath) :
33
GNEDialog(applicationWindow, title.c_str(), GUIIcon::OPEN, DialogType::FILEPATH,
34
GNEDialog::Buttons::ACCEPT_CANCEL_RESET, OpenType::MODAL, ResizeMode::STATIC),
35
myOriginalFilePath(originalFilePath) {
36
// create dialog layout (obtained from FXMessageBox)
37
//auto infoFrame = new FXVerticalFrame(myContentFrame, LAYOUT_TOP | LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 10, 10, 10, 10);
38
// add information label
39
new FXLabel(myContentFrame, info.c_str(), nullptr, GUIDesignLabel(JUSTIFY_NORMAL));
40
// create text field to enter the path
41
myPathTextField = new MFXTextFieldIcon(myContentFrame, applicationWindow->getStaticTooltipMenu(), GUIIcon::EMPTY,
42
nullptr, 0, GUIDesignTextField);
43
// set original file path
44
myPathTextField->setText(originalFilePath.c_str());
45
// open modal dialog
46
openDialog();
47
}
48
49
50
GNEFilePathDialog::~GNEFilePathDialog() {
51
}
52
53
54
void
55
GNEFilePathDialog::runInternalTest(const InternalTestStep::DialogArgument* /*dialogArgument*/) {
56
// nothing to do (yet)
57
}
58
59
60
std::string
61
GNEFilePathDialog::getFilePath() const {
62
return myPathTextField->getText().text();
63
}
64
65
66
long
67
GNEFilePathDialog::onCmdCancel(FXObject*, FXSelector, void*) {
68
// set an empty test
69
myPathTextField->setText("", FALSE);
70
return closeDialogCanceling();
71
}
72
73
74
long
75
GNEFilePathDialog::onCmdReset(FXObject*, FXSelector, void*) {
76
// restore original file path
77
myPathTextField->setText(myOriginalFilePath.c_str(), TRUE);
78
return 1;
79
}
80
81
/****************************************************************************/
82
83