gui: make resources type safe
- add string, int, color and resource loading helpers
- use typed resource classes, and some cleanup in loading code
- remove abstract GetResource() to enforce type safe access
- add height and width query methods to resources and use them
- minor cleanup
- simplify LoadPlacement
Change-Id: I9b81785109a80b3806ad6b50cba4d893b87b0db1
diff --git a/gui/image.cpp b/gui/image.cpp
index 2cf3b68..60b1cb9 100644
--- a/gui/image.cpp
+++ b/gui/image.cpp
@@ -40,12 +40,8 @@
child = node->first_node("image");
if (child)
{
- attr = child->first_attribute("resource");
- if (attr)
- mImage = PageManager::FindResource(attr->value());
- attr = child->first_attribute("highlightresource");
- if (attr)
- mHighlightImage = PageManager::FindResource(attr->value());
+ mImage = LoadAttrImage(child, "resource");
+ mHighlightImage = LoadAttrImage(child, "highlightresource");
}
// Load the placement
@@ -53,8 +49,8 @@
if (mImage && mImage->GetResource())
{
- mRenderW = gr_get_width(mImage->GetResource());
- mRenderH = gr_get_height(mImage->GetResource());
+ mRenderW = mImage->GetWidth();
+ mRenderH = mImage->GetHeight();
// Adjust for placement
if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
@@ -73,8 +69,6 @@
}
SetPlacement(TOP_LEFT);
}
-
- return;
}
int GUIImage::Render(void)