• Create Account

### #Actualanders211

Posted 19 December 2012 - 07:17 PM

What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?

OK I updated the first post. I have just written also to microsoft because this task is a bit challange and maybe not solvable.

I am in the middle of implementation my own multiline EditBox control (based on oneline EditBox from CDXUT Utility). I divided my text (which is kept in WCHAR * buffer) into lines (replacing some ' ' into '\n' between breakable words) and now my text fits into the width of EditBox but I have a problem how can I now justify (align) the text. I have to have aligment text in the buffer because only in this way when I click with the aid of mouse on the editBox, the caret will be set at the given char perfectly. I suppose it can be done with some scriptStringMethods but I don't have idea how to use them to cause the effect which I would like.

### #5anders211

Posted 19 December 2012 - 11:24 AM

What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?

OK I updated the first post

### #4anders211

Posted 19 December 2012 - 11:23 AM

What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?

OK I updated the first post

### #3anders211

Posted 19 December 2012 - 11:11 AM

What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?

Generally it is a hard challenge to implement mechanism of dividing text into lines which then fit into the editBox width and then justify the text and then to be able to scroll down/up the text, making selection, putting with the aid of mause the caret which suit perfect. And it is hard for me to believe that there aren't any simple functions. At least in DirectX utility You have CDXUTEditBox which is only one-line. There isn't multiline editbox. That is why I am implementing multiline editBox based on CDXUTEditBox. I know that there is some built-in in WINAPI editBox but I want to have my own class like CDXUTControls (because in this way I can modify background, transparency etc.etc.) As far as my function is concerned this is its the last form:

void Buffer::transformText(i32 width)
{
if(mAnalyseRequired)
if(analyse() != OK)
return;
const SCRIPT_LOGATTR* pLogAttr = ScriptString_pLogAttr(mAnalysis);
if(!pLogAttr)
return;
if(!ScriptString_pcOutChars(mAnalysis))
return;
i32 limit = *ScriptString_pcOutChars(mAnalysis);
//calculate number of words
u32 numWords = 1;
for(i32 i=0; i<limit - 1; ++i) //without '\0'
if(pLogAttr[i].fWordStop &amp;&amp; mBuffer[i] != '\n') //'\n' is also softBreak, charStop and wordStop
++numWords;
vector<i32> znaczniki;
i32 fromBegX = 0;
i32 charNr = 0;
for(i32 i=0; i<limit - 1; ++i)
if((pLogAttr[i].fWhiteSpace &amp;&amp; !pLogAttr[i+1].fWhiteSpace) || mBuffer[i] == '\n')
{
i32 X;
CPtoX(i, FALSE, &amp;X);
if(width >= X-fromBegX)
charNr = i; //remember the last succeed char number
else
{
fromBegX += width;
znaczniki.push_back(charNr); //charNr will be replaced with '\n'
}
}
i32 size = static_cast<i32>(znaczniki.size());
for(i32 i = 0; i<size; ++i)
mBuffer[znaczniki[i]] = '\n';
}


It divide the text very well into editBoxWidth, but the implementation isn't good because when I change the first ' ' into '\n' then all my calculations char positions into X coordinate aren't true. And I have to change the implementation again and again, it is easy for me but it is time consuming (I am implementing all the day the mechanism. But generally the question is HOW IN THE MOST EASIEST WAY divide text into lines which suit to editBox width and then justify text. What is more we use only ID3DXFont::DrawTextW, ScriptStringAnalyse and similar Script functions. We assume that we don't use any SetTextAlign (because we cannot mess both setTextAlign and DrawTextW). Is any simple way or my approach isn't a waste of time because the reality is that there aren't any easy built-in functions to do this?

### #2anders211

Posted 19 December 2012 - 11:11 AM

What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?

Generally it is a hard challenge to implement mechanism of dividing text into lines which then fit into the editBox width and then justify the text and then to be able to scroll down/up the text, making selection, putting with the aid of mause the caret which suit perfect. And it is hard for me to believe that there aren't any simple functions. At least in DirectX utility You have CDXUTEditBox which is only one-line. There isn't multiline editbox. That is why I am implementing multiline editBox based on CDXUTEditBox. I know that there is some built-in in WINAPI editBox but I want to have my own class like CDXUTControls (because in this way I can modify background, transparency etc.etc.) As far as my function is concerned this is its the last form:

void Buffer::transformText(i32 width)
{
if(mAnalyseRequired)
if(analyse() != OK)
return;
const SCRIPT_LOGATTR* pLogAttr = ScriptString_pLogAttr(mAnalysis);
if(!pLogAttr)
return;
if(!ScriptString_pcOutChars(mAnalysis))
return;
i32 limit = *ScriptString_pcOutChars(mAnalysis);
//calculate number of words
u32 numWords = 1;
for(i32 i=0; i<limit - 1; ++i) //without '\0'
if(pLogAttr[i].fWordStop &amp;&amp; mBuffer[i] != '\n') //'\n' is also softBreak, charStop and wordStop
++numWords;
vector<i32> znaczniki;
i32 fromBegX = 0;
i32 charNr = 0;
for(i32 i=0; i<limit - 1; ++i)
if((pLogAttr[i].fWhiteSpace &amp;&amp; !pLogAttr[i+1].fWhiteSpace) || mBuffer[i] == '\n')
{
i32 X;
CPtoX(i, FALSE, &amp;X);
if(width >= X-fromBegX)
charNr = i; //remember the last succeed char number
else
{
fromBegX += width;
znaczniki.push_back(charNr); //charNr will be replaced with '\n'
}
}
i32 size = static_cast<i32>(znaczniki.size());
for(i32 i = 0; i<size; ++i)
mBuffer[znaczniki[i]] = '\n';
}


It divide the text very well into editBoxWidth, but the implementation isn't good because when I change the first ' ' into '\n' then all my calculations char positions into X coordinate aren't true. And I have to change the implementation again and again, it is easy for me but it is time consuming (I am implementing all the day the mechanism. But generally the question is HOW IN THE MOST EASIEST WAY divide text into lines which suit to editBox width and then justify text. What is more we use only ID3DXFont::DrawTextW, ScriptStringAnalyse and similar Script functions. We assume that we don't use any SetTextAlign (because we cannot mess both setTextAlign and DrawTextW). Is any simple way or my approach isn't a waste of time because the reality is that there aren't any easy built-in functions to do this?

### #1anders211

Posted 19 December 2012 - 11:10 AM

What do you mean by it doesn't work? Do you a compile error? A runtime error? Does it not do what you want it to do? If so, what do you want it to do?

Generally it is a hard challenge to implement mechanism of dividing text into lines which then fit into the editBox width and then justify the text. And it is hard for me to believe that there aren't any simple functions. At least in DirectX utility You have CDXUTEditBox which is only one-line. There isn't multiline editbox. That is why I am implementing multiline editBox based on CDXUTEditBox. I know that there is some built-in in WINAPI editBox but I want to have my own class like CDXUTControls (because in this way I can modify background, transparency etc.etc.) As far as my function is concerned this is its the last form:

void Buffer::transformText(i32 width)
{
if(mAnalyseRequired)
if(analyse() != OK)
return;
const SCRIPT_LOGATTR* pLogAttr = ScriptString_pLogAttr(mAnalysis);
if(!pLogAttr)
return;
if(!ScriptString_pcOutChars(mAnalysis))
return;
i32 limit = *ScriptString_pcOutChars(mAnalysis);
//calculate number of words
u32 numWords = 1;
for(i32 i=0; i<limit - 1; ++i) //without '\0'
if(pLogAttr[i].fWordStop && mBuffer[i] != '\n') //'\n' is also softBreak, charStop and wordStop
++numWords;
vector<i32> znaczniki;
i32 fromBegX = 0;
i32 charNr = 0;
for(i32 i=0; i<limit - 1; ++i)
if((pLogAttr[i].fWhiteSpace && !pLogAttr[i+1].fWhiteSpace) || mBuffer[i] == '\n')
{
i32 X;
CPtoX(i, FALSE, &X);
if(width >= X-fromBegX)
charNr = i; //remember the last succeed char number
else
{
fromBegX += width;
znaczniki.push_back(charNr); //charNr will be replaced with '\n'
}
}
i32 size = static_cast<i32>(znaczniki.size());
for(i32 i = 0; i<size; ++i)
mBuffer[znaczniki[i]] = '\n';
}


It divide the text very well into editBoxWidth, but the implementation isn't good because when I change the first ' ' into '\n' then all my calculations char positions into X coordinate aren't true. And I have to change the implementation again and again, it is easy for me but it is time consuming (I am implementing all the day the mechanism. But generally the question is HOW IN THE MOST EASIEST WAY divide text into lines which suit to editBox width and then justify text. What is more we use only ID3DXFont::DrawTextW, ScriptStringAnalyse and similar Script functions. We assume that we don't use any SetTextAlign (because we cannot mess both setTextAlign and DrawTextW). Is any simple way or my approach isn't a waste of time because the reality is that there aren't any easy built-in functions to do this?

PARTNERS