]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/filedlg.mm
Revert "using #ifdef wxABORT_ON_CONFIG_ERROR not just #if as elsewhere"
[wxWidgets.git] / src / osx / cocoa / filedlg.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/filedlg.mm
3 // Purpose: wxFileDialog for wxCocoa
4 // Author: Ryan Norton
5 // Modified by:
6 // Created: 2004-10-02
7 // Copyright: (c) Ryan Norton
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #if wxUSE_FILEDLG
23
24 #include "wx/filedlg.h"
25
26 #ifndef WX_PRECOMP
27 #include "wx/msgdlg.h"
28 #include "wx/app.h"
29 #include "wx/sizer.h"
30 #include "wx/stattext.h"
31 #include "wx/choice.h"
32 #endif
33
34 #include "wx/filename.h"
35 #include "wx/tokenzr.h"
36 #include "wx/evtloop.h"
37
38 #include "wx/osx/private.h"
39 #include "wx/sysopt.h"
40 #include "wx/modalhook.h"
41
42 #include <mach-o/dyld.h>
43
44 // ============================================================================
45 // implementation
46 // ============================================================================
47
48 // Open Items:
49 // - parameter support for descending into packages as directories (setTreatsFilePackagesAsDirectories)
50 // - as setAllowedFileTypes is only functional for NSOpenPanel on 10.6+, on earlier systems, the file
51 // type choice will not be shown, but all possible file items will be shown, if a popup must be working
52 // then the delegate method - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename will have to
53 // be implemented
54
55 namespace
56 {
57
58 bool HasAppKit_10_6()
59 {
60 // Even if we require 10.6, we might be loaded by an application that
61 // was linked against 10.5. setAllowedFileTypes will still be ignored
62 // in this case. From NSSavePanel.h:
63 // NSOpenPanel: On versions less than 10.6, this property is ignored.
64 // For applications that link against 10.6 and higher, this property will
65 // determine which files should be enabled in the open panel.
66 int32_t version = NSVersionOfLinkTimeLibrary("AppKit");
67 if (version == -1)
68 {
69 // If we're loaded by an application that doesn't link against AppKit,
70 // use the runtime version instead. This check will not work for the
71 // case above.
72 version = NSVersionOfRunTimeLibrary("AppKit");
73 }
74
75 // Notice that this still works correctly even if version is -1.
76 return version >= 0x40e2400 /* version of 10.6 AppKit */;
77 }
78
79 } // anonymous namespace
80
81 @interface wxOpenPanelDelegate : NSObject wxOSX_10_6_AND_LATER(<NSOpenSavePanelDelegate>)
82 {
83 wxFileDialog* _dialog;
84 }
85
86 - (wxFileDialog*) fileDialog;
87 - (void) setFileDialog:(wxFileDialog*) dialog;
88
89 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename;
90
91 @end
92
93 @implementation wxOpenPanelDelegate
94
95 - (id) init
96 {
97 self = [super init];
98 _dialog = NULL;
99 return self;
100 }
101
102 - (wxFileDialog*) fileDialog
103 {
104 return _dialog;
105 }
106
107 - (void) setFileDialog:(wxFileDialog*) dialog
108 {
109 _dialog = dialog;
110 }
111
112 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
113 {
114 BOOL showObject = YES;
115
116 NSString* resolvedLink = [[NSFileManager defaultManager] pathContentOfSymbolicLinkAtPath:filename];
117 if ( resolvedLink != nil )
118 filename = resolvedLink;
119
120 NSDictionary* fileAttribs = [[NSFileManager defaultManager]
121 fileAttributesAtPath:filename traverseLink:YES];
122 if (fileAttribs)
123 {
124 // check for packages
125 if ([NSFileTypeDirectory isEqualTo:[fileAttribs objectForKey:NSFileType]])
126 {
127 if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename] == NO)
128 showObject = YES; // it's a folder, OK to show
129 else
130 {
131 // it's a packaged directory, apply check
132 wxCFStringRef filecf([filename retain]);
133 showObject = _dialog->CheckFile(filecf.AsString());
134 }
135 }
136 else
137 {
138 // the code above only solves links, not aliases, do this here:
139
140 NSString* resolvedAlias = nil;
141
142 CFURLRef url = CFURLCreateWithFileSystemPath (kCFAllocatorDefault,
143 (CFStringRef)filename,
144 kCFURLPOSIXPathStyle,
145 NO);
146 if (url != NULL)
147 {
148 FSRef fsRef;
149 if (CFURLGetFSRef(url, &fsRef))
150 {
151 Boolean targetIsFolder, wasAliased;
152 OSErr err = FSResolveAliasFile (&fsRef, true, &targetIsFolder, &wasAliased);
153
154 if ((err == noErr) && wasAliased)
155 {
156 CFURLRef resolvedUrl = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
157 if (resolvedUrl != NULL)
158 {
159 resolvedAlias = (NSString*) CFURLCopyFileSystemPath(resolvedUrl,
160 kCFURLPOSIXPathStyle);
161 CFRelease(resolvedUrl);
162 }
163 }
164 }
165 CFRelease(url);
166 }
167
168 if (resolvedAlias != nil)
169 {
170 // recursive call
171 [resolvedAlias autorelease];
172 showObject = [self panel:sender shouldShowFilename:resolvedAlias];
173 }
174 else
175 {
176 wxCFStringRef filecf([filename retain]);
177 showObject = _dialog->CheckFile(filecf.AsString());
178 }
179 }
180 }
181
182 return showObject;
183 }
184
185 @end
186
187 IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
188
189 void wxFileDialog::Init()
190 {
191 m_filterIndex = -1;
192 m_delegate = nil;
193 m_sheetDelegate = nil;
194 }
195
196 void wxFileDialog::Create(
197 wxWindow *parent, const wxString& message,
198 const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
199 long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
200 {
201 wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name);
202
203 m_sheetDelegate = [[ModalDialogDelegate alloc] init];
204 [(ModalDialogDelegate*)m_sheetDelegate setImplementation: this];
205 }
206
207 wxFileDialog::~wxFileDialog()
208 {
209 [m_sheetDelegate release];
210 }
211
212 bool wxFileDialog::SupportsExtraControl() const
213 {
214 return true;
215 }
216
217 NSArray* GetTypesFromExtension( const wxString extensiongroup, wxArrayString& extensions )
218 {
219 NSMutableArray* types = nil;
220 extensions.Clear();
221
222 wxStringTokenizer tokenizer( extensiongroup, wxT(";") ) ;
223 while ( tokenizer.HasMoreTokens() )
224 {
225 wxString extension = tokenizer.GetNextToken() ;
226 // Remove leading '*'
227 if ( extension.length() && (extension.GetChar(0) == '*') )
228 extension = extension.Mid( 1 );
229
230 // Remove leading '.'
231 if ( extension.length() && (extension.GetChar(0) == '.') )
232 extension = extension.Mid( 1 );
233
234 // Remove leading '*', this is for handling *.*
235 if ( extension.length() && (extension.GetChar(0) == '*') )
236 extension = extension.Mid( 1 );
237
238 if ( extension.IsEmpty() )
239 {
240 extensions.Clear();
241 [types release];
242 types = nil;
243 return nil;
244 }
245
246 if ( types == nil )
247 types = [[NSMutableArray alloc] init];
248
249 extensions.Add(extension.Lower());
250 wxCFStringRef cfext(extension);
251 [types addObject: (NSString*)cfext.AsNSString() ];
252 #if 0
253 // add support for classic fileType / creator here
254 wxUint32 fileType, creator;
255 // extension -> mactypes
256 #endif
257 }
258 [types autorelease];
259 return types;
260 }
261
262 NSArray* GetTypesFromFilter( const wxString& filter, wxArrayString& names, wxArrayString& extensiongroups )
263 {
264 NSMutableArray* types = nil;
265 bool allowAll = false;
266
267 names.Clear();
268 extensiongroups.Clear();
269
270 if ( !filter.empty() )
271 {
272 wxStringTokenizer tokenizer( filter, wxT("|") );
273 int numtokens = (int)tokenizer.CountTokens();
274 if(numtokens == 1)
275 {
276 // we allow for compatibility reason to have a single filter expression (like *.*) without
277 // an explanatory text, in that case the first part is name and extension at the same time
278 wxString extension = tokenizer.GetNextToken();
279 names.Add( extension );
280 extensiongroups.Add( extension );
281 }
282 else
283 {
284 int numextensions = numtokens / 2;
285 for(int i = 0; i < numextensions; i++)
286 {
287 wxString name = tokenizer.GetNextToken();
288 wxString extension = tokenizer.GetNextToken();
289 names.Add( name );
290 extensiongroups.Add( extension );
291 }
292 }
293
294 const size_t extCount = extensiongroups.GetCount();
295 wxArrayString extensions;
296 for ( size_t i = 0 ; i < extCount; i++ )
297 {
298 NSArray* exttypes = GetTypesFromExtension(extensiongroups[i], extensions);
299 if ( exttypes != nil )
300 {
301 if ( allowAll == false )
302 {
303 if ( types == nil )
304 types = [[NSMutableArray alloc] init];
305
306 [types addObjectsFromArray:exttypes];
307 }
308 }
309 else
310 {
311 allowAll = true;
312 [types release];
313 types = nil;
314 }
315 }
316 }
317 [types autorelease];
318 return types;
319 }
320
321 void wxFileDialog::ShowWindowModal()
322 {
323 wxCFStringRef cf( m_message );
324 wxCFStringRef dir( m_dir );
325 wxCFStringRef file( m_fileName );
326
327 wxNonOwnedWindow* parentWindow = NULL;
328
329 m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
330
331 if (GetParent())
332 parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
333
334 wxASSERT_MSG(parentWindow, "Window modal display requires parent.");
335
336 NSArray* types = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions ) ;
337 if ( HasFlag(wxFD_SAVE) )
338 {
339 NSSavePanel* sPanel = [NSSavePanel savePanel];
340
341 SetupExtraControls(sPanel);
342
343 // makes things more convenient:
344 [sPanel setCanCreateDirectories:YES];
345 [sPanel setMessage:cf.AsNSString()];
346 // if we should be able to descend into pacakges we must somehow
347 // be able to pass this in
348 [sPanel setTreatsFilePackagesAsDirectories:NO];
349 [sPanel setCanSelectHiddenExtension:YES];
350 [sPanel setAllowedFileTypes:types];
351 [sPanel setAllowsOtherFileTypes:NO];
352
353 NSWindow* nativeParent = parentWindow->GetWXWindow();
354 [sPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
355 modalForWindow: nativeParent modalDelegate: m_sheetDelegate
356 didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
357 contextInfo: nil];
358 }
359 else
360 {
361 NSOpenPanel* oPanel = [NSOpenPanel openPanel];
362
363 SetupExtraControls(oPanel);
364
365 [oPanel setTreatsFilePackagesAsDirectories:NO];
366 [oPanel setCanChooseDirectories:NO];
367 [oPanel setResolvesAliases:YES];
368 [oPanel setCanChooseFiles:YES];
369 [oPanel setMessage:cf.AsNSString()];
370 [oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
371
372 NSWindow* nativeParent = parentWindow->GetWXWindow();
373 [oPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
374 types: types modalForWindow: nativeParent
375 modalDelegate: m_sheetDelegate
376 didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
377 contextInfo: nil];
378 }
379 }
380
381 // Create a panel with the file type drop down list
382 // If extra controls need to be added (see wxFileDialog::SetExtraControlCreator), add
383 // them to the panel as well
384 // Returns the newly created wxPanel
385
386 wxWindow* wxFileDialog::CreateFilterPanel(wxWindow *extracontrol)
387 {
388 wxPanel *extrapanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
389 wxBoxSizer *verticalSizer = new wxBoxSizer(wxVERTICAL);
390 extrapanel->SetSizer(verticalSizer);
391
392 // the file type control
393 {
394 wxBoxSizer *horizontalSizer = new wxBoxSizer(wxHORIZONTAL);
395 verticalSizer->Add(horizontalSizer, 0, wxEXPAND, 0);
396 wxStaticText *stattext = new wxStaticText( extrapanel, wxID_ANY, _("File type:") );
397 horizontalSizer->Add(stattext, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
398 m_filterChoice = new wxChoice(extrapanel, wxID_ANY);
399 horizontalSizer->Add(m_filterChoice, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
400 m_filterChoice->Append(m_filterNames);
401 if( m_filterNames.GetCount() > 0)
402 {
403 if ( m_firstFileTypeFilter >= 0 )
404 m_filterChoice->SetSelection(m_firstFileTypeFilter);
405 }
406 m_filterChoice->Connect(wxEVT_CHOICE, wxCommandEventHandler(wxFileDialog::OnFilterSelected), NULL, this);
407 }
408
409 if(extracontrol)
410 {
411 wxBoxSizer *horizontalSizer = new wxBoxSizer(wxHORIZONTAL);
412 verticalSizer->Add(horizontalSizer, 0, wxEXPAND, 0);
413
414 extracontrol->Reparent(extrapanel);
415 horizontalSizer->Add(extracontrol);
416 }
417
418 verticalSizer->Layout();
419 verticalSizer->SetSizeHints(extrapanel);
420 return extrapanel;
421 }
422
423 void wxFileDialog::DoOnFilterSelected(int index)
424 {
425 NSArray* types = GetTypesFromExtension(m_filterExtensions[index],m_currentExtensions);
426 NSSavePanel* panel = (NSSavePanel*) GetWXWindow();
427 if ( m_delegate )
428 [panel validateVisibleColumns];
429 else
430 [panel setAllowedFileTypes:types];
431 }
432
433 // An item has been selected in the file filter wxChoice:
434 void wxFileDialog::OnFilterSelected( wxCommandEvent &WXUNUSED(event) )
435 {
436 DoOnFilterSelected( m_filterChoice->GetSelection() );
437 }
438
439 bool wxFileDialog::CheckFile( const wxString& filename )
440 {
441 if ( m_currentExtensions.GetCount() == 0 )
442 return true;
443
444 wxString ext = filename.AfterLast('.').Lower();
445
446 for ( size_t i = 0; i < m_currentExtensions.GetCount(); ++i )
447 {
448 if ( ext == m_currentExtensions[i] )
449 return true;
450 }
451 return false;
452 }
453
454 void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
455 {
456 NSSavePanel* panel = (NSSavePanel*) nativeWindow;
457 // for sandboxed app we cannot access the outer structures
458 // this leads to problems with extra controls, so as a temporary
459 // workaround for crashes we don't support those yet
460 if ( [panel contentView] == nil )
461 return;
462
463 wxNonOwnedWindow::Create( GetParent(), nativeWindow );
464 wxWindow* extracontrol = NULL;
465 if ( HasExtraControlCreator() )
466 {
467 CreateExtraControl();
468 extracontrol = GetExtraControl();
469 }
470
471 NSView* accView = nil;
472
473 if ( m_useFileTypeFilter )
474 {
475 m_filterPanel = CreateFilterPanel(extracontrol);
476 accView = m_filterPanel->GetHandle();
477 if( HasFlag(wxFD_OPEN) )
478 {
479 if ( UMAGetSystemVersion() < 0x1060 || !HasAppKit_10_6() )
480 {
481 wxOpenPanelDelegate* del = [[wxOpenPanelDelegate alloc]init];
482 [del setFileDialog:this];
483 [panel setDelegate:del];
484 m_delegate = del;
485 }
486 }
487 }
488 else
489 {
490 m_filterPanel = NULL;
491 m_filterChoice = NULL;
492 if ( extracontrol != nil )
493 accView = extracontrol->GetHandle();
494 }
495
496 if ( accView != nil )
497 {
498 [accView removeFromSuperview];
499 [panel setAccessoryView:accView];
500 }
501 else
502 {
503 [panel setAccessoryView:nil];
504 }
505 }
506
507 int wxFileDialog::ShowModal()
508 {
509 WX_HOOK_MODAL_DIALOG();
510
511 wxCFEventLoopPauseIdleEvents pause;
512
513 wxMacAutoreleasePool autoreleasepool;
514
515 wxCFStringRef cf( m_message );
516
517 wxCFStringRef dir( m_dir );
518 wxCFStringRef file( m_fileName );
519
520 m_path = wxEmptyString;
521 m_fileNames.Clear();
522 m_paths.Clear();
523
524 wxNonOwnedWindow* parentWindow = NULL;
525 int returnCode = -1;
526
527 if (GetParent())
528 {
529 parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
530 }
531
532
533 NSArray* types = GetTypesFromFilter( m_wildCard, m_filterNames, m_filterExtensions ) ;
534
535 m_useFileTypeFilter = m_filterExtensions.GetCount() > 1;
536
537 if( HasFlag(wxFD_OPEN) )
538 {
539 if ( !(wxSystemOptions::HasOption( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES ) && (wxSystemOptions::GetOptionInt( wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES ) == 1)) )
540 m_useFileTypeFilter = false;
541 }
542
543 m_firstFileTypeFilter = -1;
544
545 if ( m_useFileTypeFilter
546 && m_filterIndex >= 0 && m_filterIndex < m_filterExtensions.GetCount() )
547 {
548 m_firstFileTypeFilter = m_filterIndex;
549 }
550 else if ( m_useFileTypeFilter )
551 {
552 types = nil;
553 bool useDefault = true;
554 for ( size_t i = 0; i < m_filterExtensions.GetCount(); ++i )
555 {
556 types = GetTypesFromExtension(m_filterExtensions[i], m_currentExtensions);
557 if ( m_currentExtensions.GetCount() == 0 )
558 {
559 useDefault = false;
560 m_firstFileTypeFilter = i;
561 break;
562 }
563
564 for ( size_t j = 0; j < m_currentExtensions.GetCount(); ++j )
565 {
566 if ( m_fileName.EndsWith(m_currentExtensions[j]) )
567 {
568 m_firstFileTypeFilter = i;
569 useDefault = false;
570 break;
571 }
572 }
573 if ( !useDefault )
574 break;
575 }
576 if ( useDefault )
577 {
578 types = GetTypesFromExtension(m_filterExtensions[0], m_currentExtensions);
579 m_firstFileTypeFilter = 0;
580 }
581 }
582
583 if ( HasFlag(wxFD_SAVE) )
584 {
585 NSSavePanel* sPanel = [NSSavePanel savePanel];
586
587 SetupExtraControls(sPanel);
588
589 // makes things more convenient:
590 [sPanel setCanCreateDirectories:YES];
591 [sPanel setMessage:cf.AsNSString()];
592 // if we should be able to descend into pacakges we must somehow
593 // be able to pass this in
594 [sPanel setTreatsFilePackagesAsDirectories:NO];
595 [sPanel setCanSelectHiddenExtension:YES];
596 [sPanel setAllowedFileTypes:types];
597 [sPanel setAllowsOtherFileTypes:NO];
598
599 if ( HasFlag(wxFD_OVERWRITE_PROMPT) )
600 {
601 }
602
603 /*
604 Let the file dialog know what file type should be used initially.
605 If this is not done then when setting the filter index
606 programmatically to 1 the file will still have the extension
607 of the first file type instead of the second one. E.g. when file
608 types are foo and bar, a filename "myletter" with SetDialogIndex(1)
609 would result in saving as myletter.foo, while we want myletter.bar.
610 */
611 if(m_firstFileTypeFilter > 0)
612 {
613 DoOnFilterSelected(m_firstFileTypeFilter);
614 }
615
616 returnCode = [sPanel runModalForDirectory: m_dir.IsEmpty() ? nil : dir.AsNSString() file:file.AsNSString() ];
617 ModalFinishedCallback(sPanel, returnCode);
618 }
619 else
620 {
621 NSOpenPanel* oPanel = [NSOpenPanel openPanel];
622
623 SetupExtraControls(oPanel);
624
625 [oPanel setTreatsFilePackagesAsDirectories:NO];
626 [oPanel setCanChooseDirectories:NO];
627 [oPanel setResolvesAliases:YES];
628 [oPanel setCanChooseFiles:YES];
629 [oPanel setMessage:cf.AsNSString()];
630 [oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
631
632 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
633 if ( UMAGetSystemVersion() >= 0x1060 && HasAppKit_10_6() )
634 {
635 [oPanel setAllowedFileTypes: (m_delegate == nil ? types : nil)];
636 if ( !m_dir.IsEmpty() )
637 [oPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString()
638 isDirectory:YES]];
639 returnCode = [oPanel runModal];
640 }
641 else
642 #endif
643 {
644 returnCode = [oPanel runModalForDirectory:m_dir.IsEmpty() ? nil : dir.AsNSString()
645 file:file.AsNSString() types:(m_delegate == nil ? types : nil)];
646 }
647
648 ModalFinishedCallback(oPanel, returnCode);
649 }
650
651 return GetReturnCode();
652 }
653
654 void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode)
655 {
656 int result = wxID_CANCEL;
657 if (HasFlag(wxFD_SAVE))
658 {
659 if (returnCode == NSOKButton )
660 {
661 NSSavePanel* sPanel = (NSSavePanel*)panel;
662 result = wxID_OK;
663
664 m_path = wxCFStringRef::AsStringWithNormalizationFormC([sPanel filename]);
665 m_fileName = wxFileNameFromPath(m_path);
666 m_dir = wxPathOnly( m_path );
667 if (m_filterChoice)
668 {
669 m_filterIndex = m_filterChoice->GetSelection();
670 }
671 }
672 }
673 else
674 {
675 NSOpenPanel* oPanel = (NSOpenPanel*)panel;
676 if (returnCode == NSOKButton )
677 {
678 panel = oPanel;
679 result = wxID_OK;
680 NSArray* filenames = [oPanel filenames];
681 for ( size_t i = 0 ; i < [filenames count] ; ++ i )
682 {
683 wxString fnstr = wxCFStringRef::AsStringWithNormalizationFormC([filenames objectAtIndex:i]);
684 m_paths.Add( fnstr );
685 m_fileNames.Add( wxFileNameFromPath(fnstr) );
686 if ( i == 0 )
687 {
688 m_path = fnstr;
689 m_fileName = wxFileNameFromPath(fnstr);
690 m_dir = wxPathOnly( fnstr );
691 }
692 }
693 }
694 if ( m_delegate )
695 {
696 [oPanel setDelegate:nil];
697 [m_delegate release];
698 m_delegate = nil;
699 }
700 }
701 SetReturnCode(result);
702
703 if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL)
704 SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED );
705
706 // workaround for sandboxed app, see above
707 if ( m_isNativeWindowWrapper )
708 UnsubclassWin();
709 [(NSSavePanel*) panel setAccessoryView:nil];
710 }
711
712 #endif // wxUSE_FILEDLG