]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/dirdlg.cpp
'[1219035] cleanup: miscellaneous' and minor source cleaning.
[wxWidgets.git] / src / mac / carbon / dirdlg.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: dirdlg.cpp
3// Purpose: wxDirDialog
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
e9576ca5
SC
13#pragma implementation "dirdlg.h"
14#endif
15
3d1a4878
SC
16#include "wx/wxprec.h"
17
179e085f
RN
18#if wxUSE_DIRDLG
19
e9576ca5
SC
20#include "wx/utils.h"
21#include "wx/dialog.h"
22#include "wx/dirdlg.h"
23
24#include "wx/cmndata.h"
25
76a5e5d2
SC
26#include "wx/mac/private.h"
27
f5c6eb5c 28#ifdef __DARWIN__
5fde6fcc 29 #include <Carbon/Carbon.h>
03e11df5
GD
30#else
31 #include <Navigation.h>
32#endif
5b781a67 33
e9576ca5 34IMPLEMENT_CLASS(wxDirDialog, wxDialog)
519cb848 35
e78d4a23
VZ
36wxDirDialog::wxDirDialog(wxWindow *parent,
37 const wxString& message,
38 const wxString& defaultPath,
39 long style,
40 const wxPoint& WXUNUSED(pos),
41 const wxSize& WXUNUSED(size),
42 const wxString& WXUNUSED(name))
e9576ca5 43{
427ff662 44 wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
e9576ca5
SC
45 m_message = message;
46 m_dialogStyle = style;
47 m_parent = parent;
e40298d5 48 m_path = defaultPath;
e9576ca5
SC
49}
50
51int wxDirDialog::ShowModal()
52{
e40298d5 53 NavDialogOptions mNavOptions;
902725ee
WS
54 NavObjectFilterUPP mNavFilterUPP = NULL;
55 NavReplyRecord mNavReply;
56
e40298d5 57 ::NavGetDefaultDialogOptions(&mNavOptions);
76a5e5d2 58
902725ee
WS
59 mNavReply.validRecord = false;
60 mNavReply.replacing = false;
61 mNavReply.isStationery = false;
62 mNavReply.translationNeeded = false;
e40298d5 63 mNavReply.selection.descriptorType = typeNull;
902725ee
WS
64 mNavReply.selection.dataHandle = nil;
65 mNavReply.keyScript = smSystemScript;
66 mNavReply.fileTranslation = nil;
67
e40298d5
JS
68 // Set default location, the location
69 // that's displayed when the dialog
70 // first appears
902725ee 71
e40298d5 72 OSErr err = ::NavChooseFolder(
902725ee 73 NULL,
e40298d5
JS
74 &mNavReply,
75 &mNavOptions,
76 NULL,
77 mNavFilterUPP,
78 0L); // User Data
902725ee 79
e40298d5 80 if ( (err != noErr) && (err != userCanceledErr) ) {
902725ee 81 m_path = wxEmptyString ;
e40298d5
JS
82 return wxID_CANCEL ;
83 }
5b781a67 84
e40298d5 85 if (mNavReply.validRecord) { // User chose a folder
902725ee 86
a2b77260 87 FSRef folderInfo;
e40298d5 88 AEDesc specDesc ;
902725ee 89
a2b77260 90 OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSRef, &specDesc);
e40298d5 91 if ( err != noErr ) {
902725ee 92 m_path = wxEmptyString ;
e40298d5 93 return wxID_CANCEL ;
902725ee 94 }
a2b77260 95 folderInfo = **(FSRef**) specDesc.dataHandle;
e40298d5
JS
96 if (specDesc.dataHandle != nil) {
97 ::AEDisposeDesc(&specDesc);
98 }
76a5e5d2 99
a2b77260 100 m_path = wxMacFSRefToPath( &folderInfo ) ;
e40298d5
JS
101 return wxID_OK ;
102 }
103 return wxID_CANCEL;
e9576ca5
SC
104}
105
179e085f 106#endif