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 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 NavReplyRecord mNavReply
;
57 ::NavGetDefaultDialogOptions(&mNavOptions
);
59 mNavReply
.validRecord
= false;
60 mNavReply
.replacing
= false;
61 mNavReply
.isStationery
= false;
62 mNavReply
.translationNeeded
= false;
63 mNavReply
.selection
.descriptorType
= typeNull
;
64 mNavReply
.selection
.dataHandle
= nil
;
65 mNavReply
.keyScript
= smSystemScript
;
66 mNavReply
.fileTranslation
= nil
;
68 // Set default location, the location
69 // that's displayed when the dialog
72 OSErr err
= ::NavChooseFolder(
80 if ( (err
!= noErr
) && (err
!= userCanceledErr
) ) {
81 m_path
= wxEmptyString
;
85 if (mNavReply
.validRecord
) { // User chose a folder
90 OSErr err
= ::AECoerceDesc( &mNavReply
.selection
, typeFSRef
, &specDesc
);
92 m_path
= wxEmptyString
;
95 folderInfo
= **(FSRef
**) specDesc
.dataHandle
;
96 if (specDesc
.dataHandle
!= nil
) {
97 ::AEDisposeDesc(&specDesc
);
100 m_path
= wxMacFSRefToPath( &folderInfo
) ;