Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEKeepElementsDialog.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 to ask user if overwrite elements during loading
19/****************************************************************************/
20
24
26
27// ===========================================================================
28// FOX callback mapping
29// ===========================================================================
30
31FXDEFMAP(GNEKeepElementsDialog) GNEKeepElementsDialogMap[] = {
33 FXMAPFUNC(SEL_CLOSE, 0, GNEKeepElementsDialog::onCmdCancel),
34};
35
36// Object implementation
37FXIMPLEMENT(GNEKeepElementsDialog, MFXDialogBox, GNEKeepElementsDialogMap, ARRAYNUMBER(GNEKeepElementsDialogMap))
38
39// ===========================================================================
40// member method definitions
41// ===========================================================================
42
43// ---------------------------------------------------------------------------
44// GNEKeepElementsDialog - methods
45// ---------------------------------------------------------------------------
46
47GNEKeepElementsDialog::GNEKeepElementsDialog(GNEApplicationWindow* applicationWindow, const std::string elementType) :
48 MFXDialogBox(applicationWindow->getApp(), ("Keep " + elementType + " elements").c_str(), GUIDesignDialogBoxExplicit(400, 100)) {
49 // set busStop icon for this dialog
51 // create main frame
52 FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
53 // create label
54 new FXLabel(mainFrame, ("Selected " + elementType + " file was already loaded.\n Keep new or old elements?").c_str(), nullptr, GUIDesignLabelKeepElements);
55 // create buttons centered
56 FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
57 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
58 myKeepNewButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Keep new"), "", TL("Keep new elements"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_SELECT, GUIDesignButtonKeepElements);
59 myKeepOldButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Keep old"), "", TL("Keep old elements"), GUIIconSubSys::getIcon(GUIIcon::BACK), this, MID_GNE_SELECT, GUIDesignButtonKeepElements);
60 myCancelButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Cancel"), "", TL("Cancel loading of elements"), GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_SELECT, GUIDesignButtonKeepElements);
61 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
62 // create Dialog
63 create();
64 // set focus in keep news
65 myKeepNewButton->setFocus();
66 // set accept as
67 // show in the given position
68 show(PLACEMENT_SCREEN);
69 // refresh APP
70 getApp()->refresh();
71 // open as modal dialog (will block all windows until stop() or stopModal() is called)
72 applicationWindow->getApp()->runModalFor(this);
73}
74
75
78
79
84
85
86long
87GNEKeepElementsDialog::onCmdSelectOption(FXObject* obj, FXSelector, void*) {
88 if (obj == myKeepOldButton) {
90 } else if (obj == myKeepNewButton) {
92 }
93 // Stop Modal
94 getApp()->stopModal(this, FALSE);
95 return 1;
96}
97
98long
99GNEKeepElementsDialog::onCmdClose(FXObject*, FXSelector, void*) {
100 // Stop Modal
101 getApp()->stopModal(this, FALSE);
102 return 1;
103}
104
105/****************************************************************************/
FXDEFMAP(GNEKeepElementsDialog) GNEKeepElementsDialogMap[]
@ MID_GNE_SELECT
select element
Definition GUIAppEnum.h:957
#define GUIDesignDialogBoxExplicit(width, height)
design for dialog box with specific width and height (for example, additional dialogs)
Definition GUIDesigns.h:614
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition GUIDesigns.h:399
#define GUIDesignLabelKeepElements
label extended over frame without thick and with text justify to left
Definition GUIDesigns.h:261
#define GUIDesignButtonKeepElements
overwrite Button
Definition GUIDesigns.h:171
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:390
#define GUIDesignHorizontalFrame
Horizontal frame extended over frame parent with padding and spacing.
Definition GUIDesigns.h:328
@ SUPERMODEDEMAND
#define TL(string)
Definition MsgHandler.h:305
The main window of Netedit.
Result getResult() const
get result
long onCmdSelectOption(FXObject *obj, FXSelector, void *)
long onCmdClose(FXObject *obj, FXSelector, void *)
event when dialog is closed
FXButton * myKeepNewButton
button for overwrite
FXButton * myKeepOldButton
FOX need this.
Result myResult
result (by default cancel)
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long onCmdCancel(FXObject *, FXSelector, void *)
called when cancel button is pressed (or dialog is closed)
Definition json.hpp:4471