1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDirDialog
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
17 #include "wx/dialog.h"
18 #include "wx/dirdlg.h"
20 #include "wx/cmndata.h"
22 #include "wx/mac/private.h"
25 #include <Carbon/Carbon.h>
27 #include <Navigation.h>
30 IMPLEMENT_CLASS(wxDirDialog
, wxDialog
)
32 wxDirDialog::wxDirDialog(wxWindow
*parent
,
33 const wxString
& message
,
34 const wxString
& defaultPath
,
36 const wxPoint
& WXUNUSED(pos
),
37 const wxSize
& WXUNUSED(size
),
38 const wxString
& WXUNUSED(name
))
40 wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
42 m_dialogStyle
= style
;
47 int wxDirDialog::ShowModal()
50 NavDialogCreationOptions options
;
51 NavReplyRecord reply
;
52 bool disposeReply
= false ;
55 err
= NavGetDefaultDialogCreationOptions(&options
);
58 wxMacCFStringHolder
message(m_message
, m_font
.GetEncoding());
59 options
.message
= message
;
60 err
= NavCreateChooseFolderDialog(&options
, NULL
, NULL
, NULL
, &dialog
);
63 err
= NavDialogRun(dialog
);
66 err
= NavDialogGetReply(dialog
, &reply
);
74 if ( reply
.validRecord
)
79 OSErr err
= ::AECoerceDesc( &reply
.selection
, typeFSRef
, &specDesc
);
82 m_path
= wxEmptyString
;
86 folderInfo
= **(FSRef
**) specDesc
.dataHandle
;
87 m_path
= wxMacFSRefToPath( &folderInfo
) ;
88 if (specDesc
.dataHandle
!= nil
)
90 ::AEDisposeDesc(&specDesc
);
96 err
= paramErr
; // could be any error, only used for giving back wxID_CANCEL
101 ::NavDisposeReply(&reply
);
103 // apparently cancelling shouldn't change m_path
104 if ( err
!= noErr
&& err
!= userCanceledErr
)
105 m_path
= wxEmptyString
;
107 return (err
== noErr
) ? wxID_OK
: wxID_CANCEL
;