Code: Select all
/*static*/ int QuestGUINode::setHeight(CEGUI::Window* window)
{
COUT(1) << "PixelRect: " << window->getPixelRect().getHeight() << "x" << window->getPixelRect().getWidth() << std::endl; //Debug
COUT(1) << "FontHeight: " << window->getFont()->getFontHeight() << ", LineSpacing:" << window->getFont()->getLineSpacing() << std::endl; //Debug
int width = window->getPixelRect().getWidth();
COUT(1) << "Width: " << width << std::endl; //Debug
int lines = window->getFont()->getFormattedLineCount(window->getText(), window->getPixelRect(), CEGUI::WordWrapLeftAligned);
COUT(1) << "Lines: " << lines << std::endl; //Debug
int height = lines*(window->getFont()->getLineSpacing()+window->getFont()->getFontHeight());
window->setSize(CEGUI::UVector2(CEGUI::UDim(0, width),CEGUI::UDim(0, height)));
return height;
}
The problems I encounter are:
1)
The width getPixelRect() gives me is incorrect.
If, for example, I insert a window with the following properties:
Code: Select all
window->setProperty("HorzFormatting", "WordWrapLeftAligned");
window->setProperty("VertFormatting", "TopAligned");
window->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0),CEGUI::UDim(0, offset)));
window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(1.0, 0)));
,the text already set and the window already attached to another window (with addChildWindow())
And I then do the following:
Code: Select all
int height = QuestGUINode::setHeight(window);
window->setSize(CEGUI::UVector2(CEGUI::UDim(1.0, -13),CEGUI::UDim(0, height)));
It doesn't yield the same result as just doing:
Code: Select all
int height = QuestGUINode::setHeight(window);
Which brings me to the conclusion, that the width I get with gePixelRect().getWidth() is somehow not the width of my window.
2)
getFormattedLineCount() doesn't seem to work properly. Because, the number of lines I get isn't the same I count from the displayed window, which seems odd to me.
3)
getLineSpacing() and getFontHeight() seem to be off, because in my test, I get the following numbers:
FontHeight: 18.0263, LineSpacing:18.4155
Whereas, manually (through PrintScreen) the Font Height is more like 12 pixels.
These are just too many inconsistencies to all be bugs, so where did I go wrong?
If you need more information, please don't hesitate to ask.
I'd greatly appreciate your help.