Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEFileSelector.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// widget used for file selection
19/****************************************************************************/
20
21#include <fxkeys.h>
30
31#include "GNEFilePathDialog.h"
32#include "GNEFileSelector.h"
33
34#define FILELISTMASK (ICONLIST_EXTENDEDSELECT|ICONLIST_SINGLESELECT|ICONLIST_BROWSESELECT|ICONLIST_MULTIPLESELECT)
35#define FILESTYLEMASK (ICONLIST_DETAILED|ICONLIST_MINI_ICONS|ICONLIST_BIG_ICONS|ICONLIST_ROWS|ICONLIST_COLUMNS|ICONLIST_AUTOSIZE)
36
37// ===========================================================================
38// FOX callback mapping
39// ===========================================================================
40
41// Map
42FXDEFMAP(GNEFileSelector) GNEFileSelectorMap[] = {
43 // interaction
44 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_ACCEPT, GNEFileSelector::onCmdAccept),
45 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_FILEFILTER, GNEFileSelector::onCmdFilter),
46 FXMAPFUNC(SEL_DOUBLECLICKED, FXFileSelector::ID_FILELIST, GNEFileSelector::onCmdItemDoubleClicked),
47 FXMAPFUNC(SEL_SELECTED, FXFileSelector::ID_FILELIST, GNEFileSelector::onCmdItemSelected),
48 FXMAPFUNC(SEL_DESELECTED, FXFileSelector::ID_FILELIST, GNEFileSelector::onCmdItemDeselected),
49 FXMAPFUNC(SEL_RIGHTBUTTONRELEASE, FXFileSelector::ID_FILELIST, GNEFileSelector::onPopupMenu),
50 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_DIRECTORY_UP, GNEFileSelector::onCmdDirectoryUp),
51 FXMAPFUNC(SEL_UPDATE, FXFileSelector::ID_DIRECTORY_UP, GNEFileSelector::onUpdDirectoryUp),
52 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_DIRTREE, GNEFileSelector::onCmdDirTree),
53 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_HOME, GNEFileSelector::onCmdHomeFolder),
54 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_WORK, GNEFileSelector::onCmdWorkFolder),
55 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_VISIT, GNEFileSelector::onCmdVisit),
56 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_BOOKMARK, GNEFileSelector::onCmdBookmark),
57 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_NEW, GNEFileSelector::onCmdNewFolder),
58 FXMAPFUNC(SEL_UPDATE, FXFileSelector::ID_NEW, GNEFileSelector::onUpdNewFolder),
59 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_DELETE, GNEFileSelector::onCmdDelete),
60 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_MOVE, GNEFileSelector::onCmdMove),
61 FXMAPFUNC(SEL_COMMAND, FXFileSelector::ID_COPY, GNEFileSelector::onCmdCopy),
62 FXMAPFUNC(SEL_UPDATE, FXFileSelector::ID_COPY, GNEFileSelector::onUpdSelected),
63 FXMAPFUNC(SEL_UPDATE, FXFileSelector::ID_MOVE, GNEFileSelector::onUpdSelected),
64 FXMAPFUNC(SEL_UPDATE, FXFileSelector::ID_DELETE, GNEFileSelector::onUpdSelected),
65 FXMAPFUNCS(SEL_COMMAND, FXFileSelector::ID_NORMAL_SIZE, FXFileSelector::ID_GIANT_SIZE, GNEFileSelector::onCmdImageSize),
66 FXMAPFUNCS(SEL_UPDATE, FXFileSelector::ID_NORMAL_SIZE, FXFileSelector::ID_GIANT_SIZE, GNEFileSelector::onUpdImageSize),
67 FXMAPFUNC(SEL_KEYPRESS, 0, GNEFileSelector::onKeyPress),
69};
70
71// Implementation
72FXIMPLEMENT(GNEFileSelector, FXVerticalFrame, GNEFileSelectorMap, ARRAYNUMBER(GNEFileSelectorMap))
73
74// ===========================================================================
75// member method definitions
76// ===========================================================================
77
78GNEFileSelector::GNEFileSelector(GNEFileDialog* fileDialog, const std::vector<std::string>& extensions,
79 GNEFileDialog::OpenMode openMode, GNEFileDialog::ConfigType configType):
80 FXVerticalFrame(fileDialog->getContentFrame(), GUIDesignAuxiliarFrame),
81 myFileDialog(fileDialog),
82 myOpenMode(openMode),
83 myConfigType(configType),
84 myBookmarksRecentFiles(fileDialog->getApplicationWindow()->getApp(), TL("Visited Directories")) {
85 // get static tooltip
86 const auto tooltipMenu = fileDialog->getApplicationWindow()->getStaticTooltipMenu();
87 // create horizontal frame for top buttons
88 auto navigatorHorizontalFrame = new FXHorizontalFrame(this, GUIDesignDialogContentHorizontalFrame);
89 // create two horizontal frame for file selector
90 auto externFileboxframe = new FXHorizontalFrame(this, GUIDesignDialogContentFrame);
91 auto fileboxframe = new FXHorizontalFrame(externFileboxframe, GUIDesignFileBoxFrame);
92 // horizontal frame for filename
93 auto filenameHorizontalFrame = new FXHorizontalFrame(this, GUIDesignDialogContentHorizontalFrame);
94 // first create file selector
95 myFileSelector = new FXFileList(fileboxframe, this, FXFileSelector::ID_FILELIST, GUIDesignFileList);
96 // label for directory
97 new FXLabel(navigatorHorizontalFrame, TL("Directory:"), nullptr, GUIDesignLabelFixed(100));
98 // create directory box
99 myDirBox = new FXDirBox(navigatorHorizontalFrame, this, FXFileSelector::ID_DIRTREE, GUIDesignDirBox);
100 myDirBox->setNumVisible(5);
101 myDirBox->setAssociations(myFileSelector->getAssociations());
102 // build bookmark menu pane
103 buildBookmarkMenuPane(navigatorHorizontalFrame);
104 // build buttons
105 buildButtons(navigatorHorizontalFrame, tooltipMenu);
106 // create label for filename
107 new FXLabel(filenameHorizontalFrame,
108 TL("File Name:"),
109 nullptr, GUIDesignLabelFixed(100));
110 // create filename text field and set focus
111 myFilenameTextField = new MFXTextFieldIcon(filenameHorizontalFrame, tooltipMenu, GUIIcon::EMPTY,
113 // create comboBox for file filter
114 myFileFilterComboBox = new MFXComboBoxIcon(filenameHorizontalFrame, tooltipMenu, false, GUIDesignComboBoxVisibleItems,
115 this, FXFileSelector::ID_FILEFILTER, GUIDesignComboBoxFileDialog);
116 // build shortcuts
117 buildShortcuts();
118 // continue depending of open mode
119 switch (myOpenMode) {
121 myFileSelector->showOnlyDirectories(FALSE);
122 myFileSelector->setListStyle((myFileSelector->getListStyle() & ~FILELISTMASK) | ICONLIST_BROWSESELECT);
123 break;
125 myFileSelector->showOnlyDirectories(FALSE);
126 myFileSelector->setListStyle((myFileSelector->getListStyle() & ~FILELISTMASK) | ICONLIST_BROWSESELECT);
127 break;
129 myFileSelector->showOnlyDirectories(FALSE);
130 myFileSelector->setListStyle((myFileSelector->getListStyle() & ~FILELISTMASK) | ICONLIST_EXTENDEDSELECT);
131 break;
133 myFileSelector->showOnlyDirectories(TRUE);
134 myFileSelector->setListStyle((myFileSelector->getListStyle() & ~FILELISTMASK) | ICONLIST_BROWSESELECT);
135 break;
136 default:
137 throw ProcessError("Invalid open mode");
138 }
139 // set directory
140 if (gCurrentFolder.length() != 0) {
141 setDirectory(gCurrentFolder);
142 } else {
143 setDirectory(FXSystem::getCurrentDirectory());
144 }
145 // set extensions
146 if (extensions.size() == 0) {
147 throw ProcessError("At least one extension is needed");
148 } else {
149 for (const auto& extension : extensions) {
150 myFileFilterComboBox->appendIconItem(extension.c_str());
151 }
152 }
153 myFileFilterComboBox->setNumVisible(FXMIN((int)extensions.size(), 12));
154 // parse extensions
155 parseExtensions(extensions);
156 // apply first filter
157 myFileSelector->setPattern(FXFileSelector::patternFromText(extensions.front().c_str()));
158}
159
160
162 FXAccelTable* table = getShell()->getAccelTable();
163 if (table) {
164 table->removeAccel(MKUINT(KEY_BackSpace, 0));
165 table->removeAccel(MKUINT(KEY_Delete, 0));
166 table->removeAccel(MKUINT(KEY_h, CONTROLMASK));
167 table->removeAccel(MKUINT(KEY_w, CONTROLMASK));
168 table->removeAccel(MKUINT(KEY_n, CONTROLMASK));
169 table->removeAccel(MKUINT(KEY_a, CONTROLMASK));
170 table->removeAccel(MKUINT(KEY_b, CONTROLMASK));
171 table->removeAccel(MKUINT(KEY_s, CONTROLMASK));
172 table->removeAccel(MKUINT(KEY_l, CONTROLMASK));
173 }
174 delete myBookmarkMenuPane;
175}
176
177
178void
179GNEFileSelector::setPath(const std::string& path) {
180 myFilenameTextField->setText(path.c_str(), TRUE);
181}
182
183
184void
187}
188
189
190long
191GNEFileSelector::onUpdNewFolder(FXObject* sender, FXSelector, void*) {
192 // check if directory is writable
193 const bool writable = FXStat::isWritable(myFileSelector->getDirectory());
194 return sender->handle(this, writable ? FXSEL(SEL_COMMAND, ID_ENABLE) : FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
195}
196
197
198std::vector<std::string>
200 std::vector<std::string> files;
201 for (int i = 0; i < myFileSelector->getNumItems(); i++) {
202 if (myFileSelector->isItemSelected(i) && (myFileSelector->getItemFilename(i) != "..") && (myFileSelector->getItemFilename(i) != ".")) {
203 files.push_back(myFileSelector->getItemPathname(i).text());
204 }
205 }
206 return files;
207}
208
209
210std::vector<std::string>
212 std::vector<std::string> files;
213 for (int i = 0; i < myFileSelector->getNumItems(); i++) {
214 if (myFileSelector->isItemSelected(i) && !myFileSelector->isItemDirectory(i)) {
215 files.push_back(myFileSelector->getItemPathname(i).text());
216 }
217 }
218 return files;
219}
220
221
222long
223GNEFileSelector::onCmdCopy(FXObject*, FXSelector, void*) {
224 const auto filenameList = getSelectedFiles();
225 // first check if we have files to copy
226 if (filenameList.size() > 0) {
227 // get only first filename
228 const std::string originFilePath = filenameList.front();
229 // create default destiny filename
230 std::string destinyFilename = FXPath::absolute(FXPath::directory(originFilePath.c_str()), "CopyOf" + FXPath::name(originFilePath.c_str())).text();
231 // create file path dialog
232 const auto filePathDialog = new GNEFilePathDialog(myFileDialog->getApplicationWindow(), TL("Copy File"), TL("Select destination file"), destinyFilename);
233 // continue depending of filePathDialog results
234 if (filePathDialog->getResult() == GNEDialog::Result::ACCEPT) {
235 // get destiny filename from dialog
236 destinyFilename = filePathDialog->getFilePath();
237 // check if we selected the same file
238 if (FXFile::identical(originFilePath.c_str(), destinyFilename.c_str())) {
239 // open error dialog
241 TLF("Unable to copy file: %", destinyFilename),
242 TL("The source and destination files are the same"));
243 } else {
244 // check if file exist
245 if (FXStat::exists(destinyFilename.c_str())) {
246 // open question dialog
248 TL("Overwrite file"), TLF("The destination file: %", destinyFilename),
249 TL("already exist. Overwrite?"));
250 // check if abort
251 if (overwriteDialog.getResult() != GNEDialog::Result::ACCEPT) {
252 return 1;
253 }
254 }
255 // try to copy overwritten
256 if (!FXFile::copyFiles(originFilePath.c_str(), destinyFilename.c_str(), TRUE)) {
257 // open error dialog
259 TLF("Unable to copy file: %", destinyFilename),
260 TL("Check destination file permissions"));
261 }
262 }
263 }
264 }
265 return 1;
266}
267
268
269long
270GNEFileSelector::onCmdMove(FXObject*, FXSelector, void*) {
271 const auto filenameList = getSelectedFiles();
272 // first check if we have files to move
273 if (filenameList.size() > 0) {
274 // get only first filename
275 const std::string originFilePath = filenameList.front();
276 // create file path dialog
277 const auto filePathDialog = new GNEFilePathDialog(myFileDialog->getApplicationWindow(), TL("Move File"), TL("Select destination file"), originFilePath);
278 // continue depending of filePathDialog results
279 if (filePathDialog->getResult() == GNEDialog::Result::ACCEPT) {
280 // get destiny filename from dialog
281 const std::string destinyFilename = filePathDialog->getFilePath();
282 // check if we selected the same file
283 if (FXFile::identical(originFilePath.c_str(), destinyFilename.c_str())) {
284 // open error dialog
286 TLF("Unable to move file:\n%\n", destinyFilename),
287 TL("The source and destination files are the same"));
288 } else {
289 // check if file exist
290 if (FXStat::exists(destinyFilename.c_str())) {
291 // open question dialog
293 TL("Overwrite file"), TLF("The destination file: %", destinyFilename),
294 TL("already exist. Overwrite?"));
295 // check if abort
296 if (overwriteDialog.getResult() != GNEDialog::Result::ACCEPT) {
297 return 1;
298 }
299 }
300 // try to move overwritten
301 if (!FXFile::moveFiles(originFilePath.c_str(), destinyFilename.c_str(), TRUE)) {
302 // open error dialog
304 TLF("Unable to move file:\n%\n", destinyFilename),
305 TL("Check destination file permissions"));
306 }
307 }
308 }
309 }
310 return 1;
311}
312
313
314long
315GNEFileSelector::onCmdDelete(FXObject*, FXSelector, void*) {
316 const auto filenameList = getSelectedFiles();
317 // first check if we have files to link
318 if (filenameList.size() > 0) {
319 // get only first filename
320 const std::string fileToDelete = filenameList.front();
321 // open question dialog
323 TL("Deleting file"), TL("Are you sure you want to delete the file:"),
324 fileToDelete);
325 // check if continue
326 if (askDialog.getResult() == GNEDialog::Result::ACCEPT) {
327 // try to remove it
328 if (!FXFile::removeFiles(fileToDelete.c_str(), TRUE)) {
329 // open error dialog
330 GNEErrorBasicDialog(myFileDialog->getApplicationWindow(), TL("Error deleting file"),
331 TLF("Unable to delete file: %", fileToDelete),
332 TL("Check file permissions"));
333 }
334 }
335 }
336 return 1;
337}
338
339
340long
341GNEFileSelector::onUpdSelected(FXObject* sender, FXSelector, void*) {
342 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
343 if (myFileSelector->isItemSelected(i)) {
344 sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
345 return 1;
346 }
347 }
348 sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
349 return 1;
350}
351
352
353long
354GNEFileSelector::onCmdImageSize(FXObject*, FXSelector sel, void*) {
355 switch (FXSELID(sel)) {
356 case FXFileSelector::ID_NORMAL_SIZE:
357 setImageSize(32);
358 break;
359 case FXFileSelector::ID_MEDIUM_SIZE:
360 setImageSize(48);
361 break;
362 case FXFileSelector::ID_GIANT_SIZE:
363 setImageSize(64);
364 break;
365 default:
366 setImageSize(32);
367 break;
368 }
369 return 1;
370}
371
372
373long
374GNEFileSelector::onUpdImageSize(FXObject* sender, FXSelector sel, void*) {
375 FXbool check = FALSE;
376 switch (FXSELID(sel)) {
377 case FXFileSelector::ID_NORMAL_SIZE:
378 check = (getImageSize() == 32);
379 break;
380 case FXFileSelector::ID_MEDIUM_SIZE:
381 check = (getImageSize() == 48);
382 break;
383 case FXFileSelector::ID_GIANT_SIZE:
384 check = (getImageSize() == 64);
385 break;
386 default:
387 check = (getImageSize() == 32);
388 break;
389 }
390 sender->handle(this, check ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
391 return 1;
392}
393
394
395long
396GNEFileSelector::onKeyPress(FXObject* obj, FXSelector sel, void* ptr) {
397 // if ESC key is pressed, close dialog aborting
398 FXEvent* event = (FXEvent*)ptr;
399 if (event->code == KEY_Return) {
400 return onCmdAccept(obj, sel, ptr);
401 } else {
402 return FXVerticalFrame::onKeyPress(obj, sel, ptr);
403 }
404}
405
406
407long
408GNEFileSelector::onPopupMenu(FXObject*, FXSelector, void* ptr) {
409 FXEvent* event = (FXEvent*)ptr;
410 if (event->moved) {
411 return 1;
412 }
413
414 FXMenuPane filemenu(this);
415 new FXMenuCommand(&filemenu, TL("Up one level"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_DIRUP_ICON), this, FXFileSelector::ID_DIRECTORY_UP);
416 new FXMenuCommand(&filemenu, TL("Home directory"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_HOME), this, FXFileSelector::ID_HOME);
417 new FXMenuCommand(&filemenu, TL("Work directory"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_WORK), this, FXFileSelector::ID_WORK);
418 auto configDirectory = new FXMenuCommand(&filemenu, TL("Config directory"), nullptr, this, MID_GNE_BUTTON_CONFIG);
419 // disable if configuration file is empty
420 if (OptionsCont::getOptions().getString("configuration-file").empty()) {
421 configDirectory->disable();
422 }
423 // set icon and tip depending of config type
425 configDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::NETEDIT_MINI));
426 } else {
427 configDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI));
428 }
429 new FXMenuCommand(&filemenu, TL("Select all"), NULL, myFileSelector, FXFileList::ID_SELECT_ALL);
430 new FXMenuSeparator(&filemenu);
431
432 FXMenuPane sortmenu(this);
433 new FXMenuCascade(&filemenu, TL("Sort by"), NULL, &sortmenu);
434 new FXMenuRadio(&sortmenu, TL("Name"), myFileSelector, FXFileList::ID_SORT_BY_NAME);
435 new FXMenuRadio(&sortmenu, TL("Type"), myFileSelector, FXFileList::ID_SORT_BY_TYPE);
436 new FXMenuRadio(&sortmenu, TL("Size"), myFileSelector, FXFileList::ID_SORT_BY_SIZE);
437 new FXMenuRadio(&sortmenu, TL("Time"), myFileSelector, FXFileList::ID_SORT_BY_TIME);
438 new FXMenuRadio(&sortmenu, TL("User"), myFileSelector, FXFileList::ID_SORT_BY_USER);
439 new FXMenuRadio(&sortmenu, TL("Group"), myFileSelector, FXFileList::ID_SORT_BY_GROUP);
440 new FXMenuSeparator(&sortmenu);
441 new FXMenuCheck(&sortmenu, TL("Reverse"), myFileSelector, FXFileList::ID_SORT_REVERSE);
442 new FXMenuCheck(&sortmenu, TL("Ignore case"), myFileSelector, FXFileList::ID_SORT_CASE);
443
444 FXMenuPane viewmenu(this);
445 new FXMenuCascade(&filemenu, TL("View"), NULL, &viewmenu);
446 new FXMenuRadio(&viewmenu, TL("Small icons"), myFileSelector, FXFileList::ID_SHOW_MINI_ICONS);
447 new FXMenuRadio(&viewmenu, TL("Big icons"), myFileSelector, FXFileList::ID_SHOW_BIG_ICONS);
448 new FXMenuRadio(&viewmenu, TL("Details"), myFileSelector, FXFileList::ID_SHOW_DETAILS);
449 new FXMenuSeparator(&viewmenu);
450 new FXMenuRadio(&viewmenu, TL("Rows"), myFileSelector, FXFileList::ID_ARRANGE_BY_ROWS);
451 new FXMenuRadio(&viewmenu, TL("Columns"), myFileSelector, FXFileList::ID_ARRANGE_BY_COLUMNS);
452 new FXMenuSeparator(&viewmenu);
453 new FXMenuCheck(&viewmenu, TL("Hidden files"), myFileSelector, FXFileList::ID_TOGGLE_HIDDEN);
454 new FXMenuCheck(&viewmenu, TL("Preview images"), myFileSelector, FXFileList::ID_TOGGLE_IMAGES);
455 new FXMenuSeparator(&viewmenu);
456 new FXMenuRadio(&viewmenu, TL("Normal images"), this, FXFileSelector::ID_NORMAL_SIZE);
457 new FXMenuRadio(&viewmenu, TL("Medium images"), this, FXFileSelector::ID_MEDIUM_SIZE);
458 new FXMenuRadio(&viewmenu, TL("Giant images"), this, FXFileSelector::ID_GIANT_SIZE);
459
460 FXMenuPane bookmenu(this);
461 FXMenuCascade* bookcasc = new FXMenuCascade(&filemenu, TL("Bookmarks"), NULL, &bookmenu);
462 bookcasc->setTarget(this);
463 bookcasc->setSelector(FXFileSelector::ID_BOOKMENU);
464 new FXMenuCommand(&bookmenu, TL("Set bookmark"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_SET), this, FXFileSelector::ID_BOOKMARK);
465 new FXMenuCommand(&bookmenu, TL("Clear bookmarks"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_CLR), &myBookmarksRecentFiles, FXRecentFiles::ID_CLEAR);
466 FXMenuSeparator* sep1 = new FXMenuSeparator(&bookmenu);
467 sep1->setTarget(&myBookmarksRecentFiles);
468 sep1->setSelector(FXRecentFiles::ID_ANYFILES);
469 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_1);
470 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_2);
471 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_3);
472 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_4);
473 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_5);
474 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_6);
475 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_7);
476 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_8);
477 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_9);
478 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_10);
479
480 new FXMenuSeparator(&filemenu);
481 new FXMenuCommand(&filemenu, TL("New directory..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FOLDER_NEW), this, FXFileSelector::ID_NEW);
482 new FXMenuCommand(&filemenu, TL("Copy..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FILE_COPY), this, FXFileSelector::ID_COPY);
483 new FXMenuCommand(&filemenu, TL("Move..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FILE_MOVE), this, FXFileSelector::ID_MOVE);
484 // disabled linker because it doesn't work
485 new FXMenuCommand(&filemenu, TL("Delete..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FILE_DELETE), this, FXFileSelector::ID_DELETE);
486
487 filemenu.create();
488 filemenu.popup(NULL, event->root_x, event->root_y);
489 getApp()->runModalWhileShown(&filemenu);
490 return 1;
491}
492
493
494long
495GNEFileSelector::onCmdFilter(FXObject*, FXSelector, void* ptr) {
496 const FXString pat = FXFileSelector::patternFromText((FXchar*)ptr);
497 myFileSelector->setPattern(pat);
499 FXString ext = FXFileSelector::extensionFromPattern(pat);
500 if (!ext.empty()) {
501 FXString name = FXPath::stripExtension(myFilenameTextField->getText());
502 if (!name.empty()) {
503 myFilenameTextField->setText(name + "." + ext);
504 }
505 }
506 }
507 return 1;
508}
509
510
511void
512GNEFileSelector::setDirectory(const FXString& path) {
513 const FXString abspath = FXPath::absolute(path);
514 myFileSelector->setDirectory(abspath);
515 myDirBox->setDirectory(abspath);
517 myFilenameTextField->setText(FXString::null);
518 }
519}
520
521
522void
523GNEFileSelector::setFilename(const FXString& path) {
524 const FXString fullname(FXPath::absolute(path));
525 FXString name(FXPath::name(fullname));
526 myFileSelector->setCurrentFile(fullname);
527 myDirBox->setDirectory(myFileSelector->getDirectory());
529}
530
531
532std::string
534 // continue depending if we write something in the text field
535 if (myFilenameTextField->getText().empty()) {
536 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
537 if (myFileSelector->isItemSelected(i) &&
538 !myFileSelector->isItemDirectory(i)) {
539 return FXPath::absolute(myFileSelector->getDirectory(), myFileSelector->getItemFilename(i)).text();
540 }
541 }
542 return "";
543 } else {
544 return FXPath::absolute(myFileSelector->getDirectory(), myFilenameTextField->getText()).text();
545 }
546}
547
548
549std::string
551 // continue depending if we write something in the text field
552 if (myFilenameTextField->getText().empty()) {
553 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
554 if (myFileSelector->isItemSelected(i) &&
555 myFileSelector->isItemDirectory(i)) {
556 return FXPath::absolute(myFileSelector->getDirectory(), myFileSelector->getItemFilename(i)).text();
557 }
558 }
559 } else {
560 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
561 if (myFileSelector->isItemDirectory(i) &&
562 (myFileSelector->getItemFilename(i) == myFilenameTextField->getText())) {
563 return FXPath::absolute(myFileSelector->getDirectory(), myFileSelector->getItemFilename(i)).text();
564 }
565 }
566 }
567 return "";
568}
569
570
571std::vector<std::string>
575
576
577std::string
579 return myFileSelector->getDirectory().text();
580}
581
582
583const std::vector<std::string>&
587
588
589void
591 myFileSelector->setItemSpace(s);
592}
593
594
595FXint
597 return myFileSelector->getItemSpace();
598}
599
600
601void
603 myFileSelector->setListStyle((myFileSelector->getListStyle() & ~FILESTYLEMASK) | (style & FILESTYLEMASK));
604}
605
606
607FXuint
609 return myFileSelector->getListStyle()&FILESTYLEMASK;
610}
611
612
613void
615 myFileSelector->setMatchMode(mode);
616}
617
618
619FXuint
621 return myFileSelector->getMatchMode();
622}
623
624
625FXbool
627 return myFileSelector->showHiddenFiles();
628}
629
630
631void
633 myFileSelector->showHiddenFiles(showing);
634}
635
636
637FXbool
639 return myFileSelector->showImages();
640}
641
642
643void
645 myFileSelector->showImages(showing);
646}
647
648
649FXint
651 return myFileSelector->getImageSize();
652}
653
654
655void
657 myFileSelector->setImageSize(size);
658}
659
660
665
666
667long
668GNEFileSelector::onCmdItemSelected(FXObject*, FXSelector, void* ptr) {
669 const FXint index = (FXint)(FXival)ptr;
670 FXString text, file;
672 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
673 if (myFileSelector->isItemSelected(i) && !myFileSelector->isItemDirectory(i)) {
674 if (!text.empty()) {
675 text += ' ';
676 }
677 text += "\"" + myFileSelector->getItemFilename(i) + "\"";
678 }
679 }
682 if (myFileSelector->isItemDirectory(index)) {
683 text = myFileSelector->getItemFilename(index);
685 }
686 } else {
687 if (!myFileSelector->isItemDirectory(index)) {
688 text = myFileSelector->getItemFilename(index);
690 }
691 }
692 return 1;
693}
694
695
696long
697GNEFileSelector::onCmdItemDeselected(FXObject*, FXSelector, void*) {
698 FXString text, file;
700 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
701 if (myFileSelector->isItemSelected(i) && !myFileSelector->isItemDirectory(i)) {
702 if (!text.empty()) {
703 text += ' ';
704 }
705 text += "\"" + myFileSelector->getItemFilename(i) + "\"";
706 }
707 }
709 }
710 return 1;
711}
712
713
714long
715GNEFileSelector::onCmdItemDoubleClicked(FXObject* obj, FXSelector sel, void* ptr) {
716 const FXint index = (FXint)(FXival)ptr;
717 if (0 <= index) {
718 // If directory, open the directory
719 if (myFileSelector->isItemShare(index) || myFileSelector->isItemDirectory(index)) {
720 setDirectory(myFileSelector->getItemPathname(index));
721 return 1;
722 }
723 // Only return if we wanted a file
725 return onCmdAccept(obj, sel, ptr);
726 }
727 }
728 return 1;
729}
730
731
732long
733GNEFileSelector::onCmdAccept(FXObject* obj, FXSelector sel, void* ptr) {
734 // get directory
735 const std::string directory = getDirectory();
736 // continue if we selected a directory
737 if (directory.size() > 0) {
738 // In directory mode:- we got our answer!
740 return myFileDialog->onCmdAccept(obj, sel, ptr);
741 } else {
742 // Hop over to that directory
743 setDirectory(directory.c_str());
744 myFilenameTextField->setText(FXString::null);
745 return 1;
746 }
747 }
748 // get filename
749 std::string filename = getFilename();
750 // continue if we selected a filename
751 if (filename.size() > 0) {
752 // Get directory part of path
753 FXString dir = FXPath::directory(filename.c_str());
754 // In file mode, directory part of path should exist
755 if (FXStat::isDirectory(dir)) {
756 // ensure that filename has extension
757 const std::string filenameExtension = myFileDialog->assureExtension(filename);
758 const std::string file = FXPath::name(filenameExtension.c_str()).text();
759 // now continue if we're loading or saving
761 // ask if file exist
762 if (FXStat::exists(filenameExtension.c_str())) {
763 // open question dialog
765 TL("Overwrite file"), TLF("The selected file: %", file),
766 TL("already exist. Overwrite?"));
767 // check if abort
768 if (overwriteDialog.getResult() != GNEDialog::Result::ACCEPT) {
769 return 1;
770 }
771 }
772 return myFileDialog->onCmdAccept(obj, sel, ptr);
773 } else {
774 // check that file exist
775 if (FXStat::exists(filenameExtension.c_str())) {
776 return myFileDialog->onCmdAccept(obj, sel, ptr);
777 } else {
778 // open error dialog
780 TL("File doesn't exist"),
781 TLF("The selected file '%'", file),
782 TL("doesn't exist"));
783 return 0;
784 }
785 }
786 }
787 }
788 // Beep
789 getApp()->beep();
790 return 1;
791}
792
793
794long
795GNEFileSelector::onCmdDirectoryUp(FXObject*, FXSelector, void*) {
796 setDirectory(FXPath::upLevel(myFileSelector->getDirectory()));
797 return 1;
798}
799
800
801long
802GNEFileSelector::onUpdDirectoryUp(FXObject* sender, FXSelector, void*) {
803 // check if this is a top directory
804 const bool topDirectory = FXPath::isTopDirectory(myFileSelector->getDirectory());
805 return sender->handle(this, topDirectory ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
806}
807
808
809long
810GNEFileSelector::onCmdHomeFolder(FXObject*, FXSelector, void*) {
811 setDirectory(FXSystem::getHomeDirectory());
812 return 1;
813}
814
815
816long
817GNEFileSelector::onCmdWorkFolder(FXObject*, FXSelector, void*) {
818 setDirectory(FXSystem::getCurrentDirectory());
819 return 1;
820}
821
822
823long
824GNEFileSelector::onCmdConfigFolder(FXObject*, FXSelector, void*) {
825 // get config file folder
826 const auto configFileFolder = FXPath::directory(OptionsCont::getOptions().getString("configuration-file").c_str());
827 setDirectory(configFileFolder);
828 return 1;
829}
830
831
832long
833GNEFileSelector::onCmdVisit(FXObject*, FXSelector, void* ptr) {
834 setDirectory((FXchar*)ptr);
835 return 1;
836}
837
838
839long
840GNEFileSelector::onCmdBookmark(FXObject*, FXSelector, void*) {
841 myBookmarksRecentFiles.appendFile(myFileSelector->getDirectory());
842 return 1;
843}
844
845
846long
847GNEFileSelector::onCmdDirTree(FXObject*, FXSelector, void* ptr) {
848 myFileSelector->setDirectory((FXchar*)ptr);
850 myFilenameTextField->setText(FXString::null);
851 }
852 return 1;
853}
854
855
856long
857GNEFileSelector::onCmdNewFolder(FXObject*, FXSelector, void*) {
858 // create file path dialog
859 const auto filePathDialog = new GNEFilePathDialog(myFileDialog->getApplicationWindow(), TL("Create New Directory"), TL("Create new directory with name:"), "DirectoryName");
860 // continue depending of filePathDialog results
861 if (filePathDialog->getResult() == GNEDialog::Result::ACCEPT) {
862 const FXString dirname = FXPath::absolute(myFileSelector->getDirectory(), filePathDialog->getFilePath().c_str());
863 // check if exist
864 if (FXStat::exists(dirname)) {
865 // open error dialog
866 GNEErrorBasicDialog(myFileDialog->getApplicationWindow(), TL("Directory already Exists"),
867 TLF("The new directory:\n%", dirname.text()),
868 TL("already exists"));
869 return 1;
870 }
871 // try to create it
872 if (!FXDir::create(dirname)) {
873 // open error dialog
874 GNEErrorBasicDialog(myFileDialog->getApplicationWindow(), TL("Cannot create directory"),
875 TLF("Cannot create directory:\n%", dirname.text()),
876 TL("Check folder permissions"));
877 return 1;
878 }
879 // set as current directory
880 setDirectory(dirname);
881 }
882 return 1;
883}
884
885
886void
887GNEFileSelector::buildBookmarkMenuPane(FXHorizontalFrame* navigatorHorizontalFrame) {
888 // create bookmarks menu pane
889 myBookmarkMenuPane = new FXMenuPane(this, POPUP_SHRINKWRAP);
890 new FXMenuCommand(myBookmarkMenuPane, (TL("Set bookmark") + std::string("\t\t") + TL("Bookmark current directory.")).c_str(),
891 GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_SET), this, FXFileSelector::ID_BOOKMARK);
892 new FXMenuCommand(myBookmarkMenuPane, (TL("Clear bookmarks") + std::string("\t\t") + TL("Clear bookmarks.")).c_str(),
894 FXMenuSeparator* separator = new FXMenuSeparator(myBookmarkMenuPane);
895 separator->setTarget(&myBookmarksRecentFiles);
896 separator->setSelector(FXRecentFiles::ID_ANYFILES);
897 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_1);
898 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_2);
899 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_3);
900 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_4);
901 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_5);
902 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_6);
903 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_7);
904 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_8);
905 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_9);
906 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_10);
907 new FXFrame(navigatorHorizontalFrame, LAYOUT_FIX_WIDTH, 0, 0, 4, 1);
908 myBookmarksRecentFiles.setTarget(this);
909 myBookmarksRecentFiles.setSelector(FXFileSelector::ID_VISIT);
910}
911
912
913void
914GNEFileSelector::buildButtons(FXHorizontalFrame* navigatorHorizontalFrame, MFXStaticToolTip* staticTooltipMenu) {
915 // create button for going up one directory
916 auto goUpButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_DIRUP_ICON),
917 this, FXFileSelector::ID_DIRECTORY_UP, GUIDesignButtonIconFileDialog);
918 goUpButton->setTipText(TL("Go up one directory"));
919 // create button for go to home directory
920 auto goHomeButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_HOME),
921 this, FXFileSelector::ID_HOME, GUIDesignButtonIconFileDialog);
922 goHomeButton->setTipText(TL("Go to home directory"));
923 // create button for go to work directory
924 auto goWorkDirectory = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_WORK),
925 this, FXFileSelector::ID_WORK, GUIDesignButtonIconFileDialog);
926 goWorkDirectory->setTipText(TL("Go to work directory"));
927 // create button for go to work directory
928 auto goConfigDirectory = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", nullptr,
930 // disable if configuration file is empty
931 if (OptionsCont::getOptions().getString("configuration-file").empty()) {
932 goConfigDirectory->disable();
933 }
934 // set icon and tip depending of config type
936 goConfigDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::NETEDIT_MINI));
937 goConfigDirectory->setTipText(TL("Go to netedit config directory"));
938 } else {
939 goConfigDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI));
940 goConfigDirectory->setTipText(TL("Go to sumo config directory"));
941 }
942 // create button for bookmarks menu
943 auto bookmenuTooltip = new MFXMenuButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_SET),
945 bookmenuTooltip->setTipText(TL("Bookmarks"));
946 bookmenuTooltip->setSelector(FXFileSelector::ID_BOOKMENU);
947 // create button for creating a new directory
948 auto newDirectoryButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FOLDER_NEW),
949 this, FXFileSelector::ID_NEW, GUIDesignButtonIconFileDialog);
950 newDirectoryButton->setTipText(TL("Create new directory"));
951 // create button for show lists
952 auto showListButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_SHOW_SMALLICONS),
953 myFileSelector, FXFileList::ID_SHOW_MINI_ICONS, GUIDesignButtonIconFileDialog);
954 showListButton->setTipText(TL("Display directory with small icons"));
955 // create button for show icons
956 auto showIconsButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_SHOW_BIGICONS),
957 myFileSelector, FXFileList::ID_SHOW_BIG_ICONS, GUIDesignButtonIconFileDialog);
958 showIconsButton->setTipText(TL("Display directory with big icons"));
959 // create button for show details
960 auto showDetailsButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_SHOW_DETAILS),
961 myFileSelector, FXFileList::ID_SHOW_DETAILS, GUIDesignButtonIconFileDialog);
962 showDetailsButton->setTipText(TL("Display detailed directory listing"));
963 // create button for toogle show/hide hidden files
964 auto showHiddeToogleButton = new MFXToggleButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", "",
967 myFileSelector, FXFileList::ID_TOGGLE_HIDDEN, GUIDesignButtonIconFileDialog);
968 showHiddeToogleButton->setTipText(TL("Toggle show hidden files and directories"));
969}
970
971
972void
974 // set shortcuts
975 FXAccelTable* table = getShell()->getAccelTable();
976 if (table) {
977 table->addAccel(MKUINT(KEY_BackSpace, 0), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_DIRECTORY_UP));
978 table->addAccel(MKUINT(KEY_Delete, 0), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_DELETE));
979 table->addAccel(MKUINT(KEY_h, CONTROLMASK), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_HOME));
980 table->addAccel(MKUINT(KEY_w, CONTROLMASK), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_WORK));
981 table->addAccel(MKUINT(KEY_n, CONTROLMASK), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_NEW));
982 table->addAccel(MKUINT(KEY_a, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SELECT_ALL));
983 table->addAccel(MKUINT(KEY_b, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SHOW_BIG_ICONS));
984 table->addAccel(MKUINT(KEY_s, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SHOW_MINI_ICONS));
985 table->addAccel(MKUINT(KEY_l, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SHOW_DETAILS));
986 }
987}
988
989
990void
991GNEFileSelector::parseExtensions(const std::vector<std::string>& extensions) {
992 // convert extensions in FXString
993 for (const auto& extension : extensions) {
994 // first get all characters within () excluding spaces
995 const std::string cleanExtension = FXFileSelector::patternFromText(extension.c_str()).text();
996 // declare subextensions
997 std::vector<std::string> subExtensions;
998 // now subdivide
999 if (cleanExtension != "*") {
1000 // split extensions
1001 const auto subExtensionsStr = StringTokenizer(cleanExtension, ",").getVector();
1002 for (const auto& subExtensionStr : subExtensionsStr) {
1003 // ignore first *
1004 subExtensions.push_back(subExtensionStr.substr(1));
1005 }
1006 }
1007 myExtensions.push_back(subExtensions);
1008 }
1009}
1010
1011/*******************************************************************************/
FXDEFMAP(GNEFileSelector) GNEFileSelectorMap[]
#define FILELISTMASK
#define FILESTYLEMASK
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition GUIAppEnum.h:993
@ MID_GNE_BUTTON_CONFIG
config button (used in GNEFileDialog)
#define GUIDesignFileBoxFrame
design for filebox frame
Definition GUIDesigns.h:451
#define GUIDesignDialogContentFrame
design for content frame used in dialog
Definition GUIDesigns.h:418
#define GUIDesignLabelFixed(width)
label, icon before text, text centered and custom width
Definition GUIDesigns.h:248
#define GUIDesignDirBox
desing for FXDirBox
Definition GUIDesigns.h:714
#define GUIDesignButtonIconFileDialog
button only with icon
Definition GUIDesigns.h:133
#define GUIDesignDialogContentHorizontalFrame
design for content horizontal frame used in dialog
Definition GUIDesigns.h:421
#define GUIDesignComboBoxVisibleItems
Definition GUIDesigns.h:64
#define GUIDesignFileList
desing for FXDirBox
Definition GUIDesigns.h:711
#define GUIDesignTextFieldFileDialog
text field used in file dialog
Definition GUIDesigns.h:89
#define GUIDesignComboBoxFileDialog
Combo box used in filed dialog.
Definition GUIDesigns.h:313
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frame extended in all directions
Definition GUIDesigns.h:409
FXString gCurrentFolder
The folder used as last.
@ FILEDIALOG_BOOK_SET
@ FILEDIALOG_SHOW_BIGICONS
@ FILEDIALOG_FILE_DELETE
@ NETEDIT_MINI
@ FILEDIALOG_GOTO_WORK
@ FILEDIALOG_FILE_SHOWN
@ FILEDIALOG_FILE_MOVE
@ FILEDIALOG_SHOW_SMALLICONS
@ FILEDIALOG_GOTO_HOME
@ FILEDIALOG_DIRUP_ICON
@ FILEDIALOG_FILE_COPY
@ FILEDIALOG_SHOW_DETAILS
@ FILEDIALOG_BOOK_CLR
icons for file dialogs
@ FILEDIALOG_FOLDER_NEW
@ FILEDIALOG_FILE_HIDDEN
@ KEY_n
@ KEY_s
@ KEY_h
@ KEY_a
@ KEY_b
@ KEY_l
@ KEY_w
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
GNEApplicationWindow * getApplicationWindow() const
get pointer to the application window
std::string assureExtension(const std::string &filename) const
check extensions
long onCmdAccept(FXObject *, FXSelector, void *)
called when accept or yes button is pressed (can be reimplemented in children)
void parseExtensions(const std::vector< std::string > &extensions)
parse extensions from pattern text
std::string getFilename() const
Return file name, if any.
void setFilename(const FXString &path)
Change file name.
long onCmdVisit(FXObject *, FXSelector, void *)
Handler for visiting a bookmarked location.
long onKeyPress(FXObject *obj, FXSelector sel, void *ptr)
called when user press a key
void setFileBoxStyle(FXuint style)
Change file list style.
FXint getImageSize() const
Return images preview size.
std::string getDirectory() const
get selected directory
GNEFileDialog * myFileDialog
FOX needs this.
FXDirBox * myDirBox
Directory hierarchy list.
long onCmdDelete(FXObject *, FXSelector, void *)
Handler for deleting an item.
long onCmdFilter(FXObject *, FXSelector, void *)
Handler for filtering items.
const std::vector< std::string > & getFileExtension() const
get file extension
long onCmdDirTree(FXObject *, FXSelector, void *)
Handler for directory tree navigation.
long onUpdImageSize(FXObject *, FXSelector, void *)
Update handler for enabling/disabling image size command.
long onCmdItemSelected(FXObject *, FXSelector, void *)
Handler for selecting an item.
std::vector< std::string > getSelectedFiles() const
get selected files
const GNEFileDialog::ConfigType myConfigType
config type
std::vector< std::vector< std::string > > myExtensions
extensions
std::vector< std::string > getFilenames() const
get file names
FXint getItemSpace() const
Return the inter-item spacing (in pixels)
const GNEFileDialog::OpenMode myOpenMode
open mode
virtual ~GNEFileSelector()
Destructor.
MFXComboBoxIcon * myFileFilterComboBox
Combobox for pattern list.
long onCmdDirectoryUp(FXObject *, FXSelector, void *)
Handler for moving up one directory.
void setDirectory(const FXString &path)
Change directory.
long onCmdNewFolder(FXObject *, FXSelector, void *)
Handler for creating a new item or directory.
FXFileList * myFileSelector
File list widget.
void buildShortcuts()
build shortcuts
MFXTextFieldIcon * getFilenameTextField() const
get file name entry field
long onCmdItemDoubleClicked(FXObject *obj, FXSelector sel, void *ptr)
Handler for double-clicking an item.
long onCmdCopy(FXObject *, FXSelector, void *)
Handler for copying an item.
void setPath(const std::string &path)
set path (either file or directory, used for testing)
FXbool showHiddenFiles() const
Return TRUE if showing hidden files.
long onCmdMove(FXObject *, FXSelector, void *)
Handler for moving an item.
FXuint getFileBoxStyle() const
Return file list style.
long onUpdDirectoryUp(FXObject *, FXSelector, void *)
Update handler for enabling/disabling directory up command.
long onCmdHomeFolder(FXObject *, FXSelector, void *)
Handler for navigating to the home directory.
long onCmdWorkFolder(FXObject *, FXSelector, void *)
Handler for navigating to the work directory.
long onCmdItemDeselected(FXObject *, FXSelector, void *)
Handler for deselecting an item.
std::string getCurrentDirectory() const
Return current directory.
long onCmdAccept(FXObject *, FXSelector, void *)
Handler for accepting a command.
std::vector< std::string > getSelectedFilesOnly() const
get selected files that are not directories
void setMatchMode(FXuint mode)
Change wildcard matching mode.
long onPopupMenu(FXObject *, FXSelector, void *)
Handler for showing the popup menu.
MFXTextFieldIcon * myFilenameTextField
File name entry field.
FXMenuPane * myBookmarkMenuPane
Menu for myBookmarksRecentFiles.
long onCmdConfigFolder(FXObject *, FXSelector, void *)
Handler for navigating to the sumo/netedit config directory.
FXbool showImages() const
Return TRUE if image preview on.
long onUpdNewFolder(FXObject *, FXSelector, void *)
Update handler for enabling/disabling new command.
long onUpdSelected(FXObject *, FXSelector, void *)
Update handler for enabling/disabling commands based on selection.
void setImageSize(FXint size)
Change images preview size.
long onCmdBookmark(FXObject *, FXSelector, void *)
Handler for opening myBookmarksRecentFiles.
void buildBookmarkMenuPane(FXHorizontalFrame *navigatorHorizontalFrame)
build bookmarks menu
void setItemSpace(FXint s)
Set the inter-item spacing (in pixels)
long onCmdImageSize(FXObject *, FXSelector, void *)
Handler for showing or calculating image size.
FXuint getMatchMode() const
Return wildcard matching mode.
void buildButtons(FXHorizontalFrame *navigatorHorizontalFrame, MFXStaticToolTip *staticTooltipMenu)
build buttons
FXRecentFiles myBookmarksRecentFiles
Bookmarked places.
void setFilter(const int index)
set file filter (used for testing)
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
long setCurrentItem(const FXint index, FXbool notify=FALSE)
Set the current item (index is zero-based)
FXint getCurrentItem() const
Get the current item's index.
MFXStaticToolTip (based on FXToolTip)
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.
static OptionsCont & getOptions()
Retrieves the options.
std::vector< std::string > getVector()
return vector of strings
Definition json.hpp:4471