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()
54 NavDialogCreationOptions options
;
55 NavReplyRecord reply
;
56 bool disposeReply
= false ;
59 err
= NavGetDefaultDialogCreationOptions(&options
);
62 wxMacCFStringHolder
message(m_message
, m_font
.GetEncoding());
63 options
.message
= message
;
64 err
= NavCreateChooseFolderDialog(&options
, NULL
, NULL
, NULL
, &dialog
);
67 err
= NavDialogRun(dialog
);
70 err
= NavDialogGetReply(dialog
, &reply
);
78 if ( reply
.validRecord
)
83 OSErr err
= ::AECoerceDesc( &reply
.selection
, typeFSRef
, &specDesc
);
86 m_path
= wxEmptyString
;
90 folderInfo
= **(FSRef
**) specDesc
.dataHandle
;
91 m_path
= wxMacFSRefToPath( &folderInfo
) ;
92 if (specDesc
.dataHandle
!= nil
)
94 ::AEDisposeDesc(&specDesc
);
100 err
= paramErr
; // could be any error, only used for giving back wxID_CANCEL
105 ::NavDisposeReply(&reply
);
107 // apparently cancelling shouldn't change m_path
108 if ( err
!= noErr
&& err
!= userCanceledErr
)
109 m_path
= wxEmptyString
;
111 return (err
== noErr
) ? wxID_OK
: wxID_CANCEL
;