X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/af06e625119e8fd79d6a96437a2a17769c998ad2..409e6ce4dcd39c6dfe8b77cbd56d451ffe5c731c:/src/mac/carbon/window.cpp?ds=sidebyside diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 766257f0a1..acb4a6b6cb 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -78,8 +78,6 @@ BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase) EVT_NC_PAINT(wxWindowMac::OnNcPaint) EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground) EVT_PAINT(wxWindowMac::OnPaint) - EVT_SET_FOCUS(wxWindowMac::OnSetFocus) - EVT_KILL_FOCUS(wxWindowMac::OnSetFocus) EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent) END_EVENT_TABLE() @@ -160,6 +158,7 @@ static const EventTypeSpec eventList[] = { kEventClassControl , kEventControlDeactivate } , { kEventClassControl , kEventControlSetFocusPart } , + { kEventClassControl , kEventControlFocusPartChanged } , { kEventClassService , kEventServiceGetTypes }, { kEventClassService , kEventServiceCopy }, @@ -190,7 +189,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl if ( cEvent.GetParameter(kEventParamRgnHandle, &updateRgn) != noErr ) { - updateRgn = (RgnHandle) visRegion.GetWXHRGN() ; + HIShapeGetAsQDRgn( visRegion.GetWXHRGN(), updateRgn ); } else { @@ -233,17 +232,21 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl bool created = false ; CGContextRef cgContext = NULL ; OSStatus err = cEvent.GetParameter(kEventParamCGContextRef, &cgContext) ; - wxASSERT_MSG( err == noErr , wxT("Unable to retrieve CGContextRef") ) ; + if ( err != noErr ) + { + wxFAIL_MSG("Unable to retrieve CGContextRef"); + } + thisWindow->MacSetCGContextRef( cgContext ) ; { 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 @@ -259,8 +262,8 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl CGContextClearRect( cgContext, bounds ); } - - + + if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) result = noErr ; @@ -277,7 +280,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 : @@ -301,26 +310,33 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl #endif break ; - // we emulate this event under Carbon CFM - case kEventControlSetFocusPart : + // + // focus handling + // different handling on OS X + // + + case kEventControlFocusPartChanged : + // the event is emulated by wxmac for systems lower than 10.5 { - Boolean focusEverything = false ; - ControlPartCode controlPart = cEvent.GetParameter(kEventParamControlPart , typeControlPartCode ); + ControlPartCode previousControlPart = cEvent.GetParameter(kEventParamControlPreviousPart , typeControlPartCode ); + ControlPartCode currentControlPart = cEvent.GetParameter(kEventParamControlCurrentPart , typeControlPartCode ); - if ( cEvent.GetParameter(kEventParamControlFocusEverything , &focusEverything ) == noErr ) + if ( thisWindow->MacGetTopLevelWindow() && thisWindow->GetPeer()->NeedsFocusRect() ) { + thisWindow->MacInvalidateBorders(); } - if ( thisWindow->MacIsUserPane() ) - result = noErr ; - - if ( controlPart == kControlFocusNoPart ) + if ( currentControlPart == 0 ) { + // kill focus #if wxUSE_CARET if ( thisWindow->GetCaret() ) thisWindow->GetCaret()->OnKillFocus(); #endif + wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow)); + + // remove this as soon as posting the synthesized event works properly static bool inKillFocusEvent = false ; if ( !inKillFocusEvent ) @@ -328,15 +344,17 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl inKillFocusEvent = true ; wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); event.SetEventObject(thisWindow); - thisWindow->GetEventHandler()->ProcessEvent(event) ; + thisWindow->HandleWindowEvent(event) ; inKillFocusEvent = false ; } } - else + else if ( previousControlPart == 0 ) { + // set focus // panel wants to track the window which was the last to have focus in it - wxChildFocusEvent eventFocus(thisWindow); - thisWindow->GetEventHandler()->ProcessEvent(eventFocus); + wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow)); + wxChildFocusEvent eventFocus((wxWindow*)thisWindow); + thisWindow->HandleWindowEvent(eventFocus); #if wxUSE_CARET if ( thisWindow->GetCaret() ) @@ -345,7 +363,97 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId()); event.SetEventObject(thisWindow); - thisWindow->GetEventHandler()->ProcessEvent(event) ; + thisWindow->HandleWindowEvent(event) ; + } + } + break; + case kEventControlSetFocusPart : + { +#ifdef __WXMAC_OSX__ + Boolean focusEverything = false ; + if ( cEvent.GetParameter(kEventParamControlFocusEverything , &focusEverything ) == noErr ) + { + // put a breakpoint here to catch focus everything events + } +#endif + ControlPartCode controlPart = cEvent.GetParameter(kEventParamControlPart , typeControlPartCode ); + + ControlPartCode previousControlPart = 0; + verify_noerr( HIViewGetFocusPart(controlRef, &previousControlPart)); + + if ( thisWindow->MacIsUserPane() ) + { + if ( controlPart != kControlFocusNoPart ) + cEvent.SetParameter( kEventParamControlPart, typeControlPartCode, 1 ) ; + result = noErr ; + } + else + result = CallNextEventHandler(handler, event); + + if ( UMAGetSystemVersion() < 0x1050 ) + { +// set back to 0 if problems arise +#if 1 + ControlPartCode currentControlPart = cEvent.GetParameter(kEventParamControlPart , typeControlPartCode ); + // synthesize the event focus changed event + EventRef evRef = NULL ; + + OSStatus err = MacCreateEvent( + NULL , kEventClassControl , kEventControlFocusPartChanged , TicksToEventTime( TickCount() ) , + kEventAttributeUserEvent , &evRef ); + verify_noerr( err ); + + wxMacCarbonEvent iEvent( evRef ) ; + iEvent.SetParameter( kEventParamDirectObject , controlRef ) ; + iEvent.SetParameter( kEventParamControlPreviousPart, typeControlPartCode, previousControlPart ) ; + iEvent.SetParameter( kEventParamControlCurrentPart, typeControlPartCode, currentControlPart ) ; + +#if 0 + // TODO test this first, avoid double posts etc... + PostEventToQueue( GetMainEventQueue(), evRef , kEventPriorityHigh ); +#else + wxMacWindowControlEventHandler( NULL , evRef , data ) ; +#endif + ReleaseEvent( evRef ) ; +#else + // old implementation, to be removed if the new one works + if ( controlPart == kControlFocusNoPart ) + { +#if wxUSE_CARET + if ( thisWindow->GetCaret() ) + thisWindow->GetCaret()->OnKillFocus(); +#endif + + wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow)); + + static bool inKillFocusEvent = false ; + + if ( !inKillFocusEvent ) + { + inKillFocusEvent = true ; + wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); + event.SetEventObject(thisWindow); + thisWindow->HandleWindowEvent(event) ; + inKillFocusEvent = false ; + } + } + else + { + // panel wants to track the window which was the last to have focus in it + wxLogTrace(_T("Focus"), _T("focus set(%p)"), wx_static_cast(void*, thisWindow)); + wxChildFocusEvent eventFocus((wxWindow*)thisWindow); + thisWindow->HandleWindowEvent(eventFocus); + + #if wxUSE_CARET + if ( thisWindow->GetCaret() ) + thisWindow->GetCaret()->OnSetFocus(); + #endif + + wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId()); + event.SetEventObject(thisWindow); + thisWindow->HandleWindowEvent(event) ; + } +#endif } } break ; @@ -356,7 +464,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl case kEventControlGetClickActivation : { - // fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise) + // fix to always have a proper activation for DataBrowser controls (stay in bkgnd otherwise) WindowRef owner = cEvent.GetParameter(kEventParamWindowRef); if ( !IsWindowActive(owner) ) { @@ -507,7 +615,7 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even charBuf[ numChars - 1 ] = 0; #if SIZEOF_WCHAR_T == 2 uniChars = (wchar_t*) charBuf ; -/* memcpy( uniChars , charBuf , numChars * 2 ) ;*/ // is there any point in copying charBuf over itself? (in fact, memcpy isn't even guaranteed to work correctly if the source and destination ranges overlap...) +/* memcpy( uniChars , charBuf , numChars * 2 ) ;*/ // is there any point in copying charBuf over itself? (in fact, memcpy isn't even guaranteed to work correctly if the source and destination ranges overlap...) #else // the resulting string will never have more chars than the utf16 version, so this is safe wxMBConvUTF16 converter ; @@ -529,29 +637,29 @@ pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , Even UInt32 message = uniChars[pos] < 128 ? (char)uniChars[pos] : '?'; /* - NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent - multiple times to update the active range during inline input, so this handler will often receive - uncommited text, which should usually not trigger side effects. It might be a good idea to check the - kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h). - On the other hand, it can be useful for some applications to react to uncommitted text (for example, - to update a status display), as long as it does not disrupt the inline input session. Ideally, wx - should add new event types to support advanced text input. For now, I would keep things as they are. - - However, the code that was being used caused additional problems: + NB: faking a charcode here is problematic. The kEventTextInputUpdateActiveInputArea event is sent + multiple times to update the active range during inline input, so this handler will often receive + uncommited text, which should usually not trigger side effects. It might be a good idea to check the + kEventParamTextInputSendFixLen parameter and verify if input is being confirmed (see CarbonEvents.h). + On the other hand, it can be useful for some applications to react to uncommitted text (for example, + to update a status display), as long as it does not disrupt the inline input session. Ideally, wx + should add new event types to support advanced text input. For now, I would keep things as they are. + + However, the code that was being used caused additional problems: UInt32 message = (0 << 8) + ((char)uniChars[pos] ); - Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline - input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji - for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB - (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D - (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress. - Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only - overlap with Unicode within the (7-bit) ASCII range. - But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks - for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII - characters as they are and replaces the rest with '?', ensuring that update events are triggered. - It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but - I don't have time to look into that right now. - -- CL + Since it simply truncated the unichar to the last byte, it ended up causing weird bugs with inline + input, such as switching to another field when one attempted to insert the character U+4E09 (the kanji + for "three"), because it was truncated to 09 (kTabCharCode), which was later "converted" to WXK_TAB + (still 09) in wxMacTranslateKey; or triggering the default button when one attempted to insert U+840D + (the kanji for "name"), which got truncated to 0D and interpreted as a carriage return keypress. + Note that even single-byte characters could have been misinterpreted, since MacRoman charcodes only + overlap with Unicode within the (7-bit) ASCII range. + But simply passing a NUL charcode would disable text updated events, because wxTextCtrl::OnChar checks + for codes within a specific range. Therefore I went for the solution seen above, which keeps ASCII + characters as they are and replaces the rest with '?', ensuring that update events are triggered. + It would be better to change wxTextCtrl::OnChar to look at the actual unicode character instead, but + I don't have time to look into that right now. + -- CL */ if ( wxTheApp->MacSendCharEvent( focus , message , 0 , when , 0 , 0 , uniChars[pos] ) ) @@ -767,7 +875,6 @@ wxWindowMac::wxWindowMac(wxWindowMac *parent, void wxWindowMac::Init() { m_peer = NULL ; - m_frozenness = 0 ; m_macAlpha = 255 ; m_cgContextRef = NULL ; @@ -782,9 +889,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() @@ -1003,7 +1107,7 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant ) m_peer->SetData(kControlEntireControl, kControlSizeTag, &size ) ; wxFont font ; - font.MacCreateThemeFont( themeFont ) ; + font.MacCreateFromThemeFont( themeFont ) ; SetFont( font ) ; } @@ -1011,7 +1115,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() ; } @@ -1576,12 +1680,12 @@ void wxWindowMac::MacInvalidateBorders() if ( m_peer == NULL ) return ; - bool vis = MacIsReallyShown() ; + bool vis = IsShownOnScreen() ; if ( !vis ) return ; int outerBorder = MacGetLeftBorderSize() ; - if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() ) + if ( m_peer->NeedsFocusRect() /* && m_peer->HasFocus() */ ) outerBorder += 4 ; if ( outerBorder == 0 ) @@ -1677,7 +1781,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) wxPoint point(actualX, actualY); wxMoveEvent event(point, m_windowId); event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event) ; + HandleWindowEvent(event) ; } if ( doResize ) @@ -1686,7 +1790,7 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) wxSize size(actualWidth, actualHeight); wxSizeEvent event(size, m_windowId); event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + HandleWindowEvent(event); } } } @@ -1845,7 +1949,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() ; } @@ -1891,31 +1995,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() ; @@ -1977,7 +2056,7 @@ void wxWindowMac::Refresh(bool WXUNUSED(eraseBack), const wxRect *rect) if ( m_peer == NULL ) return ; - if ( !MacIsReallyShown() ) + if ( !IsShownOnScreen() ) return ; if ( rect ) @@ -1993,38 +2072,25 @@ void wxWindowMac::Refresh(bool WXUNUSED(eraseBack), const wxRect *rect) } } -void wxWindowMac::Freeze() +void wxWindowMac::DoFreeze() { #if TARGET_API_MAC_OSX - if ( !m_frozenness++ ) - { - if ( m_peer && m_peer->Ok() ) - m_peer->SetDrawingEnabled( false ) ; - } + if ( m_peer && m_peer->Ok() ) + m_peer->SetDrawingEnabled( false ) ; #endif } -void wxWindowMac::Thaw() +void wxWindowMac::DoThaw() { #if TARGET_API_MAC_OSX - wxASSERT_MSG( m_frozenness > 0, wxT("Thaw() without matching Freeze()") ); - - if ( !--m_frozenness ) + if ( m_peer && m_peer->Ok() ) { - if ( m_peer && m_peer->Ok() ) - { - m_peer->SetDrawingEnabled( true ) ; - m_peer->InvalidateWithChildren() ; - } + m_peer->SetDrawingEnabled( true ) ; + m_peer->InvalidateWithChildren() ; } #endif } -bool wxWindowMac::IsFrozen() const -{ - return m_frozenness != 0; -} - wxWindowMac *wxGetActiveWindow() { // actually this is a windows-only concept @@ -2053,6 +2119,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() ; @@ -2165,21 +2237,21 @@ void wxWindowMac::MacPaintGrowBox() CGContextRef cgContext = (CGContextRef) MacGetCGContextRef() ; wxASSERT( cgContext ) ; - + m_peer->GetRect( &rect ) ; int size = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ; CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ; CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ; CGContextSaveGState( cgContext ); - + if ( m_backgroundColour.Ok() ) { - CGContextSetFillColorWithColor( cgContext, m_backgroundColour.GetCGColor() ); + CGContextSetFillColorWithColor( cgContext, m_backgroundColour.GetCGColor() ); } 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 ); @@ -2290,7 +2362,7 @@ void wxWindowMac::DoUpdateScrollbarVisibility() { wxSizeEvent event(GetSize(), m_windowId); event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + HandleWindowEvent(event); } } @@ -2402,7 +2474,7 @@ void wxWindowMac::MacOnScroll( wxScrollEvent &event ) else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE) wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE ); - GetEventHandler()->ProcessEvent(wevent); + HandleWindowEvent(wevent); } } @@ -2414,59 +2486,11 @@ wxWindowMac *wxWindowBase::DoFindFocus() return wxFindControlFromMacControl( control ) ; } -void wxWindowMac::OnSetFocus( wxFocusEvent& event ) -{ - // panel wants to track the window which was the last to have focus in it, - // so we want to set ourselves as the window which last had focus - // - // notice that it's also important to do it upwards the tree because - // otherwise when the top level panel gets focus, it won't set it back to - // us, but to some other sibling - - // CS: don't know if this is still needed: - //wxChildFocusEvent eventFocus(this); - //(void)GetEventHandler()->ProcessEvent(eventFocus); - - if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() ) - { - GetParent()->Refresh() ; - wxMacWindowStateSaver sv( this ) ; - Rect rect ; - - m_peer->GetRect( &rect ) ; - // auf den umgebenden Rahmen zurチᅡ゚ck - InsetRect( &rect, -1 , -1 ) ; - - wxTopLevelWindowMac* top = MacGetTopLevelWindow(); - if ( top ) - { - wxPoint pt(0, 0) ; - wxMacControl::Convert( &pt , GetParent()->m_peer , top->m_peer ) ; - rect.left += pt.x ; - rect.right += pt.x ; - rect.top += pt.y ; - rect.bottom += pt.y ; - } - - bool bIsFocusEvent = (event.GetEventType() == wxEVT_SET_FOCUS); - DrawThemeFocusRect( &rect , bIsFocusEvent ) ; - if ( !bIsFocusEvent ) - { - // as this erases part of the frame we have to redraw borders - // and because our z-ordering is not always correct (staticboxes) - // we have to invalidate things, we cannot simple redraw - MacInvalidateBorders() ; - } - } - - event.Skip(); -} - 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); } @@ -2495,7 +2519,7 @@ bool wxWindowMac::MacSetupCursor( const wxPoint& pt ) { wxSetCursorEvent event( pt.x , pt.y ); - bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event); + bool processedEvtSetCursor = HandleWindowEvent(event); if ( processedEvtSetCursor && event.HasCursor() ) { cursor = event.GetCursor() ; @@ -2578,7 +2602,7 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) { static wxRegion emptyrgn ; - if ( !m_isBeingDeleted && MacIsReallyShown() /*m_peer->IsVisible() */ ) + if ( !m_isBeingDeleted && IsShownOnScreen() ) { MacUpdateClippedRects() ; if ( includeOuterStructures ) @@ -2713,7 +2737,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time ) wxEraseEvent eevent( GetId(), dc ); eevent.SetEventObject( this ); - GetEventHandler()->ProcessEvent( eevent ); + HandleWindowEvent( eevent ); delete dc ; } @@ -2731,7 +2755,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time ) wxPaintEvent event; event.SetTimestamp(time); event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + HandleWindowEvent(event); handled = true ; } @@ -2770,7 +2794,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time ) // paint custom borders wxNcPaintEvent eventNc( child->GetId() ); eventNc.SetEventObject( child ); - if ( !child->GetEventHandler()->ProcessEvent( eventNc ) ) + if ( !child->HandleWindowEvent( eventNc ) ) { child->MacPaintBorders(0, 0) ; } @@ -3105,7 +3129,8 @@ void wxWindowMac::OnMouseEvent( wxMouseEvent &event ) wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, this->GetId(), this->ClientToScreen(event.GetPosition())); - if ( ! GetEventHandler()->ProcessEvent(evtCtx) ) + evtCtx.SetEventObject(this); + if ( ! HandleWindowEvent(evtCtx) ) event.Skip() ; } else @@ -3182,3 +3207,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(); +}