X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e80711dd54ac9b84b2aa4218ef0749fe60606af9..6d2190fcb4ba8c0a297a90ac233e88ad0c5cd13f:/src/osx/window_osx.cpp?ds=sidebyside diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index e1ce896e63..afbf5a0a32 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -4,7 +4,6 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -416,6 +415,9 @@ bool wxWindowMac::Create(wxWindowMac *parent, m_windowVariant = parent->GetWindowVariant() ; + m_hScrollBarAlwaysShown = + m_vScrollBarAlwaysShown = HasFlag(wxALWAYS_SHOW_SB); + if ( m_peer != kOSXNoWidgetImpl ) { SetPeer(wxWidgetImpl::CreateUserPane( this, parent, id, pos, size , style, GetExtraStyle() )); @@ -872,9 +874,22 @@ void wxWindowMac::DoGetClientSize( int *x, int *y ) const #endif if (x) - *x = ww; + { + // we shouldn't return invalid width + if ( ww < 0 ) + ww = 0; + + *x = ww; + } + if (y) - *y = hh; + { + // we shouldn't return invalid height + if ( hh < 0 ) + hh = 0; + + *y = hh; + } } bool wxWindowMac::SetCursor(const wxCursor& cursor) @@ -1060,11 +1075,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); - HandleWindowEvent(event); + SendSizeEvent(); } } } @@ -1118,6 +1129,12 @@ wxSize wxWindowMac::DoGetBestSize() const } } +void wxWindowMac::SendSizeEvent(int flags) +{ + MacOnInternalSize(); + wxWindowBase::SendSizeEvent(flags); +} + // set the size of the window: if the dimensions are positive, just use them, // but if any of them is equal to -1, it means that we must find the value for // it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in @@ -1144,10 +1161,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 ); + SendSizeEvent(); } return; @@ -1220,7 +1234,7 @@ void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) } } -float wxWindowMac::GetContentScaleFactor() const +double wxWindowMac::GetContentScaleFactor() const { return GetPeer()->GetContentScaleFactor(); } @@ -1678,10 +1692,7 @@ void wxWindowMac::DoUpdateScrollbarVisibility() MacRepositionScrollBars() ; if ( triggerSizeEvent ) { - MacOnInternalSize(); - wxSizeEvent event(GetSize(), m_windowId); - event.SetEventObject(this); - HandleWindowEvent(event); + SendSizeEvent(); } #endif } @@ -2534,6 +2545,11 @@ bool wxWindowMac::OSXHandleClicked( double WXUNUSED(timestampsec) ) return false; } +void *wxWindowMac::OSXGetViewOrWindow() const +{ + return GetHandle(); +} + wxInt32 wxWindowMac::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event ) { #if wxOSX_USE_COCOA_OR_CARBON @@ -2778,6 +2794,10 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event ) // wxWidgetImpl // +// we are maintaining a n:1 map from native controls (ControlRef / NSView*) to their wxWidgetImpl +// n:1 because we might have an embedded view eg within a scrollview, both being part of the same impl +// the impl is calling Associate with its newly created native control(s), e.g. in InstallHandler + WX_DECLARE_HASH_MAP(WXWidget, wxWidgetImpl*, wxPointerHash, wxPointerEqual, MacControlMap); static MacControlMap wxWinMacControlList;