X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/65aeaf19f6781193697d28f868901a80ee623396..ef4279890a78cdc9f0f1b8f578ff0e573f922af3:/src/cocoa/toplevel.mm diff --git a/src/cocoa/toplevel.mm b/src/cocoa/toplevel.mm index c6bbd38319..83dd00623d 100644 --- a/src/cocoa/toplevel.mm +++ b/src/cocoa/toplevel.mm @@ -33,9 +33,10 @@ #include "wx/cocoa/autorelease.h" #include "wx/cocoa/string.h" -#import -#import +#include "wx/cocoa/objc/NSView.h" +#include "wx/cocoa/objc/NSWindow.h" #import + // ---------------------------------------------------------------------------- // globals // ---------------------------------------------------------------------------- @@ -131,10 +132,18 @@ bool wxTopLevelWindowCocoa::Create(wxWindow *parent, m_cocoaNSWindow = NULL; m_cocoaNSView = NULL; + // NOTE: We may need to deal with the contentView becoming a wx NSView as well. + NSWindow *newWindow; + // Create a WXNSPanel or a WXNSWindow depending on what type of window is desired. if(style & wxFRAME_TOOL_WINDOW) - SetNSWindow([[NSPanel alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]); + newWindow = [[WXNSPanel alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]; else - SetNSWindow([[NSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]); + newWindow = [[WXNSWindow alloc] initWithContentRect:cocoaRect styleMask:cocoaStyle backing:NSBackingStoreBuffered defer:NO]; + // Make sure the default content view is a WXNSView + [newWindow setContentView: [[WX_GET_OBJC_CLASS(WXNSView) alloc] initWithFrame: [[newWindow contentView] frame]]]; + // Associate the window and view + SetNSWindow(newWindow); + // NOTE: SetNSWindow has retained the Cocoa object for this object. // Because we do not release on close, the following release matches the // above alloc and thus the retain count will be 1. @@ -144,7 +153,7 @@ bool wxTopLevelWindowCocoa::Create(wxWindow *parent, [m_cocoaNSWindow setExcludedFromWindowsMenu: YES]; if(style & wxSTAY_ON_TOP) [m_cocoaNSWindow setLevel:NSFloatingWindowLevel]; - SetTitle(title); + [m_cocoaNSWindow setTitle:wxNSStringWithWxString(title)]; return true; } @@ -188,6 +197,8 @@ void wxTopLevelWindowCocoa::SetNSWindow(WX_NSWindow cocoaNSWindow) [cocoaNSWindow retain]; [m_cocoaNSWindow release]; m_cocoaNSWindow = cocoaNSWindow; + // NOTE: We are no longer using posing so we won't get events on the + // window's view unless it was explicitly created as the wx view class. if(m_cocoaNSWindow) SetNSView([m_cocoaNSWindow contentView]); else @@ -332,7 +343,7 @@ void wxTopLevelWindowCocoa::OnCloseWindow(wxCloseEvent& event) // wxTopLevelWindowCocoa misc // ---------------------------------------------------------------------------- -void wxTopLevelWindowCocoa::SetTitle( const wxString& WXUNUSED(title)) +void wxTopLevelWindowCocoa::SetTitle(const wxString& title) { [m_cocoaNSWindow setTitle:wxNSStringWithWxString(title)]; }