From 33b4fc4cfa31e06f9aba032a9779ceae92cb0672 Mon Sep 17 00:00:00 2001 From: micha-bbg Date: Tue, 4 Sep 2012 20:31:36 +0200 Subject: [PATCH] CComponentsItemBox: Add flag 'isCalculated' for control calculateElements() --- src/gui/components/cc.h | 2 ++ src/gui/components/components.cpp | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index e1d6cdfee..a08ac4cc6 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -342,6 +342,7 @@ class CComponentsItemBox : public CComponentsContainer size_t prevElementLeft; size_t prevElementRight; std::vector v_element_data; + bool isCalculated; void clearElements(); void initVarItemBox(); @@ -367,6 +368,7 @@ class CComponentsItemBox : public CComponentsContainer virtual void addIcon(const std::string& s_icon_name, const int align=CC_ALIGN_LEFT, size_t *index=NULL); virtual void addPicture(const std::string& s_picture_path, const int align=CC_ALIGN_LEFT, size_t *index=NULL); virtual void addClock(const int align=CC_ALIGN_RIGHT, size_t *index=NULL); + virtual int getHeight(); }; class CComponentsTitleBar : public CComponentsItemBox diff --git a/src/gui/components/components.cpp b/src/gui/components/components.cpp index 4f6f7337e..e8cbaf812 100644 --- a/src/gui/components/components.cpp +++ b/src/gui/components/components.cpp @@ -852,9 +852,17 @@ void CComponentsItemBox::initVarItemBox() prevElementLeft = 0; prevElementRight = 0; onlyOneTextElement = false; + isCalculated = false; v_element_data.clear(); } +int CComponentsItemBox::getHeight() +{ + if (!isCalculated) + calculateElements(); + return height; +} + void CComponentsItemBox::clearElements() { for(size_t i = 0; i < v_element_data.size(); i++) { @@ -874,6 +882,7 @@ void CComponentsItemBox::clearElements() break; } } + isCalculated = false; v_element_data.clear(); } @@ -911,6 +920,7 @@ bool CComponentsItemBox::addLogoOrText(int align, const std::string& logo, const v_element_data.push_back(data); if (index != NULL) *index = v_element_data.size()-1; + isCalculated = false; return true; } @@ -974,6 +984,7 @@ bool CComponentsItemBox::addElement(int align, int type, const std::string& elem v_element_data.push_back(data); if (index != NULL) *index = v_element_data.size()-1; + isCalculated = false; return true; } @@ -1199,6 +1210,7 @@ void CComponentsItemBox::calculateElements() } calPositionOfElements(); + isCalculated = true; } void CComponentsItemBox::paintItemBox(bool do_save_bg)