Ticket #55115: patch-wxw-303.diff

File patch-wxw-303.diff, 3.8 KB (added by RJVB (René Bertin), 7 years ago)
  • lib-src/FileDialog/mac/FileDialogPrivate.h

    diff --git a/lib-src/FileDialog/mac/FileDialogPrivate.h b/lib-src/FileDialog/mac/FileDialogPrivate.h
    index 697969fd2a31d24501361b71bfc076f37671f813..a2db97e9f21661e874984c01d8375b44d93ecd16 100644
    a b protected: 
    9696    int m_firstFileTypeFilter;
    9797    wxArrayString m_currentExtensions;
    9898    WX_NSObject m_delegate;
     99#if !wxCHECK_VERSION(3, 0, 3)
    99100    WX_NSObject m_sheetDelegate;
     101#endif
    100102    wxString m_noOverwritePromptFilename;
    101103#endif
    102104
  • lib-src/FileDialog/mac/FileDialogPrivate.mm

    diff --git a/lib-src/FileDialog/mac/FileDialogPrivate.mm b/lib-src/FileDialog/mac/FileDialogPrivate.mm
    index 508d8b8002dc18b17c8700f9eb7061c4178e0e6b..a9429f90f5418035152b678108dd7a97c9158653 100644
    a b void FileDialog::Init() 
    141141{
    142142    m_filterIndex = -1;
    143143    m_delegate = nil;
     144#if !wxCHECK_VERSION(3, 0, 3)
    144145    m_sheetDelegate = nil;
     146#endif
    145147    m_filterPanel = NULL;
    146148    m_filterChoice = NULL;
    147149}
    void FileDialog::Create( 
    152154    long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
    153155{
    154156    FileDialogBase::Create(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name);
    155 
     157#if !wxCHECK_VERSION(3, 0, 3)
    156158    m_sheetDelegate = [[ModalDialogDelegate alloc] init];
    157159    [(ModalDialogDelegate*)m_sheetDelegate setImplementation: this];
     160#endif
    158161}
    159162
    160163FileDialog::~FileDialog()
    161164{
     165#if !wxCHECK_VERSION(3, 0, 3)
    162166    [m_sheetDelegate release];
     167#endif
    163168}
    164169
    165170bool FileDialog::SupportsExtraControl() const
    void FileDialog::ShowWindowModal() 
    309314        [sPanel setAllowsOtherFileTypes:NO];
    310315       
    311316        NSWindow* nativeParent = parentWindow->GetWXWindow();
     317#if wxCHECK_VERSION(3, 0, 3)
     318        // the ModalDialogDelegate class is no longer exported, but the
     319        // beginSheetForDirectory: message has been deprecated since 10.6
     320        // Use the modern equivalent:
     321        [sPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString() isDirectory:YES]];
     322        [sPanel setNameFieldStringValue:file.AsNSString()];
     323        [sPanel beginSheetModalForWindow:nativeParent completionHandler:^(NSInteger result) {
     324            if (result == NSFileHandlingPanelOKButton) {
     325                NSLog(@"Saved file %@", [sPanel URL]);
     326            }
     327        }];
     328#else
    312329        [sPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
    313             modalForWindow: nativeParent modalDelegate: m_sheetDelegate
     330            modalForWindow: nativeParent
     331            modalDelegate: m_sheetDelegate
    314332            didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
    315333            contextInfo: nil];
     334#endif
    316335    }
    317     else 
     336    else
    318337    {
    319338        NSOpenPanel* oPanel = [NSOpenPanel openPanel];
    320339       
    void FileDialog::ShowWindowModal() 
    328347        [oPanel setAllowsMultipleSelection: (HasFlag(wxFD_MULTIPLE) ? YES : NO )];
    329348       
    330349        NSWindow* nativeParent = parentWindow->GetWXWindow();
     350#if wxCHECK_VERSION(3, 0, 3)
     351        [oPanel setDirectoryURL:[NSURL fileURLWithPath:dir.AsNSString() isDirectory:YES]];
     352        [oPanel setNameFieldStringValue:file.AsNSString()];
     353        [oPanel setAllowedFileTypes:types];
     354        [oPanel beginSheetModalForWindow:nativeParent completionHandler:^(NSInteger result) {
     355            if (result == NSFileHandlingPanelOKButton) {
     356                NSLog(@"Opened file(s) %@", [oPanel URLs]);
     357            }
     358        }];
     359#else
    331360        [oPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
    332361            types: types modalForWindow: nativeParent
    333362            modalDelegate: m_sheetDelegate
    334363            didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
    335364            contextInfo: nil];
     365#endif
    336366    }
    337367}
    338368