#include "wx/app.h"
#endif //WX_PRECOMP
+#include "wx/cocoa/autorelease.h"
+
+#import <AppKit/NSView.h>
#import <AppKit/NSWindow.h>
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
// wxTopLevelWindowCocoa creation
// ----------------------------------------------------------------------------
-IMPLEMENT_CLASS(wxTopLevelWindowCocoa,wxWindowCocoa)
BEGIN_EVENT_TABLE(wxTopLevelWindowCocoa,wxTopLevelWindowBase)
EVT_CLOSE(wxTopLevelWindowCocoa::OnCloseWindow)
END_EVENT_TABLE()
long style,
const wxString& name)
{
+ wxAutoNSAutoreleasePool pool;
wxTopLevelWindows.Append(this);
if(!CreateBase(parent,winid,pos,size,style,wxDefaultValidator,name))
wxTopLevelWindowCocoa::~wxTopLevelWindowCocoa()
{
+ wxAutoNSAutoreleasePool pool;
+ // Hand ownership of the content view to wxWindow so it can destroy
+ // itself properly.
+ NSView *view = [m_cocoaNSView retain];
SetNSWindow(NULL);
+ SetNSView(view);
+ [view release];
}
// ----------------------------------------------------------------------------
{
bool need_debug = cocoaNSWindow || m_cocoaNSWindow;
if(need_debug) wxLogDebug("wxTopLevelWindowCocoa=%p::SetNSWindow [m_cocoaNSWindow=%p retainCount]=%d",this,m_cocoaNSWindow,[m_cocoaNSWindow retainCount]);
- if(m_cocoaNSWindow)
- DisassociateNSWindow(m_cocoaNSWindow);
+ DisassociateNSWindow(m_cocoaNSWindow);
[cocoaNSWindow retain];
[m_cocoaNSWindow release];
m_cocoaNSWindow = cocoaNSWindow;
SetNSView([m_cocoaNSWindow contentView]);
else
SetNSView(NULL);
- if(m_cocoaNSWindow)
- AssociateNSWindow(m_cocoaNSWindow);
+ AssociateNSWindow(m_cocoaNSWindow);
if(need_debug) wxLogDebug("wxTopLevelWindowCocoa=%p::SetNSWindow [cocoaNSWindow=%p retainCount]=%d",this,cocoaNSWindow,[cocoaNSWindow retainCount]);
}
bool wxTopLevelWindowCocoa::Show(bool show)
{
+ wxAutoNSAutoreleasePool pool;
if(show)
[m_cocoaNSWindow makeKeyAndOrderFront:m_cocoaNSWindow];
else