#include "wx/mac/private.h"
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
-typedef float CGFloat;
-#endif
-
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
#pragma mark -
#pragma mark wxMacCoreGraphicsPattern, ImagePattern, HatchPattern classes
+OSStatus wxMacDrawCGImage(
+ CGContextRef inContext,
+ const HIRect * inBounds,
+ CGImageRef inImage)
+{
+#ifdef __LP64__
+ // todo flip
+ CGContextDrawImage(inContext, *inBounds, inImage );
+ return noErr;
+#else
+ return HIViewDrawCGImage( inContext, inBounds, inImage );
+#endif
+}
+
// CGPattern wrapper class: always allocate on heap, never call destructor
class wxMacCoreGraphicsPattern
{
wxASSERT( bmp && bmp->Ok() );
- Init( (CGImageRef) bmp->CGImageCreate() , transform );
+ Init( (CGImageRef) bmp->CreateCGImage() , transform );
}
// ImagePattern takes ownership of CGImageRef passed in
virtual void Render( CGContextRef ctxRef )
{
if (m_image != NULL)
- HIViewDrawCGImage( ctxRef, &m_imageBounds, m_image );
+ wxMacDrawCGImage( ctxRef, &m_imageBounds, m_image );
}
protected :
wxBitmap gs_stripedback_bmp( wxImage( (const char* const* ) gs_stripedback_xpm ), -1 ) ;
+// make sure we all use one class for all conversions from wx to native colour
+
+class wxMacCoreGraphicsColour
+{
+ public:
+ wxMacCoreGraphicsColour();
+ wxMacCoreGraphicsColour(const wxBrush &brush);
+ ~wxMacCoreGraphicsColour();
+
+ void Apply( CGContextRef cgContext );
+ protected:
+ void Init();
+ wxMacCFRefHolder<CGColorRef> m_color;
+ wxMacCFRefHolder<CGColorSpaceRef> m_colorSpace;
+
+ bool m_isPattern;
+ wxMacCFRefHolder<CGPatternRef> m_pattern;
+ CGFloat* m_patternColorComponents;
+} ;
+
wxMacCoreGraphicsColour::~wxMacCoreGraphicsColour()
{
delete[] m_patternColorComponents;
Init();
if ( brush.GetStyle() == wxSOLID )
{
- if ( brush.MacGetBrushKind() == kwxMacBrushTheme )
- {
- CGColorRef color ;
- HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color );
- m_color.Set( color ) ;
- }
- else
- {
- CGFloat components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
- brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ;
- m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
- }
+ m_color.Set( brush.GetColour().CreateCGColor() );
}
else if ( brush.IsHatch() )
{
{
m_macATSUIStyle = NULL;
+#ifdef wxMAC_USE_CORE_TEXT
+#elif defined(wxMAC_USE_ATSU_TEXT)
OSStatus status;
status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , &m_macATSUIStyle );
// we need the scale here ...
Fixed atsuSize = IntToFixed( int( 1 * font.MacGetFontSize()) );
- RGBColor atsuColor = MAC_WXCOLORREF( col.GetPixel() );
+ RGBColor atsuColor ;
+ col.GetRGBColor( &atsuColor );
ATSUAttributeTag atsuTags[] =
{
kATSUSizeTag ,
atsuTags, atsuSizes, atsuValues);
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
+#elif defined(WXMAC_USE_CG_TEXT)
+#endif
}
wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
{
+#ifdef wxMAC_USE_CORE_TEXT
+#elif defined(wxMAC_USE_ATSU_TEXT)
if ( m_macATSUIStyle )
{
::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle);
m_macATSUIStyle = NULL;
}
+#elif defined(WXMAC_USE_CG_TEXT)
+#endif
}
//
int originX , originY;
originX = originY = 0;
window->MacWindowToRootWindow( &originX , &originY );
- Rect bounds;
- GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds );
+ Rect bounds = { 0,0,0,0 };
+#ifdef __LP64__
+#else
+ GetWindowBounds( m_windowRef, kWindowContentRgn, &bounds );
+#endif
m_windowTransform = CGAffineTransformMakeTranslation( 0 , bounds.bottom - bounds.top );
m_windowTransform = CGAffineTransformScale( m_windowTransform , 1 , -1 );
m_windowTransform = CGAffineTransformTranslate( m_windowTransform, originX, originY ) ;
{
if( m_cgContext )
{
- HIShapeRef shape = HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() );
- HIShapeReplacePathInCGContext( shape, m_cgContext );
+ HIShapeReplacePathInCGContext( region.GetWXHRGN() , m_cgContext );
CGContextClip( m_cgContext );
- CFRelease( shape );
}
else
{
// this offsetting to device coords is not really correct, but since we cannot apply affine transforms
// to regions we try at least to have correct translations
- wxMacCFRefHolder<HIShapeRef> hishape ;
- hishape.Set( HIShapeCreateWithQDRgn( (RgnHandle) region.GetWXHRGN() ));
- HIMutableShapeRef mutableShape = HIShapeCreateMutableCopy( hishape );
+ HIMutableShapeRef mutableShape = HIShapeCreateMutableCopy( region.GetWXHRGN() );
CGPoint transformedOrigin = CGPointApplyAffineTransform( CGPointZero, m_windowTransform );
HIShapeOffset( mutableShape, transformedOrigin.x, transformedOrigin.y );
{
EnsureIsValid();
- CGImageRef image = (CGImageRef)( bmp.CGImageCreate() );
+ CGImageRef image = (CGImageRef)( bmp.CreateCGImage() );
HIRect r = CGRectMake( x , y , w , h );
if ( bmp.GetDepth() == 1 )
{
else
{
((wxMacCoreGraphicsBrushData*)m_brush.GetRefData())->Apply(this);
- HIViewDrawCGImage( m_cgContext , &r , image );
+ wxMacDrawCGImage( m_cgContext , &r , image );
}
}
}
else
{
- HIViewDrawCGImage( m_cgContext , &r , image );
+ wxMacDrawCGImage( m_cgContext , &r , image );
}
CGImageRelease( image );
}
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y )
{
+ if ( m_font.IsNull() )
+ return;
+
+ EnsureIsValid();
+#ifdef wxMAC_USE_CORE_TEXT
+ // TODO core text implementation here
+#elif defined(wxMAC_USE_ATSU_TEXT)
DrawText(str, x, y, 0.0);
+#elif defined(WXMAC_USE_CG_TEXT)
+ // TODO core graphics text implementation here
+#endif
}
void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDouble y, wxDouble angle )
return;
EnsureIsValid();
-
+#ifdef wxMAC_USE_CORE_TEXT
+ // default implementation takes care of rotation and calls non rotated DrawText afterwards
+ wxGraphicsContext::DrawText( str, x, y, angle );
+#elif defined(wxMAC_USE_ATSU_TEXT)
OSStatus status = noErr;
ATSUTextLayout atsuLayout;
UniCharCount chars = str.length();
#if SIZEOF_WCHAR_T == 4
free( ubuf );
#endif
+#elif defined(WXMAC_USE_CG_TEXT)
+ // default implementation takes care of rotation and calls non rotated DrawText afterwards
+ wxGraphicsContext::DrawText( str, x, y, angle );
+#endif
}
void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *width, wxDouble *height,
if (str.empty())
return;
+#ifdef wxMAC_USE_CORE_TEXT
+ // TODO core text implementation here
+#elif defined(wxMAC_USE_ATSU_TEXT)
OSStatus status = noErr;
ATSUTextLayout atsuLayout;
#if SIZEOF_WCHAR_T == 4
free( ubuf ) ;
#endif
+#elif defined(WXMAC_USE_CG_TEXT)
+ // TODO core graphics text implementation here
+#endif
}
void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const
if (text.empty())
return;
+#ifdef wxMAC_USE_CORE_TEXT
+ // TODO core text implementation here
+#elif defined(wxMAC_USE_ATSU_TEXT)
ATSUTextLayout atsuLayout;
UniCharCount chars = text.length();
UniChar* ubuf = NULL;
#if SIZEOF_WCHAR_T == 4
free( ubuf ) ;
#endif
+#elif defined(WXMAC_USE_CG_TEXT)
+ // TODO core graphics text implementation here
+#endif
}
void * wxMacCoreGraphicsContext::GetNativeContext()