from JSMOCHelper.hpp:32
class JSMOCHelper
{
public:
JSMOCHelper()
{
}
void setWidget(Drawable* newWidget)
{
widget = newWidget;
cachedVisibleRect.x = CACHED_INDICATOR;
cachedAbsX = CACHED_INDICATOR;
cachedAbsY = CACHED_INDICATOR;
}
Drawable* getWidget()
{
return widget;
}
Rect& getCachedVisibleRect()
{
assert(widget != 0);
if (!hasCachedVisibleRect())
{
Rect visibleRect(0, 0, widget->getWidth(), widget->getHeight());
widget->getVisibleRect(visibleRect);
cachedVisibleRect = visibleRect;
}
return cachedVisibleRect;
}
int16_t getCachedAbsX()
{
if (!hasCachedAbsX())
{
Rect absRect = widget->getAbsoluteRect();
cachedAbsX = absRect.x;
cachedAbsY = absRect.y;
}
return cachedAbsX;
}
int16_t getCachedAbsY()
{
if (!hasCachedAbsY())
{
Rect absRect = widget->getAbsoluteRect();
cachedAbsX = absRect.x;
cachedAbsY = absRect.y;
}
return cachedAbsY;
}
int16_t getWidth()
{
return widget->getWidth();
}
int16_t getHeight()
{
return widget->getHeight();
}
void draw(const Rect& invalidatedArea)
{
widget->draw(invalidatedArea);
}
private:
static const int16_t CACHED_INDICATOR = -1;
Drawable* widget;
Rect cachedVisibleRect;
bool hasCachedVisibleRect()
{
return cachedVisibleRect.x != CACHED_INDICATOR;
}
int16_t cachedAbsX;
int16_t cachedAbsY;
bool hasCachedAbsX()
{
return cachedAbsX != CACHED_INDICATOR;
}
bool hasCachedAbsY()
{
return cachedAbsY != CACHED_INDICATOR;
}
};