From d4a5384da10633e853cf88c1460958267d5a2b2e Mon Sep 17 00:00:00 2001 From: ceylo Date: Fri, 5 Feb 2010 19:26:20 +0000 Subject: [PATCH] Added "hack" to allow window import with Qt. git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1393 4e206d99-4929-0410-ac5d-dfc041789085 --- src/SFML/Window/Cocoa/WindowImplCocoa.mm | 41 ++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/SFML/Window/Cocoa/WindowImplCocoa.mm b/src/SFML/Window/Cocoa/WindowImplCocoa.mm index 4f6afddf..b3f426b3 100644 --- a/src/SFML/Window/Cocoa/WindowImplCocoa.mm +++ b/src/SFML/Window/Cocoa/WindowImplCocoa.mm @@ -90,16 +90,35 @@ myWheelStatus(0.0f) { if (Handle) { - if (![(NSWindow *)Handle isKindOfClass:[NSWindow class]]) - std::cerr << "Cannot import this Window Handle because it is not a object" - << "(or one of its subclasses). You gave a <" - << [[(NSWindow *)Handle className] UTF8String] - << "> object." << std::endl; + NSWindow *cocoaWindow = nil; + + if ([(id)Handle isKindOfClass:[NSWindow class]]) + { + cocoaWindow = (NSWindow *)Handle; + NSLog(@"detected window object"); + } + else if ([(id)Handle isKindOfClass:[NSView class]]) + { + cocoaWindow = [(NSView *)Handle window]; + NSLog(@"detected view object"); + } else + { + std::cerr + << "Cannot import this Window Handle because it is neither" + << "a nor object" + << "(or any of its subclasses). You gave a <" + << [[(id)Handle className] UTF8String] + << "> object." + << std::endl; + + } + + if (cocoaWindow) { // We create the window according to the given handle - myWrapper = [[WindowWrapper alloc] initWithWindow:(NSWindow *)Handle + myWrapper = [[WindowWrapper alloc] initWithWindow:cocoaWindow settings:params delegate:this]; @@ -115,6 +134,16 @@ myWheelStatus(0.0f) std::cerr << "Failed to make the public window" << std::endl; } } + else + { + std::cerr + << "Could not get a valid NSWindow object from the given handle" + << " (%p <" + << [[(id)Handle className] UTF8String] + << ">" + << std::endl; + } + } }