+ if(need_debug) wxLogTrace(wxTRACE_COCOA_RetainRelease,wxT("wxTopLevelWindowCocoa=%p::SetNSWindow [cocoaNSWindow=%p retainCount]=%d"),this,cocoaNSWindow,[cocoaNSWindow retainCount]);
+}
+
+void wxTopLevelWindowCocoa::CocoaReplaceView(WX_NSView oldView, WX_NSView newView)
+{
+ if([m_cocoaNSWindow contentView] == (id)oldView)
+ [m_cocoaNSWindow setContentView:newView];
+}
+
+/*static*/ void wxTopLevelWindowCocoa::DeactivatePendingWindow()
+{
+ if(sm_cocoaDeactivateWindow)
+ sm_cocoaDeactivateWindow->wxTopLevelWindowCocoa::CocoaDelegate_windowDidResignKey();
+ sm_cocoaDeactivateWindow = NULL;
+}
+
+void wxTopLevelWindowCocoa::CocoaDelegate_windowDidBecomeKey(void)
+{
+ DeactivatePendingWindow();
+ wxLogTrace(wxTRACE_COCOA,wxT("wxTopLevelWindowCocoa=%p::CocoaDelegate_windowDidBecomeKey"),this);
+ wxActivateEvent event(wxEVT_ACTIVATE, true, GetId());
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+}
+
+void wxTopLevelWindowCocoa::CocoaDelegate_windowDidResignKey(void)
+{
+ wxLogTrace(wxTRACE_COCOA,wxT("wxTopLevelWindowCocoa=%p::CocoaDelegate_windowDidResignKey"),this);
+ wxActivateEvent event(wxEVT_ACTIVATE, false, GetId());
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);