thank you,and i'll try to compile the source code and try it tonight.
btw:
i rewrite the guitextbox.cpp.and make it support doublebyte language,the code is shown in the following:
new:
void cguitextbox:
ettext(const wstring &strtext)
{
m_vecitems.erase(m_vecitems.begin(), m_vecitems.end());
// start wordwrapping
// set a flag so we can determine initial justification effects
bool bstartingnewline = true;
bool bbreakatspace = false;
int pos = 0;
int itextsize = (int)strtext.size();
int lpos = 0;
char szline[1024];
int itotallines = 0;
int idoublebyte = 0;////////////// add
while (pos < itextsize)
{
// get the current letter in the string
char letter = (char)strtext[pos];
// break if we get more pages then maxpages
if (((itotallines + 1) / m_iitemsperpage) > (m_imaxpages - 1)) break;
// handle the newline character
if (letter == '\n' )
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
lpos = 0;
szline[0] = 0; // reset in case of 2 line breaks in a row (don't want to add szline twice)
}
else
{
if ((lpos < 0) || (lpos > 1023 && letter<0x80) || (lpos > 1022 && letter>0x7f))
{
outputdebugstring("cguitextbox:
ettext -> errror\n");
}
szline[lpos] = letter;
if ((letter>0x7f) &&( pos < itextsize-1 ))
{
idoublebyte=1;
szline[lpos + 1] = (char)strtext[pos+1];
szline[lpos + 2] = 0;
}
else
{
idoublebyte=0;
szline[lpos + 1] = 0;
}
float fwidth, fheight;
cstdstringw strtextunicode;
g_charsetconverter.stringcharsettofontcharset(szline, strtextunicode);
if (m_pfont)
m_pfont->gettextextent( strtextunicode.c_str(), &fwidth, &fheight);
if (fwidth > m_dwwidth)
{
idoublebyte=-1;
szline[lpos]=0;
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
lpos = 0;
}
else
{
lpos = lpos +idoublebyte+1;
}
}
pos = pos +idoublebyte+1;
}
if (lpos > 0)
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
}
int ipages = m_vecitems.size() / m_iitemsperpage;
if (m_vecitems.size() % m_iitemsperpage) ipages++;
m_updown.setrange(1, ipages);
m_updown.setvalue(1);
}
old:
void cguitextbox:
ettext(const wstring &strtext)
{
m_vecitems.erase(m_vecitems.begin(), m_vecitems.end());
// start wordwrapping
// set a flag so we can determine initial justification effects
bool bstartingnewline = true;
bool bbreakatspace = false;
int pos = 0;
int itextsize = (int)strtext.size();
int lpos = 0;
int ilastspace = -1;
int ilastspaceinline = -1;
char szline[1024];
wchar wstmp[1024];
int itotallines = 0;
while (pos < itextsize)
{
// get the current letter in the string
char letter = (char)strtext[pos];
// break if we get more pages then maxpages
if (((itotallines + 1) / m_iitemsperpage) > (m_imaxpages - 1)) break;
// handle the newline character
if (letter == '\n' )
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
ilastspace = -1;
ilastspaceinline = -1;
lpos = 0;
szline[0] = 0; // reset in case of 2 line breaks in a row (don't want to add szline twice)
}
else
{
if (letter == ' ')
{
ilastspace = pos;
ilastspaceinline = lpos;
}
if (lpos < 0 || lpos > 1023)
{
outputdebugstring("cguitextbox:
ettext -> errror\n");
}
szline[lpos] = letter;
szline[lpos + 1] = 0;
float fwidth, fheight;
swprintf(wstmp, l"%s", szline);
if (m_pfont)
m_pfont->gettextextent(wstmp, &fwidth, &fheight);
if (fwidth > m_dwwidth)
{
if (ilastspace > 0 && ilastspaceinline != lpos)
{
szline[ilastspaceinline] = 0;
pos = ilastspace;
}
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
ilastspaceinline = -1;
ilastspace = -1;
lpos = 0;
}
else
{
lpos++;
}
}
pos++;
}
if (lpos > 0)
{
cguilistitem item(szline);
m_vecitems.push_back(item);
itotallines++;
}
int ipages = m_vecitems.size() / m_iitemsperpage;
if (m_vecitems.size() % m_iitemsperpage) ipages++;
m_updown.setrange(1, ipages);
m_updown.setvalue(1);
}