diff -r 8f79fa393479 lib/irrlicht/include/IGUIStaticText.h --- a/lib/irrlicht/include/IGUIStaticText.h Sat Nov 01 05:31:11 2008 +0100 +++ b/lib/irrlicht/include/IGUIStaticText.h Sat Nov 01 06:30:24 2008 +0100 @@ -90,7 +90,21 @@ //! Returns the width of the current text, in the current font /** If the text is broken, this returns the width of the widest line \return The width of the text, or the widest broken line. */ - virtual s32 getTextWidth(void) const = 0; + virtual s32 getTextWidth(void) const = 0; + + //! Set an amount of lines by which the text should be scrolled + //! \param scrolled_lines: Amount of scrolled lines. + virtual void setScrolledTextLines(s32 scrolled_lines) = 0; + + //! get the amount of lines which are scrolled + virtual s32 getScrolledTextLines() const = 0; + + //! Get the number of lines used in the static + //! This counts all lines, not just the visible ones. + virtual u32 getTextLineCount() const = 0; + + //! Return the font which is currently used for this element + virtual IGUIFont* getCurrentFont() = 0; }; diff -r 8f79fa393479 lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp --- a/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp Sat Nov 01 05:31:11 2008 +0100 +++ b/lib/irrlicht/source/Irrlicht/CGUIStaticText.cpp Sat Nov 01 06:30:24 2008 +0100 @@ -23,7 +23,7 @@ bool background) : IGUIStaticText(environment, parent, id, rectangle), Border(border), HAlign(EGUIA_UPPERLEFT), VAlign(EGUIA_UPPERLEFT), - OverrideColorEnabled(false), WordWrap(false), Background(background), + OverrideColorEnabled(false), WordWrap(false), Background(background), ScrolledLines(0), OverrideColor(video::SColor(101,255,255,255)), BGColor(video::SColor(101,210,210,210)), OverrideFont(0), LastBreakFont(0) { @@ -95,11 +95,17 @@ { frameRect.UpperLeftCorner.X = frameRect.LowerRightCorner.X - font->getDimension(Text.c_str()).Width; - } + } + + if ( ScrolledLines ) + { + s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); + frameRect.UpperLeftCorner.Y += ScrolledLines * height; + } font->draw(Text.c_str(), frameRect, OverrideColorEnabled ? OverrideColor : skin->getColor(IsEnabled ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), - HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, &AbsoluteClippingRect); + HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, &AbsoluteClippingRect); } else { @@ -117,7 +123,9 @@ { r.UpperLeftCorner.Y = r.LowerRightCorner.Y - totalHeight; } - + + r.UpperLeftCorner.Y += ScrolledLines * height; + for (u32 i=0; igetDimension(Text.c_str()).Width; } } + +void CGUIStaticText::setScrolledTextLines(s32 scrolled_lines) +{ + ScrolledLines = scrolled_lines; +} + +s32 CGUIStaticText::getScrolledTextLines() const +{ + return ScrolledLines; +} + +u32 CGUIStaticText::getTextLineCount() const +{ + return BrokenText.size(); +} + +IGUIFont* CGUIStaticText::getCurrentFont() +{ + IGUIFont * font = OverrideFont; + if(!OverrideFont) + { + IGUISkin * skin = Environment->getSkin(); + if(skin) + font = skin->getFont(); + } + + return font; +} //! Writes attributes of the element. //! Implement this to expose the attributes of your element for @@ -425,7 +462,8 @@ out->addBool ("Border", Border); out->addBool ("OverrideColorEnabled",OverrideColorEnabled); out->addBool ("WordWrap", WordWrap); - out->addBool ("Background", Background); + out->addBool ("Background", Background); + out->addInt ("ScrolledLines", ScrolledLines); out->addColor ("OverrideColor", OverrideColor); out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames); out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames); @@ -445,7 +483,8 @@ enableOverrideColor(in->getAttributeAsBool("OverrideColorEnabled")); setWordWrap(in->getAttributeAsBool("WordWrap")); - Background = in->getAttributeAsBool("Background"); + Background = in->getAttributeAsBool("Background"); + ScrolledLines = in->getAttributeAsInt("ScrolledLines"); setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); diff -r 8f79fa393479 lib/irrlicht/source/Irrlicht/CGUIStaticText.h --- a/lib/irrlicht/source/Irrlicht/CGUIStaticText.h Sat Nov 01 05:31:11 2008 +0100 +++ b/lib/irrlicht/source/Irrlicht/CGUIStaticText.h Sat Nov 01 06:30:25 2008 +0100 @@ -75,7 +75,21 @@ virtual s32 getTextHeight() const; //! Returns the width of the current text, in the current font - virtual s32 getTextWidth() const; + virtual s32 getTextWidth() const; + + //! Set an amount of lines by which the text should be scrolled + //! \param scrolled_lines: Amount of scrolled lines. + virtual void setScrolledTextLines(s32 scrolled_lines); + + //! get the amount of lines which are scrolled + virtual s32 getScrolledTextLines() const; + + //! Get the number of lines used in the static + //! This counts all lines, not just the visible ones. + virtual u32 getTextLineCount() const; + + //! Return the font which is currently used for this element + virtual IGUIFont* getCurrentFont(); //! Updates the absolute position, splits text if word wrap is enabled virtual void updateAbsolutePosition(); @@ -95,7 +109,8 @@ EGUI_ALIGNMENT HAlign, VAlign; bool OverrideColorEnabled; bool WordWrap; - bool Background; + bool Background; + s32 ScrolledLines; video::SColor OverrideColor, BGColor; gui::IGUIFont* OverrideFont;