1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDirDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dirdlg.h"
18 #include "wx/dialog.h"
19 #include "wx/dirdlg.h"
21 #include "wx/cmndata.h"
23 #include "wx/mac/private.h"
26 #include <Carbon/Carbon.h>
28 #include <Navigation.h>
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_CLASS(wxDirDialog
, wxDialog
)
35 wxDirDialog::wxDirDialog(wxWindow
*parent
,
36 const wxString
& message
,
37 const wxString
& defaultPath
,
39 const wxPoint
& WXUNUSED(pos
),
40 const wxSize
& WXUNUSED(size
),
41 const wxString
& WXUNUSED(name
))
43 wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
45 m_dialogStyle
= style
;
50 int wxDirDialog::ShowModal()
52 NavDialogOptions mNavOptions
;
53 NavObjectFilterUPP mNavFilterUPP
= NULL
;
54 NavPreviewUPP mNavPreviewUPP
= NULL
;
55 NavReplyRecord mNavReply
;
56 AEDesc
* mDefaultLocation
= NULL
;
57 bool mSelectDefault
= false ;
59 ::NavGetDefaultDialogOptions(&mNavOptions
);
63 mSelectDefault
= false;
64 mNavReply
.validRecord
= false;
65 mNavReply
.replacing
= false;
66 mNavReply
.isStationery
= false;
67 mNavReply
.translationNeeded
= false;
68 mNavReply
.selection
.descriptorType
= typeNull
;
69 mNavReply
.selection
.dataHandle
= nil
;
70 mNavReply
.keyScript
= smSystemScript
;
71 mNavReply
.fileTranslation
= nil
;
73 // Set default location, the location
74 // that's displayed when the dialog
77 if ( mDefaultLocation
) {
80 mNavOptions
.dialogOptionFlags
|= kNavSelectDefaultLocation
;
82 mNavOptions
.dialogOptionFlags
&= ~kNavSelectDefaultLocation
;
86 OSErr err
= ::NavChooseFolder(
94 if ( (err
!= noErr
) && (err
!= userCanceledErr
) ) {
99 if (mNavReply
.validRecord
) { // User chose a folder
104 OSErr err
= ::AECoerceDesc( &mNavReply
.selection
, typeFSRef
, &specDesc
);
105 if ( err
!= noErr
) {
109 folderInfo
= **(FSRef
**) specDesc
.dataHandle
;
110 if (specDesc
.dataHandle
!= nil
) {
111 ::AEDisposeDesc(&specDesc
);
114 m_path
= wxMacFSRefToPath( &folderInfo
) ;