Audacity 3.2.0
Classes | Functions
FileDialog.h File Reference
#include <wx/filedlg.h>
#include "gtk/FileDialogPrivate.h"
Include dependency graph for FileDialog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FileDialogBase
 

Functions

WX_WRAPPERS_API wxString FileSelector (const wxString &message=wxFileSelectorPromptStr, const wxString &default_path=wxEmptyString, const wxString &default_filename=wxEmptyString, const wxString &default_extension=wxEmptyString, const wxString &wildcard=wxFileSelectorDefaultWildcardStr, int flags=0, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
 
WX_WRAPPERS_API wxString FileSelectorEx (const wxString &message=wxFileSelectorPromptStr, const wxString &default_path=wxEmptyString, const wxString &default_filename=wxEmptyString, int *indexDefaultExtension=NULL, const wxString &wildcard=wxFileSelectorDefaultWildcardStr, int flags=0, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
 

Function Documentation

◆ FileSelector()

WX_WRAPPERS_API wxString FileSelector ( const wxString &  message = wxFileSelectorPromptStr,
const wxString &  default_path = wxEmptyString,
const wxString &  default_filename = wxEmptyString,
const wxString &  default_extension = wxEmptyString,
const wxString &  wildcard = wxFileSelectorDefaultWildcardStr,
int  flags = 0,
wxWindow *  parent = NULL,
int  x = wxDefaultCoord,
int  y = wxDefaultCoord 
)

Definition at line 61 of file FileDialog.cpp.

69{
70 // The defaultExtension, if non-empty, is
71 // appended to the filename if the user fails to type an extension. The new
72 // implementation (taken from FileSelectorEx) appends the extension
73 // automatically, by looking at the filter specification. In fact this
74 // should be better than the native Microsoft implementation because
75 // Windows only allows *one* default extension, whereas here we do the
76 // right thing depending on the filter the user has chosen.
77
78 // If there's a default extension specified but no filter, we create a
79 // suitable filter.
80
81 wxString filter2;
82 if ( !defaultExtension.empty() && filter.empty() )
83 filter2 = wxString(wxT("*.")) + defaultExtension;
84 else if ( !filter.empty() )
85 filter2 = filter;
86
87 FileDialog fileDialog(parent, title, defaultDir,
88 defaultFileName, filter2,
89 flags, wxPoint(x, y));
90
91 // if filter is of form "All files (*)|*|..." set correct filter index
92 if ( !defaultExtension.empty() && filter2.find(wxT('|')) != wxString::npos )
93 {
94 int filterIndex = 0;
95
96 wxArrayString descriptions, filters;
97 // don't care about errors, handled already by FileDialog
98 (void)wxParseCommonDialogsFilter(filter2, descriptions, filters);
99 for (size_t n=0; n<filters.GetCount(); n++)
100 {
101 if (filters[n].Contains(defaultExtension))
102 {
103 filterIndex = n;
104 break;
105 }
106 }
107
108 if (filterIndex > 0)
109 fileDialog.SetFilterIndex(filterIndex);
110 }
111
112 wxString filename;
113 if ( fileDialog.ShowModal() == wxID_OK )
114 {
115 filename = fileDialog.GetPath();
116 }
117
118 return filename;
119}
wxT("CloseDown"))
static const auto title
Dialog used to present platform specific "Save As" dialog with custom controls.
constexpr size_t npos(-1)

References FileDialog::GetPath(), Tuple::detail::npos(), FileDialog::SetFilterIndex(), FileDialog::ShowModal(), title, and wxT().

Referenced by SelectFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FileSelectorEx()

WX_WRAPPERS_API wxString FileSelectorEx ( const wxString &  message = wxFileSelectorPromptStr,
const wxString &  default_path = wxEmptyString,
const wxString &  default_filename = wxEmptyString,
int *  indexDefaultExtension = NULL,
const wxString &  wildcard = wxFileSelectorDefaultWildcardStr,
int  flags = 0,
wxWindow *  parent = NULL,
int  x = wxDefaultCoord,
int  y = wxDefaultCoord 
)

Definition at line 125 of file FileDialog.cpp.

135{
136 FileDialog fileDialog(parent,
137 title,
138 defaultDir,
139 defaultFileName,
140 filter,
141 flags, wxPoint(x, y));
142
143 wxString filename;
144 if ( fileDialog.ShowModal() == wxID_OK )
145 {
146 if ( defaultFilterIndex )
147 *defaultFilterIndex = fileDialog.GetFilterIndex();
148
149 filename = fileDialog.GetPath();
150 }
151
152 return filename;
153}

References FileDialog::GetFilterIndex(), FileDialog::GetPath(), FileDialog::ShowModal(), and title.

Here is the call graph for this function: