Add support for external window handling (NSView + NSWindow) (bis)

This commit is contained in:
Marco Antognini 2011-03-28 14:53:28 +02:00
parent 284bd09709
commit 9c07503350
4 changed files with 18 additions and 11 deletions

View File

@ -68,6 +68,8 @@ else() # MACOSX
${SRCROOT}/OSX/SFWindow.m
${SRCROOT}/OSX/SFWindowController.h
${SRCROOT}/OSX/SFWindowController.mm
${SRCROOT}/OSX/SFViewController.h
${SRCROOT}/OSX/SFViewController.mm
${SRCROOT}/OSX/VideoModeImpl.cpp
${SRCROOT}/OSX/WindowImplCocoa.hpp
${SRCROOT}/OSX/WindowImplCocoa.mm

View File

@ -55,7 +55,7 @@ SFContext::SFContext(SFContext* shared)
myPool = [[NSAutoreleasePool alloc] init];
// Create the context
CreateContext(shared, 0, ContextSettings(0, 0, 0));
CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0));
// Activate the context
SetActive(true);
@ -83,6 +83,7 @@ SFContext::SFContext(SFContext* shared, const WindowImpl* owner,
////////////////////////////////////////////////////////////
SFContext::~SFContext()
{
[myContext clearDrawable];
[myContext release];
[myPool drain]; // [A]

View File

@ -88,14 +88,14 @@
sf::Err()
<< "Could not create an instance of NSOpenGLView "
<< "in (SFWindowController -initWithMode:andStyle:)."
<< "in (SFWindowController -initWithWindow:)."
<< std::endl;
return self;
}
// Set the view to the window as its content view.
[myWindow setContentView:myOGLView];
[[myWindow contentView] addSubview:myOGLView];
}
return self;
@ -434,7 +434,7 @@
* for more information.
*/
sf::Err()
<< "Cannot fetch event from a worker thread. (OS X limitation)"
<< "Cannot fetch event from a worker thread. (OS X restriction)"
<< std::endl;
return;

View File

@ -30,8 +30,7 @@
#include <SFML/System/Err.hpp>
#import <SFML/Window/OSX/SFWindowController.h>
//#import <SFML/Window/OSX/SFViewController.h>
#warning SFViewController not yet implemented.
#import <SFML/Window/OSX/SFViewController.h>
#import <SFML/Window/OSX/cpp_objc_conversion.h>
namespace sf
@ -45,9 +44,6 @@ namespace priv
////////////////////////////////////////////////////////////
WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
{
sf::Err() << "Not yet fully supported." << std::endl;
#warning WindowImplCocoa(WindowHandle handle) not yet fully implemented
SetUpPoolAndApplication();
// Treat the handle as it real type
@ -56,13 +52,21 @@ WindowImplCocoa::WindowImplCocoa(WindowHandle handle)
// We have a window.
myDelegate = [[SFWindowController alloc] initWithWindow:nsHandle];
// Don't forget to update our parent (that is, WindowImpl) size :
myWidth = [[nsHandle contentView] frame].size.width;
myHeight = [[nsHandle contentView] frame].size.height;
} /*else if ([nsHandle isKindOfClass:[NSView class]]) {
} else if ([nsHandle isKindOfClass:[NSView class]]) {
// We have a view.
myDelegate = [[SFViewController alloc] initWithView:nsHandle];
} */ else {
// Don't forget to update our parent (that is, WindowImpl) size :
myWidth = [nsHandle frame].size.width;
myHeight = [nsHandle frame].size.height;
} else {
sf::Err()
<< "Cannot import this Window Handle because it is neither "