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-2026 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
32 const std::string& title, const std::string& info, const std::string& originalFilePath) :
33 GNEDialog(applicationWindow, parentDialog, 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
42 nullptr, 0, GUIDesignTextField);
43 // set original file path
44 myPathTextField->setText(originalFilePath.c_str());
45 // open modal dialog
46 openDialog();
47}
48
49
52
53
54void
56 // nothing to do (yet)
57}
58
59
60std::string
62 return myPathTextField->getText().text();
63}
64
65
66long
67GNEFilePathDialog::onCmdCancel(FXObject*, FXSelector, void*) {
68 // set an empty test
69 myPathTextField->setText("", FALSE);
70 return closeDialogCanceling();
71}
72
73
74long
75GNEFilePathDialog::onCmdReset(FXObject*, FXSelector, void*) {
76 // restore original file path
77 myPathTextField->setText(myOriginalFilePath.c_str(), TRUE);
78 return 1;
79}
80
81/****************************************************************************/
DialogType
Definition DialogType.h:30
#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
Definition GUIIcons.h:79
@ EMPTY
Definition GUIIcons.h:59
FXVerticalFrame * myContentFrame
content frame
Definition GNEDialog.h:159
void openDialog(FXWindow *focusableElement=nullptr)
open dialog
OpenType
Open dialog type.
Definition GNEDialog.h:58
GNEDialog(GNEApplicationWindow *applicationWindow, const std::string &name, GUIIcon titleIcon, DialogType type, Buttons buttons, OpenType openType, ResizeMode resizeMode)
basic constructor
Definition GNEDialog.cpp:60
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(GNEApplicationWindow *applicationWindow, GNEDialog *parentDialog, const std::string &title, const std::string &info, const std::string &originalFilePath)
Constructor.
~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
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