virtual void Freeze() ;
virtual void Thaw() ;
+ virtual void Update() ;
+ virtual void ClearBackground() ;
+
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font ) ;
virtual bool SetBackgroundColour( const wxColour &colour );
bool MacIsUserPane() { return m_macIsUserPane; }
- virtual void Update() ;
virtual bool MacSetupCursor( const wxPoint& pt ) ;
virtual void MacSetBackgroundBrush( const wxBrush &brush ) ;
wxMacCGContext::wxMacCGContext( CGrafPtr port )
{
m_qdPort = port ;
- Rect bounds ;
- GetPortBounds( (CGrafPtr) port , &bounds ) ;
- OSStatus status = QDBeginCGContext( (CGrafPtr) port , &m_cgContext ) ;
-
- wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") ) ;
- CGContextTranslateCTM( m_cgContext , 0 , bounds.bottom - bounds.top ) ;
- CGContextScaleCTM( m_cgContext , 1 , -1 ) ;
+ m_cgContext = NULL ;
}
wxMacCGContext::wxMacCGContext( CGContextRef cgcontext )
CGContextRestoreGState( m_cgContext ) ;
}
-wxGraphicPath* wxMacCGContext::CreatePath() { return new wxMacCGPath() ; }
-CGContextRef wxMacCGContext::GetNativeContext() { return m_cgContext ; }
-void wxMacCGContext::SetNativeContext( CGContextRef cg ) { m_cgContext = cg ; }
+wxGraphicPath* wxMacCGContext::CreatePath()
+{
+ CGContextRef cg = GetNativeContext() ;
+ // make sure that we now have a real cgref, before doing
+ // anything with paths
+ return new wxMacCGPath() ;
+}
+
+// in case we only got a QDPort only create a cgref now
+
+CGContextRef wxMacCGContext::GetNativeContext()
+{
+ if( m_cgContext == NULL )
+ {
+ Rect bounds ;
+ GetPortBounds( (CGrafPtr) m_qdPort , &bounds ) ;
+ OSStatus status = QDBeginCGContext( (CGrafPtr) m_qdPort , &m_cgContext ) ;
+
+ wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") ) ;
+ CGContextTranslateCTM( m_cgContext , 0 , bounds.bottom - bounds.top ) ;
+ CGContextScaleCTM( m_cgContext , 1 , -1 ) ;
+
+ SetPen( m_pen ) ;
+ SetBrush( m_brush ) ;
+ }
+ return m_cgContext ;
+}
+
+void wxMacCGContext::SetNativeContext( CGContextRef cg )
+{
+ m_cgContext = cg ;
+}
void wxMacCGContext::SetPen( const wxPen &pen )
{
+ m_pen = pen ;
+ if ( m_cgContext == NULL )
+ return ;
bool fill = m_brush.GetStyle() != wxTRANSPARENT ;
bool stroke = pen.GetStyle() != wxTRANSPARENT ;
-
+
#if 0
// we can benchmark performance, should go into a setting later
CGContextSetShouldAntialias( m_cgContext , false ) ;
}
void wxMacCGContext::SetBrush( const wxBrush &brush )
{
+ m_brush = brush ;
+ if ( m_cgContext == NULL )
+ return ;
+
bool fill = brush.GetStyle() != wxTRANSPARENT ;
bool stroke = m_pen.GetStyle() != wxTRANSPARENT ;
SetBackground(MacGetBackgroundBrush(window));
}
else
- m_graphicContext = NULL ;
+ {
+ // as out of order redraw is not supported under CQ, we have to create a qd port for these
+ // situations
+ wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
+ if (!rootwindow)
+ return;
+ WindowRef windowref = (WindowRef) rootwindow->MacGetWindowRef() ;
+ wxSize size = window->GetClientSize() ;
+ int x , y ;
+ x = y = 0 ;
+ window->MacWindowToRootWindow( &x , &y ) ;
+ m_macLocalOrigin.x = x ;
+ m_macLocalOrigin.y = y ;
+ CGrafPtr port = UMAGetWindowPort( windowref ) ;
+
+ m_graphicContext = new wxMacCGContext( port ) ;
+ m_graphicContext->SetPen( m_pen ) ;
+ m_graphicContext->SetBrush( m_brush ) ;
+ SetBackground(MacGetBackgroundBrush(window));
+ }
// there is no out-of-order drawing on OSX
#else
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
}
else
{
- /*
+ // as out of order redraw is not supported under CQ, we have to create a qd port for these
+ // situations
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
if (!rootwindow)
return;
m_graphicContext->SetPen( m_pen ) ;
m_graphicContext->SetBrush( m_brush ) ;
SetBackground(MacGetBackgroundBrush(window));
- m_ok = TRUE ;
- */
- }
+ }
m_ok = TRUE ;
#else
wxTopLevelWindowMac* rootwindow = window->MacGetTopLevelWindow() ;
return wxEmptyString ;
}
+void wxWindowMac::ClearBackground()
+{
+ Refresh() ;
+ Update() ;
+}
+
void wxWindowMac::Update()
{
#if TARGET_API_MAC_OSX
if ( RectInRgn( &childRect , updatergn ) )
{
#if wxMAC_USE_CORE_GRAPHICS
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
+ if ( HIThemeDrawFrame )
+ {
+ 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 ) ;
+ }
+#endif
#else
// paint custom borders
wxNcPaintEvent eventNc( child->GetId() );
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));