X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/65aeaf19f6781193697d28f868901a80ee623396..931d76980ee9b20d6b3874de126bea74a92a4f9c:/src/cocoa/toplevel.mm diff --git a/src/cocoa/toplevel.mm b/src/cocoa/toplevel.mm index c6bbd38319..fbcf064b1b 100644 --- a/src/cocoa/toplevel.mm +++ b/src/cocoa/toplevel.mm @@ -33,8 +33,8 @@ #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 +131,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: [[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 +152,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 +196,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 +342,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)]; }