string problem in edit(solved)

haibo19981984

18-06-2010 08:19:35


<Widget type="Edit" skin="WordWrap" position="5 10 200 540" layer="Back" name="myInfo">
<Property key="Edit_MultiLine" value="true"/>
<Property key="Edit_Static" value="true"/>
<Property key="Edit_WordWrap" value="true"/>
<Property key="Text_TextColour" value="#d8d5b4"/>
<Property key="Text_FontHeight" value="16"/>
<Property key="Text_Caption" value="WordWrap"/>
</Widget>


MyGUI::EditPtr Info = m_pGUI->findWidget<MyGUI::Edit>("myInfo");
Info->setCaption(L" 三国时的魏国,220年由魏文帝曹\n\
丕始,265年魏元帝曹奂时灭亡,曹\n\
丕之父曹操虽未称帝,但曹操奠定了\n\
曹魏立国的基础,逝后曹丕称帝后追\n\
封他为魏太祖武皇帝。");

the effect is just as image"Edit.jpg".
you see."\" make the next line is empty.But that is not what I want.
I only want the string can show mutlline in code instead of one line.
If one line,you see image"EditOneLine.JPG".

Info->setCaption((L" 三国时的魏国,220年由魏文帝曹\n丕始,265年魏元帝曹奂时灭亡,曹\n丕之父曹操虽未称帝,但曹操奠定了\n曹魏立国的基础,逝后曹丕称帝后追\n封他为魏太祖武皇帝。");

Whether is there a method to deal with "\" so that I can write string by multline in "setCaption()" and it doesn't show the effect that the next line is empty.

Altren

18-06-2010 14:06:32

MyGUI::EditPtr Info = m_pGUI->findWidget<MyGUI::Edit>("myInfo");
Info->setCaption(L" 三国时的魏国,220年由魏文帝曹\n\
丕始,265年魏元帝曹奂时灭亡,曹\n\
丕之父曹操虽未称帝,但曹操奠定了\n\
曹魏立国的基础,逝后曹丕称帝后追\n\
封他为魏太祖武皇帝。");
In this code you also include 16 spaces after each \n, so word wrap moves long word to next line. So you should use next code:
MyGUI::EditPtr Info = m_pGUI->findWidget<MyGUI::Edit>("myInfo");
Info->setCaption(L" 三国时的魏国,220年由魏文帝曹\n"
"丕始,265年魏元帝曹奂时灭亡,曹\n"
"丕之父曹操虽未称帝,但曹操奠定了\n"
"曹魏立国的基础,逝后曹丕称帝后追\n"
"封他为魏太祖武皇帝。");
// or
MyGUI::EditPtr Info = m_pGUI->findWidget<MyGUI::Edit>("myInfo");
Info->setCaption(L" 三国时的魏国,220年由魏文帝曹\n\
丕始,265年魏元帝曹奂时灭亡,曹\n\
丕之父曹操虽未称帝,但曹操奠定了\n\
曹魏立国的基础,逝后曹丕称帝后追\n\
封他为魏太祖武皇帝。");


By the way, If you know exact place where end of line is you also don't need wordwrap - only MultiLine mode.

haibo19981984

19-06-2010 03:05:48

Thanks.