Page 1 of 1

Question using getFormattedLineCount(...) function

Posted: Tue Sep 20, 2005 03:16
by kungfoomasta
For some reason, the getFormattedLineCount function always returns 1. I'm not sure if I'm using it correctly, or what the problem is. This is my implementation and use of the function:


font = CEGUI::FontManager::getSingleton().createFont( "datafiles/fonts/Celtic-10.font" );
font->defineFontGlyphs(" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~æøåÆØÅ" );

// storyBoard1
storyBoard1 = (CEGUI::FrameWindow*)wm->createWindow("TaharezLook/FrameWindow","storyBoard1");
sheet->addChildWindow(storyBoard1);
storyBoard1->setSize(CEGUI::Size( 0.1,0.1 ));
storyBoard1->setPosition(CEGUI::Point( 0.2,0.7 ));
storyBoard1->setTitleBarEnabled(true);
storyBoard1->setSizingEnabled(false);
storyBoard1->setDragMovingEnabled(false);
storyBoard1->setCloseButtonEnabled(false);
storyBoard1->setVisible(true);
storyBoard1->setMouseCursor("WindowsLook", "MouseArrow");

// setup first storyboard
storyBoard1Text = (CEGUI::StaticText*)wm->createWindow("TaharezLook/StaticText","storyBoard1Text");
storyBoard1->addChildWindow(storyBoard1Text);
storyBoard1Text->setSize( CEGUI::Size( 0.95, 0.9 ) );
storyBoard1Text->setPosition( CEGUI::Point( 0.025, 0.05 ) );
storyBoard1Text->setHorizontalFormatting(CEGUI::StaticText::HorzFormatting::WordWrapLeftAligned);
storyBoard1Text->setText("storyBoard1Text");
storyBoard1Text->setVisible(true);
storyBoard1Text->setMouseCursor("WindowsLook", "MouseArrow");

CEGUI::uint x = font->getFormattedLineCount(currentText1,storyBoard1Text->getRect(),CEGUI::TextFormatting::LeftAligned);


currentText1 is:

Man, it sure is hot today! If it wasn't for those pesky headhunters, I'd go lay in the forest!

(sorry for my cheesy text, lol)

Re: Question using getFormattedLineCount(...) function

Posted: Tue Sep 20, 2005 07:08
by kungfoomasta
I looked at the code for the function, and found the solution. When I call the function, I use "CEGUI::TextFormatting::LeftAligned". Appearance wise, the sentence is wrapped and tries to stay inside the box. However, the implementation doesn't treat the textFormat as if it's wrapped. If I substitute "CEGUI::TextFormatting::WordWrapLeftAligned" in as the last parameter the function returns 12, which is probably likely since I made a tiny area for the sentence to fit in. So for anybody else using this awesome function (really helpful for me!), make sure the textformatting has the words "WordWrap" in it, otherwise you'll always get 1.

Re: Question using getFormattedLineCount(...) function

Posted: Wed Sep 21, 2005 10:20
by CrazyEddie
Yes, which makes perfect sense; without the word wrapping formatting option, LeftAligned places the text on a single line aligned with the left edge of the formatting area - exactly as described in the API reference.