]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/dirdlg.cpp
metal appearance supported under 10.3
[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
12#ifdef __GNUG__
13#pragma implementation "dirdlg.h"
14#endif
15
16#include "wx/defs.h"
17#include "wx/utils.h"
18#include "wx/dialog.h"
19#include "wx/dirdlg.h"
20
21#include "wx/cmndata.h"
22
76a5e5d2
SC
23#include "wx/mac/private.h"
24
f5c6eb5c 25#ifdef __DARWIN__
5fde6fcc 26 #include <Carbon/Carbon.h>
03e11df5
GD
27#else
28 #include <Navigation.h>
29#endif
5b781a67 30
2f1ae414 31#if !USE_SHARED_LIBRARY
e9576ca5 32IMPLEMENT_CLASS(wxDirDialog, wxDialog)
2f1ae414 33#endif
519cb848 34
e78d4a23
VZ
35wxDirDialog::wxDirDialog(wxWindow *parent,
36 const wxString& message,
37 const wxString& defaultPath,
38 long style,
39 const wxPoint& WXUNUSED(pos),
40 const wxSize& WXUNUSED(size),
41 const wxString& WXUNUSED(name))
e9576ca5 42{
427ff662 43 wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
e9576ca5
SC
44 m_message = message;
45 m_dialogStyle = style;
46 m_parent = parent;
e40298d5 47 m_path = defaultPath;
e9576ca5
SC
48}
49
50int wxDirDialog::ShowModal()
51{
e40298d5
JS
52 NavDialogOptions mNavOptions;
53 NavObjectFilterUPP mNavFilterUPP = NULL;
54 NavPreviewUPP mNavPreviewUPP = NULL ;
55 NavReplyRecord mNavReply;
56 AEDesc* mDefaultLocation = NULL ;
57 bool mSelectDefault = false ;
58
59 ::NavGetDefaultDialogOptions(&mNavOptions);
76a5e5d2 60
e40298d5
JS
61 mNavFilterUPP = nil;
62 mNavPreviewUPP = nil;
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;
72
73 // Set default location, the location
74 // that's displayed when the dialog
75 // first appears
76
77 if ( mDefaultLocation ) {
78
79 if (mSelectDefault) {
80 mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
81 } else {
82 mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
83 }
84 }
85
86 OSErr err = ::NavChooseFolder(
87 mDefaultLocation,
88 &mNavReply,
89 &mNavOptions,
90 NULL,
91 mNavFilterUPP,
92 0L); // User Data
93
94 if ( (err != noErr) && (err != userCanceledErr) ) {
427ff662 95 m_path = wxT("") ;
e40298d5
JS
96 return wxID_CANCEL ;
97 }
5b781a67 98
e40298d5
JS
99 if (mNavReply.validRecord) { // User chose a folder
100
a2b77260 101 FSRef folderInfo;
e40298d5
JS
102 AEDesc specDesc ;
103
a2b77260 104 OSErr err = ::AECoerceDesc( &mNavReply.selection , typeFSRef, &specDesc);
e40298d5 105 if ( err != noErr ) {
427ff662 106 m_path = wxT("") ;
e40298d5
JS
107 return wxID_CANCEL ;
108 }
a2b77260 109 folderInfo = **(FSRef**) specDesc.dataHandle;
e40298d5
JS
110 if (specDesc.dataHandle != nil) {
111 ::AEDisposeDesc(&specDesc);
112 }
76a5e5d2 113
a2b77260 114 m_path = wxMacFSRefToPath( &folderInfo ) ;
e40298d5
JS
115 return wxID_OK ;
116 }
117 return wxID_CANCEL;
e9576ca5
SC
118}
119