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"
21 #include "wx/dialog.h"
22 #include "wx/dirdlg.h"
24 #include "wx/cmndata.h"
26 #include "wx/mac/private.h"
29 #include <Carbon/Carbon.h>
31 #include <Navigation.h>
34 #if !USE_SHARED_LIBRARY
35 IMPLEMENT_CLASS(wxDirDialog
, wxDialog
)
38 wxDirDialog::wxDirDialog(wxWindow
*parent
,
39 const wxString
& message
,
40 const wxString
& defaultPath
,
42 const wxPoint
& WXUNUSED(pos
),
43 const wxSize
& WXUNUSED(size
),
44 const wxString
& WXUNUSED(name
))
46 wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
48 m_dialogStyle
= style
;
53 int wxDirDialog::ShowModal()
55 NavDialogOptions mNavOptions
;
56 NavObjectFilterUPP mNavFilterUPP
= NULL
;
57 NavPreviewUPP mNavPreviewUPP
= NULL
;
58 NavReplyRecord mNavReply
;
59 AEDesc
* mDefaultLocation
= NULL
;
60 bool mSelectDefault
= false ;
62 ::NavGetDefaultDialogOptions(&mNavOptions
);
66 mSelectDefault
= false;
67 mNavReply
.validRecord
= false;
68 mNavReply
.replacing
= false;
69 mNavReply
.isStationery
= false;
70 mNavReply
.translationNeeded
= false;
71 mNavReply
.selection
.descriptorType
= typeNull
;
72 mNavReply
.selection
.dataHandle
= nil
;
73 mNavReply
.keyScript
= smSystemScript
;
74 mNavReply
.fileTranslation
= nil
;
76 // Set default location, the location
77 // that's displayed when the dialog
80 if ( mDefaultLocation
) {
83 mNavOptions
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
85 mNavOptions
.dialogOptionFlags
&= ~kNavSelectDefaultLocation
;
89 OSErr err
= ::NavChooseFolder(
97 if ( (err
!= noErr
) && (err
!= userCanceledErr
) ) {
102 if (mNavReply
.validRecord
) { // User chose a folder
107 OSErr err
= ::AECoerceDesc( &mNavReply
.selection
, typeFSRef
, &specDesc
);
108 if ( err
!= noErr
) {
112 folderInfo
= **(FSRef
**) specDesc
.dataHandle
;
113 if (specDesc
.dataHandle
!= nil
) {
114 ::AEDisposeDesc(&specDesc
);
117 m_path
= wxMacFSRefToPath( &folderInfo
) ;