Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-2024 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// ===========================================================================
29// FOX callback mapping
30// ===========================================================================
31
32FXDEFMAP(GNEKeepElementsDialog) GNEKeepElementsDialogMap[] = {
34 FXMAPFUNC(SEL_CLOSE, 0, GNEKeepElementsDialog::onCmdCancel),
35};
36
37// Object implementation
38FXIMPLEMENT(GNEKeepElementsDialog, FXDialogBox, GNEKeepElementsDialogMap, ARRAYNUMBER(GNEKeepElementsDialogMap))
39
40// ===========================================================================
41// member method definitions
42// ===========================================================================
43
44// ---------------------------------------------------------------------------
45// GNEKeepElementsDialog - methods
46// ---------------------------------------------------------------------------
47
48GNEKeepElementsDialog::GNEKeepElementsDialog(GNEApplicationWindow* applicationWindow, const std::string elementType) :
49 FXDialogBox(applicationWindow->getApp(), ("Keep " + elementType + " elements").c_str(), GUIDesignDialogBoxExplicit(400, 100)) {
50 // set busStop icon for this dialog
52 // create main frame
53 FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
54 // create label
55 new FXLabel(mainFrame, ("Selected " + elementType + " file was already loaded.\n Keep new or old elements?").c_str(), nullptr, GUIDesignLabelKeepElements);
56 // create buttons centered
57 FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
58 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
59 myKeepNewButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Keep new"), "", TL("Keep news elements"), GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_SELECT, GUIDesignButtonKeepElements);
60 myKeepOldButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Keep old"), "", TL("Keep old elements"), GUIIconSubSys::getIcon(GUIIcon::BACK), this, MID_GNE_SELECT, GUIDesignButtonKeepElements);
61 myCancelButton = GUIDesigns::buildFXButton(buttonsFrame, TL("Cancel"), "", TL("cancel loading of elements"), GUIIconSubSys::getIcon(GUIIcon::CANCEL), this, MID_GNE_SELECT, GUIDesignButtonKeepElements);
62 new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
63 // create Dialog
64 create();
65 // set focus in keep news
66 myKeepNewButton->setFocus();
67 // set accept as
68 // show in the given position
69 show(PLACEMENT_SCREEN);
70 // refresh APP
71 getApp()->refresh();
72 // open as modal dialog (will block all windows until stop() or stopModal() is called)
73 applicationWindow->getApp()->runModalFor(this);
74}
75
76
79
80
85
86
87long
88GNEKeepElementsDialog::onCmdSelectOption(FXObject* obj, FXSelector, void*) {
89 if (obj == myKeepOldButton) {
91 } else if (obj == myKeepNewButton) {
93 }
94 // Stop Modal
95 getApp()->stopModal(this, FALSE);
96 return 1;
97}
98
99long
100GNEKeepElementsDialog::onCmdClose(FXObject*, FXSelector, void*) {
101 // Stop Modal
102 getApp()->stopModal(this, FALSE);
103 return 1;
104}
105
106/****************************************************************************/
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:315
The main window of Netedit.
Dialog for edit rerouters.
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
Definition json.hpp:4471