From 6062fe5c9e63cae73d1705fecc32587f0b80270f Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Thu, 1 Mar 2012 15:04:42 +0000 Subject: [PATCH] Added MacInternalOnSize() to allow windows to resize themselves independently of size events git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70765 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/frame.h | 3 ++- include/wx/osx/window.h | 3 +++ src/osx/carbon/frame.cpp | 9 --------- src/osx/cocoa/toolbar.mm | 3 +++ src/osx/cocoa/window.mm | 2 ++ src/osx/nonownedwnd_osx.cpp | 3 +++ src/osx/window_osx.cpp | 3 +++ 7 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/wx/osx/frame.h b/include/wx/osx/frame.h index 21693f7cfc..eaea567261 100644 --- a/include/wx/osx/frame.h +++ b/include/wx/osx/frame.h @@ -59,7 +59,6 @@ public: // event handlers void OnActivate(wxActivateEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event); - void OnSize(wxSizeEvent& event); // Toolbar #if wxUSE_TOOLBAR @@ -84,6 +83,8 @@ public: void PositionBars(); + // internal response to size events + virtual void MacOnInternalSize() { PositionBars(); } protected: // common part of all ctors diff --git a/include/wx/osx/window.h b/include/wx/osx/window.h index 2114cb7b68..757455f813 100644 --- a/include/wx/osx/window.h +++ b/include/wx/osx/window.h @@ -288,6 +288,9 @@ public: float GetContentScaleFactor() const ; + // internal response to size events + virtual void MacOnInternalSize() {} + protected: // For controls like radio buttons which are genuinely composite wxList m_subControls; diff --git a/src/osx/carbon/frame.cpp b/src/osx/carbon/frame.cpp index e7c53a27aa..2c9e0f3926 100644 --- a/src/osx/carbon/frame.cpp +++ b/src/osx/carbon/frame.cpp @@ -29,7 +29,6 @@ BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) EVT_ACTIVATE(wxFrame::OnActivate) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) - EVT_SIZE(wxFrame::OnSize) END_EVENT_TABLE() #define WX_MAC_STATUSBAR_HEIGHT 18 @@ -216,14 +215,6 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } - -void wxFrame::OnSize(wxSizeEvent& event) -{ - PositionBars(); - - event.Skip(); -} - #if wxUSE_MENUS void wxFrame::DetachMenuBar() { diff --git a/src/osx/cocoa/toolbar.mm b/src/osx/cocoa/toolbar.mm index a253e011aa..d5d0256f45 100644 --- a/src/osx/cocoa/toolbar.mm +++ b/src/osx/cocoa/toolbar.mm @@ -1193,6 +1193,9 @@ bool wxToolBar::Realize() SetInitialSize( wxSize(m_minWidth, m_minHeight)); SendSizeEventToParent(); + wxWindow * const parent = GetParent(); + if ( parent && !parent->IsBeingDeleted() ) + parent->MacOnInternalSize(); return true; } diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 048117a2cd..bab18f2386 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1615,6 +1615,7 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible ) wxUnusedVar(progress); m_win->SendSizeEvent(); + m_win->MacOnInternalSize(); } - (void)animationDidEnd:(NSAnimation*)animation @@ -1791,6 +1792,7 @@ wxWidgetCocoaImpl::ShowViewOrWindowWithEffect(wxWindow *win, // refresh it once again after the end to ensure that everything is in // place win->SendSizeEvent(); + win->MacOnInternalSize(); } [anim setDelegate:nil]; diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index feea6b5d9e..10daf9d052 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -249,6 +249,7 @@ bool wxNonOwnedWindow::OSXShowWithEffect(bool show, { // as apps expect a size event to occur when the window is shown, // generate one when it is shown with effect too + MacOnInternalSize(); wxSizeEvent event(GetSize(), m_windowId); event.SetEventObject(this); HandleWindowEvent(event); @@ -311,6 +312,7 @@ void wxNonOwnedWindow::HandleActivated( double timestampsec, bool didActivate ) void wxNonOwnedWindow::HandleResized( double timestampsec ) { + MacOnInternalSize(); wxSizeEvent wxevent( GetSize() , GetId()); wxevent.SetTimestamp( (int) (timestampsec * 1000) ); wxevent.SetEventObject( this ); @@ -385,6 +387,7 @@ bool wxNonOwnedWindow::Show(bool show) if ( show ) { // because apps expect a size event to occur at this moment + MacOnInternalSize(); wxSizeEvent event(GetSize() , m_windowId); event.SetEventObject(this); HandleWindowEvent(event); diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 0208bf8838..e9b2ac7f4e 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1065,6 +1065,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) if ( doResize ) { MacRepositionScrollBars() ; + MacOnInternalSize(); wxSize size(actualWidth, actualHeight); wxSizeEvent event(size, m_windowId); event.SetEventObject(this); @@ -1148,6 +1149,7 @@ void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags) if (sizeFlags & wxSIZE_FORCE_EVENT) { + MacOnInternalSize(); wxSizeEvent event( wxSize(width,height), GetId() ); event.SetEventObject( this ); HandleWindowEvent( event ); @@ -1686,6 +1688,7 @@ void wxWindowMac::DoUpdateScrollbarVisibility() MacRepositionScrollBars() ; if ( triggerSizeEvent ) { + MacOnInternalSize(); wxSizeEvent event(GetSize(), m_windowId); event.SetEventObject(this); HandleWindowEvent(event); -- 2.45.2