Eclipse SUMO - Simulation of Urban MObility
GNEUndoListDialog.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 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 for show undo-list
19 /****************************************************************************/
20 #include <config.h>
21 
26 #include <netedit/GNENet.h>
28 #include <netedit/GNEViewNet.h>
29 #include <netedit/GNEUndoList.h>
30 
31 #include "GNEUndoListDialog.h"
32 
33 
34 // ===========================================================================
35 // FOX callback mapping
36 // ===========================================================================
37 
38 FXDEFMAP(GNEUndoListDialog) GNEUndoListDialogMap[] = {
39  FXMAPFUNC(SEL_CLOSE, 0, GNEUndoListDialog::onCmdClose),
42 };
43 
44 // Object implementation
45 FXIMPLEMENT(GNEUndoListDialog, FXTopWindow, GNEUndoListDialogMap, ARRAYNUMBER(GNEUndoListDialogMap))
46 
47 // ===========================================================================
48 // member method definitions
49 // ===========================================================================
50 
52  FXTopWindow(GNEApp->getApp(), "Undo/Redo history", GUIIconSubSys::getIcon(GUIIcon::UNDOLIST), GUIIconSubSys::getIcon(GUIIcon::UNDOLIST), GUIDesignDialogBoxExplicit(300, 400)),
53  myGNEApp(GNEApp) {
54  // create main frame
55  FXVerticalFrame* mainFrame = new FXVerticalFrame(this, GUIDesignAuxiliarFrame);
56  // create treelist dinamic
57  myTreeListDinamic = new FXTreeListDinamic(mainFrame, this, MID_GNE_UNDOLIST_UPDATE, GUIDesignTreeListDinamicExpandHeight);
58  // create buttons centered
59  FXHorizontalFrame* buttonsFrame = new FXHorizontalFrame(mainFrame, GUIDesignHorizontalFrame);
60  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
61  new FXButton(buttonsFrame, "OK\tclose dialog", GUIIconSubSys::getIcon(GUIIcon::ACCEPT), this, MID_GNE_BUTTON_ACCEPT, GUIDesignButtonAccept);
62  new FXHorizontalFrame(buttonsFrame, GUIDesignAuxiliarHorizontalFrame);
63 }
64 
65 
67 
68 
69 void
71  // update table
72  updateList();
73  // show
74  show(PLACEMENT_SCREEN);
75 }
76 
77 
78 void
80  FXTopWindow::hide();
81 }
82 
83 
84 bool
86  return FXWindow::shown();
87 }
88 
89 
90 void
92  FXWindow::setFocus();
93 }
94 
95 
96 long
97 GNEUndoListDialog::onCmdClose(FXObject*, FXSelector, void*) {
98  // just close dialog
99  hide();
100  return 1;
101 }
102 
103 
104 long
105 GNEUndoListDialog::onCmdSelectElement(FXObject*, FXSelector, void*) {
106  // currently unused
107  return 1;
108 }
109 
110 
111 void
113  // first clear myTreeListDinamic
114  myTreeListDinamic->clearItems();
115  // declare iterator over UndoList
117  // fill myTreeListDinamic
118  while (!it.end()) {
119  myTreeListDinamic->insertItem(nullptr, nullptr, it.getDescription().c_str(), it.getIcon(), it.getIcon());
120  it++;
121  }
122 }
123 
124 /****************************************************************************/
FXDEFMAP(GNEUndoListDialog) GNEUndoListDialogMap[]
@ MID_GNE_REROUTEDIALOG_ADD_INTERVAL
add interval
Definition: GUIAppEnum.h:1235
@ MID_GNE_UNDOLIST_UPDATE
update undolist
Definition: GUIAppEnum.h:1304
@ MID_GNE_BUTTON_ACCEPT
accept button
Definition: GUIAppEnum.h:1191
#define GUIDesignDialogBoxExplicit(width, height)
design for dialog box with specift width and height (for example, additional dialogs)
Definition: GUIDesigns.h:539
#define GUIDesignTreeListDinamicExpandHeight
treeListDinamic used in undoList
Definition: GUIDesigns.h:605
#define GUIDesignButtonAccept
Accept Button.
Definition: GUIDesigns.h:127
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
Definition: GUIDesigns.h:343
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
Definition: GUIDesigns.h:340
#define GUIDesignHorizontalFrame
Definition: GUIDesigns.h:293
GUIIcon
An enumeration of icons used by the gui applications.
Definition: GUIIcons.h:33
FXTreeListDinamic.
The main window of the Netedit.
GNEUndoList * getUndoList()
get pointer to undoList
FOX declaration.
Definition: GNEUndoList.h:48
const std::string getDescription() const
get description
Definition: GNEUndoList.cpp:79
bool end() const
check if iterator is at the end
Definition: GNEUndoList.cpp:67
FXIcon * getIcon() const
get icon
Definition: GNEUndoList.cpp:90
Dialog for edit rerouters.
void updateList()
update data table
~GNEUndoListDialog()
destructor
FXTreeListDinamic * myTreeListDinamic
tree list dinamic to show the elements to erase
long onCmdClose(FXObject *, FXSelector, void *)
bool shown() const
shown
void setFocus()
Move the focus to this window.
void hide()
hide window
GNEApplicationWindow * myGNEApp
pointer to GNEApplicationWindow
long onCmdSelectElement(FXObject *, FXSelector, void *)
event after selecting an element in the undoredolist
void open()
open window
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon