X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9bd2d050ef9e22a05b66dc3e51a8bf7a29b3f437..993da3969b28e4f80b492cc26114fb0e151163cb:/src/mac/carbon/window.cpp diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index c73013d50e..c30e7a0467 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -146,28 +146,33 @@ static pascal OSStatus wxMacWindowControlEventHandler( EventHandlerCallRef handl { updateRgn = (RgnHandle) visRegion.GetWXHRGN() ; } - else - { - // unfortunately this update region may be incorrect (tree ctrl sample ) - // so we have to reset it - // updateRgn = (RgnHandle) visRegion.GetWXHRGN() ; - } // GrafPtr myport = cEvent.GetParameter(kEventParamGrafPort,typeGrafPtr) ; -#if 0 // in case we would need a coregraphics compliant background erase first +#if 0 + // in case we would need a coregraphics compliant background erase first + // now usable to track redraws CGContextRef cgContext = cEvent.GetParameter(kEventParamCGContextRef) ; if ( thisWindow->MacIsUserPane() ) { + static float color = 0.5 ; + static channel = 0 ; HIRect bounds; - err = HIViewGetBounds( controlRef, &bounds ); - CGContextSetRGBFillColor( cgContext, 1 , 1 , 1 , 1 ); -// CGContextSetRGBFillColor( cgContext, .95, .95, .95, 1 ); + HIViewGetBounds( controlRef, &bounds ); + CGContextSetRGBFillColor( cgContext, channel == 0 ? color : 0.5 , + channel == 1 ? color : 0.5 , channel == 2 ? color : 0.5 , 1 ); CGContextFillRect( cgContext, bounds ); + color += 0.1 ; + if ( color > 0.9 ) + { + color = 0.5 ; + channel++ ; + if ( channel == 3 ) + channel = 0 ; + } } #endif - if ( !thisWindow->MacIsUserPane() && thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) + if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) ) result = noErr ; - } break ; case kEventControlVisibilityChanged : @@ -264,7 +269,12 @@ static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control, Contro void wxWindowMac::MacControlUserPaneDrawProc(wxInt16 part) { - MacDoRedraw( MacGetVisibleRegion().GetWXHRGN() , 0 ) ; + RgnHandle rgn = NewRgn() ; + GetClip( rgn ) ; + wxMacWindowStateSaver sv( this ) ; + SectRgn( rgn , (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , rgn ) ; + MacDoRedraw( rgn , 0 ) ; + DisposeRgn( rgn ) ; } wxInt16 wxWindowMac::MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) @@ -415,6 +425,7 @@ pascal void wxMacLiveScrollbarActionProc( ControlRef control , ControlPartCode p void wxWindowMac::Init() { + m_frozenness = 0 ; m_backgroundTransparent = FALSE; // as all windows are created with WS_VISIBLE style... @@ -451,6 +462,8 @@ void wxWindowMac::Init() wxMacSetupControlBackgroundUPP = NewControlColorUPP( wxMacSetupControlBackground ) ; } + // we need a valid font for the encodings + wxWindowBase::SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); } // Destructor @@ -559,9 +572,9 @@ bool wxWindowMac::Create(wxWindowMac *parent, wxWindowID id, ::CreateUserPaneControl( MAC_WXHWND(GetParent()->MacGetTopLevelWindowRef()) , &bounds, kControlSupportsEmbedding , (ControlRef*) &m_macControl); MacPostControlCreate(pos,size) ; +#if !TARGET_API_MAC_OSX SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneDrawProcTag, sizeof(gControlUserPaneDrawUPP),(Ptr) &gControlUserPaneDrawUPP); -#if !TARGET_API_MAC_OSX SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneHitTestProcTag, sizeof(gControlUserPaneHitTestUPP),(Ptr) &gControlUserPaneHitTestUPP); SetControlData((ControlRef) m_macControl,kControlEntireControl,kControlUserPaneTrackingProcTag, @@ -908,7 +921,7 @@ void wxWindowMac::MacGetPositionAndSizeFromControl(int& x, int& y, bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos, const wxSize& size, int& x, int& y, - int& w, int& h) const + int& w, int& h , bool adjustOrigin ) const { x = (int)pos.x; y = (int)pos.y; @@ -918,7 +931,8 @@ bool wxWindowMac::MacGetBoundsForControl(const wxPoint& pos, #if !TARGET_API_MAC_OSX GetParent()->MacWindowToRootWindow( &x , &y ) ; #endif - + if ( adjustOrigin ) + AdjustForParentClientOrigin( x , y ) ; return true ; } @@ -1348,14 +1362,27 @@ void wxWindowMac::DoMoveWindow(int x, int y, int width, int height) if ( doMove || doResize ) { - Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) ) ; + // we don't adjust twice for the origin + Rect r = wxMacGetBoundsForControl(this , wxPoint( actualX,actualY), wxSize( actualWidth, actualHeight ) , false ) ; + bool vis = IsControlVisible( (ControlRef) m_macControl ) ; #if TARGET_API_MAC_OSX - SetControlBounds( (ControlRef) m_macControl , &r ) ; + // the HIViewSetFrame call itself should invalidate the areas, but when testing with the UnicodeTextCtrl it does not ! + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , false , true ) ; + HIRect hir = { r.left , r.top , r.right - r.left , r.bottom - r.top } ; + HIViewSetFrame ( (ControlRef) m_macControl , &hir ) ; + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , true , true ) ; #else +// TODO TEST SetControlBounds( (ControlRef) m_macControl , &r ) ; + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , false , true ) ; if ( doMove ) MoveControl( (ControlRef) m_macControl , r.left , r.top ) ; if ( doSize ) SizeControl( (ControlRef) m_macControl , r.right-r.left , r.bottom-r.top ) ; + if ( vis ) + SetControlVisibility( (ControlRef)m_macControl , true , true ) ; #endif MacRepositionScrollBars() ; if ( doMove ) @@ -1719,7 +1746,9 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) { RgnHandle update = NewRgn() ; SetRectRgn( update , rect->x , rect->y , rect->x + rect->width , rect->y + rect->height ) ; - SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ; + SectRgn( (RgnHandle) MacGetVisibleRegion().GetWXHRGN() , update , update ) ; + wxPoint origin = GetClientAreaOrigin() ; + OffsetRgn( update, origin.x , origin.y ) ; HIViewSetNeedsDisplayInRegion( (ControlRef) m_macControl , update , true ) ; } #else @@ -1785,6 +1814,29 @@ void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect) #endif } +void wxWindowMac::Freeze() +{ +#if TARGET_API_MAC_OSX + if ( !m_frozenness++ ) + { + HIViewSetDrawingEnabled( (HIViewRef) m_macControl , false ) ; + } +#endif +} + +void wxWindowMac::Thaw() +{ +#if TARGET_API_MAC_OSX + wxASSERT_MSG( m_frozenness > 0, _T("Thaw() without matching Freeze()") ); + + if ( !--m_frozenness ) + { + HIViewSetDrawingEnabled( (HIViewRef) m_macControl , true ) ; + HIViewSetNeedsDisplay( (HIViewRef) m_macControl , true ) ; + } +#endif +} + void wxWindowMac::MacRedrawControl() { /* @@ -2729,11 +2781,11 @@ void wxWindowMac::MacHandleControlClick( WXWidget control , wxInt16 controlpart wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ; } -Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size ) +Rect wxMacGetBoundsForControl( wxWindow* window , const wxPoint& pos , const wxSize &size , bool adjustForOrigin ) { int x ,y , w ,h ; - window->MacGetBoundsForControl( pos , size , x , y, w, h ) ; + window->MacGetBoundsForControl( pos , size , x , y, w, h , adjustForOrigin) ; Rect bounds = { y , x , y+h , x+w }; return bounds ; }