use MoreFilesX instead of MoreFiles when building with Apple Developer Tools
improved wxGenericDirCtrl when building with Apple Developer Tools improved wxDirData to correctly handle hidden directories git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18483 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -144,10 +144,14 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
|
# ifdef __DARWIN__
|
||||||
|
# include "MoreFilesX.h"
|
||||||
|
# else
|
||||||
# include "MoreFiles.h"
|
# include "MoreFiles.h"
|
||||||
# include "MoreFilesExtras.h"
|
# include "MoreFilesExtras.h"
|
||||||
# include "FullPath.h"
|
# include "FullPath.h"
|
||||||
# include "FSpCompat.h"
|
# include "FSpCompat.h"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -79,7 +79,11 @@
|
|||||||
#endif // __WXPM__
|
#endif // __WXPM__
|
||||||
|
|
||||||
#if defined(__WXMAC__)
|
#if defined(__WXMAC__)
|
||||||
# include "MoreFilesExtras.h"
|
# ifdef __DARWIN__
|
||||||
|
# include "MoreFilesX.h"
|
||||||
|
# else
|
||||||
|
# include "MoreFilesExtras.h"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
@@ -373,7 +377,7 @@ bool wxIsDriveAvailable(const wxString& dirName)
|
|||||||
bool success = TRUE;
|
bool success = TRUE;
|
||||||
|
|
||||||
// Check if this is a root directory and if so,
|
// Check if this is a root directory and if so,
|
||||||
// whether the drive is avaiable.
|
// whether the drive is available.
|
||||||
if (dirName.Len() == 3 && dirName[(size_t)1] == wxT(':'))
|
if (dirName.Len() == 3 && dirName[(size_t)1] == wxT(':'))
|
||||||
{
|
{
|
||||||
wxString dirNameLower(dirName.Lower());
|
wxString dirNameLower(dirName.Lower());
|
||||||
@@ -660,16 +664,81 @@ void wxGenericDirCtrl::SetupSections()
|
|||||||
#endif // __WIN32__/!__WIN32__
|
#endif // __WIN32__/!__WIN32__
|
||||||
|
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
|
# ifdef __DARWIN__
|
||||||
|
FSRef **theVolRefs;
|
||||||
|
ItemCount theVolCount;
|
||||||
|
char thePath[FILENAME_MAX];
|
||||||
|
|
||||||
|
if (FSGetMountedVolumes(&theVolRefs, &theVolCount) == noErr) {
|
||||||
|
ItemCount index;
|
||||||
|
::HLock( (Handle)theVolRefs ) ;
|
||||||
|
for (index = 0; index < theVolCount; ++index) {
|
||||||
|
// get the POSIX path associated with the FSRef
|
||||||
|
if ( FSRefMakePath(&((*theVolRefs)[index]),
|
||||||
|
(UInt8 *)thePath, sizeof(thePath)) != noErr ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// add path separator at end if necessary
|
||||||
|
wxString path( thePath ) ;
|
||||||
|
if (path.Last() != wxFILE_SEP_PATH) {
|
||||||
|
path += wxFILE_SEP_PATH;
|
||||||
|
}
|
||||||
|
// get Mac volume name for display
|
||||||
|
FSVolumeRefNum vRefNum ;
|
||||||
|
HFSUniStr255 volumeName ;
|
||||||
|
|
||||||
|
if ( FSGetVRefNum(&((*theVolRefs)[index]), &vRefNum) != noErr ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( FSGetVInfo(vRefNum, &volumeName, NULL, NULL) != noErr ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// get C string from Unicode HFS name
|
||||||
|
// see: http://developer.apple.com/carbon/tipsandtricks.html
|
||||||
|
CFStringRef cfstr = CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
|
volumeName.unicode,
|
||||||
|
volumeName.length );
|
||||||
|
// Do something with str
|
||||||
|
char *cstr = NewPtr(CFStringGetLength(cfstr) + 1);
|
||||||
|
if (( cstr == NULL ) ||
|
||||||
|
!CFStringGetCString(cfstr, cstr, CFStringGetLength(cfstr) + 1,
|
||||||
|
kCFStringEncodingMacRoman)) {
|
||||||
|
CFRelease( cstr );
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wxString name( cstr ) ;
|
||||||
|
DisposePtr( cstr ) ;
|
||||||
|
CFRelease( cfstr );
|
||||||
|
|
||||||
|
GetVolParmsInfoBuffer volParmsInfo;
|
||||||
|
UInt32 actualSize;
|
||||||
|
if ( FSGetVolParms(vRefNum, sizeof(volParmsInfo), &volParmsInfo, &actualSize) != noErr ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( VolIsEjectable(&volParmsInfo) ) {
|
||||||
|
AddSection(path, name, 5/*cd-rom*/);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AddSection(path, name, 4/*disk*/);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
::HUnlock( (Handle)theVolRefs ) ;
|
||||||
|
::DisposeHandle( (Handle)theVolRefs ) ;
|
||||||
|
}
|
||||||
|
# else
|
||||||
FSSpec volume ;
|
FSSpec volume ;
|
||||||
short index = 1 ;
|
short index = 1 ;
|
||||||
while(1) {
|
while(1) {
|
||||||
short actualCount = 0 ;
|
short actualCount = 0 ;
|
||||||
if ( OnLine( &volume , 1 , &actualCount , &index ) != noErr || actualCount == 0 )
|
if ( OnLine( &volume , 1 , &actualCount , &index ) != noErr || actualCount == 0 ) {
|
||||||
break ;
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
wxString name = wxMacFSSpec2MacFilename( &volume ) ;
|
wxString name = wxMacFSSpec2MacFilename( &volume ) ;
|
||||||
AddSection(name + wxFILE_SEP_PATH, name, 0);
|
AddSection(name + wxFILE_SEP_PATH, name, 4/*disk*/);
|
||||||
}
|
}
|
||||||
|
# endif /* __DARWIN__ */
|
||||||
#elif defined(__UNIX__)
|
#elif defined(__UNIX__)
|
||||||
AddSection(wxT("/"), wxT("/"), 3/*computer icon*/);
|
AddSection(wxT("/"), wxT("/"), 3/*computer icon*/);
|
||||||
#else
|
#else
|
||||||
|
@@ -42,8 +42,12 @@
|
|||||||
|
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
#include "MoreFiles.h"
|
#ifdef __DARWIN__
|
||||||
#include "MoreFilesExtras.h"
|
# include "MoreFilesX.h"
|
||||||
|
#else
|
||||||
|
# include "MoreFiles.h"
|
||||||
|
# include "MoreFilesExtras.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
@@ -102,6 +106,8 @@ private:
|
|||||||
wxDirData::wxDirData(const wxString& dirname)
|
wxDirData::wxDirData(const wxString& dirname)
|
||||||
: m_dirname(dirname)
|
: m_dirname(dirname)
|
||||||
{
|
{
|
||||||
|
OSErr err;
|
||||||
|
|
||||||
// throw away the trailing slashes
|
// throw away the trailing slashes
|
||||||
size_t n = m_dirname.length();
|
size_t n = m_dirname.length();
|
||||||
wxCHECK_RET( n, _T("empty dir name in wxDir") );
|
wxCHECK_RET( n, _T("empty dir name in wxDir") );
|
||||||
@@ -110,16 +116,27 @@ wxDirData::wxDirData(const wxString& dirname)
|
|||||||
;
|
;
|
||||||
|
|
||||||
m_dirname.Truncate(n + 1);
|
m_dirname.Truncate(n + 1);
|
||||||
|
|
||||||
|
#ifdef __DARWIN__
|
||||||
|
FSRef theRef;
|
||||||
|
|
||||||
FSSpec fsspec ;
|
// get the FSRef associated with the POSIX path
|
||||||
|
err = FSPathMakeRef((const UInt8 *) m_dirname, &theRef, NULL);
|
||||||
|
FSGetVRefNum(&theRef, &(m_CPB.hFileInfo.ioVRefNum));
|
||||||
|
|
||||||
|
err = FSGetNodeID( &theRef , &m_dirId , &m_isDir ) ;
|
||||||
|
#else
|
||||||
|
FSSpec fsspec ;
|
||||||
|
|
||||||
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
|
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
|
||||||
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
|
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
|
||||||
m_CPB.hFileInfo.ioNamePtr = m_name ;
|
|
||||||
m_index = 0 ;
|
|
||||||
|
|
||||||
OSErr err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
|
err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
|
||||||
wxASSERT_MSG( err == noErr , "Error accessing directory") ;
|
#endif
|
||||||
|
wxASSERT_MSG( (err == noErr) || (err == nsvErr) , "Error accessing directory " + m_dirname) ;
|
||||||
|
|
||||||
|
m_CPB.hFileInfo.ioNamePtr = m_name ;
|
||||||
|
m_index = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDirData::~wxDirData()
|
wxDirData::~wxDirData()
|
||||||
@@ -141,68 +158,75 @@ bool wxDirData::Read(wxString *filename)
|
|||||||
#endif
|
#endif
|
||||||
wxString result;
|
wxString result;
|
||||||
|
|
||||||
short err = noErr ;
|
short err = noErr ;
|
||||||
|
|
||||||
while ( err == noErr )
|
while ( err == noErr )
|
||||||
{
|
{
|
||||||
m_index++ ;
|
m_index++ ;
|
||||||
m_CPB.dirInfo.ioFDirIndex = m_index;
|
m_CPB.dirInfo.ioFDirIndex = m_index;
|
||||||
m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
|
m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
|
||||||
err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
|
err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
|
||||||
if ( err != noErr )
|
if ( err != noErr )
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
p2cstrcpy( c_name, m_name ) ;
|
p2cstrcpy( c_name, m_name ) ;
|
||||||
strcpy( (char *)m_name, c_name);
|
strcpy( (char *)m_name, c_name);
|
||||||
#else
|
#else
|
||||||
p2cstr( m_name ) ;
|
p2cstr( m_name ) ;
|
||||||
|
#endif
|
||||||
|
// its hidden but we don't want it
|
||||||
|
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) )
|
||||||
|
continue ;
|
||||||
|
#ifdef __DARWIN__
|
||||||
|
// under X, names that start with '.' are hidden
|
||||||
|
if ( ( m_name[0] == '.' ) && !(m_flags & wxDIR_HIDDEN) )
|
||||||
|
continue;
|
||||||
#endif
|
#endif
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
// under X thats the way the mounting points look like
|
// under X thats the way the mounting points look like
|
||||||
if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) )
|
if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) )
|
||||||
break ;
|
break ;
|
||||||
#endif
|
#endif
|
||||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
|
// we have a directory
|
||||||
break ;
|
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) )
|
||||||
|
break ;
|
||||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) // its a file but we don't want it
|
|
||||||
continue ;
|
// its a file but we don't want it
|
||||||
|
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) )
|
||||||
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
|
continue ;
|
||||||
continue ;
|
|
||||||
|
wxString file( m_name ) ;
|
||||||
wxString file( m_name ) ;
|
if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" )
|
||||||
if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" )
|
{
|
||||||
{
|
}
|
||||||
}
|
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
|
||||||
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
|
{
|
||||||
{
|
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
|
||||||
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
|
{
|
||||||
{
|
continue ;
|
||||||
continue ;
|
}
|
||||||
}
|
}
|
||||||
}
|
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
|
||||||
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
|
{
|
||||||
{
|
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
|
||||||
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
|
{
|
||||||
{
|
continue ;
|
||||||
continue ;
|
}
|
||||||
}
|
}
|
||||||
}
|
else if ( file.Upper() != m_filespec.Upper() )
|
||||||
else if ( file.Upper() != m_filespec.Upper() )
|
{
|
||||||
{
|
continue ;
|
||||||
continue ;
|
}
|
||||||
}
|
|
||||||
|
break ;
|
||||||
break ;
|
}
|
||||||
}
|
if ( err != noErr )
|
||||||
if ( err != noErr )
|
{
|
||||||
{
|
return FALSE ;
|
||||||
return FALSE ;
|
}
|
||||||
}
|
|
||||||
|
*filename = (char*) m_name ;
|
||||||
*filename = (char*) m_name ;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -35,9 +35,13 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
|
|||||||
|
|
||||||
#include <Navigation.h>
|
#include <Navigation.h>
|
||||||
|
|
||||||
#include "MoreFiles.h"
|
#ifdef __DARWIN__
|
||||||
#include "MoreFilesExtras.h"
|
# include "MoreFilesX.h"
|
||||||
|
#else
|
||||||
|
# include "MoreFiles.h"
|
||||||
|
# include "MoreFilesExtras.h"
|
||||||
|
#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
|
||||||
@@ -350,204 +354,204 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
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 ;
|
||||||
if (theItem->descriptorType == typeFSS && !theInfo->isFolder)
|
if (theItem->descriptorType == typeFSS && !theInfo->isFolder)
|
||||||
{
|
{
|
||||||
FSSpec spec;
|
FSSpec spec;
|
||||||
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
||||||
display = CheckFile( spec.name , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
display = CheckFile( spec.name , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFileDialog::ShowModal()
|
int wxFileDialog::ShowModal()
|
||||||
{
|
{
|
||||||
NavDialogOptions mNavOptions;
|
NavDialogOptions mNavOptions;
|
||||||
NavObjectFilterUPP mNavFilterUPP = NULL;
|
NavObjectFilterUPP mNavFilterUPP = NULL;
|
||||||
NavPreviewUPP mNavPreviewUPP = NULL ;
|
NavPreviewUPP mNavPreviewUPP = NULL ;
|
||||||
NavReplyRecord mNavReply;
|
NavReplyRecord mNavReply;
|
||||||
AEDesc mDefaultLocation ;
|
AEDesc mDefaultLocation ;
|
||||||
bool mSelectDefault = false ;
|
bool mSelectDefault = false ;
|
||||||
|
|
||||||
::NavGetDefaultDialogOptions(&mNavOptions);
|
::NavGetDefaultDialogOptions(&mNavOptions);
|
||||||
|
|
||||||
mNavFilterUPP = nil;
|
mNavFilterUPP = nil;
|
||||||
mNavPreviewUPP = nil;
|
mNavPreviewUPP = nil;
|
||||||
mSelectDefault = false;
|
mSelectDefault = false;
|
||||||
mNavReply.validRecord = false;
|
mNavReply.validRecord = false;
|
||||||
mNavReply.replacing = false;
|
mNavReply.replacing = false;
|
||||||
mNavReply.isStationery = false;
|
mNavReply.isStationery = false;
|
||||||
mNavReply.translationNeeded = false;
|
mNavReply.translationNeeded = false;
|
||||||
mNavReply.selection.descriptorType = typeNull;
|
mNavReply.selection.descriptorType = typeNull;
|
||||||
mNavReply.selection.dataHandle = nil;
|
mNavReply.selection.dataHandle = nil;
|
||||||
mNavReply.keyScript = smSystemScript;
|
mNavReply.keyScript = smSystemScript;
|
||||||
mNavReply.fileTranslation = nil;
|
mNavReply.fileTranslation = nil;
|
||||||
|
|
||||||
// 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 ) ;
|
||||||
OSErr err = noErr ;
|
OSErr err = noErr ;
|
||||||
|
|
||||||
mDefaultLocation.descriptorType = typeNull;
|
mDefaultLocation.descriptorType = typeNull;
|
||||||
mDefaultLocation.dataHandle = nil;
|
mDefaultLocation.dataHandle = nil;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy((StringPtr)mNavOptions.message, m_message) ;
|
c2pstrcpy((StringPtr)mNavOptions.message, m_message) ;
|
||||||
#else
|
#else
|
||||||
strcpy((char *)mNavOptions.message, m_message) ;
|
strcpy((char *)mNavOptions.message, m_message) ;
|
||||||
c2pstr((char *)mNavOptions.message ) ;
|
c2pstr((char *)mNavOptions.message ) ;
|
||||||
#endif
|
#endif
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy((StringPtr)mNavOptions.savedFileName, m_fileName) ;
|
c2pstrcpy((StringPtr)mNavOptions.savedFileName, m_fileName) ;
|
||||||
#else
|
#else
|
||||||
strcpy((char *)mNavOptions.savedFileName, m_fileName) ;
|
strcpy((char *)mNavOptions.savedFileName, m_fileName) ;
|
||||||
c2pstr((char *)mNavOptions.savedFileName ) ;
|
c2pstr((char *)mNavOptions.savedFileName ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OpenUserDataRec myData;
|
OpenUserDataRec myData;
|
||||||
MakeUserDataRec( &myData , m_wildCard ) ;
|
MakeUserDataRec( &myData , m_wildCard ) ;
|
||||||
myData.currentfilter = m_filterIndex ;
|
myData.currentfilter = m_filterIndex ;
|
||||||
if ( myData.extensions.GetCount() > 0 )
|
if ( myData.extensions.GetCount() > 0 )
|
||||||
{
|
{
|
||||||
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' ;
|
||||||
(*mNavOptions.popupExtension)[i].menuType = i ;
|
(*mNavOptions.popupExtension)[i].menuType = i ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy((StringPtr)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
c2pstrcpy((StringPtr)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
||||||
#else
|
#else
|
||||||
strcpy((char *)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
strcpy((char *)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
||||||
c2pstr((char *)(*mNavOptions.popupExtension)[i].menuItemName ) ;
|
c2pstr((char *)(*mNavOptions.popupExtension)[i].menuItemName ) ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( m_dialogStyle & wxSAVE )
|
if ( m_dialogStyle & wxSAVE )
|
||||||
{
|
{
|
||||||
myData.saveMode = true ;
|
myData.saveMode = true ;
|
||||||
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
||||||
|
|
||||||
err = ::NavPutFile(
|
err = ::NavPutFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
&mNavOptions,
|
&mNavOptions,
|
||||||
sStandardNavEventFilter ,
|
sStandardNavEventFilter ,
|
||||||
NULL,
|
NULL,
|
||||||
kNavGenericSignature,
|
kNavGenericSignature,
|
||||||
&myData); // User Data
|
&myData); // User Data
|
||||||
m_filterIndex = myData.currentfilter ;
|
m_filterIndex = myData.currentfilter ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myData.saveMode = false ;
|
myData.saveMode = false ;
|
||||||
|
|
||||||
mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
|
mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
|
||||||
if ( m_dialogStyle & wxMULTIPLE )
|
if ( m_dialogStyle & wxMULTIPLE )
|
||||||
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
||||||
else
|
else
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
||||||
|
|
||||||
err = ::NavGetFile(
|
err = ::NavGetFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
&mNavOptions,
|
&mNavOptions,
|
||||||
sStandardNavEventFilter ,
|
sStandardNavEventFilter ,
|
||||||
mNavPreviewUPP,
|
mNavPreviewUPP,
|
||||||
mNavFilterUPP,
|
mNavFilterUPP,
|
||||||
NULL ,
|
NULL ,
|
||||||
&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) ) {
|
||||||
m_path = "" ;
|
m_path = "" ;
|
||||||
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 = "" ;
|
m_path = "" ;
|
||||||
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);
|
||||||
}
|
}
|
||||||
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
|
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
|
||||||
m_paths.Add( m_path ) ;
|
m_paths.Add( m_path ) ;
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
|
||||||
m_fileNames.Add(m_fileName);
|
|
||||||
}
|
|
||||||
// set these to the first hit
|
|
||||||
m_path = m_paths[ 0 ] ;
|
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
m_fileName = wxFileNameFromPath(m_path);
|
||||||
m_dir = wxPathOnly(m_path);
|
m_fileNames.Add(m_fileName);
|
||||||
NavDisposeReply( &mNavReply ) ;
|
}
|
||||||
return wxID_OK ;
|
// set these to the first hit
|
||||||
}
|
m_path = m_paths[ 0 ] ;
|
||||||
return wxID_CANCEL;
|
m_fileName = wxFileNameFromPath(m_path);
|
||||||
|
m_dir = wxPathOnly(m_path);
|
||||||
|
NavDisposeReply( &mNavReply ) ;
|
||||||
|
return wxID_OK ;
|
||||||
|
}
|
||||||
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic file load/save dialog
|
// Generic file load/save dialog
|
||||||
static wxString
|
static wxString
|
||||||
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
|
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
|
||||||
{
|
{
|
||||||
char *ext = (char *)extension;
|
char *ext = (char *)extension;
|
||||||
|
|
||||||
char prompt[50];
|
char prompt[50];
|
||||||
wxString str;
|
wxString str;
|
||||||
if (load)
|
if (load)
|
||||||
str = "Load %s file";
|
str = "Load %s file";
|
||||||
else
|
else
|
||||||
str = "Save %s file";
|
str = "Save %s file";
|
||||||
sprintf(prompt, wxGetTranslation(str), what);
|
sprintf(prompt, wxGetTranslation(str), what);
|
||||||
|
|
||||||
if (*ext == '.') ext++;
|
if (*ext == '.') ext++;
|
||||||
char wild[60];
|
char wild[60];
|
||||||
sprintf(wild, "*.%s", ext);
|
sprintf(wild, "*.%s", ext);
|
||||||
|
|
||||||
return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
|
return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic file load dialog
|
// Generic file load dialog
|
||||||
|
@@ -26,8 +26,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "MoreFiles.h"
|
#ifdef __DARWIN__
|
||||||
#include "MoreFilesExtras.h"
|
# include "MoreFilesX.h"
|
||||||
|
#else
|
||||||
|
# include "MoreFiles.h"
|
||||||
|
# include "MoreFilesExtras.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include <Threads.h>
|
#include <Threads.h>
|
||||||
@@ -362,19 +366,19 @@ wxString wxMacFindFolder( short vol,
|
|||||||
OSType folderType,
|
OSType folderType,
|
||||||
Boolean createFolder)
|
Boolean createFolder)
|
||||||
{
|
{
|
||||||
short vRefNum ;
|
short vRefNum ;
|
||||||
long dirID ;
|
long dirID ;
|
||||||
wxString strDir ;
|
wxString strDir ;
|
||||||
|
|
||||||
if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
|
if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
|
||||||
{
|
{
|
||||||
FSSpec file ;
|
FSSpec file ;
|
||||||
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
|
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
|
||||||
{
|
{
|
||||||
strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ;
|
strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strDir ;
|
return strDir ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
@@ -479,8 +483,8 @@ void wxDisplaySizeMM(int *width, int *height)
|
|||||||
|
|
||||||
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
||||||
{
|
{
|
||||||
BitMap screenBits;
|
BitMap screenBits;
|
||||||
GetQDGlobalsScreenBits( &screenBits );
|
GetQDGlobalsScreenBits( &screenBits );
|
||||||
|
|
||||||
if (x) *x = 0;
|
if (x) *x = 0;
|
||||||
if (y) *y = 0;
|
if (y) *y = 0;
|
||||||
@@ -488,15 +492,15 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
|||||||
*width = screenBits.bounds.right - screenBits.bounds.left ;
|
*width = screenBits.bounds.right - screenBits.bounds.left ;
|
||||||
*height = screenBits.bounds.bottom - screenBits.bounds.top ;
|
*height = screenBits.bounds.bottom - screenBits.bounds.top ;
|
||||||
|
|
||||||
SInt16 mheight ;
|
SInt16 mheight ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
GetThemeMenuBarHeight( &mheight ) ;
|
GetThemeMenuBarHeight( &mheight ) ;
|
||||||
#else
|
#else
|
||||||
mheight = LMGetMBarHeight() ;
|
mheight = LMGetMBarHeight() ;
|
||||||
#endif
|
#endif
|
||||||
*height -= mheight ;
|
*height -= mheight ;
|
||||||
if ( y )
|
if ( y )
|
||||||
*y = mheight ;
|
*y = mheight ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
||||||
|
@@ -42,8 +42,12 @@
|
|||||||
|
|
||||||
#include "wx/mac/private.h"
|
#include "wx/mac/private.h"
|
||||||
|
|
||||||
#include "MoreFiles.h"
|
#ifdef __DARWIN__
|
||||||
#include "MoreFilesExtras.h"
|
# include "MoreFilesX.h"
|
||||||
|
#else
|
||||||
|
# include "MoreFiles.h"
|
||||||
|
# include "MoreFilesExtras.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
@@ -102,6 +106,8 @@ private:
|
|||||||
wxDirData::wxDirData(const wxString& dirname)
|
wxDirData::wxDirData(const wxString& dirname)
|
||||||
: m_dirname(dirname)
|
: m_dirname(dirname)
|
||||||
{
|
{
|
||||||
|
OSErr err;
|
||||||
|
|
||||||
// throw away the trailing slashes
|
// throw away the trailing slashes
|
||||||
size_t n = m_dirname.length();
|
size_t n = m_dirname.length();
|
||||||
wxCHECK_RET( n, _T("empty dir name in wxDir") );
|
wxCHECK_RET( n, _T("empty dir name in wxDir") );
|
||||||
@@ -110,16 +116,27 @@ wxDirData::wxDirData(const wxString& dirname)
|
|||||||
;
|
;
|
||||||
|
|
||||||
m_dirname.Truncate(n + 1);
|
m_dirname.Truncate(n + 1);
|
||||||
|
|
||||||
|
#ifdef __DARWIN__
|
||||||
|
FSRef theRef;
|
||||||
|
|
||||||
FSSpec fsspec ;
|
// get the FSRef associated with the POSIX path
|
||||||
|
err = FSPathMakeRef((const UInt8 *) m_dirname, &theRef, NULL);
|
||||||
|
FSGetVRefNum(&theRef, &(m_CPB.hFileInfo.ioVRefNum));
|
||||||
|
|
||||||
|
err = FSGetNodeID( &theRef , &m_dirId , &m_isDir ) ;
|
||||||
|
#else
|
||||||
|
FSSpec fsspec ;
|
||||||
|
|
||||||
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
|
wxMacFilename2FSSpec( m_dirname , &fsspec ) ;
|
||||||
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
|
m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
|
||||||
m_CPB.hFileInfo.ioNamePtr = m_name ;
|
|
||||||
m_index = 0 ;
|
|
||||||
|
|
||||||
OSErr err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
|
err = FSpGetDirectoryID( &fsspec , &m_dirId , &m_isDir ) ;
|
||||||
wxASSERT_MSG( err == noErr , "Error accessing directory") ;
|
#endif
|
||||||
|
wxASSERT_MSG( (err == noErr) || (err == nsvErr) , "Error accessing directory " + m_dirname) ;
|
||||||
|
|
||||||
|
m_CPB.hFileInfo.ioNamePtr = m_name ;
|
||||||
|
m_index = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDirData::~wxDirData()
|
wxDirData::~wxDirData()
|
||||||
@@ -141,68 +158,75 @@ bool wxDirData::Read(wxString *filename)
|
|||||||
#endif
|
#endif
|
||||||
wxString result;
|
wxString result;
|
||||||
|
|
||||||
short err = noErr ;
|
short err = noErr ;
|
||||||
|
|
||||||
while ( err == noErr )
|
while ( err == noErr )
|
||||||
{
|
{
|
||||||
m_index++ ;
|
m_index++ ;
|
||||||
m_CPB.dirInfo.ioFDirIndex = m_index;
|
m_CPB.dirInfo.ioFDirIndex = m_index;
|
||||||
m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
|
m_CPB.dirInfo.ioDrDirID = m_dirId; /* we need to do this every time */
|
||||||
err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
|
err = PBGetCatInfoSync((CInfoPBPtr)&m_CPB);
|
||||||
if ( err != noErr )
|
if ( err != noErr )
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
p2cstrcpy( c_name, m_name ) ;
|
p2cstrcpy( c_name, m_name ) ;
|
||||||
strcpy( (char *)m_name, c_name);
|
strcpy( (char *)m_name, c_name);
|
||||||
#else
|
#else
|
||||||
p2cstr( m_name ) ;
|
p2cstr( m_name ) ;
|
||||||
|
#endif
|
||||||
|
// its hidden but we don't want it
|
||||||
|
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) )
|
||||||
|
continue ;
|
||||||
|
#ifdef __DARWIN__
|
||||||
|
// under X, names that start with '.' are hidden
|
||||||
|
if ( ( m_name[0] == '.' ) && !(m_flags & wxDIR_HIDDEN) )
|
||||||
|
continue;
|
||||||
#endif
|
#endif
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
// under X thats the way the mounting points look like
|
// under X thats the way the mounting points look like
|
||||||
if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) )
|
if ( ( m_CPB.dirInfo.ioDrDirID == 0 ) && ( m_flags & wxDIR_DIRS) )
|
||||||
break ;
|
break ;
|
||||||
#endif
|
#endif
|
||||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) ) // we have a directory
|
// we have a directory
|
||||||
break ;
|
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (m_flags & wxDIR_DIRS) )
|
||||||
|
break ;
|
||||||
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) ) // its a file but we don't want it
|
|
||||||
continue ;
|
// its a file but we don't want it
|
||||||
|
if ( ( m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(m_flags & wxDIR_FILES ) )
|
||||||
if ( ( m_CPB.hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible ) && !(m_flags & wxDIR_HIDDEN) ) // its hidden but we don't want it
|
continue ;
|
||||||
continue ;
|
|
||||||
|
wxString file( m_name ) ;
|
||||||
wxString file( m_name ) ;
|
if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" )
|
||||||
if ( m_filespec.IsEmpty() || m_filespec == "*.*" || m_filespec == "*" )
|
{
|
||||||
{
|
}
|
||||||
}
|
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
|
||||||
else if ( m_filespec.Length() > 1 && m_filespec.Left(1) =="*" )
|
{
|
||||||
{
|
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
|
||||||
if ( file.Right( m_filespec.Length() - 1 ).Upper() != m_filespec.Mid(1).Upper() )
|
{
|
||||||
{
|
continue ;
|
||||||
continue ;
|
}
|
||||||
}
|
}
|
||||||
}
|
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
|
||||||
else if ( m_filespec.Length() > 1 && m_filespec.Right(1) == "*" )
|
{
|
||||||
{
|
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
|
||||||
if ( file.Left( m_filespec.Length() - 1 ).Upper() != m_filespec.Left( m_filespec.Length() - 1 ).Upper() )
|
{
|
||||||
{
|
continue ;
|
||||||
continue ;
|
}
|
||||||
}
|
}
|
||||||
}
|
else if ( file.Upper() != m_filespec.Upper() )
|
||||||
else if ( file.Upper() != m_filespec.Upper() )
|
{
|
||||||
{
|
continue ;
|
||||||
continue ;
|
}
|
||||||
}
|
|
||||||
|
break ;
|
||||||
break ;
|
}
|
||||||
}
|
if ( err != noErr )
|
||||||
if ( err != noErr )
|
{
|
||||||
{
|
return FALSE ;
|
||||||
return FALSE ;
|
}
|
||||||
}
|
|
||||||
|
*filename = (char*) m_name ;
|
||||||
*filename = (char*) m_name ;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@@ -35,9 +35,13 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
|
|||||||
|
|
||||||
#include <Navigation.h>
|
#include <Navigation.h>
|
||||||
|
|
||||||
#include "MoreFiles.h"
|
#ifdef __DARWIN__
|
||||||
#include "MoreFilesExtras.h"
|
# include "MoreFilesX.h"
|
||||||
|
#else
|
||||||
|
# include "MoreFiles.h"
|
||||||
|
# include "MoreFilesExtras.h"
|
||||||
|
#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
|
||||||
@@ -350,204 +354,204 @@ pascal Boolean CrossPlatformFilterCallback (
|
|||||||
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 ;
|
||||||
if (theItem->descriptorType == typeFSS && !theInfo->isFolder)
|
if (theItem->descriptorType == typeFSS && !theInfo->isFolder)
|
||||||
{
|
{
|
||||||
FSSpec spec;
|
FSSpec spec;
|
||||||
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
|
||||||
display = CheckFile( spec.name , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
display = CheckFile( spec.name , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return display;
|
return display;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFileDialog::ShowModal()
|
int wxFileDialog::ShowModal()
|
||||||
{
|
{
|
||||||
NavDialogOptions mNavOptions;
|
NavDialogOptions mNavOptions;
|
||||||
NavObjectFilterUPP mNavFilterUPP = NULL;
|
NavObjectFilterUPP mNavFilterUPP = NULL;
|
||||||
NavPreviewUPP mNavPreviewUPP = NULL ;
|
NavPreviewUPP mNavPreviewUPP = NULL ;
|
||||||
NavReplyRecord mNavReply;
|
NavReplyRecord mNavReply;
|
||||||
AEDesc mDefaultLocation ;
|
AEDesc mDefaultLocation ;
|
||||||
bool mSelectDefault = false ;
|
bool mSelectDefault = false ;
|
||||||
|
|
||||||
::NavGetDefaultDialogOptions(&mNavOptions);
|
::NavGetDefaultDialogOptions(&mNavOptions);
|
||||||
|
|
||||||
mNavFilterUPP = nil;
|
mNavFilterUPP = nil;
|
||||||
mNavPreviewUPP = nil;
|
mNavPreviewUPP = nil;
|
||||||
mSelectDefault = false;
|
mSelectDefault = false;
|
||||||
mNavReply.validRecord = false;
|
mNavReply.validRecord = false;
|
||||||
mNavReply.replacing = false;
|
mNavReply.replacing = false;
|
||||||
mNavReply.isStationery = false;
|
mNavReply.isStationery = false;
|
||||||
mNavReply.translationNeeded = false;
|
mNavReply.translationNeeded = false;
|
||||||
mNavReply.selection.descriptorType = typeNull;
|
mNavReply.selection.descriptorType = typeNull;
|
||||||
mNavReply.selection.dataHandle = nil;
|
mNavReply.selection.dataHandle = nil;
|
||||||
mNavReply.keyScript = smSystemScript;
|
mNavReply.keyScript = smSystemScript;
|
||||||
mNavReply.fileTranslation = nil;
|
mNavReply.fileTranslation = nil;
|
||||||
|
|
||||||
// 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 ) ;
|
||||||
OSErr err = noErr ;
|
OSErr err = noErr ;
|
||||||
|
|
||||||
mDefaultLocation.descriptorType = typeNull;
|
mDefaultLocation.descriptorType = typeNull;
|
||||||
mDefaultLocation.dataHandle = nil;
|
mDefaultLocation.dataHandle = nil;
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy((StringPtr)mNavOptions.message, m_message) ;
|
c2pstrcpy((StringPtr)mNavOptions.message, m_message) ;
|
||||||
#else
|
#else
|
||||||
strcpy((char *)mNavOptions.message, m_message) ;
|
strcpy((char *)mNavOptions.message, m_message) ;
|
||||||
c2pstr((char *)mNavOptions.message ) ;
|
c2pstr((char *)mNavOptions.message ) ;
|
||||||
#endif
|
#endif
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy((StringPtr)mNavOptions.savedFileName, m_fileName) ;
|
c2pstrcpy((StringPtr)mNavOptions.savedFileName, m_fileName) ;
|
||||||
#else
|
#else
|
||||||
strcpy((char *)mNavOptions.savedFileName, m_fileName) ;
|
strcpy((char *)mNavOptions.savedFileName, m_fileName) ;
|
||||||
c2pstr((char *)mNavOptions.savedFileName ) ;
|
c2pstr((char *)mNavOptions.savedFileName ) ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OpenUserDataRec myData;
|
OpenUserDataRec myData;
|
||||||
MakeUserDataRec( &myData , m_wildCard ) ;
|
MakeUserDataRec( &myData , m_wildCard ) ;
|
||||||
myData.currentfilter = m_filterIndex ;
|
myData.currentfilter = m_filterIndex ;
|
||||||
if ( myData.extensions.GetCount() > 0 )
|
if ( myData.extensions.GetCount() > 0 )
|
||||||
{
|
{
|
||||||
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' ;
|
||||||
(*mNavOptions.popupExtension)[i].menuType = i ;
|
(*mNavOptions.popupExtension)[i].menuType = i ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
c2pstrcpy((StringPtr)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
c2pstrcpy((StringPtr)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
||||||
#else
|
#else
|
||||||
strcpy((char *)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
strcpy((char *)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
|
||||||
c2pstr((char *)(*mNavOptions.popupExtension)[i].menuItemName ) ;
|
c2pstr((char *)(*mNavOptions.popupExtension)[i].menuItemName ) ;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( m_dialogStyle & wxSAVE )
|
if ( m_dialogStyle & wxSAVE )
|
||||||
{
|
{
|
||||||
myData.saveMode = true ;
|
myData.saveMode = true ;
|
||||||
|
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
|
||||||
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
|
||||||
|
|
||||||
err = ::NavPutFile(
|
err = ::NavPutFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
&mNavOptions,
|
&mNavOptions,
|
||||||
sStandardNavEventFilter ,
|
sStandardNavEventFilter ,
|
||||||
NULL,
|
NULL,
|
||||||
kNavGenericSignature,
|
kNavGenericSignature,
|
||||||
&myData); // User Data
|
&myData); // User Data
|
||||||
m_filterIndex = myData.currentfilter ;
|
m_filterIndex = myData.currentfilter ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myData.saveMode = false ;
|
myData.saveMode = false ;
|
||||||
|
|
||||||
mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
|
mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
|
||||||
if ( m_dialogStyle & wxMULTIPLE )
|
if ( m_dialogStyle & wxMULTIPLE )
|
||||||
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
|
||||||
else
|
else
|
||||||
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
|
||||||
|
|
||||||
err = ::NavGetFile(
|
err = ::NavGetFile(
|
||||||
&mDefaultLocation,
|
&mDefaultLocation,
|
||||||
&mNavReply,
|
&mNavReply,
|
||||||
&mNavOptions,
|
&mNavOptions,
|
||||||
sStandardNavEventFilter ,
|
sStandardNavEventFilter ,
|
||||||
mNavPreviewUPP,
|
mNavPreviewUPP,
|
||||||
mNavFilterUPP,
|
mNavFilterUPP,
|
||||||
NULL ,
|
NULL ,
|
||||||
&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) ) {
|
||||||
m_path = "" ;
|
m_path = "" ;
|
||||||
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 = "" ;
|
m_path = "" ;
|
||||||
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);
|
||||||
}
|
}
|
||||||
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
|
m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
|
||||||
m_paths.Add( m_path ) ;
|
m_paths.Add( m_path ) ;
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
|
||||||
m_fileNames.Add(m_fileName);
|
|
||||||
}
|
|
||||||
// set these to the first hit
|
|
||||||
m_path = m_paths[ 0 ] ;
|
|
||||||
m_fileName = wxFileNameFromPath(m_path);
|
m_fileName = wxFileNameFromPath(m_path);
|
||||||
m_dir = wxPathOnly(m_path);
|
m_fileNames.Add(m_fileName);
|
||||||
NavDisposeReply( &mNavReply ) ;
|
}
|
||||||
return wxID_OK ;
|
// set these to the first hit
|
||||||
}
|
m_path = m_paths[ 0 ] ;
|
||||||
return wxID_CANCEL;
|
m_fileName = wxFileNameFromPath(m_path);
|
||||||
|
m_dir = wxPathOnly(m_path);
|
||||||
|
NavDisposeReply( &mNavReply ) ;
|
||||||
|
return wxID_OK ;
|
||||||
|
}
|
||||||
|
return wxID_CANCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic file load/save dialog
|
// Generic file load/save dialog
|
||||||
static wxString
|
static wxString
|
||||||
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
|
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
|
||||||
{
|
{
|
||||||
char *ext = (char *)extension;
|
char *ext = (char *)extension;
|
||||||
|
|
||||||
char prompt[50];
|
char prompt[50];
|
||||||
wxString str;
|
wxString str;
|
||||||
if (load)
|
if (load)
|
||||||
str = "Load %s file";
|
str = "Load %s file";
|
||||||
else
|
else
|
||||||
str = "Save %s file";
|
str = "Save %s file";
|
||||||
sprintf(prompt, wxGetTranslation(str), what);
|
sprintf(prompt, wxGetTranslation(str), what);
|
||||||
|
|
||||||
if (*ext == '.') ext++;
|
if (*ext == '.') ext++;
|
||||||
char wild[60];
|
char wild[60];
|
||||||
sprintf(wild, "*.%s", ext);
|
sprintf(wild, "*.%s", ext);
|
||||||
|
|
||||||
return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
|
return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic file load dialog
|
// Generic file load dialog
|
||||||
|
@@ -26,8 +26,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "MoreFiles.h"
|
#ifdef __DARWIN__
|
||||||
#include "MoreFilesExtras.h"
|
# include "MoreFilesX.h"
|
||||||
|
#else
|
||||||
|
# include "MoreFiles.h"
|
||||||
|
# include "MoreFilesExtras.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
#include <Threads.h>
|
#include <Threads.h>
|
||||||
@@ -362,19 +366,19 @@ wxString wxMacFindFolder( short vol,
|
|||||||
OSType folderType,
|
OSType folderType,
|
||||||
Boolean createFolder)
|
Boolean createFolder)
|
||||||
{
|
{
|
||||||
short vRefNum ;
|
short vRefNum ;
|
||||||
long dirID ;
|
long dirID ;
|
||||||
wxString strDir ;
|
wxString strDir ;
|
||||||
|
|
||||||
if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
|
if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr)
|
||||||
{
|
{
|
||||||
FSSpec file ;
|
FSSpec file ;
|
||||||
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
|
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
|
||||||
{
|
{
|
||||||
strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ;
|
strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strDir ;
|
return strDir ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __DARWIN__
|
#ifndef __DARWIN__
|
||||||
@@ -479,8 +483,8 @@ void wxDisplaySizeMM(int *width, int *height)
|
|||||||
|
|
||||||
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
||||||
{
|
{
|
||||||
BitMap screenBits;
|
BitMap screenBits;
|
||||||
GetQDGlobalsScreenBits( &screenBits );
|
GetQDGlobalsScreenBits( &screenBits );
|
||||||
|
|
||||||
if (x) *x = 0;
|
if (x) *x = 0;
|
||||||
if (y) *y = 0;
|
if (y) *y = 0;
|
||||||
@@ -488,15 +492,15 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
|
|||||||
*width = screenBits.bounds.right - screenBits.bounds.left ;
|
*width = screenBits.bounds.right - screenBits.bounds.left ;
|
||||||
*height = screenBits.bounds.bottom - screenBits.bounds.top ;
|
*height = screenBits.bounds.bottom - screenBits.bounds.top ;
|
||||||
|
|
||||||
SInt16 mheight ;
|
SInt16 mheight ;
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
GetThemeMenuBarHeight( &mheight ) ;
|
GetThemeMenuBarHeight( &mheight ) ;
|
||||||
#else
|
#else
|
||||||
mheight = LMGetMBarHeight() ;
|
mheight = LMGetMBarHeight() ;
|
||||||
#endif
|
#endif
|
||||||
*height -= mheight ;
|
*height -= mheight ;
|
||||||
if ( y )
|
if ( y )
|
||||||
*y = mheight ;
|
*y = mheight ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
|
||||||
|
Reference in New Issue
Block a user