X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ec7ff71b3c6176fbd575949d9fa22841a155cde5..0bbe61b8c18a1795189f0cf73cc61c14a0fb846d:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 5bafb0db3f..2a583e69e2 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() @@ -170,6 +168,8 @@ static const EventTypeSpec eventList[] = // { kEventClassControl , kEventControlBoundsChanged } , } ; +wxWindowMac* targetWindow = NULL; + static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; @@ -234,17 +234,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 @@ -260,8 +264,8 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl CGContextClearRect( cgContext, bounds ); } - - + + if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) result = noErr ; @@ -278,7 +282,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 : @@ -306,12 +316,18 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl // focus handling // different handling on OS X // - + case kEventControlFocusPartChanged : // the event is emulated by wxmac for systems lower than 10.5 { ControlPartCode previousControlPart = cEvent.GetParameter(kEventParamControlPreviousPart , typeControlPartCode ); ControlPartCode currentControlPart = cEvent.GetParameter(kEventParamControlCurrentPart , typeControlPartCode ); + + if ( thisWindow->MacGetTopLevelWindow() && thisWindow->GetPeer()->NeedsFocusRect() ) + { + thisWindow->MacInvalidateBorders(); + } + if ( currentControlPart == 0 ) { // kill focus @@ -319,9 +335,9 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl 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 ; @@ -330,7 +346,8 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl inKillFocusEvent = true ; wxFocusEvent event( wxEVT_KILL_FOCUS, thisWindow->GetId()); event.SetEventObject(thisWindow); - thisWindow->GetEventHandler()->ProcessEvent(event) ; + event.SetWindow(targetWindow); + thisWindow->HandleWindowEvent(event) ; inKillFocusEvent = false ; } } @@ -340,16 +357,16 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl // 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->GetEventHandler()->ProcessEvent(eventFocus); - + thisWindow->HandleWindowEvent(eventFocus); + #if wxUSE_CARET if ( thisWindow->GetCaret() ) thisWindow->GetCaret()->OnSetFocus(); #endif - + wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId()); event.SetEventObject(thisWindow); - thisWindow->GetEventHandler()->ProcessEvent(event) ; + thisWindow->HandleWindowEvent(event) ; } } break; @@ -361,9 +378,11 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl { // put a breakpoint here to catch focus everything events } -#endif +#endif ControlPartCode controlPart = cEvent.GetParameter(kEventParamControlPart , typeControlPartCode ); - + if ( controlPart != kControlFocusNoPart ) + targetWindow = thisWindow; + ControlPartCode previousControlPart = 0; verify_noerr( HIViewGetFocusPart(controlRef, &previousControlPart)); @@ -375,25 +394,25 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl } else result = CallNextEventHandler(handler, event); - + if ( UMAGetSystemVersion() < 0x1050 ) { // set back to 0 if problems arise -#if 1 +#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 ); @@ -411,7 +430,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl #endif wxLogTrace(_T("Focus"), _T("focus lost(%p)"), wx_static_cast(void*, thisWindow)); - + static bool inKillFocusEvent = false ; if ( !inKillFocusEvent ) @@ -419,7 +438,7 @@ 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 ; } } @@ -428,7 +447,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl // 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->GetEventHandler()->ProcessEvent(eventFocus); + thisWindow->HandleWindowEvent(eventFocus); #if wxUSE_CARET if ( thisWindow->GetCaret() ) @@ -437,7 +456,7 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl wxFocusEvent event(wxEVT_SET_FOCUS, thisWindow->GetId()); event.SetEventObject(thisWindow); - thisWindow->GetEventHandler()->ProcessEvent(event) ; + thisWindow->HandleWindowEvent(event) ; } #endif } @@ -450,7 +469,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) ) { @@ -601,7 +620,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 ; @@ -623,29 +642,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] ) ) @@ -861,7 +880,6 @@ wxWindowMac::wxWindowMac(wxWindowMac *parent, void wxWindowMac::Init() { m_peer = NULL ; - m_frozenness = 0 ; m_macAlpha = 255 ; m_cgContextRef = NULL ; @@ -876,9 +894,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() @@ -1097,7 +1112,7 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant ) m_peer->SetData(kControlEntireControl, kControlSizeTag, &size ) ; wxFont font ; - font.MacCreateThemeFont( themeFont ) ; + font.MacCreateFromThemeFont( themeFont ) ; SetFont( font ) ; } @@ -1105,7 +1120,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() ; } @@ -1396,7 +1411,7 @@ void wxWindowMac::MacWindowToRootWindow( int *x , int *y ) const if ( !IsTopLevel() ) { - wxTopLevelWindowMac* top = MacGetTopLevelWindow(); + wxNonOwnedWindow* top = MacGetTopLevelWindow(); if (top) { pt.x -= MacGetLeftBorderSize() ; @@ -1439,7 +1454,7 @@ void wxWindowMac::MacRootWindowToWindow( int *x , int *y ) const if ( !IsTopLevel() ) { - wxTopLevelWindowMac* top = MacGetTopLevelWindow(); + wxNonOwnedWindow* top = MacGetTopLevelWindow(); if (top) { wxMacControl::Convert( &pt , top->m_peer , m_peer ) ; @@ -1570,7 +1585,7 @@ bool wxWindowMac::SetCursor(const wxCursor& cursor) wxWindowMac *mouseWin = 0 ; { - wxTopLevelWindowMac *tlw = MacGetTopLevelWindow() ; + wxNonOwnedWindow *tlw = MacGetTopLevelWindow() ; WindowRef window = (WindowRef) ( tlw ? tlw->MacGetWindowRef() : 0 ) ; ControlPartCode part ; @@ -1670,12 +1685,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 ) @@ -1771,7 +1786,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 ) @@ -1780,7 +1795,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); } } } @@ -1939,7 +1954,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() ; } @@ -1985,31 +2000,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() ; @@ -2071,7 +2061,7 @@ void wxWindowMac::Refresh(bool WXUNUSED(eraseBack), const wxRect *rect) if ( m_peer == NULL ) return ; - if ( !MacIsReallyShown() ) + if ( !IsShownOnScreen() ) return ; if ( rect ) @@ -2087,38 +2077,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 @@ -2147,6 +2124,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() ; @@ -2259,21 +2242,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 ); @@ -2384,7 +2367,7 @@ void wxWindowMac::DoUpdateScrollbarVisibility() { wxSizeEvent event(GetSize(), m_windowId); event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + HandleWindowEvent(event); } } @@ -2496,7 +2479,7 @@ void wxWindowMac::MacOnScroll( wxScrollEvent &event ) else if (event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE) wevent.SetEventType( wxEVT_SCROLLWIN_THUMBRELEASE ); - GetEventHandler()->ProcessEvent(wevent); + HandleWindowEvent(wevent); } } @@ -2508,59 +2491,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 ) ; - // on the surrounding frame - 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); } @@ -2589,7 +2524,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() ; @@ -2632,14 +2567,14 @@ void wxWindowMac::ClearBackground() void wxWindowMac::Update() { - wxTopLevelWindowMac* top = MacGetTopLevelWindow(); + wxNonOwnedWindow* top = MacGetTopLevelWindow(); if (top) top->MacPerformUpdates() ; } -wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const +wxNonOwnedWindow* wxWindowMac::MacGetTopLevelWindow() const { - wxTopLevelWindowMac* win = NULL ; + wxNonOwnedWindow* win = NULL ; WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; if ( window ) win = wxFindWinFromMacWindow( window ) ; @@ -2672,7 +2607,7 @@ const wxRegion& wxWindowMac::MacGetVisibleRegion( bool includeOuterStructures ) { static wxRegion emptyrgn ; - if ( !m_isBeingDeleted && MacIsReallyShown() /*m_peer->IsVisible() */ ) + if ( !m_isBeingDeleted && IsShownOnScreen() ) { MacUpdateClippedRects() ; if ( includeOuterStructures ) @@ -2807,7 +2742,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time ) wxEraseEvent eevent( GetId(), dc ); eevent.SetEventObject( this ); - GetEventHandler()->ProcessEvent( eevent ); + HandleWindowEvent( eevent ); delete dc ; } @@ -2825,7 +2760,7 @@ bool wxWindowMac::MacDoRedraw( void* updatergnr , long time ) wxPaintEvent event; event.SetTimestamp(time); event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + HandleWindowEvent(event); handled = true ; } @@ -2864,7 +2799,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) ; } @@ -2890,7 +2825,7 @@ WXWindow wxWindowMac::MacGetTopLevelWindowRef() const #if wxUSE_POPUPWIN wxPopupWindow* popupwin = wxDynamicCast(iter,wxPopupWindow); if ( popupwin ) - return popupwin->MacGetPopupWindowRef(); + return popupwin->MacGetWindowRef(); #endif } iter = iter->GetParent() ; @@ -3199,7 +3134,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 @@ -3276,3 +3212,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(); +}