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
178long
179GNEFileSelector::onUpdNewFolder(FXObject* sender, FXSelector, void*) {
180 // check if directory is writable
181 const bool writable = FXStat::isWritable(myFileSelector->getDirectory());
182 return sender->handle(this, writable ? FXSEL(SEL_COMMAND, ID_ENABLE) : FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
183}
184
185
186std::vector<std::string>
188 std::vector<std::string> files;
189 for (int i = 0; i < myFileSelector->getNumItems(); i++) {
190 if (myFileSelector->isItemSelected(i) && (myFileSelector->getItemFilename(i) != "..") && (myFileSelector->getItemFilename(i) != ".")) {
191 files.push_back(myFileSelector->getItemPathname(i).text());
192 }
193 }
194 return files;
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->isItemDirectory(i)) {
203 files.push_back(myFileSelector->getItemPathname(i).text());
204 }
205 }
206 return files;
207}
208
209
210long
211GNEFileSelector::onCmdCopy(FXObject*, FXSelector, void*) {
212 const auto filenameList = getSelectedFiles();
213 // first check if we have files to copy
214 if (filenameList.size() > 0) {
215 // get only first filename
216 const std::string originFilePath = filenameList.front();
217 // create default destiny filename
218 std::string destinyFilename = FXPath::absolute(FXPath::directory(originFilePath.c_str()), "CopyOf" + FXPath::name(originFilePath.c_str())).text();
219 // create file path dialog
220 const auto filePathDialog = new GNEFilePathDialog(myFileDialog->getApplicationWindow(), TL("Copy File"), TL("Select destiny file"), destinyFilename);
221 // continue depending of filePathDialog results
222 if (filePathDialog->getResult() == GNEDialog::Result::ACCEPT) {
223 // get destiny filename from dialog
224 destinyFilename = filePathDialog->getFilePath();
225 // check if we selected the same file
226 if (FXFile::identical(originFilePath.c_str(), destinyFilename.c_str())) {
227 // open error dialog
229 TLF("Unable to copy file:\n%\n", destinyFilename),
230 TL("The source and destiny files are the same"));
231 } else {
232 // check if file exist
233 if (FXStat::exists(destinyFilename.c_str())) {
234 // open question dialog
236 TL("Overwrite file"), TLF("The destiny file:\n%\n", destinyFilename),
237 TL("already exist. Overwrite?"));
238 // check if abort
239 if (overwriteDialog.getResult() != GNEDialog::Result::ACCEPT) {
240 return 1;
241 }
242 }
243 // try to copy overwritten
244 if (!FXFile::copyFiles(originFilePath.c_str(), destinyFilename.c_str(), TRUE)) {
245 // open error dialog
247 TLF("Unable to copy file:\n%\n", destinyFilename),
248 TL("Check destiny file permissions"));
249 }
250 }
251 }
252 }
253 return 1;
254}
255
256
257long
258GNEFileSelector::onCmdMove(FXObject*, FXSelector, void*) {
259 const auto filenameList = getSelectedFiles();
260 // first check if we have files to move
261 if (filenameList.size() > 0) {
262 // get only first filename
263 const std::string originFilePath = filenameList.front();
264 // create file path dialog
265 const auto filePathDialog = new GNEFilePathDialog(myFileDialog->getApplicationWindow(), TL("Move File"), TL("Select destiny file"), originFilePath);
266 // continue depending of filePathDialog results
267 if (filePathDialog->getResult() == GNEDialog::Result::ACCEPT) {
268 // get destiny filename from dialog
269 const std::string destinyFilename = filePathDialog->getFilePath();
270 // check if we selected the same file
271 if (FXFile::identical(originFilePath.c_str(), destinyFilename.c_str())) {
272 // open error dialog
274 TLF("Unable to move file:\n%\n", destinyFilename),
275 TL("The source and destiny files are the same"));
276 } else {
277 // check if file exist
278 if (FXStat::exists(destinyFilename.c_str())) {
279 // open question dialog
281 TL("Overwrite file"), TLF("The destiny file:\n%\n", destinyFilename),
282 TL("already exist. Overwrite?"));
283 // check if abort
284 if (overwriteDialog.getResult() != GNEDialog::Result::ACCEPT) {
285 return 1;
286 }
287 }
288 // try to move overwritten
289 if (!FXFile::moveFiles(originFilePath.c_str(), destinyFilename.c_str(), TRUE)) {
290 // open error dialog
292 TLF("Unable to move file:\n%\n", destinyFilename),
293 TL("Check destiny file permissions"));
294 }
295 }
296 }
297 }
298 return 1;
299}
300
301
302long
303GNEFileSelector::onCmdDelete(FXObject*, FXSelector, void*) {
304 const auto filenameList = getSelectedFiles();
305 // first check if we have files to link
306 if (filenameList.size() > 0) {
307 // get only first filename
308 const std::string fileToDelete = filenameList.front();
309 // open question dialog
311 TL("Deleting file"), TL("Are you sure you want to delete the file:"),
312 fileToDelete);
313 // check if continue
314 if (askDialog.getResult() == GNEDialog::Result::ACCEPT) {
315 // try to remove it
316 if (!FXFile::removeFiles(fileToDelete.c_str(), TRUE)) {
317 // open error dialog
318 GNEErrorBasicDialog(myFileDialog->getApplicationWindow(), TL("Error deleting file"),
319 TLF("Unable to delete file:\n%\n", fileToDelete),
320 TL("Check file permissions"));
321 }
322 }
323 }
324 return 1;
325}
326
327
328long
329GNEFileSelector::onUpdSelected(FXObject* sender, FXSelector, void*) {
330 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
331 if (myFileSelector->isItemSelected(i)) {
332 sender->handle(this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
333 return 1;
334 }
335 }
336 sender->handle(this, FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
337 return 1;
338}
339
340
341long
342GNEFileSelector::onCmdImageSize(FXObject*, FXSelector sel, void*) {
343 switch (FXSELID(sel)) {
344 case FXFileSelector::ID_NORMAL_SIZE:
345 setImageSize(32);
346 break;
347 case FXFileSelector::ID_MEDIUM_SIZE:
348 setImageSize(48);
349 break;
350 case FXFileSelector::ID_GIANT_SIZE:
351 setImageSize(64);
352 break;
353 }
354 return 1;
355}
356
357
358long
359GNEFileSelector::onUpdImageSize(FXObject* sender, FXSelector sel, void*) {
360 FXbool check = FALSE;
361 switch (FXSELID(sel)) {
362 case FXFileSelector::ID_NORMAL_SIZE:
363 check = (getImageSize() == 32);
364 break;
365 case FXFileSelector::ID_MEDIUM_SIZE:
366 check = (getImageSize() == 48);
367 break;
368 case FXFileSelector::ID_GIANT_SIZE:
369 check = (getImageSize() == 64);
370 break;
371 }
372 sender->handle(this, check ? FXSEL(SEL_COMMAND, ID_CHECK) : FXSEL(SEL_COMMAND, ID_UNCHECK), NULL);
373 return 1;
374}
375
376
377long
378GNEFileSelector::onKeyPress(FXObject* obj, FXSelector sel, void* ptr) {
379 // if ESC key is pressed, close dialog aborting
380 FXEvent* event = (FXEvent*)ptr;
381 if (event->code == KEY_Return) {
382 return onCmdAccept(obj, sel, ptr);
383 } else {
384 return FXVerticalFrame::onKeyPress(obj, sel, ptr);
385 }
386}
387
388
389long
390GNEFileSelector::onPopupMenu(FXObject*, FXSelector, void* ptr) {
391 FXEvent* event = (FXEvent*)ptr;
392 if (event->moved) {
393 return 1;
394 }
395
396 FXMenuPane filemenu(this);
397 new FXMenuCommand(&filemenu, TL("Up one level"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_DIRUP_ICON), this, FXFileSelector::ID_DIRECTORY_UP);
398 new FXMenuCommand(&filemenu, TL("Home directory"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_HOME), this, FXFileSelector::ID_HOME);
399 new FXMenuCommand(&filemenu, TL("Work directory"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_WORK), this, FXFileSelector::ID_WORK);
400 auto configDirectory = new FXMenuCommand(&filemenu, TL("Config directory"), nullptr, this, MID_GNE_BUTTON_CONFIG);
401 // disable if configuration file is empty
402 if (OptionsCont::getOptions().getString("configuration-file").empty()) {
403 configDirectory->disable();
404 }
405 // set icon and tip depending of config type
407 configDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::NETEDIT_MINI));
408 } else {
409 configDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI));
410 }
411 new FXMenuCommand(&filemenu, TL("Select all"), NULL, myFileSelector, FXFileList::ID_SELECT_ALL);
412 new FXMenuSeparator(&filemenu);
413
414 FXMenuPane sortmenu(this);
415 new FXMenuCascade(&filemenu, TL("Sort by"), NULL, &sortmenu);
416 new FXMenuRadio(&sortmenu, TL("Name"), myFileSelector, FXFileList::ID_SORT_BY_NAME);
417 new FXMenuRadio(&sortmenu, TL("Type"), myFileSelector, FXFileList::ID_SORT_BY_TYPE);
418 new FXMenuRadio(&sortmenu, TL("Size"), myFileSelector, FXFileList::ID_SORT_BY_SIZE);
419 new FXMenuRadio(&sortmenu, TL("Time"), myFileSelector, FXFileList::ID_SORT_BY_TIME);
420 new FXMenuRadio(&sortmenu, TL("User"), myFileSelector, FXFileList::ID_SORT_BY_USER);
421 new FXMenuRadio(&sortmenu, TL("Group"), myFileSelector, FXFileList::ID_SORT_BY_GROUP);
422 new FXMenuSeparator(&sortmenu);
423 new FXMenuCheck(&sortmenu, TL("Reverse"), myFileSelector, FXFileList::ID_SORT_REVERSE);
424 new FXMenuCheck(&sortmenu, TL("Ignore case"), myFileSelector, FXFileList::ID_SORT_CASE);
425
426 FXMenuPane viewmenu(this);
427 new FXMenuCascade(&filemenu, TL("View"), NULL, &viewmenu);
428 new FXMenuRadio(&viewmenu, TL("Small icons"), myFileSelector, FXFileList::ID_SHOW_MINI_ICONS);
429 new FXMenuRadio(&viewmenu, TL("Big icons"), myFileSelector, FXFileList::ID_SHOW_BIG_ICONS);
430 new FXMenuRadio(&viewmenu, TL("Details"), myFileSelector, FXFileList::ID_SHOW_DETAILS);
431 new FXMenuSeparator(&viewmenu);
432 new FXMenuRadio(&viewmenu, TL("Rows"), myFileSelector, FXFileList::ID_ARRANGE_BY_ROWS);
433 new FXMenuRadio(&viewmenu, TL("Columns"), myFileSelector, FXFileList::ID_ARRANGE_BY_COLUMNS);
434 new FXMenuSeparator(&viewmenu);
435 new FXMenuCheck(&viewmenu, TL("Hidden files"), myFileSelector, FXFileList::ID_TOGGLE_HIDDEN);
436 new FXMenuCheck(&viewmenu, TL("Preview images"), myFileSelector, FXFileList::ID_TOGGLE_IMAGES);
437 new FXMenuSeparator(&viewmenu);
438 new FXMenuRadio(&viewmenu, TL("Normal images"), this, FXFileSelector::ID_NORMAL_SIZE);
439 new FXMenuRadio(&viewmenu, TL("Medium images"), this, FXFileSelector::ID_MEDIUM_SIZE);
440 new FXMenuRadio(&viewmenu, TL("Giant images"), this, FXFileSelector::ID_GIANT_SIZE);
441
442 FXMenuPane bookmenu(this);
443 FXMenuCascade* bookcasc = new FXMenuCascade(&filemenu, TL("Bookmarks"), NULL, &bookmenu);
444 bookcasc->setTarget(this);
445 bookcasc->setSelector(FXFileSelector::ID_BOOKMENU);
446 new FXMenuCommand(&bookmenu, TL("Set bookmark"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_SET), this, FXFileSelector::ID_BOOKMARK);
447 new FXMenuCommand(&bookmenu, TL("Clear bookmarks"), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_CLR), &myBookmarksRecentFiles, FXRecentFiles::ID_CLEAR);
448 FXMenuSeparator* sep1 = new FXMenuSeparator(&bookmenu);
449 sep1->setTarget(&myBookmarksRecentFiles);
450 sep1->setSelector(FXRecentFiles::ID_ANYFILES);
451 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_1);
452 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_2);
453 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_3);
454 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_4);
455 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_5);
456 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_6);
457 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_7);
458 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_8);
459 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_9);
460 new FXMenuCommand(&bookmenu, FXString::null, NULL, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_10);
461
462 new FXMenuSeparator(&filemenu);
463 new FXMenuCommand(&filemenu, TL("New directory..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FOLDER_NEW), this, FXFileSelector::ID_NEW);
464 new FXMenuCommand(&filemenu, TL("Copy..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FILE_COPY), this, FXFileSelector::ID_COPY);
465 new FXMenuCommand(&filemenu, TL("Move..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FILE_MOVE), this, FXFileSelector::ID_MOVE);
466 // disabled linker because it doesn't work
467 new FXMenuCommand(&filemenu, TL("Delete..."), GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FILE_DELETE), this, FXFileSelector::ID_DELETE);
468
469 filemenu.create();
470 filemenu.popup(NULL, event->root_x, event->root_y);
471 getApp()->runModalWhileShown(&filemenu);
472 return 1;
473}
474
475
476long
477GNEFileSelector::onCmdFilter(FXObject*, FXSelector, void* ptr) {
478 const FXString pat = FXFileSelector::patternFromText((FXchar*)ptr);
479 myFileSelector->setPattern(pat);
481 FXString ext = FXFileSelector::extensionFromPattern(pat);
482 if (!ext.empty()) {
483 FXString name = FXPath::stripExtension(myFilenameTextField->getText());
484 if (!name.empty()) {
485 myFilenameTextField->setText(name + "." + ext);
486 }
487 }
488 }
489 return 1;
490}
491
492
493void
494GNEFileSelector::setDirectory(const FXString& path) {
495 const FXString abspath = FXPath::absolute(path);
496 myFileSelector->setDirectory(abspath);
497 myDirBox->setDirectory(abspath);
499 myFilenameTextField->setText(FXString::null);
500 }
501}
502
503
504void
505GNEFileSelector::setFilename(const FXString& path) {
506 const FXString fullname(FXPath::absolute(path));
507 FXString name(FXPath::name(fullname));
508 myFileSelector->setCurrentFile(fullname);
509 myDirBox->setDirectory(myFileSelector->getDirectory());
511}
512
513
514std::string
517 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
518 if (myFileSelector->isItemSelected(i) && !myFileSelector->isItemDirectory(i)) {
519 return FXPath::absolute(myFileSelector->getDirectory(), myFileSelector->getItemFilename(i)).text();
520 }
521 }
522 } else if (!myFilenameTextField->getText().empty()) {
523 //return FXPath::absolute(myFileSelector->getDirectory(),myFilenameTextField->getText());
524 return FXPath::absolute(myFileSelector->getDirectory(), FXPath::expand(myFilenameTextField->getText())).text(); // FIXME don't always want to expand!
525 }
526 return "";
527}
528
529
530std::vector<std::string>
534
535
536std::string
538 return myFileSelector->getDirectory().text();
539}
540
541
542const std::vector<std::string>&
546
547
548void
550 myFileSelector->setItemSpace(s);
551}
552
553
554FXint
556 return myFileSelector->getItemSpace();
557}
558
559
560void
562 myFileSelector->setListStyle((myFileSelector->getListStyle() & ~FILESTYLEMASK) | (style & FILESTYLEMASK));
563}
564
565
566FXuint
568 return myFileSelector->getListStyle()&FILESTYLEMASK;
569}
570
571
572void
574 myFileSelector->setMatchMode(mode);
575}
576
577
578FXuint
580 return myFileSelector->getMatchMode();
581}
582
583
584FXbool
586 return myFileSelector->showHiddenFiles();
587}
588
589
590void
592 myFileSelector->showHiddenFiles(showing);
593}
594
595
596FXbool
598 return myFileSelector->showImages();
599}
600
601
602void
604 myFileSelector->showImages(showing);
605}
606
607
608FXint
610 return myFileSelector->getImageSize();
611}
612
613
614void
616 myFileSelector->setImageSize(size);
617}
618
619
624
625
626long
627GNEFileSelector::onCmdItemSelected(FXObject*, FXSelector, void* ptr) {
628 const FXint index = (FXint)(FXival)ptr;
629 FXString text, file;
631 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
632 if (myFileSelector->isItemSelected(i) && !myFileSelector->isItemDirectory(i)) {
633 if (!text.empty()) {
634 text += ' ';
635 }
636 text += "\"" + myFileSelector->getItemFilename(i) + "\"";
637 }
638 }
641 if (myFileSelector->isItemDirectory(index)) {
642 text = myFileSelector->getItemFilename(index);
644 }
645 } else {
646 if (!myFileSelector->isItemDirectory(index)) {
647 text = myFileSelector->getItemFilename(index);
649 }
650 }
651 return 1;
652}
653
654
655long
656GNEFileSelector::onCmdItemDeselected(FXObject*, FXSelector, void*) {
657 FXString text, file;
659 for (FXint i = 0; i < myFileSelector->getNumItems(); i++) {
660 if (myFileSelector->isItemSelected(i) && !myFileSelector->isItemDirectory(i)) {
661 if (!text.empty()) {
662 text += ' ';
663 }
664 text += "\"" + myFileSelector->getItemFilename(i) + "\"";
665 }
666 }
668 }
669 return 1;
670}
671
672
673long
674GNEFileSelector::onCmdItemDoubleClicked(FXObject* obj, FXSelector sel, void* ptr) {
675 const FXint index = (FXint)(FXival)ptr;
676 if (0 <= index) {
677 // If directory, open the directory
678 if (myFileSelector->isItemShare(index) || myFileSelector->isItemDirectory(index)) {
679 setDirectory(myFileSelector->getItemPathname(index));
680 return 1;
681 }
682 // Only return if we wanted a file
684 return myFileDialog->onCmdAccept(obj, sel, ptr);
685 }
686 }
687 return 1;
688}
689
690
691long
692GNEFileSelector::onCmdAccept(FXObject* obj, FXSelector sel, void* ptr) {
693 // Get (first) myFilenameTextField or directory
694 std::string path = getFilename();
695 // Only do something if a selection was made
696 if (path.size() > 0) {
697 // Is directory?
698 if (FXStat::isDirectory(path.c_str())) {
699 // In directory mode:- we got our answer!
701 return myFileDialog->onCmdAccept(obj, sel, ptr);
702 }
703 // Hop over to that directory
704 myDirBox->setDirectory(path.c_str());
705 myFileSelector->setDirectory(path.c_str());
706 myFilenameTextField->setText(FXString::null);
707 return 1;
708 }
709 // Get directory part of path
710 FXString dir = FXPath::directory(path.c_str());
711 // In file mode, directory part of path should exist
712 if (FXStat::isDirectory(dir)) {
713 // In any mode, existing directory part is good enough
715 return myFileDialog->onCmdAccept(obj, sel, ptr);
716 }
717 // Otherwise, the whole myFilenameTextField must exist and be a file
718 if (FXStat::exists(path.c_str())) {
719 return myFileDialog->onCmdAccept(obj, sel, ptr);
720
721 }
722 }
723 // Go up to the lowest directory which still exists
724 while (!FXPath::isTopDirectory(dir) && !FXStat::isDirectory(dir)) {
725 dir = FXPath::upLevel(dir);
726 }
727 // Switch as far as we could go
728 myDirBox->setDirectory(dir);
729 myFileSelector->setDirectory(dir);
730 // Put the tail end back for further editing
731 FXASSERT(dir.length() <= (int)path.size());
732 if (ISPATHSEP(path[dir.length()])) {
733 path.erase(0, dir.length() + 1);
734 } else {
735 path.erase(0, dir.length());
736 }
737 // Replace text box with new stuff
738 myFilenameTextField->setText(path.c_str());
740 }
741 // Beep
742 getApp()->beep();
743 return 1;
744}
745
746
747long
748GNEFileSelector::onCmdDirectoryUp(FXObject*, FXSelector, void*) {
749 setDirectory(FXPath::upLevel(myFileSelector->getDirectory()));
750 return 1;
751}
752
753
754long
755GNEFileSelector::onUpdDirectoryUp(FXObject* sender, FXSelector, void*) {
756 // check if this is a top directory
757 const bool topDirectory = FXPath::isTopDirectory(myFileSelector->getDirectory());
758 return sender->handle(this, topDirectory ? FXSEL(SEL_COMMAND, ID_DISABLE) : FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
759}
760
761
762long
763GNEFileSelector::onCmdHomeFolder(FXObject*, FXSelector, void*) {
764 setDirectory(FXSystem::getHomeDirectory());
765 return 1;
766}
767
768
769long
770GNEFileSelector::onCmdWorkFolder(FXObject*, FXSelector, void*) {
771 setDirectory(FXSystem::getCurrentDirectory());
772 return 1;
773}
774
775
776long
777GNEFileSelector::onCmdConfigFolder(FXObject*, FXSelector, void*) {
778 // get config file folder
779 const auto configFileFolder = FXPath::directory(OptionsCont::getOptions().getString("configuration-file").c_str());
780 setDirectory(configFileFolder);
781 return 1;
782}
783
784
785long
786GNEFileSelector::onCmdVisit(FXObject*, FXSelector, void* ptr) {
787 setDirectory((FXchar*)ptr);
788 return 1;
789}
790
791
792long
793GNEFileSelector::onCmdBookmark(FXObject*, FXSelector, void*) {
794 myBookmarksRecentFiles.appendFile(myFileSelector->getDirectory());
795 return 1;
796}
797
798
799long
800GNEFileSelector::onCmdDirTree(FXObject*, FXSelector, void* ptr) {
801 myFileSelector->setDirectory((FXchar*)ptr);
803 myFilenameTextField->setText(FXString::null);
804 }
805 return 1;
806}
807
808
809long
810GNEFileSelector::onCmdNewFolder(FXObject*, FXSelector, void*) {
811 // create file path dialog
812 const auto filePathDialog = new GNEFilePathDialog(myFileDialog->getApplicationWindow(), TL("Create New Directory"), TL("Create new directory with name:"), "DirectoryName");
813 // continue depending of filePathDialog results
814 if (filePathDialog->getResult() == GNEDialog::Result::ACCEPT) {
815 const FXString dirname = FXPath::absolute(myFileSelector->getDirectory(), filePathDialog->getFilePath().c_str());
816 // check if exist
817 if (FXStat::exists(dirname)) {
818 // open error dialog
819 GNEErrorBasicDialog(myFileDialog->getApplicationWindow(), TL("Directory already Exists"),
820 TLF("The new directory:\n%", dirname.text()),
821 TL("already exists"));
822 return 1;
823 }
824 // try to create it
825 if (!FXDir::create(dirname)) {
826 // open error dialog
827 GNEErrorBasicDialog(myFileDialog->getApplicationWindow(), TL("Cannot create directory"),
828 TLF("Cannot create directory:\n%", dirname.text()),
829 TL("Check folder permissions"));
830 return 1;
831 }
832 // set as current directory
833 setDirectory(dirname);
834 }
835 return 1;
836}
837
838
839void
840GNEFileSelector::buildBookmarkMenuPane(FXHorizontalFrame* navigatorHorizontalFrame) {
841 // create bookmarks menu pane
842 myBookmarkMenuPane = new FXMenuPane(this, POPUP_SHRINKWRAP);
843 new FXMenuCommand(myBookmarkMenuPane, (TL("Set bookmark") + std::string("\t\t") + TL("Bookmark current directory.")).c_str(),
844 GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_SET), this, FXFileSelector::ID_BOOKMARK);
845 new FXMenuCommand(myBookmarkMenuPane, (TL("Clear bookmarks") + std::string("\t\t") + TL("Clear bookmarks.")).c_str(),
847 FXMenuSeparator* separator = new FXMenuSeparator(myBookmarkMenuPane);
848 separator->setTarget(&myBookmarksRecentFiles);
849 separator->setSelector(FXRecentFiles::ID_ANYFILES);
850 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_1);
851 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_2);
852 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_3);
853 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_4);
854 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_5);
855 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_6);
856 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_7);
857 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_8);
858 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_9);
859 new FXMenuCommand(myBookmarkMenuPane, FXString::null, nullptr, &myBookmarksRecentFiles, FXRecentFiles::ID_FILE_10);
860 new FXFrame(navigatorHorizontalFrame, LAYOUT_FIX_WIDTH, 0, 0, 4, 1);
861 myBookmarksRecentFiles.setTarget(this);
862 myBookmarksRecentFiles.setSelector(FXFileSelector::ID_VISIT);
863}
864
865
866void
867GNEFileSelector::buildButtons(FXHorizontalFrame* navigatorHorizontalFrame, MFXStaticToolTip* staticTooltipMenu) {
868 // create button for going up one directory
869 auto goUpButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_DIRUP_ICON),
870 this, FXFileSelector::ID_DIRECTORY_UP, GUIDesignButtonIconFileDialog);
871 goUpButton->setTipText(TL("Go up one directory"));
872 // create button for go to home directory
873 auto goHomeButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_HOME),
874 this, FXFileSelector::ID_HOME, GUIDesignButtonIconFileDialog);
875 goHomeButton->setTipText(TL("Go to home directory"));
876 // create button for go to work directory
877 auto goWorkDirectory = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_GOTO_WORK),
878 this, FXFileSelector::ID_WORK, GUIDesignButtonIconFileDialog);
879 goWorkDirectory->setTipText(TL("Go to work directory"));
880 // create button for go to work directory
881 auto goConfigDirectory = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", nullptr,
883 // disable if configuration file is empty
884 if (OptionsCont::getOptions().getString("configuration-file").empty()) {
885 goConfigDirectory->disable();
886 }
887 // set icon and tip depending of config type
889 goConfigDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::NETEDIT_MINI));
890 goConfigDirectory->setTipText(TL("Go to netedit config directory"));
891 } else {
892 goConfigDirectory->setIcon(GUIIconSubSys::getIcon(GUIIcon::SUMO_MINI));
893 goConfigDirectory->setTipText(TL("Go to sumo config directory"));
894 }
895 // create button for bookmarks menu
896 auto bookmenuTooltip = new MFXMenuButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_BOOK_SET),
898 bookmenuTooltip->setTipText(TL("Bookmarks"));
899 bookmenuTooltip->setSelector(FXFileSelector::ID_BOOKMENU);
900 // create button for creating a new directory
901 auto newDirectoryButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_FOLDER_NEW),
902 this, FXFileSelector::ID_NEW, GUIDesignButtonIconFileDialog);
903 newDirectoryButton->setTipText(TL("Create new directory"));
904 // create button for show lists
905 auto showListButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_SHOW_SMALLICONS),
906 myFileSelector, FXFileList::ID_SHOW_MINI_ICONS, GUIDesignButtonIconFileDialog);
907 showListButton->setTipText(TL("Display directory with small icons"));
908 // create button for show icons
909 auto showIconsButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_SHOW_BIGICONS),
910 myFileSelector, FXFileList::ID_SHOW_BIG_ICONS, GUIDesignButtonIconFileDialog);
911 showIconsButton->setTipText(TL("Display directory with big icons"));
912 // create button for show details
913 auto showDetailsButton = new MFXButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", GUIIconSubSys::getIcon(GUIIcon::FILEDIALOG_SHOW_DETAILS),
914 myFileSelector, FXFileList::ID_SHOW_DETAILS, GUIDesignButtonIconFileDialog);
915 showDetailsButton->setTipText(TL("Display detailed directory listing"));
916 // create button for toogle show/hide hidden files
917 auto showHiddeToogleButton = new MFXToggleButtonTooltip(navigatorHorizontalFrame, staticTooltipMenu, "", "",
920 myFileSelector, FXFileList::ID_TOGGLE_HIDDEN, GUIDesignButtonIconFileDialog);
921 showHiddeToogleButton->setTipText(TL("Toggle show hidden files and directories"));
922}
923
924
925void
927 // set shortcuts
928 FXAccelTable* table = getShell()->getAccelTable();
929 if (table) {
930 table->addAccel(MKUINT(KEY_BackSpace, 0), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_DIRECTORY_UP));
931 table->addAccel(MKUINT(KEY_Delete, 0), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_DELETE));
932 table->addAccel(MKUINT(KEY_h, CONTROLMASK), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_HOME));
933 table->addAccel(MKUINT(KEY_w, CONTROLMASK), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_WORK));
934 table->addAccel(MKUINT(KEY_n, CONTROLMASK), this, FXSEL(SEL_COMMAND, FXFileSelector::ID_NEW));
935 table->addAccel(MKUINT(KEY_a, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SELECT_ALL));
936 table->addAccel(MKUINT(KEY_b, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SHOW_BIG_ICONS));
937 table->addAccel(MKUINT(KEY_s, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SHOW_MINI_ICONS));
938 table->addAccel(MKUINT(KEY_l, CONTROLMASK), myFileSelector, FXSEL(SEL_COMMAND, FXFileList::ID_SHOW_DETAILS));
939 }
940}
941
942
943void
944GNEFileSelector::parseExtensions(const std::vector<std::string>& extensions) {
945 // convert extensions in FXString
946 for (const auto& extension : extensions) {
947 // first get all characters within () excluding spaces
948 const std::string cleanExtension = FXFileSelector::patternFromText(extension.c_str()).text();
949 // declare subextensions
950 std::vector<std::string> subExtensions;
951 // now subdivide
952 if (cleanExtension != "*") {
953 // split extensions
954 const auto subExtensionsStr = StringTokenizer(cleanExtension, ",").getVector();
955 for (const auto& subExtensionStr : subExtensionsStr) {
956 // ignore first *
957 subExtensions.push_back(subExtensionStr.substr(1));
958 }
959 }
960 myExtensions.push_back(subExtensions);
961 }
962}
963
964/*******************************************************************************/
FXDEFMAP(GNEFileSelector) GNEFileSelectorMap[]
#define FILELISTMASK
#define FILESTYLEMASK
@ MID_GNE_SET_ATTRIBUTE
attribute edited
Definition GUIAppEnum.h:991
@ 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:305
#define TLF(string,...)
Definition MsgHandler.h:307
GNEApplicationWindow * getApplicationWindow() const
get pointer to the application window
Definition GNEDialog.cpp:93
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
Return 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.
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.
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.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXint getCurrentItem() const
Get the current item's index.
MFXStaticToolTip (based on FXToolTip)
FXString getText() const
Get the text for this label.
FXbool selectAll()
Select all text.
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