X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17808a759627b03c2acbe7333dd2386557e1b804..8064223b7b1b3657363b7a635c381b9269d95e55:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index abf913ca76..11a7167c4a 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -237,12 +237,12 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl { wxMacCGContextStateSaver sg( cgContext ) ; - float alpha = 1.0 ; + CGFloat alpha = (CGFloat)1.0 ; { wxWindow* iter = thisWindow ; while ( iter ) { - alpha *= (float) iter->GetTransparent()/255.0 ; + alpha *= (CGFloat)( iter->GetTransparent()/255.0 ) ; if ( iter->IsTopLevel() ) iter = NULL ; else @@ -276,7 +276,13 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl break ; case kEventControlVisibilityChanged : - thisWindow->MacVisibilityChanged() ; + // we might have two native controls attributed to the same wxWindow instance + // eg a scrollview and an embedded textview, make sure we only fire for the 'outer' + // control, as otherwise native and wx visibility are different + if ( thisWindow->GetPeer() != NULL && thisWindow->GetPeer()->GetControlRef() == controlRef ) + { + thisWindow->MacVisibilityChanged() ; + } break ; case kEventControlEnabledStateChanged : @@ -879,9 +885,6 @@ void wxWindowMac::Init() m_macIsUserPane = true; m_clipChildren = false ; m_cachedClippedRectValid = false ; - - // we need a valid font for the encodings - wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); } wxWindowMac::~wxWindowMac() @@ -1108,7 +1111,7 @@ void wxWindowMac::MacUpdateControlFont() { m_peer->SetFont( GetFont() , GetForegroundColour() , GetWindowStyle() ) ; // do not trigger refreshes upon invisible and possible partly created objects - if ( MacIsReallyShown() ) + if ( IsShownOnScreen() ) Refresh() ; } @@ -1673,7 +1676,7 @@ void wxWindowMac::MacInvalidateBorders() if ( m_peer == NULL ) return ; - bool vis = MacIsReallyShown() ; + bool vis = IsShownOnScreen() ; if ( !vis ) return ; @@ -1942,7 +1945,7 @@ void wxWindowMac::SetLabel(const wxString& title) m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics) ) ; // do not trigger refreshes upon invisible and possible partly created objects - if ( MacIsReallyShown() ) + if ( IsShownOnScreen() ) Refresh() ; } @@ -1988,31 +1991,6 @@ void wxWindowMac::MacEnabledStateChanged() // status queries on the inherited window's state // -bool wxWindowMac::MacIsReallyShown() -{ - // only under OSX the visibility of the TLW is taken into account - if ( m_isBeingDeleted ) - return false ; - -#if TARGET_API_MAC_OSX - if ( m_peer && m_peer->Ok() ) - return m_peer->IsVisible(); -#endif - - wxWindow* win = this ; - while ( win->IsShown() ) - { - if ( win->IsTopLevel() ) - return true ; - - win = win->GetParent() ; - if ( win == NULL ) - return true ; - } - - return false ; -} - bool wxWindowMac::MacIsReallyEnabled() { return m_peer->IsEnabled() ; @@ -2074,7 +2052,7 @@ void wxWindowMac::Refresh(bool WXUNUSED(eraseBack), const wxRect *rect) if ( m_peer == NULL ) return ; - if ( !MacIsReallyShown() ) + if ( !IsShownOnScreen() ) return ; if ( rect ) @@ -2137,6 +2115,12 @@ void wxWindowMac::OnEraseBackground(wxEraseEvent& event) { event.GetDC()->Clear() ; } + else if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM ) + { + // don't skip the event here, custom background means that the app + // is drawing it itself in its OnPaint(), so don't draw it at all + // now to avoid flicker + } else { event.Skip() ; @@ -2263,7 +2247,7 @@ void wxWindowMac::MacPaintGrowBox() } else { - CGContextSetRGBFillColor( cgContext, 1.0, 1.0 , 1.0 , 1.0 ); + CGContextSetRGBFillColor( cgContext, (CGFloat) 1.0, (CGFloat)1.0 ,(CGFloat) 1.0 , (CGFloat)1.0 ); } CGContextFillRect( cgContext, cgrect ); CGContextRestoreGState( cgContext ); @@ -2502,7 +2486,7 @@ void wxWindowMac::OnInternalIdle() { // This calls the UI-update mechanism (querying windows for // menu/toolbar/control state information) - if (wxUpdateUIEvent::CanUpdate(this) && IsShown()) + if (wxUpdateUIEvent::CanUpdate(this) && IsShownOnScreen()) UpdateWindowUI(wxUPDATE_UI_FROMIDLE); } @@ -2614,7 +2598,7 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) { static wxRegion emptyrgn ; - if ( !m_isBeingDeleted && MacIsReallyShown() /*m_peer->IsVisible() */ ) + if ( !m_isBeingDeleted && IsShownOnScreen() ) { MacUpdateClippedRects() ; if ( includeOuterStructures ) @@ -3219,3 +3203,29 @@ wxByte wxWindowMac::GetTransparent() const { return m_macAlpha ; } + +bool wxWindowMac::IsShownOnScreen() const +{ +#if TARGET_API_MAC_OSX + if ( m_peer && m_peer->Ok() ) + { + bool peerVis = m_peer->IsVisible(); + bool wxVis = wxWindowBase::IsShownOnScreen(); + if( peerVis != wxVis ) + { + // CS : put a breakpoint here to investigate differences + // between native an wx visibilities + // the only place where I've encountered them until now + // are the hiding/showing sequences where the vis-changed event is + // first sent to the innermost control, while wx does things + // from the outmost control + wxVis = wxWindowBase::IsShownOnScreen(); + return wxVis; + } + + return m_peer->IsVisible(); + } +#endif + + return wxWindowBase::IsShownOnScreen(); +}