BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
EVT_NC_PAINT(wxWindowMac::OnNcPaint)
EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
-// TODO EVT_PAINT(wxWindowMac::OnPaint)
+#if TARGET_API_MAC_OSX
+ EVT_PAINT(wxWindowMac::OnPaint)
+#endif
EVT_SET_FOCUS(wxWindowMac::OnSetFocus)
EVT_KILL_FOCUS(wxWindowMac::OnSetFocus)
EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
}
}
#endif
+ {
#if wxMAC_USE_CORE_GRAPHICS
- CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
- thisWindow->MacSetCGContextRef( cgContext ) ;
+ CGContextRef cgContext = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef) ;
+ thisWindow->MacSetCGContextRef( cgContext ) ;
+ wxMacCGContextStateSaver sg( cgContext ) ;
#endif
- if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
- result = noErr ;
+ if ( thisWindow->MacDoRedraw( updateRgn , cEvent.GetTicks() ) )
+ result = noErr ;
#if wxMAC_USE_CORE_GRAPHICS
- thisWindow->MacSetCGContextRef( NULL ) ;
+ thisWindow->MacSetCGContextRef( NULL ) ;
#endif
+ }
if ( allocatedRgn )
DisposeRgn( allocatedRgn ) ;
}
RectRgn( updateOuter , &rect ) ;
DiffRgn( updateOuter , updateInner ,updateOuter ) ;
wxPoint parent(0,0);
+#if TARGET_API_MAC_OSX
+ // no offsetting needed when compositing
+#else
GetParent()->MacWindowToRootWindow( &parent.x , &parent.y ) ;
parent -= GetParent()->GetClientAreaOrigin() ;
OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
+#endif
CopyRgn( updateOuter , updateTotal ) ;
rect = r ;
OffsetRgn( updateOuter , -parent.x , -parent.y ) ;
UnionRgn( updateOuter , updateTotal , updateTotal ) ;
- GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
+ GetParent()->m_peer->SetNeedsDisplay( true , updateTotal ) ;
DisposeRgn(updateOuter) ;
DisposeRgn(updateInner) ;
DisposeRgn(updateTotal) ;
#endif
}
-/* TODO
-void wxWindowMac::OnPaint(wxPaintEvent& event)
-{
- // why don't we skip that here ?
-}
-*/
-
wxWindowMac *wxGetActiveWindow()
{
// actually this is a windows-only concept
}
}
-void wxWindowMac::MacPaintBorders( int left , int top )
+//
+// we draw borders and grow boxes, are already set up and clipped in the current port / cgContextRef
+// our own window origin is at leftOrigin/rightOrigin
+//
+
+void wxWindowMac::MacPaintBorders( int leftOrigin , int rightOrigin )
{
if( IsTopLevel() )
return ;
Rect rect ;
+ bool hasFocus = m_peer->NeedsFocusRect() && m_peer->HasFocus() ;
+ bool hasBothScrollbars = ( m_hScrollBar && m_hScrollBar->IsShown()) && ( m_vScrollBar && m_vScrollBar->IsShown()) ;
+
m_peer->GetRect( &rect ) ;
InsetRect( &rect, -MacGetLeftBorderSize() , -MacGetTopBorderSize() ) ;
- if ( !IsTopLevel() )
+#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+ if ( HIThemeDrawFrame != 0)
+ {
+ Rect srect = rect ;
+ HIThemeFrameDrawInfo info ;
+ memset( &info, 0 , sizeof( info ) ) ;
+
+ info.version = 0 ;
+ info.kind = 0 ;
+ info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
+ info.isFocused = hasFocus ;
+ bool draw = false ;
+
+ CGContextRef cgContext = (CGContextRef) GetParent()->MacGetCGContextRef() ;
+ wxASSERT( cgContext ) ;
+
+ if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
+ {
+ SInt32 border = 0 ;
+ GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
+ InsetRect( &srect , border , border );
+ info.kind = kHIThemeFrameTextFieldSquare ;
+ draw = true ;
+ }
+ else if (HasFlag(wxSIMPLE_BORDER))
+ {
+ SInt32 border = 0 ;
+ GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
+ InsetRect( &srect , border , border );
+ info.kind = kHIThemeFrameListBox ;
+ draw = true ;
+ }
+
+ if ( draw )
+ {
+ CGRect cgrect = CGRectMake( srect.left , srect.top , srect.right - srect.left ,
+ srect.bottom - srect.top ) ;
+ HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
+ }
+ else if ( hasFocus )
+ {
+ srect = rect ;
+ CGRect cgrect = CGRectMake( srect.left , srect.top , srect.right - srect.left ,
+ srect.bottom - srect.top ) ;
+ HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
+ }
+
+ m_peer->GetRect( &rect ) ;
+ if ( hasBothScrollbars )
+ {
+ srect = rect ;
+ int size = m_hScrollBar->GetWindowVariant() == wxWINDOW_VARIANT_NORMAL ? 16 : 12 ;
+ CGRect cgrect = CGRectMake( srect.right - size , srect.bottom - size , size , size ) ;
+ CGPoint cgpoint = CGPointMake( srect.right - size , srect.bottom - size ) ;
+ HIThemeGrowBoxDrawInfo info ;
+ memset( &info, 0 , sizeof( info ) ) ;
+ info.version = 0 ;
+ info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
+ info.kind = kHIThemeGrowBoxKindNone ;
+ info.size = kHIThemeGrowBoxSizeNormal ;
+ info.direction = kThemeGrowRight | kThemeGrowDown ;
+ HIThemeDrawGrowBox( &cgpoint , &info , cgContext , kHIThemeOrientationNormal ) ;
+ }
+ }
+ else
+#endif
{
wxTopLevelWindowMac* top = MacGetTopLevelWindow();
if (top)
rect.top += pt.y ;
rect.bottom += pt.y ;
}
- }
- if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
- {
- Rect srect = rect ;
- SInt32 border = 0 ;
- GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
- InsetRect( &srect , border , border );
- DrawThemeEditTextFrame(&srect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
- }
- else if (HasFlag(wxSIMPLE_BORDER))
- {
- Rect srect = rect ;
- SInt32 border = 0 ;
- GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
- InsetRect( &srect , border , border );
- DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
+ if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
+ {
+ Rect srect = rect ;
+ SInt32 border = 0 ;
+ GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
+ InsetRect( &srect , border , border );
+ DrawThemeEditTextFrame(&srect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
+ }
+ else if (HasFlag(wxSIMPLE_BORDER))
+ {
+ Rect srect = rect ;
+ SInt32 border = 0 ;
+ GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
+ InsetRect( &srect , border , border );
+ DrawThemeListBoxFrame(&rect,IsEnabled() ? kThemeStateActive : kThemeStateInactive) ;
+ }
+
+ if ( hasFocus )
+ {
+ Rect srect = rect ;
+ DrawThemeFocusRect( &srect , true ) ;
+ }
+ if ( hasBothScrollbars )
+ {
+ // GetThemeStandaloneGrowBoxBounds
+ //DrawThemeStandaloneNoGrowBox
+ }
}
}
if ( MacGetTopLevelWindow() && m_peer->NeedsFocusRect() )
{
+ #if !wxMAC_USE_CORE_GRAPHICS
wxMacWindowStateSaver sv( this ) ;
int w , h ;
DisposeRgn(updateOuter) ;
DisposeRgn(updateInner) ;
}
+#else
+ GetParent()->Refresh() ;
+#endif
}
event.Skip();
Rect updatebounds ;
GetRegionBounds( updatergn , &updatebounds ) ;
-// wxLogDebug("update for %s bounds %d , %d , %d , %d",typeid(*this).name() , updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
- if ( !EmptyRgn(updatergn) )
+ // wxLogDebug(wxT("update for %s bounds %d , %d , %d , %d"),wxString(GetClassInfo()->GetClassName()).c_str(), updatebounds.left , updatebounds.top , updatebounds.right , updatebounds.bottom ) ;
+
+ if ( !EmptyRgn(updatergn) )
{
RgnHandle newupdate = NewRgn() ;
wxSize point = GetClientSize() ;
// first send an erase event to the entire update area
{
- wxWindowDC dc(this);
- dc.SetClippingRegion(wxRegion(updatergn));
- wxEraseEvent eevent( GetId(), &dc );
+ // for the toplevel window this really is the entire area
+ // for all the others only their client area, otherwise they
+ // might be drawing with full alpha and eg put blue into
+ // the grow-box area of a scrolled window (scroll sample)
+ wxDC* dc ;
+ if ( IsTopLevel() )
+ dc = new wxWindowDC(this);
+ else
+ dc = new wxClientDC(this);
+ dc->SetClippingRegion(wxRegion(updatergn));
+ wxEraseEvent eevent( GetId(), dc );
eevent.SetEventObject( this );
GetEventHandler()->ProcessEvent( eevent );
+ delete dc ;
}
// calculate a client-origin version of the update rgn and set m_updateRegion to that
if ( !m_updateRegion.Empty() )
{
// paint the window itself
+
wxPaintEvent event;
event.SetTimestamp(time);
event.SetEventObject(this);
- handled = GetEventHandler()->ProcessEvent(event);
-
- // we have to call the default built-in handler, as otherwise our frames will be drawn and immediately erased afterwards
- if ( !handled )
- {
- if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
- {
- CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
- handled = true ;
- }
- }
-
+ GetEventHandler()->ProcessEvent(event);
+ handled = true ;
}
// now we cannot rely on having its borders drawn by a window itself, as it does not
if (child->IsTopLevel()) continue;
if (!child->IsShown()) continue;
+ // only draw those in the update region (add a safety margin of 10 pixels for shadow effects
+
int x,y;
child->GetPosition( &x, &y );
int w,h;
child->GetSize( &w, &h );
Rect childRect = { y , x , y + h , x + w } ;
OffsetRect( &childRect , clientOrigin.x , clientOrigin.y ) ;
- if ( child->MacGetTopBorderSize() )
+ InsetRect( &childRect , -10 , -10) ;
+
+ if ( RectInRgn( &childRect , updatergn ) )
{
- if ( RectInRgn( &childRect , updatergn ) )
+
+ // paint custom borders
+ wxNcPaintEvent eventNc( child->GetId() );
+ eventNc.SetEventObject( child );
+ if ( !child->GetEventHandler()->ProcessEvent( eventNc ) )
{
-#if wxMAC_USE_CORE_GRAPHICS
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
- if ( HIThemeDrawFrame )
+#if wxMAC_USE_CORE_GRAPHICS && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+ if ( HIThemeDrawFrame != 0)
{
- Rect srect = childRect ;
- HIThemeFrameDrawInfo info ;
- info.version = 0 ;
- info.kind = 0 ;
- info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
- if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
- {
- SInt32 border = 0 ;
- GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
- InsetRect( &srect , border , border );
- info.kind = kHIThemeFrameTextFieldSquare ;
- }
- else if (HasFlag(wxSIMPLE_BORDER))
- {
- SInt32 border = 0 ;
- GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
- InsetRect( &srect , border , border );
- info.kind = kHIThemeFrameListBox ;
- }
-
- CGRect rect = CGRectMake( srect.left , srect.top , srect.right - srect.left ,
- srect.bottom - srect.top ) ;
- HIThemeDrawFrame( &rect , &info , (CGContextRef) MacGetCGContextRef() , kHIThemeOrientationNormal ) ;
+ child->MacPaintBorders(0,0) ;
}
+ else
#endif
-#else
- // paint custom borders
- wxNcPaintEvent eventNc( child->GetId() );
- eventNc.SetEventObject( child );
- if ( !child->GetEventHandler()->ProcessEvent( eventNc ) )
{
+#if !wxMAC_USE_CORE_GRAPHICS
wxWindowDC dc(this) ;
dc.SetClippingRegion(wxRegion(updatergn));
wxMacPortSetter helper(&dc) ;
- child->MacPaintBorders( dc.m_macLocalOrigin.x + childRect.left , dc.m_macLocalOrigin.y + childRect.top) ;
- }
+ child->MacPaintBorders(0,0) ;
#endif
+ }
}
}
- if ( child->m_peer->NeedsFocusRect() && child->m_peer->HasFocus() )
- {
-#if wxMAC_USE_CORE_GRAPHICS
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
- if ( HIThemeDrawFocusRect )
- {
- CGRect rect = CGRectMake( childRect.left , childRect.top , childRect.right - childRect.left ,
- childRect.bottom - childRect.top ) ;
- HIThemeDrawFocusRect( &rect , true , (CGContextRef) MacGetCGContextRef() , kHIThemeOrientationNormal ) ;
- }
-#endif
-#else
- wxWindowDC dc(this) ;
- dc.SetClippingRegion(wxRegion(updatergn));
- wxMacPortSetter helper(&dc) ;
- Rect r = childRect ;
- OffsetRect( &r , dc.m_macLocalOrigin.x , dc.m_macLocalOrigin.y ) ;
- DrawThemeFocusRect( &r , true ) ;
-#endif
- }
}
}
return handled ;
}
}
+void wxWindowMac::OnPaint( wxPaintEvent & event )
+{
+ if ( wxTheApp->MacGetCurrentEvent() != NULL && wxTheApp->MacGetCurrentEventHandlerCallRef() != NULL )
+ {
+ CallNextEventHandler((EventHandlerCallRef)wxTheApp->MacGetCurrentEventHandlerCallRef() , (EventRef) wxTheApp->MacGetCurrentEvent() ) ;
+ }
+}
+
void wxWindowMac::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) )
{
}