版权申明:http://yarin.iteye.com/blog/453262
本来是个很简单的问题,既然有人问,就写在这里吧!
代码:
//在指定矩形中输出文字
void DrawTextInRect( IDisplay *m_pIDisplay,
AEEFont font,
RGBVAL r gb,
AECHAR *pText,
const AEERect *pRect )
{
if( !pText )
{
return;
}
RGBVAL rgb_old = IDISPLAY_SetColor( m_pIDisplay, CLR_USER_TEXT, rgb );
int8 text_height;
AECHAR *text_pos = pText;
text_height= IDISPLAY_GetFontMetrics( m_pIDisplay, font, NULL, NULL ) + LINEBLANK;
int16 pos_y;
for( pos_y = pRect->y; pos_y <= pRect->y + pRect->dy - text_height; pos_y = pos_y + text_height )
{
int draw_num;
IDISPLAY_MeasureTextEx( m_pIDisplay, font, text_pos, -1,pRect->dx, &draw_num );
IDISPLAY_DrawText( m_pIDisplay, font, text_pos, draw_num,pRect->x, pos_y, NULL, IDF_TEXT_TRANSPARENT );
text_pos += draw_num;
if( *text_pos == NULL )
{
IDISPLAY_SetColor( m_pIDisplay, CLR_USER_TEXT, rgb_old );
return;
}
}
IDISPLAY_SetColor( m_pIDisplay, CLR_USER_TEXT, rgb_old );
}