From 26f1fbd1ccfb747cc2cd3be0b052133e73e585dd Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 11 Oct 2009 15:13:31 +0100 Subject: [PATCH] Add render method --- include/gui2/Button.hpp | 2 ++ include/gui2/ContainerWidget.hpp | 6 ++++-- include/gui2/Label.hpp | 2 ++ include/gui2/Widget.hpp | 2 ++ include/gui2/Window.hpp | 2 ++ src/gui2/Button.cpp | 5 +++++ src/gui2/Label.cpp | 5 +++++ src/gui2/Layout.cpp | 23 +++++++++++++++++++++++ src/gui2/Window.cpp | 6 ++++++ 9 files changed, 51 insertions(+), 2 deletions(-) diff --git a/include/gui2/Button.hpp b/include/gui2/Button.hpp index bf472ef..9207372 100644 --- a/include/gui2/Button.hpp +++ b/include/gui2/Button.hpp @@ -33,6 +33,8 @@ namespace gui { const string& label() const { return label_; } void label(const string& t) { label_ = t; } + + void render() const; private: string label_; }; diff --git a/include/gui2/ContainerWidget.hpp b/include/gui2/ContainerWidget.hpp index 5c5c095..e530535 100644 --- a/include/gui2/ContainerWidget.hpp +++ b/include/gui2/ContainerWidget.hpp @@ -38,8 +38,10 @@ namespace gui { ChildList::iterator begin() { return children.begin(); } ChildList::iterator end() { return children.end(); } - ChildList::const_iterator const_begin() { return children.begin(); } - ChildList::const_iterator const_end() { return children.end(); } + ChildList::const_iterator const_begin() const + { return children.begin(); } + ChildList::const_iterator const_end() const + { return children.end(); } private: ChildList children; }; diff --git a/include/gui2/Label.hpp b/include/gui2/Label.hpp index f42d8f4..c70bce7 100644 --- a/include/gui2/Label.hpp +++ b/include/gui2/Label.hpp @@ -33,6 +33,8 @@ namespace gui { const string& text() const { return text_; } void text(const string& t) { text_ = t; } + + void render() const; private: string text_; }; diff --git a/include/gui2/Widget.hpp b/include/gui2/Widget.hpp index 80fd102..f68b1fd 100644 --- a/include/gui2/Widget.hpp +++ b/include/gui2/Widget.hpp @@ -40,6 +40,8 @@ namespace gui { boost::any get_property(const string& key) const; void set_property(const string& key, boost::any value); + virtual void render() const = 0; + protected: template void const_property(const string& key, T& value, diff --git a/include/gui2/Window.hpp b/include/gui2/Window.hpp index 28c7772..f983ed9 100644 --- a/include/gui2/Window.hpp +++ b/include/gui2/Window.hpp @@ -34,6 +34,8 @@ namespace gui { const string& title() const { return title_; } void title(const string& t) { title_ = t; } + + void render() const; private: string title_; }; diff --git a/src/gui2/Button.cpp b/src/gui2/Button.cpp index 5953021..c3fc624 100644 --- a/src/gui2/Button.cpp +++ b/src/gui2/Button.cpp @@ -24,3 +24,8 @@ Button::Button(const AttributeSet& attrs) { property("label", label_); } + +void Button::render() const +{ + +} diff --git a/src/gui2/Label.cpp b/src/gui2/Label.cpp index 05a4dda..f93dd17 100644 --- a/src/gui2/Label.cpp +++ b/src/gui2/Label.cpp @@ -24,3 +24,8 @@ Label::Label(const AttributeSet& attrs) { property("text", text_); } + +void Label::render() const +{ + +} diff --git a/src/gui2/Layout.cpp b/src/gui2/Layout.cpp index 60bc848..421d892 100644 --- a/src/gui2/Layout.cpp +++ b/src/gui2/Layout.cpp @@ -39,6 +39,7 @@ public: // IXMLCallback interface void startElement(const string& local_name, const AttributeSet &attrs); + void endElement(const string& local_name); private: // Manages paths during parsing @@ -53,7 +54,16 @@ private: vector path_comps; }; + // Root of widget hierarchy + class RootWidget : public ContainerWidget { + public: + RootWidget(const AttributeSet& attrs) : ContainerWidget(attrs) {} + + void render() const; + }; + PathStack parse_path; + Widget* root; }; Layout::Layout(const string& file_name) @@ -68,6 +78,7 @@ void Layout::startElement(const string& local_name, Widget* w = NULL; if (local_name == "layout") { + root = new RootWidget(attrs); parse_path.push("<>"); return; } @@ -83,11 +94,23 @@ void Layout::startElement(const string& local_name, parse_path.push(w->name()); } +void Layout::endElement(const string& local_name) +{ + parse_path.pop(); +} + void Layout::render() const { } +void Layout::RootWidget::render() const +{ + for (ChildList::const_iterator it = const_begin(); + it != const_end(); ++it) + (*it)->render(); +} + IWidgetPtr Layout::get(const string& path) const { return IWidgetPtr(); diff --git a/src/gui2/Window.cpp b/src/gui2/Window.cpp index e424d60..d2f496e 100644 --- a/src/gui2/Window.cpp +++ b/src/gui2/Window.cpp @@ -24,3 +24,9 @@ Window::Window(const AttributeSet& attrs) { property("title", title_); } + +void Window::render() const +{ + +} + -- 2.39.2