From 050fabe3b9ecbf3fd55b64ebbe542b8d88a407b7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 5 Mar 2014 16:29:46 +0000 Subject: [PATCH] Add wxFD_NO_FOLLOW style for wxFileDialog. This style tells the dialog to return the paths of the link being selected without dereferencing it. Currently only implemented under wxMSW as the links are not dereferenced by default in wxGTK anyhow. But we may want to change this and implement it there too for consistency in the future. Closes #15429. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76085 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/filedlg.h | 1 + interface/wx/filedlg.h | 8 ++++++++ samples/dialogs/dialogs.cpp | 2 +- src/msw/filedlg.cpp | 3 +++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 844c881935..eaa1f2a749 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -26,6 +26,7 @@ All: All (GUI): - XRC handler for wxAuiToolBar added (Kinaou Hervé, David Hart). +- Add wxFD_NO_FOLLOW style for wxFileDialog (Luca Bacci). - Add support for embedding bitmaps in generated SVG in wxSVGFileDC (iwbnwif). - Add support for sorting wxDataViewCtrl by multiple columns (Trigve). - Add wxHtmlWindow::SetDefaultHTMLCursor() (Jeff A. Marr). diff --git a/include/wx/filedlg.h b/include/wx/filedlg.h index 1df6ec620b..deed9d1e15 100644 --- a/include/wx/filedlg.h +++ b/include/wx/filedlg.h @@ -43,6 +43,7 @@ enum wxFD_OPEN = 0x0001, wxFD_SAVE = 0x0002, wxFD_OVERWRITE_PROMPT = 0x0004, + wxFD_NO_FOLLOW = 0x0008, wxFD_FILE_MUST_EXIST = 0x0010, wxFD_MULTIPLE = 0x0020, wxFD_CHANGE_DIR = 0x0080, diff --git a/interface/wx/filedlg.h b/interface/wx/filedlg.h index 92ac23c70c..9591dd52be 100644 --- a/interface/wx/filedlg.h +++ b/interface/wx/filedlg.h @@ -10,6 +10,7 @@ enum wxFD_OPEN = 0x0001, wxFD_SAVE = 0x0002, wxFD_OVERWRITE_PROMPT = 0x0004, + wxFD_NO_FOLLOW = 0x0008, wxFD_FILE_MUST_EXIST = 0x0010, wxFD_MULTIPLE = 0x0020, wxFD_CHANGE_DIR = 0x0080, @@ -119,6 +120,13 @@ const char wxFileSelectorDefaultWildcardStr[]; @style{wxFD_OVERWRITE_PROMPT} For save dialog only: prompt for a confirmation if a file will be overwritten. + @style{wxFD_NO_FOLLOW} + Directs the dialog to return the path and file name of the selected + shortcut file, not its target as it does by default. Currently this + flag is only implemented in wxMSW and the non-dereferenced link path + is always returned, even without this flag, under Unix and so using + it there doesn't do anything. This flag was added in wxWidgets + 3.1.0. @style{wxFD_FILE_MUST_EXIST} For open dialog only: the user may only select files that actually exist. Notice that under OS X the file dialog with @c wxFD_OPEN diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 331f61c59a..e73ad27d3c 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -1444,7 +1444,7 @@ void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) ) wxFileSelectorDefaultWildcardStr, wxFileSelectorDefaultWildcardStr ), - wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW, + wxFD_OPEN|wxFD_CHANGE_DIR|wxFD_PREVIEW|wxFD_NO_FOLLOW, this ); diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index 15db452bae..12d0414ee5 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -497,6 +497,9 @@ int wxFileDialog::ShowModal() long msw_flags = OFN_HIDEREADONLY; + if ( HasFdFlag(wxFD_NO_FOLLOW) ) + msw_flags |= OFN_NODEREFERENCELINKS; + if ( HasFdFlag(wxFD_FILE_MUST_EXIST) ) msw_flags |= OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; /*