- status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
- &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
-
- wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
-
- status = ::ATSUSetTransientFontMatching( atsuLayout , true ) ;
- wxASSERT_MSG( status == noErr , wxT("couldn't setup transient font matching") );
-
- int iAngle = int( angle );
- if ( abs(iAngle) > 0 )
- {
- Fixed atsuAngle = IntToFixed( iAngle ) ;
- ATSUAttributeTag atsuTags[] =
- {
- kATSULineRotationTag ,
- } ;
- ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- sizeof( Fixed ) ,
- } ;
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- &atsuAngle ,
- } ;
- status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag),
- atsuTags, atsuSizes, atsuValues ) ;
- }
- {
- CGContextRef cgContext = ((wxMacCGContext*)(m_graphicContext))->GetNativeContext() ;
- ATSUAttributeTag atsuTags[] =
- {
- kATSUCGContextTag ,
- } ;
- ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- sizeof( CGContextRef ) ,
- } ;
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
- {
- &cgContext ,
- } ;
- status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags)/sizeof(ATSUAttributeTag),
- atsuTags, atsuSizes, atsuValues ) ;
- }
-
- ATSUTextMeasurement textBefore ;
- ATSUTextMeasurement textAfter ;
- ATSUTextMeasurement ascent ;
- ATSUTextMeasurement descent ;
-
- status = ::ATSUGetUnjustifiedBounds( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- &textBefore , &textAfter, &ascent , &descent );
- wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
-
- Rect rect ;
-
- if ( m_backgroundMode == wxSOLID )
- {
- wxGraphicPath* path = m_graphicContext->CreatePath() ;
- path->MoveToPoint(
- drawX ,
- drawY ) ;
- path->AddLineToPoint(
- (int) (drawX + sin(angle/RAD2DEG) * FixedToInt(ascent + descent)) ,
- (int) (drawY + cos(angle/RAD2DEG) * FixedToInt(ascent + descent)) ) ;
- path->AddLineToPoint(
- (int) (drawX + sin(angle/RAD2DEG) * FixedToInt(ascent + descent ) + cos(angle/RAD2DEG) * FixedToInt(textAfter)) ,
- (int) (drawY + cos(angle/RAD2DEG) * FixedToInt(ascent + descent) - sin(angle/RAD2DEG) * FixedToInt(textAfter)) ) ;
- path->AddLineToPoint(
- (int) (drawX + cos(angle/RAD2DEG) * FixedToInt(textAfter)) ,
- (int) (drawY - sin(angle/RAD2DEG) * FixedToInt(textAfter)) ) ;
-
- m_graphicContext->FillPath( path , m_textBackgroundColour ) ;
- delete path ;
- }
-
- drawX += (int)(sin(angle/RAD2DEG) * FixedToInt(ascent));
- drawY += (int)(cos(angle/RAD2DEG) * FixedToInt(ascent));
-
- status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- IntToFixed(drawX) , IntToFixed(drawY) , &rect );
- wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
-
- CGContextSaveGState(((wxMacCGContext*)(m_graphicContext))->GetNativeContext());
- CGContextTranslateCTM(((wxMacCGContext*)(m_graphicContext))->GetNativeContext(), drawX, drawY);
- CGContextScaleCTM(((wxMacCGContext*)(m_graphicContext))->GetNativeContext(), 1, -1);
- status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
- IntToFixed(0) , IntToFixed(0) );
- wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") );
- CGContextRestoreGState( ((wxMacCGContext*)(m_graphicContext))->GetNativeContext() ) ;
-
- CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) );
- CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) );
-
- ::ATSUDisposeTextLayout(atsuLayout);
-#if SIZEOF_WCHAR_T == 4
- free( ubuf ) ;
-#endif