gui: allow specifying object type in element name

e.g. '<button ...>' instead of '<object type="button" ...>'

Also get rid of default parameters to make things more explicit.

Change-Id: Ie4d1231b725aeb6cbf0041622c9780c86cf8e1c1
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 975d40f..4c98a72 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -267,7 +267,7 @@
 	return 0;
 }
 
-Page::Page(xml_node<>* page, std::vector<xml_node<>*> *templates /* = NULL */)
+Page::Page(xml_node<>* page, std::vector<xml_node<>*> *templates)
 {
 	mTouchStart = NULL;
 
@@ -296,9 +296,7 @@
 	LOGINFO("Loading page %s\n", mName.c_str());
 
 	// This is a recursive routine for template handling
-	ProcessNode(page, templates);
-
-	return;
+	ProcessNode(page, templates, 0);
 }
 
 Page::~Page()
@@ -307,7 +305,7 @@
 		delete *itr;
 }
 
-bool Page::ProcessNode(xml_node<>* page, std::vector<xml_node<>*> *templates /* = NULL */, int depth /* = 0 */)
+bool Page::ProcessNode(xml_node<>* page, std::vector<xml_node<>*> *templates, int depth)
 {
 	if (depth == 10)
 	{
@@ -315,26 +313,20 @@
 		return false;
 	}
 
-	// Let's retrieve the background value, if any
-	xml_node<>* bg = page->first_node("background");
-	if (bg)
+	for (xml_node<>* child = page->first_node(); child; child = child->next_sibling())
 	{
-		xml_attribute<>* attr = bg->first_attribute("color");
-		if (attr)
-		{
-			std::string color = attr->value();
-			ConvertStrToColor(color, &mBackground);
+		std::string type = child->name();
+
+		if (type == "background") {
+			mBackground = LoadAttrColor(child, "color", COLOR(0,0,0,0));
+			continue;
 		}
-	}
 
-	xml_node<>* child;
-	child = page->first_node("object");
-	while (child)
-	{
-		if (!child->first_attribute("type"))
-			break;
-
-		std::string type = child->first_attribute("type")->value();
+		if (type == "object") {
+			// legacy format : <object type="...">
+			xml_attribute<>* attr = child->first_attribute("type");
+			type = attr ? attr->value() : "*unspecified*";
+		}
 
 		if (type == "text")
 		{
@@ -486,14 +478,14 @@
 							break;
 						node = node->next_sibling("template");
 					}
+					// [check] why is there no if (node_found) here too?
 				}
 			}
 		}
 		else
 		{
-			LOGERR("Unknown object type.\n");
+			LOGERR("Unknown object type: %s.\n", type.c_str());
 		}
-		child = child->next_sibling("object");
 	}
 	return true;
 }
@@ -660,7 +652,7 @@
 	if (xmlFile)
 		mDoc.parse<0>(mXmlFile);
 	else
-		mCurrentPage = new Page(NULL);
+		mCurrentPage = new Page(NULL, NULL);
 }
 
 PageSet::~PageSet()
diff --git a/gui/pages.hpp b/gui/pages.hpp
index f0b2155..81112f9 100644
--- a/gui/pages.hpp
+++ b/gui/pages.hpp
@@ -46,7 +46,7 @@
 class Page
 {
 public:
-	Page(xml_node<>* page, std::vector<xml_node<>*> *templates = NULL);
+	Page(xml_node<>* page, std::vector<xml_node<>*> *templates);
 	virtual ~Page();
 
 	std::string GetName(void)   { return mName; }
@@ -72,7 +72,7 @@
 	COLOR mBackground;
 
 protected:
-	bool ProcessNode(xml_node<>* page, std::vector<xml_node<>*> *templates = NULL, int depth = 0);
+	bool ProcessNode(xml_node<>* page, std::vector<xml_node<>*> *templates, int depth);
 };
 
 class PageSet