[Orxonox-commit 3274] r7965 - in code/branches/kicklib: data/gui/scripts src/libraries/core

dafrick at orxonox.net dafrick at orxonox.net
Sat Feb 26 11:06:36 CET 2011


Author: dafrick
Date: 2011-02-26 11:06:36 +0100 (Sat, 26 Feb 2011)
New Revision: 7965

Modified:
   code/branches/kicklib/data/gui/scripts/GUITools.lua
   code/branches/kicklib/src/libraries/core/GUIManager.h
Log:
getStaticTextWindowHeight() working again for CEGUI < 0.7


Modified: code/branches/kicklib/data/gui/scripts/GUITools.lua
===================================================================
--- code/branches/kicklib/data/gui/scripts/GUITools.lua	2011-02-26 05:46:36 UTC (rev 7964)
+++ code/branches/kicklib/data/gui/scripts/GUITools.lua	2011-02-26 10:06:36 UTC (rev 7965)
@@ -45,18 +45,19 @@
     return 0.008*ratio/0.3204
 end
 
-function getStaticTextArea(static_text)
-    local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(static_text:getLookNFeel())
-
-    return lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(static_text)
-end
-
 function getStaticTextWindowHeight(window)
     -- Get the area the text is formatted and drawn into.
-    local formattedArea = getStaticTextArea(window)
+    local lookAndFeel = CEGUI.WidgetLookManager:getSingleton():getWidgetLook(window:getLookNFeel())
+    local formattedArea = lookAndFeel:getNamedArea("WithFrameTextRenderArea"):getArea():getPixelRect(window)
     -- Calculate the pixel height of the frame by subtracting the height of the area above from the total height of the window.
     local frameHeight = window:getUnclippedOuterRect():getHeight() - formattedArea:getHeight()
 
-    local height = math.floor(CEGUI.PropertyHelper.stringToFloat(window:getProperty("VertExtent")) + frameHeight) + 1
+    local height = 0
+    if orxonox.GUIManager:isCEGUIVersion7() then
+        height = math.floor(CEGUI.PropertyHelper.stringToFloat(window:getProperty("VertExtent")) + frameHeight) + 1
+    else
+        local lines = window:getFont():getFormattedLineCount(window:getText(), formattedArea, CEGUI.WordWrapLeftAligned)
+        height = lines * window:getFont():getLineSpacing() + frameHeight
+    end
     return height
 end

Modified: code/branches/kicklib/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/kicklib/src/libraries/core/GUIManager.h	2011-02-26 05:46:36 UTC (rev 7964)
+++ code/branches/kicklib/src/libraries/core/GUIManager.h	2011-02-26 10:06:36 UTC (rev 7965)
@@ -115,6 +115,8 @@
         static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); //tolua_export
         static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); //tolua_export
 
+        static bool isCEGUIVersion7(void) { return CEGUIVERSION7; } // tolua_export
+
         static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export
 
     private:
@@ -149,10 +151,12 @@
 #if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
         CEGUI::OgreCEGUIRenderer*            guiRenderer_;      //!< CEGUI's interface to the Ogre Engine
         CEGUI::ResourceProvider*             resourceProvider_; //!< CEGUI's resource provider
+        static const bool                    CEGUIVERSION7 = false;
 #else
         CEGUI::OgreRenderer*                 guiRenderer_;      //!< CEGUI's interface to the Ogre Engine
         CEGUI::OgreResourceProvider*         resourceProvider_; //!< CEGUI's resource provider
         CEGUI::OgreImageCodec*               imageCodec_;
+        static const bool                    CEGUIVERSION7 = false;
 #endif
         LuaState*                            luaState_;         //!< LuaState, access point to the Lua engine
         CEGUI::LuaScriptModule*              scriptModule_;     //!< CEGUI's script module to use Lua




More information about the Orxonox-commit mailing list