event. This will come in handy for MDI among other things.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24545
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// Author: David Elliott
// Modified by:
// Created: 2002/12/08
// Author: David Elliott
// Modified by:
// Created: 2002/12/08
// Copyright: (c) 2002 David Elliott
// Copyright: (c) 2002 David Elliott
-// Licence: wxWindows license
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_TOPLEVEL_H__
///////////////////////////////////////////////////////////////////////////////
#ifndef __WX_COCOA_TOPLEVEL_H__
virtual void CocoaDelegate_windowDidBecomeMain(void);
virtual void CocoaDelegate_windowDidResignMain(void);
virtual wxMenuBar* GetAppMenuBar(wxCocoaNSWindow *win);
virtual void CocoaDelegate_windowDidBecomeMain(void);
virtual void CocoaDelegate_windowDidResignMain(void);
virtual wxMenuBar* GetAppMenuBar(wxCocoaNSWindow *win);
+ static void DeactivatePendingWindow();
protected:
void SetNSWindow(WX_NSWindow cocoaNSWindow);
WX_NSWindow m_cocoaNSWindow;
protected:
void SetNSWindow(WX_NSWindow cocoaNSWindow);
WX_NSWindow m_cocoaNSWindow;
virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
static unsigned int NSWindowStyleForWxStyle(long style);
virtual void CocoaReplaceView(WX_NSView oldView, WX_NSView newView);
static unsigned int NSWindowStyleForWxStyle(long style);
+ static wxTopLevelWindowCocoa *sm_cocoaDeactivateWindow;
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
// ------------------------------------------------------------------------
// Implementation
// ------------------------------------------------------------------------
public:
+ virtual bool Destroy();
// Pure virtuals
virtual void Maximize(bool maximize = true);
virtual bool IsMaximized() const;
// Pure virtuals
virtual void Maximize(bool maximize = true);
virtual bool IsMaximized() const;
void wxApp::CocoaDelegate_applicationWillResignActive()
{
void wxApp::CocoaDelegate_applicationWillResignActive()
{
+ wxTopLevelWindowCocoa::DeactivatePendingWindow();
}
void wxApp::CocoaDelegate_applicationDidResignActive()
}
void wxApp::CocoaDelegate_applicationDidResignActive()
// wxTopLevelWindowCocoa implementation
// ============================================================================
// wxTopLevelWindowCocoa implementation
// ============================================================================
+wxTopLevelWindowCocoa *wxTopLevelWindowCocoa::sm_cocoaDeactivateWindow = NULL;
+
// ----------------------------------------------------------------------------
// wxTopLevelWindowCocoa creation
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxTopLevelWindowCocoa creation
// ----------------------------------------------------------------------------
wxTopLevelWindowCocoa::~wxTopLevelWindowCocoa()
{
wxTopLevelWindowCocoa::~wxTopLevelWindowCocoa()
{
+ wxASSERT(sm_cocoaDeactivateWindow!=this);
wxAutoNSAutoreleasePool pool;
DestroyChildren();
SetNSWindow(NULL);
}
wxAutoNSAutoreleasePool pool;
DestroyChildren();
SetNSWindow(NULL);
}
+bool wxTopLevelWindowCocoa::Destroy()
+{
+ if(sm_cocoaDeactivateWindow==this)
+ {
+ sm_cocoaDeactivateWindow = NULL;
+ wxTopLevelWindowCocoa::CocoaDelegate_windowDidResignKey();
+ }
+ return wxTopLevelWindowBase::Destroy();
+}
+
// ----------------------------------------------------------------------------
// wxTopLevelWindowCocoa Cocoa Specifics
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxTopLevelWindowCocoa Cocoa Specifics
// ----------------------------------------------------------------------------
[m_cocoaNSWindow setContentView:newView];
}
[m_cocoaNSWindow setContentView:newView];
}
+/*static*/ void wxTopLevelWindowCocoa::DeactivatePendingWindow()
+{
+ if(sm_cocoaDeactivateWindow)
+ sm_cocoaDeactivateWindow->wxTopLevelWindowCocoa::CocoaDelegate_windowDidResignKey();
+ sm_cocoaDeactivateWindow = NULL;
+}
+
void wxTopLevelWindowCocoa::CocoaDelegate_windowDidBecomeKey(void)
{
void wxTopLevelWindowCocoa::CocoaDelegate_windowDidBecomeKey(void)
{
+ DeactivatePendingWindow();
wxLogDebug("wxTopLevelWindowCocoa=%p::CocoaDelegate_windowDidBecomeKey",this);
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, GetId());
event.SetEventObject(this);
wxLogDebug("wxTopLevelWindowCocoa=%p::CocoaDelegate_windowDidBecomeKey",this);
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, GetId());
event.SetEventObject(this);