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