Fixed signed/unsigned warning (GetCount() returns size_t, not int); Slight cosmetic cleanup.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24675 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: filedlg.cpp
|
// Name: filedlg.cpp
|
||||||
// Purpose: wxFileDialog
|
// Purpose: wxFileDialog
|
||||||
// Author: Stefan Csomor
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 1998-01-01
|
// Created: 1998-01-01
|
||||||
@@ -41,7 +41,7 @@ IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
|
|||||||
# include "MoreFiles.h"
|
# include "MoreFiles.h"
|
||||||
# include "MoreFilesExtras.h"
|
# include "MoreFilesExtras.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool gUseNavServices ;
|
extern bool gUseNavServices ;
|
||||||
|
|
||||||
// the data we need to pass to our standard file hook routine
|
// the data we need to pass to our standard file hook routine
|
||||||
@@ -56,7 +56,7 @@ struct OpenUserDataRec {
|
|||||||
wxArrayString name ;
|
wxArrayString name ;
|
||||||
wxArrayString extensions ;
|
wxArrayString extensions ;
|
||||||
wxArrayLong filtermactypes ;
|
wxArrayLong filtermactypes ;
|
||||||
wxString defaultLocation;
|
wxString defaultLocation;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
CFArrayRef menuitems ;
|
CFArrayRef menuitems ;
|
||||||
#else
|
#else
|
||||||
@@ -87,10 +87,10 @@ NavEventProc(
|
|||||||
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
||||||
if (inSelector == kNavCBEvent) {
|
if (inSelector == kNavCBEvent) {
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
#else
|
#else
|
||||||
wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
|
wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if ( inSelector == kNavCBStart )
|
else if ( inSelector == kNavCBStart )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
@@ -124,7 +124,7 @@ NavEventProc(
|
|||||||
wxString extension = data->extensions[i].AfterLast('.') ;
|
wxString extension = data->extensions[i].AfterLast('.') ;
|
||||||
extension.MakeLower() ;
|
extension.MakeLower() ;
|
||||||
wxString sfilename ;
|
wxString sfilename ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
|
wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
|
||||||
sfilename = cfString.AsString() ;
|
sfilename = cfString.AsString() ;
|
||||||
@@ -135,7 +135,7 @@ NavEventProc(
|
|||||||
sfilename = wxMacMakeStringFromPascal( filename ) ;
|
sfilename = wxMacMakeStringFromPascal( filename ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pos = sfilename.Find('.',TRUE) ;
|
int pos = sfilename.Find('.', true) ;
|
||||||
if ( pos != wxNOT_FOUND )
|
if ( pos != wxNOT_FOUND )
|
||||||
{
|
{
|
||||||
sfilename = sfilename.Left(pos+1)+extension ;
|
sfilename = sfilename.Left(pos+1)+extension ;
|
||||||
@@ -157,8 +157,8 @@ const wxChar * gfilters[] =
|
|||||||
wxT("*.TXT") ,
|
wxT("*.TXT") ,
|
||||||
wxT("*.TIF") ,
|
wxT("*.TIF") ,
|
||||||
wxT("*.JPG") ,
|
wxT("*.JPG") ,
|
||||||
|
|
||||||
NULL
|
NULL
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
OSType gfiltersmac[] =
|
OSType gfiltersmac[] =
|
||||||
@@ -166,7 +166,7 @@ OSType gfiltersmac[] =
|
|||||||
'TEXT' ,
|
'TEXT' ,
|
||||||
'TIFF' ,
|
'TIFF' ,
|
||||||
'JPEG' ,
|
'JPEG' ,
|
||||||
|
|
||||||
'****'
|
'****'
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -175,8 +175,8 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
{
|
{
|
||||||
myData->menuitems = NULL ;
|
myData->menuitems = NULL ;
|
||||||
myData->currentfilter = 0 ;
|
myData->currentfilter = 0 ;
|
||||||
myData->saveMode = FALSE ;
|
myData->saveMode = false ;
|
||||||
|
|
||||||
if ( filter && filter[0] )
|
if ( filter && filter[0] )
|
||||||
{
|
{
|
||||||
wxString filter2(filter) ;
|
wxString filter2(filter) ;
|
||||||
@@ -204,7 +204,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
}
|
}
|
||||||
// we allow for compatibility reason to have a single filter expression (like *.*) without
|
// we allow for compatibility reason to have a single filter expression (like *.*) without
|
||||||
// an explanatory text, in that case the first part is name and extension at the same time
|
// 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") ) ;
|
wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ;
|
||||||
if ( current.IsEmpty() )
|
if ( current.IsEmpty() )
|
||||||
myData->extensions.Add( myData->name[filterIndex] ) ;
|
myData->extensions.Add( myData->name[filterIndex] ) ;
|
||||||
@@ -212,9 +212,9 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
myData->extensions.Add( current.MakeUpper() ) ;
|
myData->extensions.Add( current.MakeUpper() ) ;
|
||||||
if ( filterIndex == 0 || isName )
|
if ( filterIndex == 0 || isName )
|
||||||
myData->name.Add( current.MakeUpper() ) ;
|
myData->name.Add( current.MakeUpper() ) ;
|
||||||
|
|
||||||
++filterIndex ;
|
++filterIndex ;
|
||||||
|
|
||||||
const size_t extCount = myData->extensions.GetCount();
|
const size_t extCount = myData->extensions.GetCount();
|
||||||
for ( size_t i = 0 ; i < extCount; i++ )
|
for ( size_t i = 0 ; i < extCount; i++ )
|
||||||
{
|
{
|
||||||
@@ -239,25 +239,25 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
|
|||||||
{
|
{
|
||||||
wxString file(filename) ;
|
wxString file(filename) ;
|
||||||
file.MakeUpper() ;
|
file.MakeUpper() ;
|
||||||
|
|
||||||
if ( data->extensions.GetCount() > 0 )
|
if ( data->extensions.GetCount() > 0 )
|
||||||
{
|
{
|
||||||
//for ( int i = 0 ; i < data->numfilters ; ++i )
|
//for ( int i = 0 ; i < data->numfilters ; ++i )
|
||||||
int i = data->currentfilter ;
|
int i = data->currentfilter ;
|
||||||
if ( data->extensions[i].Right(2) == wxT(".*") )
|
if ( data->extensions[i].Right(2) == wxT(".*") )
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
{
|
{
|
||||||
if ( type == (OSType)data->filtermactypes[i] )
|
if ( type == (OSType)data->filtermactypes[i] )
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ;
|
wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ;
|
||||||
while( tokenizer.HasMoreTokens() )
|
while( tokenizer.HasMoreTokens() )
|
||||||
{
|
{
|
||||||
wxString extension = tokenizer.GetNextToken() ;
|
wxString extension = tokenizer.GetNextToken() ;
|
||||||
if ( extension.GetChar(0) == '*' )
|
if ( extension.GetChar(0) == '*' )
|
||||||
extension = extension.Mid(1) ;
|
extension = extension.Mid(1) ;
|
||||||
|
|
||||||
if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) )
|
if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) )
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -275,22 +275,22 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat
|
|||||||
|
|
||||||
Boolean visibleFlag;
|
Boolean visibleFlag;
|
||||||
Boolean folderFlag;
|
Boolean folderFlag;
|
||||||
|
|
||||||
visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible);
|
visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible);
|
||||||
folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10);
|
folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10);
|
||||||
|
|
||||||
// because the semantics of the filter proc are "true means don't show
|
// because the semantics of the filter proc are "true means don't show
|
||||||
// it" we need to invert the result that we return
|
// it" we need to invert the result that we return
|
||||||
|
|
||||||
if ( !visibleFlag )
|
if ( !visibleFlag )
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
if ( !folderFlag )
|
if ( !folderFlag )
|
||||||
{
|
{
|
||||||
wxString file = wxMacMakeStringFromPascal( myCInfoPBPtr->hFileInfo.ioNamePtr ) ;
|
wxString file = wxMacMakeStringFromPascal( myCInfoPBPtr->hFileInfo.ioNamePtr ) ;
|
||||||
return !CheckFile( file , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ;
|
return !CheckFile( file , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -306,15 +306,15 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pascal Boolean CrossPlatformFilterCallback (
|
pascal Boolean CrossPlatformFilterCallback (
|
||||||
AEDesc *theItem,
|
AEDesc *theItem,
|
||||||
void *info,
|
void *info,
|
||||||
void *callBackUD,
|
void *callBackUD,
|
||||||
NavFilterModes filterMode
|
NavFilterModes filterMode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bool display = true;
|
bool display = true;
|
||||||
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
|
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
|
||||||
|
|
||||||
if (filterMode == kNavFilteringBrowserList)
|
if (filterMode == kNavFilteringBrowserList)
|
||||||
{
|
{
|
||||||
NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
|
NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
|
||||||
@@ -326,7 +326,7 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
||||||
wxString file = wxMacMakeStringFromPascal( spec.name ) ;
|
wxString file = wxMacMakeStringFromPascal( spec.name ) ;
|
||||||
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
else if ( theItem->descriptorType == typeFSRef )
|
else if ( theItem->descriptorType == typeFSRef )
|
||||||
{
|
{
|
||||||
@@ -341,7 +341,7 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,70 +352,71 @@ int wxFileDialog::ShowModal()
|
|||||||
NavDialogCreationOptions dialogCreateOptions;
|
NavDialogCreationOptions dialogCreateOptions;
|
||||||
// set default options
|
// set default options
|
||||||
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
|
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
|
||||||
|
|
||||||
// this was always unset in the old code
|
// this was always unset in the old code
|
||||||
dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
|
dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
// tried using wxMacCFStringHolder in the code below, but it seems
|
// tried using wxMacCFStringHolder in the code below, but it seems
|
||||||
// the CFStrings were being released before the save dialog was called,
|
// the CFStrings were being released before the save dialog was called,
|
||||||
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_message.wc_str(),
|
m_message.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
kCFStringEncodingUnicode);
|
||||||
#else
|
#else
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_message.c_str(),
|
m_message.c_str(),
|
||||||
CFStringGetSystemEncoding());
|
CFStringGetSystemEncoding());
|
||||||
#endif
|
#endif
|
||||||
dialogCreateOptions.windowTitle = titleRef;
|
dialogCreateOptions.windowTitle = titleRef;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_fileName.wc_str(),
|
m_fileName.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
kCFStringEncodingUnicode);
|
||||||
#else
|
#else
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_fileName.c_str(),
|
m_fileName.c_str(),
|
||||||
CFStringGetSystemEncoding());
|
CFStringGetSystemEncoding());
|
||||||
#endif
|
#endif
|
||||||
dialogCreateOptions.saveFileName = defaultFileNameRef;
|
dialogCreateOptions.saveFileName = defaultFileNameRef;
|
||||||
NavDialogRef dialog;
|
NavDialogRef dialog;
|
||||||
NavObjectFilterUPP navFilterUPP = NULL;
|
NavObjectFilterUPP navFilterUPP = NULL;
|
||||||
CFArrayRef cfArray = NULL; // for popupExtension
|
CFArrayRef cfArray = NULL; // for popupExtension
|
||||||
OpenUserDataRec myData;
|
OpenUserDataRec myData;
|
||||||
myData.defaultLocation = m_dir;
|
myData.defaultLocation = m_dir;
|
||||||
|
|
||||||
if (m_dialogStyle & wxSAVE)
|
if (m_dialogStyle & wxSAVE)
|
||||||
{
|
{
|
||||||
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
|
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
|
||||||
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
|
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
|
||||||
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
|
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
|
||||||
|
|
||||||
// The extension is important
|
// The extension is important
|
||||||
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
|
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
|
||||||
|
|
||||||
|
|
||||||
err = ::NavCreatePutFileDialog(&dialogCreateOptions,
|
err = ::NavCreatePutFileDialog(&dialogCreateOptions,
|
||||||
'TEXT',
|
'TEXT',
|
||||||
'TEXT',
|
'TEXT',
|
||||||
sStandardNavEventFilter,
|
sStandardNavEventFilter,
|
||||||
&myData, // for defaultLocation
|
&myData, // for defaultLocation
|
||||||
&dialog);
|
&dialog);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MakeUserDataRec(&myData , m_wildCard);
|
MakeUserDataRec(&myData , m_wildCard);
|
||||||
int numfilters = myData.extensions.GetCount();
|
size_t numfilters = myData.extensions.GetCount();
|
||||||
if (numfilters > 0){
|
if (numfilters > 0)
|
||||||
CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
|
|
||||||
numfilters , &kCFTypeArrayCallBacks ) ;
|
|
||||||
dialogCreateOptions.popupExtension = popup ;
|
|
||||||
myData.menuitems = dialogCreateOptions.popupExtension ;
|
|
||||||
for ( size_t i = 0 ; i < numfilters ; ++i )
|
|
||||||
{
|
{
|
||||||
CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] ) ) ;
|
CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
|
||||||
}
|
numfilters , &kCFTypeArrayCallBacks ) ;
|
||||||
}
|
dialogCreateOptions.popupExtension = popup ;
|
||||||
|
myData.menuitems = dialogCreateOptions.popupExtension ;
|
||||||
|
for ( size_t i = 0 ; i < numfilters ; ++i )
|
||||||
|
{
|
||||||
|
CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] ) ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
|
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
|
||||||
err = ::NavCreateGetFileDialog(&dialogCreateOptions,
|
err = ::NavCreateGetFileDialog(&dialogCreateOptions,
|
||||||
NULL, // NavTypeListHandle
|
NULL, // NavTypeListHandle
|
||||||
@@ -428,7 +429,7 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
err = ::NavDialogRun(dialog);
|
err = ::NavDialogRun(dialog);
|
||||||
|
|
||||||
// clean up filter related data, etc.
|
// clean up filter related data, etc.
|
||||||
if (navFilterUPP)
|
if (navFilterUPP)
|
||||||
::DisposeNavObjectFilterUPP(navFilterUPP);
|
::DisposeNavObjectFilterUPP(navFilterUPP);
|
||||||
@@ -447,46 +448,46 @@ int wxFileDialog::ShowModal()
|
|||||||
::CFRelease(titleRef);
|
::CFRelease(titleRef);
|
||||||
if (defaultFileNameRef)
|
if (defaultFileNameRef)
|
||||||
::CFRelease(defaultFileNameRef);
|
::CFRelease(defaultFileNameRef);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
|
|
||||||
NavReplyRecord navReply;
|
NavReplyRecord navReply;
|
||||||
err = ::NavDialogGetReply(dialog, &navReply);
|
err = ::NavDialogGetReply(dialog, &navReply);
|
||||||
if (err == noErr && navReply.validRecord)
|
if (err == noErr && navReply.validRecord)
|
||||||
{
|
{
|
||||||
AEKeyword theKeyword;
|
AEKeyword theKeyword;
|
||||||
DescType actualType;
|
DescType actualType;
|
||||||
Size actualSize;
|
Size actualSize;
|
||||||
FSRef theFSRef;
|
FSRef theFSRef;
|
||||||
char thePath[FILENAME_MAX];
|
char thePath[FILENAME_MAX];
|
||||||
|
|
||||||
long count;
|
long count;
|
||||||
::AECountItems(&navReply.selection , &count);
|
::AECountItems(&navReply.selection , &count);
|
||||||
for (long i = 1; i <= count; ++i)
|
for (long i = 1; i <= count; ++i)
|
||||||
{
|
{
|
||||||
err = ::AEGetNthPtr(&(navReply.selection), 1, typeFSRef, &theKeyword, &actualType,
|
err = ::AEGetNthPtr(&(navReply.selection), 1, typeFSRef, &theKeyword, &actualType,
|
||||||
&theFSRef, sizeof(theFSRef), &actualSize);
|
&theFSRef, sizeof(theFSRef), &actualSize);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (m_dialogStyle & wxSAVE)
|
if (m_dialogStyle & wxSAVE)
|
||||||
{
|
{
|
||||||
thePath[0] = '\0';
|
thePath[0] = '\0';
|
||||||
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
||||||
|
|
||||||
if (parentURLRef)
|
if (parentURLRef)
|
||||||
{
|
{
|
||||||
CFURLRef fullURLRef =
|
CFURLRef fullURLRef =
|
||||||
::CFURLCreateCopyAppendingPathComponent(NULL,
|
::CFURLCreateCopyAppendingPathComponent(NULL,
|
||||||
parentURLRef,
|
parentURLRef,
|
||||||
navReply.saveFileName,
|
navReply.saveFileName,
|
||||||
false);
|
false);
|
||||||
::CFRelease(parentURLRef);
|
::CFRelease(parentURLRef);
|
||||||
if (fullURLRef)
|
if (fullURLRef)
|
||||||
{
|
{
|
||||||
CFStringRef cfString = ::CFURLCopyPath(fullURLRef);
|
CFStringRef cfString = ::CFURLCopyPath(fullURLRef);
|
||||||
::CFRelease(fullURLRef);
|
::CFRelease(fullURLRef);
|
||||||
|
|
||||||
if (cfString)
|
if (cfString)
|
||||||
{
|
{
|
||||||
// unescape the URL for
|
// unescape the URL for
|
||||||
@@ -496,18 +497,18 @@ int wxFileDialog::ShowModal()
|
|||||||
cfString,
|
cfString,
|
||||||
CFSTR(""));
|
CFSTR(""));
|
||||||
::CFRelease(cfString);
|
::CFRelease(cfString);
|
||||||
|
|
||||||
if (cfStringUnescaped)
|
if (cfStringUnescaped)
|
||||||
{
|
{
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
::CFStringGetCString(cfStringUnescaped,
|
||||||
thePath,
|
thePath,
|
||||||
FILENAME_MAX,
|
FILENAME_MAX,
|
||||||
kCFStringEncodingUnicode);
|
kCFStringEncodingUnicode);
|
||||||
#else
|
#else
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
::CFStringGetCString(cfStringUnescaped,
|
||||||
thePath,
|
thePath,
|
||||||
FILENAME_MAX,
|
FILENAME_MAX,
|
||||||
CFStringGetSystemEncoding());
|
CFStringGetSystemEncoding());
|
||||||
#endif
|
#endif
|
||||||
::CFRelease(cfStringUnescaped);
|
::CFRelease(cfStringUnescaped);
|
||||||
@@ -521,11 +522,11 @@ int wxFileDialog::ShowModal()
|
|||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = ::FSRefMakePath(&theFSRef,
|
err = ::FSRefMakePath(&theFSRef,
|
||||||
(UInt8 *)thePath, sizeof(thePath));
|
(UInt8 *)thePath, sizeof(thePath));
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_path = thePath;
|
m_path = thePath;
|
||||||
@@ -539,7 +540,7 @@ int wxFileDialog::ShowModal()
|
|||||||
m_dir = wxPathOnly(m_path);
|
m_dir = wxPathOnly(m_path);
|
||||||
}
|
}
|
||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
|
|
||||||
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
||||||
#else // TARGET_CARBON
|
#else // TARGET_CARBON
|
||||||
|
|
||||||
@@ -551,7 +552,7 @@ int wxFileDialog::ShowModal()
|
|||||||
bool mSelectDefault = false ;
|
bool mSelectDefault = false ;
|
||||||
OSStatus err = noErr ;
|
OSStatus err = noErr ;
|
||||||
// setup dialog
|
// setup dialog
|
||||||
|
|
||||||
mNavFilterUPP = nil;
|
mNavFilterUPP = nil;
|
||||||
mNavPreviewUPP = nil;
|
mNavPreviewUPP = nil;
|
||||||
mSelectDefault = false;
|
mSelectDefault = false;
|
||||||
@@ -565,15 +566,16 @@ int wxFileDialog::ShowModal()
|
|||||||
// Set default location, the location
|
// Set default location, the location
|
||||||
// that's displayed when the dialog
|
// that's displayed when the dialog
|
||||||
// first appears
|
// first appears
|
||||||
|
|
||||||
FSSpec location ;
|
FSSpec location ;
|
||||||
wxMacFilename2FSSpec( m_dir , &location ) ;
|
wxMacFilename2FSSpec( m_dir , &location ) ;
|
||||||
|
|
||||||
err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
|
err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
|
||||||
|
|
||||||
if ( mDefaultLocation.dataHandle ) {
|
if ( mDefaultLocation.dataHandle )
|
||||||
|
{
|
||||||
if (mSelectDefault) {
|
if (mSelectDefault)
|
||||||
|
{
|
||||||
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
|
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
|
||||||
} else {
|
} else {
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
|
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
|
||||||
@@ -590,9 +592,9 @@ int wxFileDialog::ShowModal()
|
|||||||
mNavReply.keyScript = smSystemScript;
|
mNavReply.keyScript = smSystemScript;
|
||||||
mNavReply.fileTranslation = nil;
|
mNavReply.fileTranslation = nil;
|
||||||
mNavReply.version = kNavReplyRecordVersion ;
|
mNavReply.version = kNavReplyRecordVersion ;
|
||||||
|
|
||||||
// zero all data
|
// zero all data
|
||||||
|
|
||||||
m_path = wxEmptyString ;
|
m_path = wxEmptyString ;
|
||||||
m_fileName = wxEmptyString ;
|
m_fileName = wxEmptyString ;
|
||||||
m_paths.Empty();
|
m_paths.Empty();
|
||||||
@@ -605,7 +607,7 @@ int wxFileDialog::ShowModal()
|
|||||||
{
|
{
|
||||||
mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
|
mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
|
||||||
myData.menuitems = mNavOptions.popupExtension ;
|
myData.menuitems = mNavOptions.popupExtension ;
|
||||||
for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
|
for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
|
||||||
{
|
{
|
||||||
(*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
|
(*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
|
||||||
(*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
|
(*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
|
||||||
@@ -620,7 +622,7 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
||||||
|
|
||||||
err = ::NavPutFile(
|
err = ::NavPutFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
@@ -640,7 +642,7 @@ int wxFileDialog::ShowModal()
|
|||||||
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
||||||
else
|
else
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
||||||
|
|
||||||
err = ::NavGetFile(
|
err = ::NavGetFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
@@ -652,32 +654,33 @@ int wxFileDialog::ShowModal()
|
|||||||
&myData);
|
&myData);
|
||||||
m_filterIndex = myData.currentfilter ;
|
m_filterIndex = myData.currentfilter ;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeNavObjectFilterUPP(mNavFilterUPP);
|
DisposeNavObjectFilterUPP(mNavFilterUPP);
|
||||||
if ( mDefaultLocation.dataHandle != nil )
|
if ( mDefaultLocation.dataHandle != nil )
|
||||||
{
|
{
|
||||||
::AEDisposeDesc(&mDefaultLocation);
|
::AEDisposeDesc(&mDefaultLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (err != noErr) && (err != userCanceledErr) ) {
|
if ( (err != noErr) && (err != userCanceledErr) ) {
|
||||||
return wxID_CANCEL ;
|
return wxID_CANCEL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNavReply.validRecord) {
|
if (mNavReply.validRecord)
|
||||||
|
{
|
||||||
FSSpec outFileSpec ;
|
FSSpec outFileSpec ;
|
||||||
AEDesc specDesc ;
|
AEDesc specDesc ;
|
||||||
AEKeyword keyWord ;
|
AEKeyword keyWord ;
|
||||||
|
|
||||||
long count ;
|
long count ;
|
||||||
::AECountItems( &mNavReply.selection , &count ) ;
|
::AECountItems( &mNavReply.selection , &count ) ;
|
||||||
for ( long i = 1 ; i <= count ; ++i )
|
for ( long i = 1 ; i <= count ; ++i )
|
||||||
{
|
{
|
||||||
OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
|
OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
|
||||||
if ( err != noErr ) {
|
if ( err != noErr )
|
||||||
|
{
|
||||||
m_path = wxT("") ;
|
m_path = wxT("") ;
|
||||||
return wxID_CANCEL ;
|
return wxID_CANCEL ;
|
||||||
}
|
}
|
||||||
outFileSpec = **(FSSpec**) specDesc.dataHandle;
|
outFileSpec = **(FSSpec**) specDesc.dataHandle;
|
||||||
if (specDesc.dataHandle != nil) {
|
if (specDesc.dataHandle != nil) {
|
||||||
::AEDisposeDesc(&specDesc);
|
::AEDisposeDesc(&specDesc);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: filedlg.cpp
|
// Name: filedlg.cpp
|
||||||
// Purpose: wxFileDialog
|
// Purpose: wxFileDialog
|
||||||
// Author: Stefan Csomor
|
// Author: Stefan Csomor
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 1998-01-01
|
// Created: 1998-01-01
|
||||||
@@ -41,7 +41,7 @@ IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
|
|||||||
# include "MoreFiles.h"
|
# include "MoreFiles.h"
|
||||||
# include "MoreFilesExtras.h"
|
# include "MoreFilesExtras.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern bool gUseNavServices ;
|
extern bool gUseNavServices ;
|
||||||
|
|
||||||
// the data we need to pass to our standard file hook routine
|
// the data we need to pass to our standard file hook routine
|
||||||
@@ -56,7 +56,7 @@ struct OpenUserDataRec {
|
|||||||
wxArrayString name ;
|
wxArrayString name ;
|
||||||
wxArrayString extensions ;
|
wxArrayString extensions ;
|
||||||
wxArrayLong filtermactypes ;
|
wxArrayLong filtermactypes ;
|
||||||
wxString defaultLocation;
|
wxString defaultLocation;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
CFArrayRef menuitems ;
|
CFArrayRef menuitems ;
|
||||||
#else
|
#else
|
||||||
@@ -87,10 +87,10 @@ NavEventProc(
|
|||||||
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
|
||||||
if (inSelector == kNavCBEvent) {
|
if (inSelector == kNavCBEvent) {
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
#else
|
#else
|
||||||
wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
|
wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if ( inSelector == kNavCBStart )
|
else if ( inSelector == kNavCBStart )
|
||||||
{
|
{
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
@@ -124,7 +124,7 @@ NavEventProc(
|
|||||||
wxString extension = data->extensions[i].AfterLast('.') ;
|
wxString extension = data->extensions[i].AfterLast('.') ;
|
||||||
extension.MakeLower() ;
|
extension.MakeLower() ;
|
||||||
wxString sfilename ;
|
wxString sfilename ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
|
wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
|
||||||
sfilename = cfString.AsString() ;
|
sfilename = cfString.AsString() ;
|
||||||
@@ -135,7 +135,7 @@ NavEventProc(
|
|||||||
sfilename = wxMacMakeStringFromPascal( filename ) ;
|
sfilename = wxMacMakeStringFromPascal( filename ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pos = sfilename.Find('.',TRUE) ;
|
int pos = sfilename.Find('.', true) ;
|
||||||
if ( pos != wxNOT_FOUND )
|
if ( pos != wxNOT_FOUND )
|
||||||
{
|
{
|
||||||
sfilename = sfilename.Left(pos+1)+extension ;
|
sfilename = sfilename.Left(pos+1)+extension ;
|
||||||
@@ -157,8 +157,8 @@ const wxChar * gfilters[] =
|
|||||||
wxT("*.TXT") ,
|
wxT("*.TXT") ,
|
||||||
wxT("*.TIF") ,
|
wxT("*.TIF") ,
|
||||||
wxT("*.JPG") ,
|
wxT("*.JPG") ,
|
||||||
|
|
||||||
NULL
|
NULL
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
OSType gfiltersmac[] =
|
OSType gfiltersmac[] =
|
||||||
@@ -166,7 +166,7 @@ OSType gfiltersmac[] =
|
|||||||
'TEXT' ,
|
'TEXT' ,
|
||||||
'TIFF' ,
|
'TIFF' ,
|
||||||
'JPEG' ,
|
'JPEG' ,
|
||||||
|
|
||||||
'****'
|
'****'
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
@@ -175,8 +175,8 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
{
|
{
|
||||||
myData->menuitems = NULL ;
|
myData->menuitems = NULL ;
|
||||||
myData->currentfilter = 0 ;
|
myData->currentfilter = 0 ;
|
||||||
myData->saveMode = FALSE ;
|
myData->saveMode = false ;
|
||||||
|
|
||||||
if ( filter && filter[0] )
|
if ( filter && filter[0] )
|
||||||
{
|
{
|
||||||
wxString filter2(filter) ;
|
wxString filter2(filter) ;
|
||||||
@@ -204,7 +204,7 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
}
|
}
|
||||||
// we allow for compatibility reason to have a single filter expression (like *.*) without
|
// we allow for compatibility reason to have a single filter expression (like *.*) without
|
||||||
// an explanatory text, in that case the first part is name and extension at the same time
|
// 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") ) ;
|
wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ;
|
||||||
if ( current.IsEmpty() )
|
if ( current.IsEmpty() )
|
||||||
myData->extensions.Add( myData->name[filterIndex] ) ;
|
myData->extensions.Add( myData->name[filterIndex] ) ;
|
||||||
@@ -212,9 +212,9 @@ void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
|
|||||||
myData->extensions.Add( current.MakeUpper() ) ;
|
myData->extensions.Add( current.MakeUpper() ) ;
|
||||||
if ( filterIndex == 0 || isName )
|
if ( filterIndex == 0 || isName )
|
||||||
myData->name.Add( current.MakeUpper() ) ;
|
myData->name.Add( current.MakeUpper() ) ;
|
||||||
|
|
||||||
++filterIndex ;
|
++filterIndex ;
|
||||||
|
|
||||||
const size_t extCount = myData->extensions.GetCount();
|
const size_t extCount = myData->extensions.GetCount();
|
||||||
for ( size_t i = 0 ; i < extCount; i++ )
|
for ( size_t i = 0 ; i < extCount; i++ )
|
||||||
{
|
{
|
||||||
@@ -239,25 +239,25 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR
|
|||||||
{
|
{
|
||||||
wxString file(filename) ;
|
wxString file(filename) ;
|
||||||
file.MakeUpper() ;
|
file.MakeUpper() ;
|
||||||
|
|
||||||
if ( data->extensions.GetCount() > 0 )
|
if ( data->extensions.GetCount() > 0 )
|
||||||
{
|
{
|
||||||
//for ( int i = 0 ; i < data->numfilters ; ++i )
|
//for ( int i = 0 ; i < data->numfilters ; ++i )
|
||||||
int i = data->currentfilter ;
|
int i = data->currentfilter ;
|
||||||
if ( data->extensions[i].Right(2) == wxT(".*") )
|
if ( data->extensions[i].Right(2) == wxT(".*") )
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
{
|
{
|
||||||
if ( type == (OSType)data->filtermactypes[i] )
|
if ( type == (OSType)data->filtermactypes[i] )
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ;
|
wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ;
|
||||||
while( tokenizer.HasMoreTokens() )
|
while( tokenizer.HasMoreTokens() )
|
||||||
{
|
{
|
||||||
wxString extension = tokenizer.GetNextToken() ;
|
wxString extension = tokenizer.GetNextToken() ;
|
||||||
if ( extension.GetChar(0) == '*' )
|
if ( extension.GetChar(0) == '*' )
|
||||||
extension = extension.Mid(1) ;
|
extension = extension.Mid(1) ;
|
||||||
|
|
||||||
if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) )
|
if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) )
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
@@ -275,22 +275,22 @@ static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dat
|
|||||||
|
|
||||||
Boolean visibleFlag;
|
Boolean visibleFlag;
|
||||||
Boolean folderFlag;
|
Boolean folderFlag;
|
||||||
|
|
||||||
visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible);
|
visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible);
|
||||||
folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10);
|
folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10);
|
||||||
|
|
||||||
// because the semantics of the filter proc are "true means don't show
|
// because the semantics of the filter proc are "true means don't show
|
||||||
// it" we need to invert the result that we return
|
// it" we need to invert the result that we return
|
||||||
|
|
||||||
if ( !visibleFlag )
|
if ( !visibleFlag )
|
||||||
return true ;
|
return true ;
|
||||||
|
|
||||||
if ( !folderFlag )
|
if ( !folderFlag )
|
||||||
{
|
{
|
||||||
wxString file = wxMacMakeStringFromPascal( myCInfoPBPtr->hFileInfo.ioNamePtr ) ;
|
wxString file = wxMacMakeStringFromPascal( myCInfoPBPtr->hFileInfo.ioNamePtr ) ;
|
||||||
return !CheckFile( file , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ;
|
return !CheckFile( file , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false ;
|
return false ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -306,15 +306,15 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
pascal Boolean CrossPlatformFilterCallback (
|
pascal Boolean CrossPlatformFilterCallback (
|
||||||
AEDesc *theItem,
|
AEDesc *theItem,
|
||||||
void *info,
|
void *info,
|
||||||
void *callBackUD,
|
void *callBackUD,
|
||||||
NavFilterModes filterMode
|
NavFilterModes filterMode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
bool display = true;
|
bool display = true;
|
||||||
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
|
OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
|
||||||
|
|
||||||
if (filterMode == kNavFilteringBrowserList)
|
if (filterMode == kNavFilteringBrowserList)
|
||||||
{
|
{
|
||||||
NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
|
NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
|
||||||
@@ -326,7 +326,7 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
||||||
wxString file = wxMacMakeStringFromPascal( spec.name ) ;
|
wxString file = wxMacMakeStringFromPascal( spec.name ) ;
|
||||||
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
else if ( theItem->descriptorType == typeFSRef )
|
else if ( theItem->descriptorType == typeFSRef )
|
||||||
{
|
{
|
||||||
@@ -341,7 +341,7 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,70 +352,71 @@ int wxFileDialog::ShowModal()
|
|||||||
NavDialogCreationOptions dialogCreateOptions;
|
NavDialogCreationOptions dialogCreateOptions;
|
||||||
// set default options
|
// set default options
|
||||||
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
|
::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
|
||||||
|
|
||||||
// this was always unset in the old code
|
// this was always unset in the old code
|
||||||
dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
|
dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
|
||||||
|
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
// tried using wxMacCFStringHolder in the code below, but it seems
|
// tried using wxMacCFStringHolder in the code below, but it seems
|
||||||
// the CFStrings were being released before the save dialog was called,
|
// the CFStrings were being released before the save dialog was called,
|
||||||
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_message.wc_str(),
|
m_message.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
kCFStringEncodingUnicode);
|
||||||
#else
|
#else
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_message.c_str(),
|
m_message.c_str(),
|
||||||
CFStringGetSystemEncoding());
|
CFStringGetSystemEncoding());
|
||||||
#endif
|
#endif
|
||||||
dialogCreateOptions.windowTitle = titleRef;
|
dialogCreateOptions.windowTitle = titleRef;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_fileName.wc_str(),
|
m_fileName.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
kCFStringEncodingUnicode);
|
||||||
#else
|
#else
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_fileName.c_str(),
|
m_fileName.c_str(),
|
||||||
CFStringGetSystemEncoding());
|
CFStringGetSystemEncoding());
|
||||||
#endif
|
#endif
|
||||||
dialogCreateOptions.saveFileName = defaultFileNameRef;
|
dialogCreateOptions.saveFileName = defaultFileNameRef;
|
||||||
NavDialogRef dialog;
|
NavDialogRef dialog;
|
||||||
NavObjectFilterUPP navFilterUPP = NULL;
|
NavObjectFilterUPP navFilterUPP = NULL;
|
||||||
CFArrayRef cfArray = NULL; // for popupExtension
|
CFArrayRef cfArray = NULL; // for popupExtension
|
||||||
OpenUserDataRec myData;
|
OpenUserDataRec myData;
|
||||||
myData.defaultLocation = m_dir;
|
myData.defaultLocation = m_dir;
|
||||||
|
|
||||||
if (m_dialogStyle & wxSAVE)
|
if (m_dialogStyle & wxSAVE)
|
||||||
{
|
{
|
||||||
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
|
dialogCreateOptions.optionFlags |= kNavNoTypePopup;
|
||||||
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
|
dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
|
||||||
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
|
dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
|
||||||
|
|
||||||
// The extension is important
|
// The extension is important
|
||||||
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
|
dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
|
||||||
|
|
||||||
|
|
||||||
err = ::NavCreatePutFileDialog(&dialogCreateOptions,
|
err = ::NavCreatePutFileDialog(&dialogCreateOptions,
|
||||||
'TEXT',
|
'TEXT',
|
||||||
'TEXT',
|
'TEXT',
|
||||||
sStandardNavEventFilter,
|
sStandardNavEventFilter,
|
||||||
&myData, // for defaultLocation
|
&myData, // for defaultLocation
|
||||||
&dialog);
|
&dialog);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MakeUserDataRec(&myData , m_wildCard);
|
MakeUserDataRec(&myData , m_wildCard);
|
||||||
int numfilters = myData.extensions.GetCount();
|
size_t numfilters = myData.extensions.GetCount();
|
||||||
if (numfilters > 0){
|
if (numfilters > 0)
|
||||||
CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
|
|
||||||
numfilters , &kCFTypeArrayCallBacks ) ;
|
|
||||||
dialogCreateOptions.popupExtension = popup ;
|
|
||||||
myData.menuitems = dialogCreateOptions.popupExtension ;
|
|
||||||
for ( size_t i = 0 ; i < numfilters ; ++i )
|
|
||||||
{
|
{
|
||||||
CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] ) ) ;
|
CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
|
||||||
}
|
numfilters , &kCFTypeArrayCallBacks ) ;
|
||||||
}
|
dialogCreateOptions.popupExtension = popup ;
|
||||||
|
myData.menuitems = dialogCreateOptions.popupExtension ;
|
||||||
|
for ( size_t i = 0 ; i < numfilters ; ++i )
|
||||||
|
{
|
||||||
|
CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] ) ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
|
navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
|
||||||
err = ::NavCreateGetFileDialog(&dialogCreateOptions,
|
err = ::NavCreateGetFileDialog(&dialogCreateOptions,
|
||||||
NULL, // NavTypeListHandle
|
NULL, // NavTypeListHandle
|
||||||
@@ -428,7 +429,7 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
if (err == noErr)
|
if (err == noErr)
|
||||||
err = ::NavDialogRun(dialog);
|
err = ::NavDialogRun(dialog);
|
||||||
|
|
||||||
// clean up filter related data, etc.
|
// clean up filter related data, etc.
|
||||||
if (navFilterUPP)
|
if (navFilterUPP)
|
||||||
::DisposeNavObjectFilterUPP(navFilterUPP);
|
::DisposeNavObjectFilterUPP(navFilterUPP);
|
||||||
@@ -447,46 +448,46 @@ int wxFileDialog::ShowModal()
|
|||||||
::CFRelease(titleRef);
|
::CFRelease(titleRef);
|
||||||
if (defaultFileNameRef)
|
if (defaultFileNameRef)
|
||||||
::CFRelease(defaultFileNameRef);
|
::CFRelease(defaultFileNameRef);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
|
|
||||||
NavReplyRecord navReply;
|
NavReplyRecord navReply;
|
||||||
err = ::NavDialogGetReply(dialog, &navReply);
|
err = ::NavDialogGetReply(dialog, &navReply);
|
||||||
if (err == noErr && navReply.validRecord)
|
if (err == noErr && navReply.validRecord)
|
||||||
{
|
{
|
||||||
AEKeyword theKeyword;
|
AEKeyword theKeyword;
|
||||||
DescType actualType;
|
DescType actualType;
|
||||||
Size actualSize;
|
Size actualSize;
|
||||||
FSRef theFSRef;
|
FSRef theFSRef;
|
||||||
char thePath[FILENAME_MAX];
|
char thePath[FILENAME_MAX];
|
||||||
|
|
||||||
long count;
|
long count;
|
||||||
::AECountItems(&navReply.selection , &count);
|
::AECountItems(&navReply.selection , &count);
|
||||||
for (long i = 1; i <= count; ++i)
|
for (long i = 1; i <= count; ++i)
|
||||||
{
|
{
|
||||||
err = ::AEGetNthPtr(&(navReply.selection), 1, typeFSRef, &theKeyword, &actualType,
|
err = ::AEGetNthPtr(&(navReply.selection), 1, typeFSRef, &theKeyword, &actualType,
|
||||||
&theFSRef, sizeof(theFSRef), &actualSize);
|
&theFSRef, sizeof(theFSRef), &actualSize);
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (m_dialogStyle & wxSAVE)
|
if (m_dialogStyle & wxSAVE)
|
||||||
{
|
{
|
||||||
thePath[0] = '\0';
|
thePath[0] = '\0';
|
||||||
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
||||||
|
|
||||||
if (parentURLRef)
|
if (parentURLRef)
|
||||||
{
|
{
|
||||||
CFURLRef fullURLRef =
|
CFURLRef fullURLRef =
|
||||||
::CFURLCreateCopyAppendingPathComponent(NULL,
|
::CFURLCreateCopyAppendingPathComponent(NULL,
|
||||||
parentURLRef,
|
parentURLRef,
|
||||||
navReply.saveFileName,
|
navReply.saveFileName,
|
||||||
false);
|
false);
|
||||||
::CFRelease(parentURLRef);
|
::CFRelease(parentURLRef);
|
||||||
if (fullURLRef)
|
if (fullURLRef)
|
||||||
{
|
{
|
||||||
CFStringRef cfString = ::CFURLCopyPath(fullURLRef);
|
CFStringRef cfString = ::CFURLCopyPath(fullURLRef);
|
||||||
::CFRelease(fullURLRef);
|
::CFRelease(fullURLRef);
|
||||||
|
|
||||||
if (cfString)
|
if (cfString)
|
||||||
{
|
{
|
||||||
// unescape the URL for
|
// unescape the URL for
|
||||||
@@ -496,18 +497,18 @@ int wxFileDialog::ShowModal()
|
|||||||
cfString,
|
cfString,
|
||||||
CFSTR(""));
|
CFSTR(""));
|
||||||
::CFRelease(cfString);
|
::CFRelease(cfString);
|
||||||
|
|
||||||
if (cfStringUnescaped)
|
if (cfStringUnescaped)
|
||||||
{
|
{
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
::CFStringGetCString(cfStringUnescaped,
|
||||||
thePath,
|
thePath,
|
||||||
FILENAME_MAX,
|
FILENAME_MAX,
|
||||||
kCFStringEncodingUnicode);
|
kCFStringEncodingUnicode);
|
||||||
#else
|
#else
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
::CFStringGetCString(cfStringUnescaped,
|
||||||
thePath,
|
thePath,
|
||||||
FILENAME_MAX,
|
FILENAME_MAX,
|
||||||
CFStringGetSystemEncoding());
|
CFStringGetSystemEncoding());
|
||||||
#endif
|
#endif
|
||||||
::CFRelease(cfStringUnescaped);
|
::CFRelease(cfStringUnescaped);
|
||||||
@@ -521,11 +522,11 @@ int wxFileDialog::ShowModal()
|
|||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = ::FSRefMakePath(&theFSRef,
|
err = ::FSRefMakePath(&theFSRef,
|
||||||
(UInt8 *)thePath, sizeof(thePath));
|
(UInt8 *)thePath, sizeof(thePath));
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_path = thePath;
|
m_path = thePath;
|
||||||
@@ -539,7 +540,7 @@ int wxFileDialog::ShowModal()
|
|||||||
m_dir = wxPathOnly(m_path);
|
m_dir = wxPathOnly(m_path);
|
||||||
}
|
}
|
||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
|
|
||||||
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
return (err == noErr) ? wxID_OK : wxID_CANCEL;
|
||||||
#else // TARGET_CARBON
|
#else // TARGET_CARBON
|
||||||
|
|
||||||
@@ -551,7 +552,7 @@ int wxFileDialog::ShowModal()
|
|||||||
bool mSelectDefault = false ;
|
bool mSelectDefault = false ;
|
||||||
OSStatus err = noErr ;
|
OSStatus err = noErr ;
|
||||||
// setup dialog
|
// setup dialog
|
||||||
|
|
||||||
mNavFilterUPP = nil;
|
mNavFilterUPP = nil;
|
||||||
mNavPreviewUPP = nil;
|
mNavPreviewUPP = nil;
|
||||||
mSelectDefault = false;
|
mSelectDefault = false;
|
||||||
@@ -565,15 +566,16 @@ int wxFileDialog::ShowModal()
|
|||||||
// Set default location, the location
|
// Set default location, the location
|
||||||
// that's displayed when the dialog
|
// that's displayed when the dialog
|
||||||
// first appears
|
// first appears
|
||||||
|
|
||||||
FSSpec location ;
|
FSSpec location ;
|
||||||
wxMacFilename2FSSpec( m_dir , &location ) ;
|
wxMacFilename2FSSpec( m_dir , &location ) ;
|
||||||
|
|
||||||
err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
|
err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
|
||||||
|
|
||||||
if ( mDefaultLocation.dataHandle ) {
|
if ( mDefaultLocation.dataHandle )
|
||||||
|
{
|
||||||
if (mSelectDefault) {
|
if (mSelectDefault)
|
||||||
|
{
|
||||||
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
|
mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
|
||||||
} else {
|
} else {
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
|
mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
|
||||||
@@ -590,9 +592,9 @@ int wxFileDialog::ShowModal()
|
|||||||
mNavReply.keyScript = smSystemScript;
|
mNavReply.keyScript = smSystemScript;
|
||||||
mNavReply.fileTranslation = nil;
|
mNavReply.fileTranslation = nil;
|
||||||
mNavReply.version = kNavReplyRecordVersion ;
|
mNavReply.version = kNavReplyRecordVersion ;
|
||||||
|
|
||||||
// zero all data
|
// zero all data
|
||||||
|
|
||||||
m_path = wxEmptyString ;
|
m_path = wxEmptyString ;
|
||||||
m_fileName = wxEmptyString ;
|
m_fileName = wxEmptyString ;
|
||||||
m_paths.Empty();
|
m_paths.Empty();
|
||||||
@@ -605,7 +607,7 @@ int wxFileDialog::ShowModal()
|
|||||||
{
|
{
|
||||||
mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
|
mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
|
||||||
myData.menuitems = mNavOptions.popupExtension ;
|
myData.menuitems = mNavOptions.popupExtension ;
|
||||||
for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
|
for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
|
||||||
{
|
{
|
||||||
(*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
|
(*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
|
||||||
(*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
|
(*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
|
||||||
@@ -620,7 +622,7 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
||||||
|
|
||||||
err = ::NavPutFile(
|
err = ::NavPutFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
@@ -640,7 +642,7 @@ int wxFileDialog::ShowModal()
|
|||||||
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
||||||
else
|
else
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
||||||
|
|
||||||
err = ::NavGetFile(
|
err = ::NavGetFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
@@ -652,32 +654,33 @@ int wxFileDialog::ShowModal()
|
|||||||
&myData);
|
&myData);
|
||||||
m_filterIndex = myData.currentfilter ;
|
m_filterIndex = myData.currentfilter ;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeNavObjectFilterUPP(mNavFilterUPP);
|
DisposeNavObjectFilterUPP(mNavFilterUPP);
|
||||||
if ( mDefaultLocation.dataHandle != nil )
|
if ( mDefaultLocation.dataHandle != nil )
|
||||||
{
|
{
|
||||||
::AEDisposeDesc(&mDefaultLocation);
|
::AEDisposeDesc(&mDefaultLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (err != noErr) && (err != userCanceledErr) ) {
|
if ( (err != noErr) && (err != userCanceledErr) ) {
|
||||||
return wxID_CANCEL ;
|
return wxID_CANCEL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mNavReply.validRecord) {
|
if (mNavReply.validRecord)
|
||||||
|
{
|
||||||
FSSpec outFileSpec ;
|
FSSpec outFileSpec ;
|
||||||
AEDesc specDesc ;
|
AEDesc specDesc ;
|
||||||
AEKeyword keyWord ;
|
AEKeyword keyWord ;
|
||||||
|
|
||||||
long count ;
|
long count ;
|
||||||
::AECountItems( &mNavReply.selection , &count ) ;
|
::AECountItems( &mNavReply.selection , &count ) ;
|
||||||
for ( long i = 1 ; i <= count ; ++i )
|
for ( long i = 1 ; i <= count ; ++i )
|
||||||
{
|
{
|
||||||
OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
|
OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
|
||||||
if ( err != noErr ) {
|
if ( err != noErr )
|
||||||
|
{
|
||||||
m_path = wxT("") ;
|
m_path = wxT("") ;
|
||||||
return wxID_CANCEL ;
|
return wxID_CANCEL ;
|
||||||
}
|
}
|
||||||
outFileSpec = **(FSSpec**) specDesc.dataHandle;
|
outFileSpec = **(FSSpec**) specDesc.dataHandle;
|
||||||
if (specDesc.dataHandle != nil) {
|
if (specDesc.dataHandle != nil) {
|
||||||
::AEDisposeDesc(&specDesc);
|
::AEDisposeDesc(&specDesc);
|
||||||
|
Reference in New Issue
Block a user