+ wxCFStringRef cf( m_message );
+ wxCFStringRef dir( m_dir );
+ wxCFStringRef file( m_fileName );
+
+ wxNonOwnedWindow* parentWindow = NULL;
+
+ m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
+
+ if (GetParent())
+ parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
+
+ wxASSERT_MSG(parentWindow, "Window modal display requires parent.");
+
+ if (HasFlag(wxFD_SAVE))
+ {
+ NSSavePanel* sPanel = [NSSavePanel savePanel];
+ // makes things more convenient:
+ [sPanel setCanCreateDirectories:YES];
+ [sPanel setMessage:cf.AsNSString()];
+ // if we should be able to descend into pacakges we must somehow
+ // be able to pass this in
+ [sPanel setTreatsFilePackagesAsDirectories:NO];
+ [sPanel setCanSelectHiddenExtension:YES];
+
+ NSWindow* nativeParent = parentWindow->GetWXWindow();
+ ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init];
+ [sheetDelegate setImplementation: this];
+ [sPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
+ modalForWindow: nativeParent modalDelegate: sheetDelegate
+ didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
+ contextInfo: nil];
+ }
+ else
+ {
+ NSArray* types = GetTypesFromFilter( m_wildCard ) ;
+ NSOpenPanel* oPanel = [NSOpenPanel openPanel];
+ [oPanel setTreatsFilePackagesAsDirectories:NO];
+ [oPanel setCanChooseDirectories:NO];
+ [oPanel setResolvesAliases:YES];
+ [oPanel setCanChooseFiles:YES];
+ [oPanel setMessage:cf.AsNSString()];
+
+ NSWindow* nativeParent = parentWindow->GetWXWindow();
+ ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init];
+ [sheetDelegate setImplementation: this];
+ [oPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
+ types: types modalForWindow: nativeParent
+ modalDelegate: sheetDelegate
+ didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
+ contextInfo: nil];
+ }
+}