X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6264c8e2bd71e325342a5588e8634c6e05d7c5c5..c60122bf37a65f07f517e14a98ce988a3eae8305:/src/mac/carbon/filedlg.cpp diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index 5e129eaf91..1eee666aae 100644 --- a/src/mac/carbon/filedlg.cpp +++ b/src/mac/carbon/filedlg.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: filedlg.cpp +// Name: src/mac/carbon/filedlg.cpp // Purpose: wxFileDialog // Author: Stefan Csomor // Modified by: @@ -11,27 +11,29 @@ #include "wx/wxprec.h" -#include "wx/app.h" -#include "wx/utils.h" -#include "wx/dialog.h" +#if wxUSE_FILEDLG + #include "wx/filedlg.h" -#include "wx/intl.h" + +#ifndef WX_PRECOMP + #include "wx/intl.h" + #include "wx/app.h" + #include "wx/utils.h" + #include "wx/dialog.h" +#endif + #include "wx/tokenzr.h" #include "wx/filename.h" #include "wx/mac/private.h" #ifndef __DARWIN__ - #include - #include "PLStringFuncs.h" + #include + #include "PLStringFuncs.h" #endif -#include "MoreFilesX.h" - IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase) -extern bool gUseNavServices; - // the data we need to pass to our standard file hook routine // includes a pointer to the dialog, a pointer to the standard // file reply record (so we can inspect the current selection) @@ -70,14 +72,14 @@ static pascal void NavEventProc( } else if ( inSelector == kNavCBStart ) { - if (data && !(data->defaultLocation).IsEmpty()) + if (data && !(data->defaultLocation).empty()) { // Set default location for the modern Navigation APIs // Apple Technical Q&A 1151 - FSSpec theFSSpec; - wxMacFilename2FSSpec(data->defaultLocation, &theFSSpec); + FSRef theFile; + wxMacPathToFSRef(data->defaultLocation, &theFile); AEDesc theLocation = { typeNull, NULL }; - if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation)) + if (noErr == ::AECreateDesc(typeFSRef, &theFile, sizeof(FSRef), &theLocation)) ::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation); } @@ -131,7 +133,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) bool isName = true ; wxString current ; - for ( unsigned int i = 0; i < filter2.Len() ; i++ ) + for ( unsigned int i = 0; i < filter2.length() ; i++ ) { if ( filter2.GetChar(i) == wxT('|') ) { @@ -157,7 +159,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) // an explanatory text, in that case the first part is name and extension at the same time wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ; - if ( current.IsEmpty() ) + if ( current.empty() ) myData->extensions.Add( myData->name[filterIndex] ) ; else myData->extensions.Add( current.MakeUpper() ) ; @@ -179,7 +181,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ) // Remove leading '.' if (extension.length() && (extension.GetChar(0) == '.')) extension = extension.Mid( 1 ); - + if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator )) myData->filtermactypes.Add( (OSType)fileType ); else @@ -211,7 +213,7 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR if ( extension.GetChar(0) == '*' ) extension = extension.Mid(1) ; - if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) ) + if ( file.length() >= extension.length() && extension == file.Right(extension.length() ) ) return true ; } } @@ -255,8 +257,8 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, - long style, const wxPoint& pos) - : wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos) + long style, const wxPoint& pos, const wxSize& sz, const wxString& name) + : wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name) { wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ; } @@ -275,16 +277,11 @@ pascal Boolean CrossPlatformFilterCallback( NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ; if ( !theInfo->isFolder ) { - if (theItem->descriptorType == typeFSS) + AECoerceDesc (theItem, typeFSRef, theItem); + + FSRef fsref ; + if ( AEGetDescData (theItem, &fsref, sizeof (FSRef)) == noErr ) { - FSSpec spec; - memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ; - wxString file = wxMacMakeStringFromPascal( spec.name ) ; - display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ; - } - else if ( theItem->descriptorType == typeFSRef ) - { - FSRef fsref ; memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ; wxString file = wxMacFSRefToPath( &fsref ) ; display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ; @@ -315,7 +312,6 @@ int wxFileDialog::ShowModal() NavDialogRef dialog; NavObjectFilterUPP navFilterUPP = NULL; - CFArrayRef cfArray = NULL; // for popupExtension OpenUserDataRec myData; myData.defaultLocation = m_dir; @@ -334,7 +330,7 @@ int wxFileDialog::ShowModal() } } - if (m_dialogStyle & wxSAVE) + if (HasFdFlag(wxFD_SAVE)) { myData.saveMode = true; @@ -348,7 +344,7 @@ int wxFileDialog::ShowModal() dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension; #if TARGET_API_MAC_OSX - if (!(m_dialogStyle & wxOVERWRITE_PROMPT)) + if (!(m_windowStyle & wxFD_OVERWRITE_PROMPT)) dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement; #endif @@ -364,7 +360,7 @@ int wxFileDialog::ShowModal() { // let the user select bundles/programs in dialogs dialogCreateOptions.optionFlags |= kNavSupportPackages; - + navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback); err = ::NavCreateGetFileDialog( &dialogCreateOptions, @@ -382,8 +378,6 @@ int wxFileDialog::ShowModal() // clean up filter related data, etc. if (navFilterUPP) ::DisposeNavObjectFilterUPP(navFilterUPP); - if (cfArray) - ::CFRelease(cfArray); if (err != noErr) return wxID_CANCEL; @@ -409,11 +403,11 @@ int wxFileDialog::ShowModal() if (err != noErr) break; - if (m_dialogStyle & wxSAVE) + if (HasFdFlag(wxFD_SAVE)) thePath = wxMacFSRefToPath( &theFSRef, navReply.saveFileName ); else thePath = wxMacFSRefToPath( &theFSRef ); - + if (!thePath) { ::NavDisposeReply(&navReply); @@ -437,3 +431,5 @@ int wxFileDialog::ShowModal() return (err == noErr) ? wxID_OK : wxID_CANCEL; } +#endif // wxUSE_FILEDLG +