From ad630c5acb59802cb6ce416f04fb594175049bf6 Mon Sep 17 00:00:00 2001 From: Michael Liebmann Date: Wed, 23 Oct 2013 16:42:40 +0200 Subject: [PATCH] CComponentsText: Add function getTextLinesAutoHeight() - Function is used for determine the number of lines in a text box in AUTO_HIGH mode. Signed-off-by: Thilo Graf --- src/gui/components/cc_item_text.cpp | 15 +++++++++++++++ src/gui/components/cc_item_text.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp index 1b5aba9a1..dbd94b4c2 100644 --- a/src/gui/components/cc_item_text.cpp +++ b/src/gui/components/cc_item_text.cpp @@ -273,3 +273,18 @@ string CComponentsText::iToString(int int_val) string i_string(i_str.str()); return i_string; } + +//helper, get lines per textbox page +int CComponentsText::getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode) +{ + CComponentsText box; + box.iX = 0; + box.iY = 0; + box.iWidth = textWidth; + box.iHeight = textMaxHeight; + + CTextBox tb(ct_text.c_str(), ct_font, mode, &box); + int ret = tb.getLinesPerPage(); + + return ret; +} diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h index c20420d9a..8c87b8d5e 100644 --- a/src/gui/components/cc_item_text.h +++ b/src/gui/components/cc_item_text.h @@ -133,6 +133,9 @@ class CComponentsText : public CComponentsItem, public CBox ///gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties virtual CTextBox* getCTextBoxObject() { return ct_textbox; }; + + ///returns count of lines from a text box page + virtual int getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode); };