论坛首页 综合技术论坛

Brew教程之Brew中文字自动换行

浏览 2044 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2009-06-21   最后修改:2009-08-20

版权申明: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 );
} 

 

论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics