#endif
#if wxOSX_USE_COCOA_OR_IPHONE
-extern CGContextRef wxOSXGetContextFromCurrentNSContext() ;
+extern CGContextRef wxOSXGetContextFromCurrentContext() ;
+#if wxOSX_USE_COCOA
extern bool wxOSXLockFocus( WXWidget view) ;
extern void wxOSXUnlockFocus( WXWidget view) ;
#endif
+#endif
#if 1 // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
kCGCompositeOperationDestinationAtop = 9,
kCGCompositeOperationXOR = 10,
kCGCompositeOperationPlusDarker = 11,
-// NS only, unsupported by CG : Highlight
+// NS only, unsupported by CG : Highlight
kCGCompositeOperationPlusLighter = 12
} CGCompositeOperation ;
CTFontRef wxMacCreateCTFont( const wxFont& font )
{
#ifdef __WXMAC__
- return wxCFRetain((CTFontRef) font.MacGetCTFont());
+ return wxCFRetain((CTFontRef) font.OSXGetCTFont());
#else
return CTFontCreateWithName( wxCFStringRef( font.GetFaceName(), wxLocale::GetSystemEncoding() ) , font.GetPointSize() , NULL );
#endif
virtual ATSUStyle GetATSUStyle() { return m_macATSUIStyle; }
#endif
#if wxOSX_USE_CORE_TEXT
- CTFontRef GetCTFont() const { return m_ctFont ; }
+ CTFontRef OSXGetCTFont() const { return m_ctFont ; }
#endif
wxColour GetColour() const { return m_colour ; }
// we need the scale here ...
- Fixed atsuSize = IntToFixed( int( 1 * font.MacGetFontSize()) );
+ Fixed atsuSize = IntToFixed( int( 1 * font.GetPointSize()) );
RGBColor atsuColor ;
col.GetRGBColor( &atsuColor );
ATSUAttributeTag atsuTags[] =
kATSUSizeTag ,
kATSUColorTag ,
};
- ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ByteCount atsuSizes[WXSIZEOF(atsuTags)] =
{
sizeof( Fixed ) ,
sizeof( RGBColor ) ,
};
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] =
{
&atsuSize ,
&atsuColor ,
};
status = ::ATSUSetAttributes(
- m_macATSUIStyle, sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
+ m_macATSUIStyle, WXSIZEOF(atsuTags),
atsuTags, atsuSizes, atsuValues);
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
virtual void BeginLayer(wxDouble opacity);
virtual void EndLayer();
-
+
//
// transformation
//
#if wxOSX_USE_COCOA_OR_IPHONE
m_view = window->GetHandle();
- if ( !((wxWidgetCocoaImpl*) window->GetPeer())->IsFlipped() )
+#if wxOSX_USE_COCOA
+ if ( ! window->GetPeer()->IsFlipped() )
{
m_windowTransform = CGAffineTransformMakeTranslation( 0 , m_height );
m_windowTransform = CGAffineTransformScale( m_windowTransform , 1 , -1 );
}
else
+#endif
{
m_windowTransform = CGAffineTransformIdentity;
}
{
if (m_invisible)
return false;
-
-#if wxOSX_USE_COCOA_OR_IPHONE
+
+#if wxOSX_USE_COCOA
if ( wxOSXLockFocus(m_view) )
{
- m_cgContext = wxOSXGetContextFromCurrentNSContext();
- wxASSERT_MSG( m_cgContext != NULL, _T("Unable to retrieve drawing context from View"));
+ m_cgContext = wxOSXGetContextFromCurrentContext();
+ wxASSERT_MSG( m_cgContext != NULL, wxT("Unable to retrieve drawing context from View"));
}
else
{
m_invisible = true;
}
#endif
+#if wxOSX_USE_IPHONE
+ m_cgContext = wxOSXGetContextFromCurrentContext();
+ if ( m_cgContext == NULL )
+ {
+ m_invisible = true;
+ }
+#endif
#if wxOSX_USE_CARBON
OSStatus status = QDBeginCGContext( GetWindowPort( m_windowRef ) , &m_cgContext );
if ( status != noErr )
CGContextConcatCTM( m_cgContext, m_windowTransform );
CGContextSaveGState( m_cgContext );
m_contextSynthesized = true;
+#if wxOSX_USE_COCOA_OR_CARBON
if ( m_clipRgn.get() )
{
// the clip region is in device coordinates, so we convert this again to user coordinates
CGContextClip( m_cgContext );
}
}
+#endif
CGContextSaveGState( m_cgContext );
-
+
#if 0 // turn on for debugging of clientdc
static float color = 0.5 ;
static int channel = 0 ;
if (m_antialias == antialias)
return true;
-
+
m_antialias = antialias;
-
+
bool antialiasMode;
switch (antialias)
{
if ( m_composition == op )
return true;
-
+
m_composition = op;
-
+
if (m_composition == wxCOMPOSITION_DEST)
return true;
-
+
#if wxOSX_USE_COCOA_OR_CARBON
-#if 1 // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
if ( UMAGetSystemVersion() < 0x1060 )
{
CGCompositeOperation cop = kCGCompositeOperationSourceOver;
switch( op )
{
case wxCOMPOSITION_CLEAR:
- cop = kCGCompositeOperationClear;
+ cop = kCGCompositeOperationClear;
break;
case wxCOMPOSITION_SOURCE:
- cop = kCGCompositeOperationCopy;
+ cop = kCGCompositeOperationCopy;
break;
case wxCOMPOSITION_OVER:
- mode = kCGBlendModeNormal;
+ mode = kCGBlendModeNormal;
break;
case wxCOMPOSITION_IN:
- cop = kCGCompositeOperationSourceIn;
+ cop = kCGCompositeOperationSourceIn;
break;
case wxCOMPOSITION_OUT:
- cop = kCGCompositeOperationSourceOut;
+ cop = kCGCompositeOperationSourceOut;
break;
case wxCOMPOSITION_ATOP:
- cop = kCGCompositeOperationSourceAtop;
+ cop = kCGCompositeOperationSourceAtop;
break;
case wxCOMPOSITION_DEST_OVER:
- cop = kCGCompositeOperationDestinationOver;
+ cop = kCGCompositeOperationDestinationOver;
break;
case wxCOMPOSITION_DEST_IN:
- cop = kCGCompositeOperationDestinationIn;
+ cop = kCGCompositeOperationDestinationIn;
break;
case wxCOMPOSITION_DEST_OUT:
- cop = kCGCompositeOperationDestinationOut;
+ cop = kCGCompositeOperationDestinationOut;
break;
case wxCOMPOSITION_DEST_ATOP:
- cop = kCGCompositeOperationDestinationAtop;
+ cop = kCGCompositeOperationDestinationAtop;
break;
case wxCOMPOSITION_XOR:
- cop = kCGCompositeOperationXOR;
+ cop = kCGCompositeOperationXOR;
break;
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
case wxCOMPOSITION_ADD:
mode = kCGBlendModePlusLighter ;
break;
+#endif
default:
return false;
}
else
CGContextSetBlendMode(m_cgContext, mode);
}
- else
-#endif
#endif
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
+ else
{
CGBlendMode mode = kCGBlendModeNormal;
switch( op )
{
case wxCOMPOSITION_CLEAR:
- mode = kCGBlendModeClear;
+ mode = kCGBlendModeClear;
break;
case wxCOMPOSITION_SOURCE:
- mode = kCGBlendModeCopy;
+ mode = kCGBlendModeCopy;
break;
case wxCOMPOSITION_OVER:
- mode = kCGBlendModeNormal;
+ mode = kCGBlendModeNormal;
break;
case wxCOMPOSITION_IN:
- mode = kCGBlendModeSourceIn;
+ mode = kCGBlendModeSourceIn;
break;
case wxCOMPOSITION_OUT:
- mode = kCGBlendModeSourceOut;
+ mode = kCGBlendModeSourceOut;
break;
case wxCOMPOSITION_ATOP:
- mode = kCGBlendModeSourceAtop;
+ mode = kCGBlendModeSourceAtop;
break;
case wxCOMPOSITION_DEST_OVER:
- mode = kCGBlendModeDestinationOver;
+ mode = kCGBlendModeDestinationOver;
break;
case wxCOMPOSITION_DEST_IN:
- mode = kCGBlendModeDestinationIn;
+ mode = kCGBlendModeDestinationIn;
break;
case wxCOMPOSITION_DEST_OUT:
- mode = kCGBlendModeDestinationOut;
+ mode = kCGBlendModeDestinationOut;
break;
case wxCOMPOSITION_DEST_ATOP:
- mode = kCGBlendModeDestinationAtop;
+ mode = kCGBlendModeDestinationAtop;
break;
case wxCOMPOSITION_XOR:
- mode = kCGBlendModeXOR;
+ mode = kCGBlendModeXOR;
break;
-
+
case wxCOMPOSITION_ADD:
mode = kCGBlendModePlusLighter ;
break;
}
CGContextSetBlendMode(m_cgContext, mode);
}
+#endif
return true;
}
void wxMacCoreGraphicsContext::BeginLayer(wxDouble opacity)
{
CGContextSaveGState(m_cgContext);
- CGContextSetAlpha(m_cgContext, opacity);
+ CGContextSetAlpha(m_cgContext, (CGFloat) opacity);
CGContextBeginTransparencyLayer(m_cgContext, 0);
}
if (EnsureIsValid()==false)
return;
-
+
if (m_composition == wxCOMPOSITION_DEST)
return;
{
if (EnsureIsValid()==false)
return;
-
+
if (m_composition == wxCOMPOSITION_DEST)
return;
if (EnsureIsValid()==false)
return;
-
+
if (m_composition == wxCOMPOSITION_DEST)
return;
CGContextRestoreGState( m_cgContext );
if ( m_contextSynthesized )
{
- // TODO: in case of performance problems, try issuing this not too
+ // TODO: in case of performance problems, try issuing this not too
// frequently (half of refresh rate)
CGContextFlush(m_cgContext);
#if wxOSX_USE_CARBON
QDEndCGContext( GetWindowPort( m_windowRef ) , &m_cgContext);
#endif
-#if wxOSX_USE_COCOA_OR_IPHONE
+#if wxOSX_USE_COCOA
wxOSXUnlockFocus(m_view);
#endif
}
if (m_composition == wxCOMPOSITION_DEST)
return;
-
+
#ifdef __WXMAC__
wxMacCoreGraphicsBitmapData* refdata =static_cast<wxMacCoreGraphicsBitmapData*>(bmp.GetRefData());
CGImageRef image = refdata->GetBitmap();
{
if (EnsureIsValid()==false)
return;
-
+
if (m_composition == wxCOMPOSITION_DEST)
return;
{
if (EnsureIsValid()==false)
return;
-
+
CGContextSaveGState( m_cgContext );
}
{
if (EnsureIsValid()==false)
return;
-
+
CGContextRestoreGState( m_cgContext );
}
if (EnsureIsValid()==false)
return;
-
+
if (m_composition == wxCOMPOSITION_DEST)
return;
{
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
wxCFStringRef text(str, wxLocale::GetSystemEncoding() );
- CTFontRef font = fref->GetCTFont();
+ CTFontRef font = fref->OSXGetCTFont();
CGColorRef col = wxMacCreateCGColor( fref->GetColour() );
CTUnderlineStyle ustyle = fref->GetUnderlined() ? kCTUnderlineStyleSingle : kCTUnderlineStyleNone ;
wxCFRef<CFNumberRef> underlined( CFNumberCreate(NULL, kCFNumberSInt32Type, &ustyle) );
y += CTFontGetAscent(font);
CGContextSaveGState(m_cgContext);
- CGContextTranslateCTM(m_cgContext, x, y);
+ CGContextTranslateCTM(m_cgContext, (CGFloat) x, (CGFloat) y);
CGContextScaleCTM(m_cgContext, 1, -1);
CGContextSetTextPosition(m_cgContext, 0, 0);
CTLineDraw( line, m_cgContext );
if (EnsureIsValid()==false)
return;
-
+
if (m_composition == wxCOMPOSITION_DEST)
return;
{
kATSULineRotationTag ,
};
- ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ByteCount atsuSizes[WXSIZEOF(atsuTags)] =
{
sizeof( Fixed ) ,
};
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] =
{
&atsuAngle ,
};
- status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag),
+ status = ::ATSUSetLayoutControls(atsuLayout , WXSIZEOF(atsuTags),
atsuTags, atsuSizes, atsuValues );
}
{
kATSUCGContextTag ,
};
- ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ByteCount atsuSizes[WXSIZEOF(atsuTags)] =
{
sizeof( CGContextRef ) ,
};
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] =
{
&m_cgContext ,
};
- status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag),
+ status = ::ATSUSetLayoutControls(atsuLayout , WXSIZEOF(atsuTags),
atsuTags, atsuSizes, atsuValues );
}
if ( UMAGetSystemVersion() >= 0x1050 )
{
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
- CTFontRef font = fref->GetCTFont();
+ CTFontRef font = fref->OSXGetCTFont();
wxCFStringRef text(str, wxLocale::GetSystemEncoding() );
CFStringRef keys[] = { kCTFontAttributeName };
wxCFRef<CFAttributedStringRef> attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, attributes) );
wxCFRef<CTLineRef> line( CTLineCreateWithAttributedString(attrtext) );
- CGFloat w, a, d, l;
+ double w;
+ CGFloat a, d, l;
w = CTLineGetTypographicBounds(line, &a, &d, &l) ;
#if wxOSX_USE_CORE_TEXT
{
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
- CTFontRef font = fref->GetCTFont();
+ CTFontRef font = fref->OSXGetCTFont();
wxCFStringRef t(text, wxLocale::GetSystemEncoding() );
CFStringRef keys[] = { kCTFontAttributeName };
#if wxOSX_USE_CARBON
return new wxMacCoreGraphicsContext(this,(WindowRef)window);
#else
+ wxUnusedVar(window);
return NULL;
#endif
}