X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/41fecb4451682f11e352fc5b9b7383f6335322a7..c9b3918ae42b774d5194b2e5006c4b53d8ed106e:/src/generic/filedlgg.cpp diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 3d7e58d701..87eab5073c 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -409,8 +409,8 @@ wxFileData::wxFileData( const wxString &name, const wxString &fname ) } #endif - struct stat buff; - wxStat( m_fileName.fn_str(), &buff ); + wxStructStat buff; + wxStat( m_fileName, &buff ); #if defined(__UNIX__) && (!defined( __EMX__ ) && !defined(__VMS)) struct stat lbuff; @@ -437,10 +437,21 @@ wxFileData::wxFileData( const wxString &name, const wxString &fname ) m_year = t->tm_year; m_year += 1900; - m_permissions.sprintf( wxT("%c%c%c"), - ((( buff.st_mode & S_IRUSR ) == S_IRUSR ) ? wxT('r') : wxT('-')), - ((( buff.st_mode & S_IWUSR ) == S_IWUSR ) ? wxT('w') : wxT('-')), - ((( buff.st_mode & S_IXUSR ) == S_IXUSR ) ? wxT('x') : wxT('-')) ); + char buffer[10]; + sprintf( buffer, "%c%c%c", + ((( buff.st_mode & S_IRUSR ) == S_IRUSR ) ? 'r' : '-'), + ((( buff.st_mode & S_IWUSR ) == S_IWUSR ) ? 'w' : '-'), + ((( buff.st_mode & S_IXUSR ) == S_IXUSR ) ? 'x' : '-') ); +#if wxUSE_UNICODE + m_permissions = wxConvUTF8.cMB2WC( buffer ); +#else + m_permissions = buffer; +#endif + +// m_permissions.sprintf( wxT("%c%c%c"), +// ((( buff.st_mode & S_IRUSR ) == S_IRUSR ) ? wxT('r') : wxT('-')), +// ((( buff.st_mode & S_IWUSR ) == S_IWUSR ) ? wxT('w') : wxT('-')), +// ((( buff.st_mode & S_IXUSR ) == S_IXUSR ) ? wxT('x') : wxT('-')) ); } wxString wxFileData::GetName() const @@ -1211,6 +1222,14 @@ wxFileDialog::~wxFileDialog() } } +void wxFileDialog::SetFilterIndex( int filterindex ) +{ + m_choice->SetSelection( filterindex ); + wxCommandEvent event; + event.SetInt( filterindex ); + OnChoice( event ); +} + void wxFileDialog::OnChoice( wxCommandEvent &event ) { int index = (int)event.GetInt(); @@ -1540,39 +1559,53 @@ wxString wxFileSelector( const wxChar *title, } } -wxString wxLoadFileSelector( const wxChar *what, const wxChar *ext, const wxChar *default_name, wxWindow *parent ) +static wxString GetWildcardString(const wxChar *ext) { - wxString prompt = wxString::Format(_("Load %s file"), what); - - if (*ext == wxT('.')) - ext++; + wxString wild; + if ( ext ) + { + if ( *ext == wxT('.') ) + ext++; - wxString wild = wxString::Format(_T("*.%s"), ext); + wild << _T("*.") << ext; + } + else // no extension specified + { + wild = wxFileSelectorDefaultWildcardStr; + } - return wxFileSelector(prompt, (const wxChar *) NULL, default_name, - ext, wild, 0, parent); + return wild; } -wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name, - wxWindow *parent ) +wxString wxLoadFileSelector(const wxChar *what, + const wxChar *ext, + const wxChar *nameDef, + wxWindow *parent) { - wxChar *ext = (wxChar *)extension; - - wxString prompt = wxString::Format(_("Save %s file"), what); - - if (*ext == wxT('.')) - ext++; - - wxString wild = wxString::Format(_T("*.%s"), ext); + wxString prompt; + if ( what && *what ) + prompt = wxString::Format(_("Load %s file"), what); + else + prompt = _("Load file"); - return wxFileSelector(prompt, (const wxChar *) NULL, default_name, - ext, wild, 0, parent); + return wxFileSelector(prompt, NULL, nameDef, ext, + GetWildcardString(ext), 0, parent); } +wxString wxSaveFileSelector(const wxChar *what, + const wxChar *ext, + const wxChar *nameDef, + wxWindow *parent) +{ + wxString prompt; + if ( what && *what ) + prompt = wxString::Format(_("Save %s file"), what); + else + prompt = _("Save file"); - - - + return wxFileSelector(prompt, NULL, nameDef, ext, + GetWildcardString(ext), 0, parent); +} // A module to allow icons table cleanup