1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDirDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "dirdlg.h"
16 #include "wx/wxprec.h"
19 #include "wx/dialog.h"
20 #include "wx/dirdlg.h"
22 #include "wx/cmndata.h"
24 #include "wx/mac/private.h"
27 #include <Carbon/Carbon.h>
29 #include <Navigation.h>
32 #if !USE_SHARED_LIBRARY
33 IMPLEMENT_CLASS(wxDirDialog
, wxDialog
)
36 wxDirDialog::wxDirDialog(wxWindow
*parent
,
37 const wxString
& message
,
38 const wxString
& defaultPath
,
40 const wxPoint
& WXUNUSED(pos
),
41 const wxSize
& WXUNUSED(size
),
42 const wxString
& WXUNUSED(name
))
44 wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
46 m_dialogStyle
= style
;
51 int wxDirDialog::ShowModal()
53 NavDialogOptions mNavOptions
;
54 NavObjectFilterUPP mNavFilterUPP
= NULL
;
55 NavPreviewUPP mNavPreviewUPP
= NULL
;
56 NavReplyRecord mNavReply
;
57 AEDesc
* mDefaultLocation
= NULL
;
58 bool mSelectDefault
= false ;
60 ::NavGetDefaultDialogOptions(&mNavOptions
);
64 mSelectDefault
= false;
65 mNavReply
.validRecord
= false;
66 mNavReply
.replacing
= false;
67 mNavReply
.isStationery
= false;
68 mNavReply
.translationNeeded
= false;
69 mNavReply
.selection
.descriptorType
= typeNull
;
70 mNavReply
.selection
.dataHandle
= nil
;
71 mNavReply
.keyScript
= smSystemScript
;
72 mNavReply
.fileTranslation
= nil
;
74 // Set default location, the location
75 // that's displayed when the dialog
78 if ( mDefaultLocation
) {
81 mNavOptions
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
83 mNavOptions
.dialogOptionFlags
&= ~kNavSelectDefaultLocation
;
87 OSErr err
= ::NavChooseFolder(
95 if ( (err
!= noErr
) && (err
!= userCanceledErr
) ) {
100 if (mNavReply
.validRecord
) { // User chose a folder
105 OSErr err
= ::AECoerceDesc( &mNavReply
.selection
, typeFSRef
, &specDesc
);
106 if ( err
!= noErr
) {
110 folderInfo
= **(FSRef
**) specDesc
.dataHandle
;
111 if (specDesc
.dataHandle
!= nil
) {
112 ::AEDisposeDesc(&specDesc
);
115 m_path
= wxMacFSRefToPath( &folderInfo
) ;