X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0f9b48d1e1535f8b92a73031be8cceff39123d27..b90817de2b4543762b308f15f7010a19e941991e:/src/osx/cocoa/dirdlg.mm diff --git a/src/osx/cocoa/dirdlg.mm b/src/osx/cocoa/dirdlg.mm index 6094f86e03..9baab201ae 100644 --- a/src/osx/cocoa/dirdlg.mm +++ b/src/osx/cocoa/dirdlg.mm @@ -1,8 +1,8 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/osx/cocoa/dirdlg.mm -// Purpose: wxDirDialog +// Purpose: wxDirDialog // Author: Stefan Csomor -// Modified by: +// Modified by: // Created: 2008-08-30 // RCS-ID: $Id: dirdlg.mm 40007 2006-07-05 13:10:46Z SC $ // Copyright: (c) Stefan Csomor @@ -37,8 +37,8 @@ IMPLEMENT_CLASS(wxDirDialog, wxDialog) wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, - const wxString& defaultPath, long style, const wxPoint& pos, - const wxSize& size, const wxString& name) + const wxString& defaultPath, long style, const wxPoint& WXUNUSED(pos), + const wxSize& WXUNUSED(size), const wxString& WXUNUSED(name)) { m_parent = parent; @@ -51,27 +51,55 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, int wxDirDialog::ShowModal() { int result = wxID_CANCEL; - + NSOpenPanel *oPanel = [NSOpenPanel openPanel]; [oPanel setCanChooseDirectories:YES]; [oPanel setResolvesAliases:YES]; [oPanel setCanChooseFiles:NO]; - + wxCFStringRef cf( m_message ); [oPanel setMessage:cf.AsNSString()]; - - if ( HasFlag(wxDD_NEW_DIR_BUTTON) ) + + if ( HasFlag(wxDD_NEW_DIR_BUTTON) ) [oPanel setCanCreateDirectories:YES]; wxCFStringRef dir( m_path ); - + m_path = wxEmptyString; - - if ( [oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil] == NSOKButton ) + + wxNonOwnedWindow* parentWindow = NULL; + int returnCode = -1; + + if (GetParent()) + { + parentWindow = dynamic_cast(wxGetTopLevelParent(GetParent())); + } + else + { + fprintf(stderr, "No parent!\n"); + } + +/* + if (parentWindow) + { + NSWindow* nativeParent = parentWindow->GetWXWindow(); + ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init]; + [oPanel beginSheetForDirectory:dir.AsNSString() file:nil types: nil + modalForWindow: nativeParent modalDelegate: sheetDelegate + didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo: nil]; + [sheetDelegate waitForSheetToFinish]; + returnCode = [sheetDelegate code]; + [sheetDelegate release]; + } + else +*/ + { + returnCode = (NSInteger)[oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil]; + } + if (returnCode == NSOKButton ) { - wxCFStringRef resultpath( [[[oPanel filenames] objectAtIndex:0] retain] ); - - SetPath( resultpath.AsString() ); + SetPath( wxCFStringRef::AsString([[oPanel filenames] objectAtIndex:0])); result = wxID_OK; } return result;