X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/05c218ee24532e075111254384d11e39f3106fcb..bd235295fb3b35fdb29326084b87893cf5432eb5:/src/osx/cocoa/filedlg.mm diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index fd87e5b385..4d5aaad01f 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -52,6 +52,11 @@ wxFileDialog::wxFileDialog( { } +bool wxFileDialog::SupportsExtraControl() const +{ + return true; +} + NSArray* GetTypesFromFilter( const wxString filter ) { NSMutableArray* types = nil; @@ -162,6 +167,9 @@ void wxFileDialog::ShowWindowModal() if (HasFlag(wxFD_SAVE)) { NSSavePanel* sPanel = [NSSavePanel savePanel]; + + SetupExtraControls(sPanel); + // makes things more convenient: [sPanel setCanCreateDirectories:YES]; [sPanel setMessage:cf.AsNSString()]; @@ -182,6 +190,9 @@ void wxFileDialog::ShowWindowModal() { NSArray* types = GetTypesFromFilter( m_wildCard ) ; NSOpenPanel* oPanel = [NSOpenPanel openPanel]; + + SetupExtraControls(oPanel); + [oPanel setTreatsFilePackagesAsDirectories:NO]; [oPanel setCanChooseDirectories:NO]; [oPanel setResolvesAliases:YES]; @@ -199,10 +210,31 @@ void wxFileDialog::ShowWindowModal() } } -int wxFileDialog::ShowModal() +void wxFileDialog::SetupExtraControls(WXWindow nativeWindow) { - NSSavePanel *panel = nil; + 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() +{ wxCFStringRef cf( m_message ); wxCFStringRef dir( m_dir ); @@ -225,6 +257,9 @@ int wxFileDialog::ShowModal() if (HasFlag(wxFD_SAVE)) { NSSavePanel* sPanel = [NSSavePanel savePanel]; + + SetupExtraControls(sPanel); + // makes things more convenient: [sPanel setCanCreateDirectories:YES]; [sPanel setMessage:cf.AsNSString()]; @@ -239,11 +274,16 @@ int wxFileDialog::ShowModal() returnCode = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ]; ModalFinishedCallback(sPanel, returnCode); + + [sPanel setAccessoryView:nil]; } else { NSArray* types = GetTypesFromFilter( m_wildCard ) ; NSOpenPanel* oPanel = [NSOpenPanel openPanel]; + + SetupExtraControls(oPanel); + [oPanel setTreatsFilePackagesAsDirectories:NO]; [oPanel setCanChooseDirectories:NO]; [oPanel setResolvesAliases:YES]; @@ -255,6 +295,8 @@ int wxFileDialog::ShowModal() ModalFinishedCallback(oPanel, returnCode); + [oPanel setAccessoryView:nil]; + if ( types != nil ) [types release]; } @@ -303,6 +345,8 @@ void wxFileDialog::ModalFinishedCallback(void* panel, int returnCode) if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL) SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED ); + + [(NSSavePanel*) panel setAccessoryView:nil]; } #endif // wxUSE_FILEDLG