在区域内绘制宽字符串多行自动换行的c语言实现方法
来源:互联网 发布:网络用语2017最新骂人 编辑:程序博客网 时间:2024/05/05 19:26
static WCHAR wm_drawstringDeco[40][40];
static int wm_totallines;
//用来计算行数的
static WCHAR mydrawstring[1200];
static WCHAR wtmpstring[1200];
static WCHAR strdec[40][40];
static int count_oneline_word_num(WCHAR * string,int countperline,int clipw,unsigned char * bover)
{
int i,w;
WCHAR str[80];
int len = countperline;
memset(str,NULL,20);
wstrncpy(str,string,len);
* bover = FALSE;
for (i = 0;i < 20;i ++)
{
if ((w = vm_graphic_get_string_width(str)) <= clipw)
{
memset(str,NULL,20);
wstrncpy(str,string,len + i);
if(* (string + len + i - 1) == NULL)
{
* bover = TRUE;
return countperline + i - 1;
}
}
else
{
return countperline + i - 1 - 1;
}
}
return len;
}
static void DecodeWstring(WCHAR * string,int clipw)
{
char str[40];
WCHAR wtmpstringtemp[1200] = {0};
WCHAR * wtmpstring1p = wtmpstringtemp;
int w = 0;
int onerow_wordnum = 0;
int strLen = 0;
int countperline = 0,totallines = 0,i = 0,j = 0;
unsigned char bover = FALSE;
WCHAR * ret;
for (i = 0; i < 40; i++)
for (j = 0; j < 40; j++)
wm_drawstringDeco[i][j] = 0;
strLen = wstrlen((wchar_t *)string);
wm_totallines = 0;
wstrcpy(wtmpstringtemp,string);
wstrcpy(wm_drawstring,wtmpstringtemp);
ret = my_ucs2_string("围");
w = vm_graphic_get_string_width (ret);
countperline = clipw / w;
totallines = vm_graphic_get_string_width(wtmpstringtemp) / clipw + ((vm_graphic_get_string_width(wtmpstring) % clipw > 0)?1:0);
/*临时总行数多加1*/
totallines += 1;
for(i = 0; i < totallines; i ++)
{
wm_totallines ++;
if(strLen > countperline)
{
onerow_wordnum = count_oneline_word_num(wtmpstring1p,countperline,clipw,&bover);
wstrncpy(wm_drawstringDeco[i],wtmpstring1p,onerow_wordnum);
vm_ucs2_to_gb2312(str,40,wm_drawstringDeco[i]);
vm_ucs2_to_gb2312(str,40,wtmpstring1p);
wm_drawstringDeco[i][onerow_wordnum] = '\0';
wtmpstring1p += onerow_wordnum;
strLen -= onerow_wordnum;
if(bover)
{
break;
}
}
else
{
wstrncpy(wm_drawstringDeco[i],wtmpstring1p,strLen);
wm_drawstringDeco[i][strLen] = '\0';
break;
}
}
}
void drawWstring(WCHAR * string,int x, int y)
{
int w = 0,strLen = 0;
w = vm_graphic_get_string_width(string);
strLen = wstrlen((wchar_t *)string)*2;
vm_graphic_drawtext(x,y,string,strLen,VRE_COLOR(0xffffff));
}
void drawWstringEx(WCHAR * string,int x, int y, int clipx, int clipy, int clipw, int cliph)
{
int i;
int h;
h = vm_graphic_get_character_height();
h = h+LINEDISTANCE;
if(wstrcmp(wm_drawstring,string) != 0)
{
DecodeWstring(string,clipw);
}
for(i = 0; i < wm_totallines; i ++)
{
if( y + i * h >= clipy && y + i * h <= clipy + cliph - h)
{
drawWstring(wm_drawstringDeco[i],x,y + i * h);
}
}
}
- 在区域内绘制宽字符串多行自动换行的c语言实现方法
- 绘制在某个矩形区域内字符串自动多行换行的一个方法(c)语言实现
- 在指定区域内输出具备自动换行的文本
- c#(mobile) 绘制文字自动换行的实现
- c#(mobile) 绘制文字自动换行的实现
- Android绘制字符串自动换行
- 使文本区域内自动换行
- j2me在Canvas上绘制大量文本自动换行的实现
- iOS7.0 UILabel 字符串的绘制和自动换行
- css 不换行 自动换行 强制换行的实现方法
- 一种将图片绘制在一个圆形区域内的简单方法——CGContextClip
- C语言字符串相关方法的实现
- 在指定区域内绘制文本
- 在C语言中换行的 行 读什么啊
- 【C语言】如何实现多行字符串的输入 并 将文本打印在屏幕上?
- C# 在字符串中添加“\r”换行符 实现lable自动换行
- 实现C语言自动释放资源的方法与探讨
- html5-canvas的绘制文本自动换行
- 改进后的计算CPU的使用率实现
- Convert Sorted Array(List) to Binary Search Tree
- 苹果推送通知流程
- 如何在Qt Creator 创建一个.pri文件
- Android Camera Parameters 获取
- 在区域内绘制宽字符串多行自动换行的c语言实现方法
- 相机标定--知识点整理1
- 倒水
- jQuery select下拉基本属性
- msp430头文件中 DEFC DEFW 及周边的解释【转】
- 电商的“小猫腻”层出不穷
- TwoLibs——mk
- 绘制在某个矩形区域内字符串自动多行换行的一个方法(c)语言实现
- gdb 调试被调用的程序