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);
}
}
}