From b6dc21e7689cf7bf9ecf74701fbe2df8168d33ac Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Sun, 8 Nov 2009 03:03:06 +0000 Subject: [PATCH] Make wxSTAY_ON_TOP and other window styles toggleable via SetWindowStyleFlag under OS X Cocoa. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/cocoa/private.h | 1 + include/wx/osx/core/private.h | 6 +++++- include/wx/osx/nonownedwnd.h | 1 + src/osx/cocoa/nonownedwnd.mm | 15 +++++++++++++++ src/osx/nonownedwnd_osx.cpp | 11 +++++++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/wx/osx/cocoa/private.h b/include/wx/osx/cocoa/private.h index 3473aadca9..9a3e131a81 100644 --- a/include/wx/osx/cocoa/private.h +++ b/include/wx/osx/cocoa/private.h @@ -210,6 +210,7 @@ public : bool SetTransparent(wxByte alpha); bool SetBackgroundColour(const wxColour& col ); void SetExtraStyle( long exStyle ); + void SetWindowStyleFlag( long style ); bool SetBackgroundStyle(wxBackgroundStyle style); bool CanSetTransparent(); diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 9d3fbdb52f..47c9179bf3 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -685,7 +685,11 @@ public : virtual void SetExtraStyle( long WXUNUSED(exStyle) ) { } - + + virtual void SetWindowStyleFlag( long WXUNUSED(style) ) + { + } + virtual bool SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style)) { return false ; diff --git a/include/wx/osx/nonownedwnd.h b/include/wx/osx/nonownedwnd.h index e650d7e094..cf537e15ec 100644 --- a/include/wx/osx/nonownedwnd.h +++ b/include/wx/osx/nonownedwnd.h @@ -80,6 +80,7 @@ public: static void MacDelayedDeactivation(long timestamp); virtual void MacActivate( long timestamp , bool inIsActivating ) ; + virtual void SetWindowStyleFlag(long flags); virtual void Raise(); virtual void Lower(); diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index c19341742e..b0af31cc07 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -533,6 +533,21 @@ void wxNonOwnedWindowCocoaImpl::SetExtraStyle( long exStyle ) } } +void wxNonOwnedWindowCocoaImpl::SetWindowStyleFlag( long style ) +{ + if (m_macWindow) + { + CGWindowLevel level = kCGNormalWindowLevel; + + if (style & wxSTAY_ON_TOP) + level = kCGUtilityWindowLevel; + else if (( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW )) + level = kCGFloatingWindowLevel; + + [m_macWindow setLevel: level]; + } +} + bool wxNonOwnedWindowCocoaImpl::SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style)) { return true; diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index bdc9be1d32..9adc5647d5 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -217,6 +217,17 @@ bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) return true; } +void wxNonOwnedWindow::SetWindowStyleFlag(long flags) +{ + if (flags == GetWindowStyleFlag()) + return; + + wxWindow::SetWindowStyleFlag(flags); + + if (m_nowpeer) + m_nowpeer->SetWindowStyleFlag(flags); +} + // Raise the window to the top of the Z order void wxNonOwnedWindow::Raise() { -- 2.45.2