HIShapeCreateEmpty doesn't exist prior to OSX 10.4, use
HIShapeCreateWithRect with an empty rectangle instead. Also detabified. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42406 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -95,11 +95,11 @@ public :
|
|||||||
// draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
|
// draws a an arc to two tangents connecting (current) to (x1,y1) and (x1,y1) to (x2,y2), also a straight line from (current) to (x1,y1)
|
||||||
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r );
|
virtual void AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2, wxDouble y2, wxDouble r );
|
||||||
|
|
||||||
// returns the native path
|
// returns the native path
|
||||||
virtual void * GetNativePath() const { return m_path; }
|
virtual void * GetNativePath() const { return m_path; }
|
||||||
|
|
||||||
// give the native path returned by GetNativePath() back (there might be some deallocations necessary)
|
// give the native path returned by GetNativePath() back (there might be some deallocations necessary)
|
||||||
virtual void UnGetNativePath(void *p) {}
|
virtual void UnGetNativePath(void *p) {}
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxMacCoreGraphicsPath)
|
DECLARE_DYNAMIC_CLASS(wxMacCoreGraphicsPath)
|
||||||
DECLARE_NO_COPY_CLASS(wxMacCoreGraphicsPath)
|
DECLARE_NO_COPY_CLASS(wxMacCoreGraphicsPath)
|
||||||
@@ -198,7 +198,7 @@ public:
|
|||||||
|
|
||||||
~wxMacCoreGraphicsContext();
|
~wxMacCoreGraphicsContext();
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
// creates a path instance that corresponds to the type of graphics context, ie GDIPlus, cairo, CoreGraphics ...
|
// creates a path instance that corresponds to the type of graphics context, ie GDIPlus, cairo, CoreGraphics ...
|
||||||
virtual wxGraphicsPath * CreatePath();
|
virtual wxGraphicsPath * CreatePath();
|
||||||
@@ -214,12 +214,12 @@ public:
|
|||||||
|
|
||||||
// clips drawings to the rect
|
// clips drawings to the rect
|
||||||
virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
|
virtual void Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h );
|
||||||
|
|
||||||
// resets the clipping to original extent
|
// resets the clipping to original extent
|
||||||
virtual void ResetClip();
|
virtual void ResetClip();
|
||||||
|
|
||||||
virtual void * GetNativeContext();
|
virtual void * GetNativeContext();
|
||||||
|
|
||||||
//
|
//
|
||||||
// transformation
|
// transformation
|
||||||
//
|
//
|
||||||
@@ -307,19 +307,19 @@ public:
|
|||||||
DECLARE_DYNAMIC_CLASS(wxMacCoreGraphicsContext)
|
DECLARE_DYNAMIC_CLASS(wxMacCoreGraphicsContext)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void EnsureIsValid();
|
void EnsureIsValid();
|
||||||
|
|
||||||
CGContextRef m_cgContext;
|
CGContextRef m_cgContext;
|
||||||
WindowRef m_windowRef;
|
WindowRef m_windowRef;
|
||||||
int m_originX;
|
int m_originX;
|
||||||
int m_originY;
|
int m_originY;
|
||||||
wxMacCFRefHolder<HIShapeRef> m_clipRgn;
|
wxMacCFRefHolder<HIShapeRef> m_clipRgn;
|
||||||
bool m_releaseContext;
|
bool m_releaseContext;
|
||||||
CGPathDrawingMode m_mode;
|
CGPathDrawingMode m_mode;
|
||||||
ATSUStyle m_macATSUIStyle;
|
ATSUStyle m_macATSUIStyle;
|
||||||
wxPen m_pen;
|
wxPen m_pen;
|
||||||
wxBrush m_brush;
|
wxBrush m_brush;
|
||||||
wxFont m_font;
|
wxFont m_font;
|
||||||
wxColor m_textForegroundColor;
|
wxColor m_textForegroundColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -346,35 +346,36 @@ void wxMacCoreGraphicsContext::Init()
|
|||||||
m_cgContext = NULL;
|
m_cgContext = NULL;
|
||||||
m_mode = kCGPathFill;
|
m_mode = kCGPathFill;
|
||||||
m_macATSUIStyle = NULL;
|
m_macATSUIStyle = NULL;
|
||||||
m_releaseContext = false;
|
m_releaseContext = false;
|
||||||
m_clipRgn.Set(HIShapeCreateEmpty());
|
HIRect r = CGRectMake(0,0,0,0);
|
||||||
|
m_clipRgn.Set(HIShapeCreateWithRect(&r));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( CGContextRef cgcontext )
|
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( CGContextRef cgcontext )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_cgContext = cgcontext;
|
m_cgContext = cgcontext;
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( WindowRef window )
|
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( WindowRef window )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_windowRef = window;
|
m_windowRef = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxWindow* window )
|
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext( wxWindow* window )
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
m_windowRef = (WindowRef) window->MacGetTopLevelWindowRef();
|
m_windowRef = (WindowRef) window->MacGetTopLevelWindowRef();
|
||||||
m_originX = m_originY = 0;
|
m_originX = m_originY = 0;
|
||||||
window->MacWindowToRootWindow( &m_originX , &m_originY );
|
window->MacWindowToRootWindow( &m_originX , &m_originY );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext()
|
wxMacCoreGraphicsContext::wxMacCoreGraphicsContext()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
|
wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
|
||||||
@@ -387,73 +388,74 @@ wxMacCoreGraphicsContext::~wxMacCoreGraphicsContext()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( m_releaseContext )
|
if ( m_releaseContext )
|
||||||
QDEndCGContext( GetWindowPort( m_windowRef ) , &m_cgContext);
|
QDEndCGContext( GetWindowPort( m_windowRef ) , &m_cgContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::EnsureIsValid()
|
void wxMacCoreGraphicsContext::EnsureIsValid()
|
||||||
{
|
{
|
||||||
if ( !m_cgContext )
|
if ( !m_cgContext )
|
||||||
{
|
{
|
||||||
OSStatus status = QDBeginCGContext( GetWindowPort( m_windowRef ) , &m_cgContext );
|
OSStatus status = QDBeginCGContext( GetWindowPort( m_windowRef ) , &m_cgContext );
|
||||||
wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") );
|
wxASSERT_MSG( status == noErr , wxT("Cannot nest wxDCs on the same window") );
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds );
|
GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds );
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
CGContextTranslateCTM( m_cgContext , 0 , bounds.bottom - bounds.top );
|
CGContextTranslateCTM( m_cgContext , 0 , bounds.bottom - bounds.top );
|
||||||
CGContextScaleCTM( m_cgContext , 1 , -1 );
|
CGContextScaleCTM( m_cgContext , 1 , -1 );
|
||||||
CGContextTranslateCTM( m_cgContext, m_originX, m_originY );
|
CGContextTranslateCTM( m_cgContext, m_originX, m_originY );
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
m_releaseContext = true;
|
m_releaseContext = true;
|
||||||
if ( !HIShapeIsEmpty(m_clipRgn) )
|
if ( !HIShapeIsEmpty(m_clipRgn) )
|
||||||
{
|
{
|
||||||
HIShapeReplacePathInCGContext( m_clipRgn, m_cgContext );
|
HIShapeReplacePathInCGContext( m_clipRgn, m_cgContext );
|
||||||
CGContextClip( m_cgContext );
|
CGContextClip( m_cgContext );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::Clip( const wxRegion ®ion )
|
void wxMacCoreGraphicsContext::Clip( const wxRegion ®ion )
|
||||||
{
|
{
|
||||||
if( m_cgContext )
|
if( m_cgContext )
|
||||||
{
|
{
|
||||||
HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
|
HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
|
||||||
HIShapeReplacePathInCGContext( shape, m_cgContext );
|
HIShapeReplacePathInCGContext( shape, m_cgContext );
|
||||||
CGContextClip( m_cgContext );
|
CGContextClip( m_cgContext );
|
||||||
CFRelease( shape );
|
CFRelease( shape );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_clipRgn.Set(HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() ));
|
m_clipRgn.Set(HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clips drawings to the rect
|
// clips drawings to the rect
|
||||||
void wxMacCoreGraphicsContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
|
void wxMacCoreGraphicsContext::Clip( wxDouble x, wxDouble y, wxDouble w, wxDouble h )
|
||||||
{
|
{
|
||||||
HIRect r = CGRectMake( x , y , w , h );
|
HIRect r = CGRectMake( x , y , w , h );
|
||||||
if ( m_cgContext )
|
if ( m_cgContext )
|
||||||
{
|
{
|
||||||
CGContextClipToRect( m_cgContext, r );
|
CGContextClipToRect( m_cgContext, r );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_clipRgn.Set(HIShapeCreateWithRect(&r));
|
m_clipRgn.Set(HIShapeCreateWithRect(&r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// resets the clipping to original extent
|
// resets the clipping to original extent
|
||||||
void wxMacCoreGraphicsContext::ResetClip()
|
void wxMacCoreGraphicsContext::ResetClip()
|
||||||
{
|
{
|
||||||
if ( m_cgContext )
|
if ( m_cgContext )
|
||||||
{
|
{
|
||||||
CGContextRestoreGState( m_cgContext );
|
CGContextRestoreGState( m_cgContext );
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_clipRgn.Set(HIShapeCreateEmpty());
|
HIRect r = CGRectMake(0,0,0,0);
|
||||||
}
|
m_clipRgn.Set(HIShapeCreateWithRect(&r));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
||||||
@@ -474,8 +476,8 @@ void wxMacCoreGraphicsContext::StrokePath( const wxGraphicsPath *path )
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillStyle )
|
void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillStyle )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGPathDrawingMode mode = m_mode;
|
CGPathDrawingMode mode = m_mode;
|
||||||
|
|
||||||
if ( fillStyle == wxODDEVEN_RULE )
|
if ( fillStyle == wxODDEVEN_RULE )
|
||||||
@@ -500,8 +502,8 @@ void wxMacCoreGraphicsContext::DrawPath( const wxGraphicsPath *path , int fillSt
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath *path , int fillStyle )
|
void wxMacCoreGraphicsContext::FillPath( const wxGraphicsPath *path , int fillStyle )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
CGContextAddPath( m_cgContext , (CGPathRef) path->GetNativePath() );
|
||||||
if ( fillStyle == wxODDEVEN_RULE )
|
if ( fillStyle == wxODDEVEN_RULE )
|
||||||
CGContextEOFillPath( m_cgContext );
|
CGContextEOFillPath( m_cgContext );
|
||||||
@@ -526,29 +528,29 @@ void wxMacCoreGraphicsContext::SetNativeContext( CGContextRef cg )
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::Translate( wxDouble dx , wxDouble dy )
|
void wxMacCoreGraphicsContext::Translate( wxDouble dx , wxDouble dy )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGContextTranslateCTM( m_cgContext, dx, dy );
|
CGContextTranslateCTM( m_cgContext, dx, dy );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::Scale( wxDouble xScale , wxDouble yScale )
|
void wxMacCoreGraphicsContext::Scale( wxDouble xScale , wxDouble yScale )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGContextScaleCTM( m_cgContext , xScale , yScale );
|
CGContextScaleCTM( m_cgContext , xScale , yScale );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::Rotate( wxDouble angle )
|
void wxMacCoreGraphicsContext::Rotate( wxDouble angle )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGContextRotateCTM( m_cgContext , angle );
|
CGContextRotateCTM( m_cgContext , angle );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h )
|
void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDouble y, wxDouble w, wxDouble h )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGImageRef image = (CGImageRef)( bmp.CGImageCreate() );
|
CGImageRef image = (CGImageRef)( bmp.CGImageCreate() );
|
||||||
HIRect r = CGRectMake( x , y , w , h );
|
HIRect r = CGRectMake( x , y , w , h );
|
||||||
HIViewDrawCGImage( m_cgContext , &r , image );
|
HIViewDrawCGImage( m_cgContext , &r , image );
|
||||||
@@ -557,8 +559,8 @@ void wxMacCoreGraphicsContext::DrawBitmap( const wxBitmap &bmp, wxDouble x, wxDo
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h )
|
void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxDouble w, wxDouble h )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGRect r = CGRectMake( 00 , 00 , w , h );
|
CGRect r = CGRectMake( 00 , 00 , w , h );
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
CGContextTranslateCTM( m_cgContext, x , y + h );
|
CGContextTranslateCTM( m_cgContext, x , y + h );
|
||||||
@@ -570,23 +572,23 @@ void wxMacCoreGraphicsContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDoubl
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::PushState()
|
void wxMacCoreGraphicsContext::PushState()
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGContextSaveGState( m_cgContext );
|
CGContextSaveGState( m_cgContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::PopState()
|
void wxMacCoreGraphicsContext::PopState()
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
CGContextRestoreGState( m_cgContext );
|
CGContextRestoreGState( m_cgContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacCoreGraphicsContext::SetTextColor( const wxColour &col )
|
void wxMacCoreGraphicsContext::SetTextColor( const wxColour &col )
|
||||||
{
|
{
|
||||||
m_textForegroundColor = col;
|
m_textForegroundColor = col;
|
||||||
// to recreate the native font after color change
|
// to recreate the native font after color change
|
||||||
SetFont( m_font );
|
SetFont( m_font );
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@@ -1052,8 +1054,8 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
|
|||||||
|
|
||||||
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle )
|
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle )
|
||||||
{
|
{
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
|
|
||||||
OSStatus status = noErr;
|
OSStatus status = noErr;
|
||||||
ATSUTextLayout atsuLayout;
|
ATSUTextLayout atsuLayout;
|
||||||
UniCharCount chars = str.length();
|
UniCharCount chars = str.length();
|
||||||
@@ -1304,7 +1306,7 @@ void wxMacCoreGraphicsContext::SetFont( const wxFont &font )
|
|||||||
|
|
||||||
if ( font.Ok() )
|
if ( font.Ok() )
|
||||||
{
|
{
|
||||||
m_font = font ;
|
m_font = font ;
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
|
|
||||||
status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , (ATSUStyle*) &m_macATSUIStyle );
|
status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , (ATSUStyle*) &m_macATSUIStyle );
|
||||||
@@ -1341,7 +1343,7 @@ void wxMacCoreGraphicsContext::SetFont( const wxFont &font )
|
|||||||
|
|
||||||
void * wxMacCoreGraphicsContext::GetNativeContext()
|
void * wxMacCoreGraphicsContext::GetNativeContext()
|
||||||
{
|
{
|
||||||
return m_cgContext;
|
return m_cgContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC &dc )
|
wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC &dc )
|
||||||
@@ -1351,7 +1353,7 @@ wxGraphicsContext* wxGraphicsContext::Create( const wxWindowDC &dc )
|
|||||||
|
|
||||||
wxGraphicsContext* wxGraphicsContext::Create( wxWindow * window )
|
wxGraphicsContext* wxGraphicsContext::Create( wxWindow * window )
|
||||||
{
|
{
|
||||||
return new wxMacCoreGraphicsContext( window );
|
return new wxMacCoreGraphicsContext( window );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
|
wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
|
||||||
|
Reference in New Issue
Block a user