Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEFilePathDialog.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// A basic dialog for selecting a file path (used in GNEFileSelector)
19/****************************************************************************/
20
24
25#include "GNEFilePathDialog.h"
26
27// ===========================================================================
28// method definitions
29// ===========================================================================
30
31GNEFilePathDialog::GNEFilePathDialog(GNEApplicationWindow* applicationWindow, const std::string& title,
32 const std::string& info, const std::string& originalFilePath) :
33 GNEDialog(applicationWindow, title.c_str(), GUIIcon::OPEN, GNEDialog::Buttons::ACCEPT_CANCEL_RESET, OpenType::MODAL, ResizeMode::STATIC),
34 myOriginalFilePath(originalFilePath) {
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 new FXLabel(myContentFrame, info.c_str(), nullptr, GUIDesignLabel(JUSTIFY_NORMAL));
39 // create text field to enter the path
41 nullptr, 0, GUIDesignTextField);
42 // set original file path
43 myPathTextField->setText(originalFilePath.c_str());
44 // open modal dialog
45 openDialog();
46}
47
48
51
52
53void
55 // nothing to do (yet)
56}
57
58
59std::string
61 return myPathTextField->getText().text();
62}
63
64
65long
66GNEFilePathDialog::onCmdCancel(FXObject*, FXSelector, void*) {
67 // set an empty test
68 myPathTextField->setText("", FALSE);
69 return closeDialogCanceling();
70}
71
72
73long
74GNEFilePathDialog::onCmdReset(FXObject*, FXSelector, void*) {
75 // restore original file path
77 return 1;
78}
79
80/****************************************************************************/
#define GUIDesignTextField
Definition GUIDesigns.h:74
#define GUIDesignLabel(justify)
Definition GUIDesigns.h:245
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
@ OPEN
open icons
The main window of Netedit.
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:135
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
OpenType
Open dialog type.
Definition GNEDialog.h:55
long closeDialogCanceling()
close dialog declining the changes
std::string getFilePath() const
get the file path
long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel or no button is pressed (can be reimplemented in children)
~GNEFilePathDialog()
Destructor.
long onCmdReset(FXObject *, FXSelector, void *)
called when reset button is pressed (must be reimplemented in children)
std::string myOriginalFilePath
original file path (used for reset)
void runInternalTest(const InternalTestStep::DialogArgument *dialogArgument)
run internal test
GNEFilePathDialog(GNEApplicationWindow *applicationWindow, const std::string &title, const std::string &info, const std::string &originalFilePath)
Constructor.
MFXTextFieldIcon * myPathTextField
text field to enter the path
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
dialog arguments, used for certain modal dialogs that can not be edited using tab
FXString getText() const
Get the text for this label.
void setText(const FXString &text, FXbool notify=FALSE)
Change the text and move cursor to end.