// where is in native window relative coordinates
virtual void SetNeedsDisplay( Rect* where = NULL ) ;
- virtual void ScrollRect( const wxRect &rect , int dx , int dy ) ;
+ // if rect = NULL, entire view
+ virtual void ScrollRect( wxRect *rect , int dx , int dy ) ;
// in native parent window relative coordinates
virtual void GetRect( Rect *r ) ;
WXWindow MacGetWindowRef() { return m_macWindow ; }
virtual void MacActivate( long timestamp , bool inIsActivating ) ;
+ virtual void MacPerformUpdates() ;
virtual void Raise();
virtual void Lower();
return attr ;
}
+void wxTopLevelWindowMac::MacPerformUpdates()
+{
+#if TARGET_API_MAC_OSX
+ if ( m_macUsesCompositing )
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+ // for composited windows this also triggers a redraw of all
+ // invalid views in the window
+ if( UMAGetSystemVersion() >= 0x1030 )
+ HIWindowFlush((WindowRef) m_macWindow) ;
+ else
+#endif
+ {
+ // the only way to trigger the redrawing on earlier systems is to call
+ // ReceiveNextEvent
+
+ EventRef currentEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ;
+ UInt32 currentEventClass = 0 ;
+ UInt32 currentEventKind = 0 ;
+ if ( currentEvent != NULL )
+ {
+ currentEventClass = ::GetEventClass( currentEvent ) ;
+ currentEventKind = ::GetEventKind( currentEvent ) ;
+ }
+ if ( currentEventClass != kEventClassMenu )
+ {
+ // when tracking a menu, strange redraw errors occur if we flush now, so leave..
+ EventRef theEvent;
+ OSStatus status = noErr ;
+ status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ;
+ }
+ }
+ }
+ else
+#endif
+ {
+ BeginUpdate( (WindowRef) m_macWindow ) ;
+
+ RgnHandle updateRgn = NewRgn();
+ if ( updateRgn )
+ {
+ GetPortVisibleRegion( GetWindowPort( (WindowRef)m_macWindow ), updateRgn );
+ UpdateControls( (WindowRef)m_macWindow , updateRgn ) ;
+ // if ( !EmptyRgn( updateRgn ) )
+ // MacDoRedraw( updateRgn , 0 , true) ;
+ DisposeRgn( updateRgn );
+ }
+ EndUpdate( (WindowRef)m_macWindow ) ;
+ QDFlushPortBuffer( GetWindowPort( (WindowRef)m_macWindow ) , NULL ) ;
+ }
+}
+
// Attracts the users attention to this window if the application is
// inactive (should be called when a background event occurs)
bool wxMacControl::GetNeedsDisplay() const
{
#if TARGET_API_MAC_OSX
- return HIViewGetNeedsDisplay( m_controlRef ) ;
-#else
- return false ;
+ if ( m_isCompositing )
+ {
+ return HIViewGetNeedsDisplay( m_controlRef ) ;
+ }
+ else
#endif
+ {
+ if ( !IsVisible() )
+ return false ;
+
+ Rect controlBounds ;
+ GetControlBounds( m_controlRef, &controlBounds ) ;
+ RgnHandle rgn = NewRgn() ;
+ GetWindowRegion ( GetControlOwner( m_controlRef ) , kWindowUpdateRgn , rgn ) ;
+ Boolean intersect = RectInRgn ( &controlBounds , rgn ) ;
+ DisposeRgn( rgn ) ;
+ return intersect ;
+ }
+
}
#endif
Rect controlBounds = *r ;
+ // since the rect passed in is always (even in non-compositing) relative
+ // to the (native) parent, we have to adjust to window relative here
wxMacControl* parent = m_peer->GetParent()->GetPeer() ;
if( parent->m_isRootControl == false )
{
#endif
}
-void wxMacControl::ScrollRect( const wxRect &r , int dx , int dy )
+void wxMacControl::ScrollRect( wxRect *r , int dx , int dy )
{
+ wxASSERT( r != NULL ) ;
#if TARGET_API_MAC_OSX
- HIRect scrollarea = CGRectMake( r.x , r.y , r.width , r.height) ;
- HIViewScrollRect ( m_controlRef , &scrollarea , dx ,dy ) ;
+ if ( m_isCompositing )
+ {
+ HIRect scrollarea = CGRectMake( r->x , r->y , r->width , r->height) ;
+ HIViewScrollRect ( m_controlRef , &scrollarea , dx ,dy ) ;
+ }
+ else
#endif
+ {
+ Rect bounds ;
+ GetControlBounds( m_controlRef , &bounds ) ;
+ Point topleft = { bounds.top , bounds.left } ;
+ bounds.left += r->x ;
+ bounds.top += r->y ;
+ bounds.bottom = bounds.top + r->height ;
+ bounds.right = bounds.left + r->width ;
+ wxMacWindowClipper clip( m_peer ) ;
+ RgnHandle updateRgn = NewRgn() ;
+ ::ScrollRect( &bounds , dx , dy , updateRgn ) ;
+ InvalWindowRgn( GetControlOwner( m_controlRef ) , updateRgn ) ;
+ }
}
if( dx == 0 && dy ==0 )
return ;
-
- {
-
int width , height ;
GetClientSize( &width , &height ) ;
#if TARGET_API_MAC_OSX
+ if ( 1 /* m_peer->IsCompositing() */ )
+ {
// note there currently is a bug in OSX which makes inefficient refreshes in case an entire control
// area is scrolled, this does not occur if width and height are 2 pixels less,
// TODO write optimal workaround
m_peer->SetNeedsDisplay() ;
#else
// this would be the preferred version for fast drawing controls
- if( UMAGetSystemVersion() < 0x1030 )
+
+ if( UMAGetSystemVersion() < 0x1030 || !m_peer->IsCompositing() )
Update() ;
else
HIViewRender(m_peer->GetControlRef()) ;
}
// as the native control might be not a 0/0 wx window coordinates, we have to offset
scrollrect.Offset( -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
- m_peer->ScrollRect( scrollrect , dx , dy ) ;
+ m_peer->ScrollRect( (&scrollrect) , dx , dy ) ;
+
+ // becuase HIViewScrollRect does not scroll the already invalidated area we have two options
+ // either immediate redraw or full invalidate
+#if 0
+ // is the better overall solution, as it does not slow down scrolling
+ m_peer->SetNeedsDisplay() ;
#else
+ // this would be the preferred version for fast drawing controls
+
+ if( UMAGetSystemVersion() < 0x1030 || !m_peer->IsCompositing() )
+ Update() ;
+ else
+ HIViewRender(m_peer->GetControlRef()) ;
+#endif
+ }
+ else
+#endif
+ {
wxPoint pos;
pos.x = pos.y = 0;
wxClientDC dc(this) ;
wxMacPortSetter helper(&dc) ;
- m_peer->GetRect( &scrollrect ) ;
- scrollrect.top += MacGetTopBorderSize() ;
- scrollrect.left += MacGetLeftBorderSize() ;
+ m_peer->GetRectInWindowCoords( &scrollrect ) ;
+ //scrollrect.top += MacGetTopBorderSize() ;
+ //scrollrect.left += MacGetLeftBorderSize() ;
scrollrect.bottom = scrollrect.top + height ;
scrollrect.right = scrollrect.left + width ;
DisposeRgn( formerUpdateRgn ) ;
DisposeRgn( scrollRgn ) ;
}
-#endif
+ Update() ;
}
for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node; node = node->GetNext())
void wxWindowMac::Update()
{
#if TARGET_API_MAC_OSX
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
- WindowRef window = (WindowRef)MacGetTopLevelWindowRef() ;
-
- // for composited windows this also triggers a redraw of all
- // invalid views in the window
- if( UMAGetSystemVersion() >= 0x1030 )
- HIWindowFlush(window) ;
- else
-#endif
- {
- // the only way to trigger the redrawing on earlier systems is to call
- // ReceiveNextEvent
-
- EventRef currentEvent = (EventRef) wxTheApp->MacGetCurrentEvent() ;
- UInt32 currentEventClass = 0 ;
- UInt32 currentEventKind = 0 ;
- if ( currentEvent != NULL )
- {
- currentEventClass = ::GetEventClass( currentEvent ) ;
- currentEventKind = ::GetEventKind( currentEvent ) ;
- }
- if ( currentEventClass != kEventClassMenu )
- {
- // when tracking a menu, strange redraw errors occur if we flush now, so leave..
-
- EventRef theEvent;
- OSStatus status = noErr ;
- status = ReceiveNextEvent( 0 , NULL , kEventDurationNoWait , false , &theEvent ) ;
- }
- else
- m_peer->SetNeedsDisplay() ;
- }
+ MacGetTopLevelWindow()->MacPerformUpdates() ;
#else
::Draw1Control( m_peer->GetControlRef() ) ;
#endif