+ // 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];
+
+ SetupExtraControls(oPanel);
+
+ [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];
+ }
+}
+
+void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
+{
+ NSSavePanel* panel = (NSSavePanel*) nativeWindow;
+
+ wxNonOwnedWindow::Create( GetParent(), nativeWindow );
+
+ if (HasExtraControlCreator())
+ {
+ CreateExtraControl();
+ wxWindow* control = GetExtraControl();
+ if ( control )
+ {
+ NSView* accView = control->GetHandle();
+ [accView removeFromSuperview];
+ [panel setAccessoryView:accView];
+ }
+ else
+ {
+ [panel setAccessoryView:nil];
+ }
+ }
+}
+
+int wxFileDialog::ShowModal()
+{