Sheet support for wxDirDialog.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Kevin Ollivier
2009-03-05 21:21:45 +00:00
parent b2c47ad3f8
commit a905992cf7
2 changed files with 29 additions and 2 deletions

View File

@@ -26,7 +26,6 @@ public:
virtual int ShowModal();
protected:
wxWindow * m_parent;
DECLARE_DYNAMIC_CLASS(wxDirDialog)
};

View File

@@ -66,8 +66,36 @@ int wxDirDialog::ShowModal()
wxCFStringRef dir( m_path );
m_path = wxEmptyString;
wxNonOwnedWindow* parentWindow = NULL;
int returnCode = -1;
if ( [oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil] == NSOKButton )
if (GetParent())
{
parentWindow = dynamic_cast<wxNonOwnedWindow*>(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] );