From 65bbdd707ba33de08101076a7191585d6f44c507 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Sun, 17 Aug 2003 00:56:52 +0000 Subject: [PATCH] Now widgets are passed as pointer (and stored as pointers) in container classes. Added an append() method to append content to a container. --- container.cpp | 10 +++++++--- container.h | 13 ++++++++++--- fallback.cpp | 4 ++-- fallback.h | 6 +++--- translate.cpp | 4 ++-- translate.h | 6 +++--- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/container.cpp b/container.cpp index 85d1242..a896674 100644 --- a/container.cpp +++ b/container.cpp @@ -24,7 +24,7 @@ Container::Container(const Hash& attrs): Widget(attrs) { #endif } -Container::Container(const Hash& attrs, Widget& content): Widget(attrs) { +Container::Container(const Hash& attrs, Widget* content): Widget(attrs) { // FIXME - this->content.push_back(content); #ifdef DEBUG cerr << "In Container::Container(attrs = {" /* TODO << attrs */ @@ -32,7 +32,7 @@ Container::Container(const Hash& attrs, Widget& content): Widget(attrs) { #endif } -Container::Container(Widget& content, const Hash& attrs): Widget(attrs) { +Container::Container(Widget* content, const Hash& attrs): Widget(attrs) { // FIXME - this->content.push_back(content); #ifdef DEBUG cerr << "In Container::Container(content = {" /* TODO << content */ @@ -63,7 +63,11 @@ string Container::render(HIT& hit) { string Container::renderContent(HIT& hit) { stringstream out; for (Content::iterator i = content.begin(); i != content.end(); i++) { - out << i->render(hit); + out << (*i)->render(hit); } return out.str(); } + +void Container::append(Widget* widget) { + content.push_back(widget); +} diff --git a/container.h b/container.h index f01dcac..eb2bb1f 100644 --- a/container.h +++ b/container.h @@ -21,7 +21,7 @@ namespace bife { class Container: public Widget { // Typedefs protected: - typedef std::vector Content; + typedef std::vector Content; // Attributes. protected: @@ -48,7 +48,7 @@ namespace bife { * @param attrs Widget attributes. * @param content Content of the widget. */ - Container(const Hash&, Widget&); + Container(const Hash&, Widget*); /** * Constructor. @@ -56,7 +56,7 @@ namespace bife { * @param content Content of the widget. * @param attrs Widget attributes. */ - Container(Widget&, const Hash&); + Container(Widget*, const Hash&); /** * Destructor. @@ -70,6 +70,13 @@ namespace bife { * @return Rendered widget. */ virtual string renderContent(HIT&); + + /** + * Appends a widget to the container. + * + * @param widget Widget to append. + */ + virtual void append(Widget*); }; } diff --git a/fallback.cpp b/fallback.cpp index 6179706..ca188b3 100644 --- a/fallback.cpp +++ b/fallback.cpp @@ -26,7 +26,7 @@ Fallback::Fallback(const string& name, const Hash& attrs): #endif } -Fallback::Fallback(const string& name, const Hash& attrs, Widget& content): +Fallback::Fallback(const string& name, const Hash& attrs, Widget* content): Container(attrs, content), name(name) { // FIXME - this->content.push_back(content); #ifdef DEBUG @@ -36,7 +36,7 @@ Fallback::Fallback(const string& name, const Hash& attrs, Widget& content): #endif } -Fallback::Fallback(const string& name, Widget& content, const Hash& attrs): +Fallback::Fallback(const string& name, Widget* content, const Hash& attrs): Container(content, attrs), name(name) { // FIXME - this->content.push_back(content); #ifdef DEBUG diff --git a/fallback.h b/fallback.h index ade02b8..c54dae1 100644 --- a/fallback.h +++ b/fallback.h @@ -49,7 +49,7 @@ namespace bife { * @param attrs Widget attributes. * @param content Content of the widget. */ - Fallback(const string&, const Hash&, Widget&); + Fallback(const string&, const Hash&, Widget*); /** * Constructor. @@ -57,7 +57,7 @@ namespace bife { * @param name Name of the widget. * @param content Content of the widget. */ - Fallback(const string&, Widget&); + Fallback(const string&, Widget*); /** * Constructor. @@ -66,7 +66,7 @@ namespace bife { * @param content Content of the widget. * @param attrs Widget attributes. */ - Fallback(const string&, Widget&, const Hash&); + Fallback(const string&, Widget*, const Hash&); /** * Destructor. diff --git a/translate.cpp b/translate.cpp index d3bb41b..b37453a 100644 --- a/translate.cpp +++ b/translate.cpp @@ -25,7 +25,7 @@ Translate::Translate(const string& name, const Hash& attrs): Fallback(name, attr #endif } -Translate::Translate(const string& name, const Hash& attrs, Widget& content): +Translate::Translate(const string& name, const Hash& attrs, Widget* content): Fallback(name, attrs, content) { // FIXME - this->content.push_back(content); #ifdef DEBUG @@ -35,7 +35,7 @@ Translate::Translate(const string& name, const Hash& attrs, Widget& content): #endif } -Translate::Translate(const string& name, Widget& content, const Hash& attrs): +Translate::Translate(const string& name, Widget* content, const Hash& attrs): Fallback(name, content, attrs) { // FIXME - this->content.push_back(content); #ifdef DEBUG diff --git a/translate.h b/translate.h index 8a11499..7f4be70 100644 --- a/translate.h +++ b/translate.h @@ -44,7 +44,7 @@ namespace bife { * @param attrs Widget attributes. * @param content Content of the widget. */ - Translate(const string&, const Hash&, Widget&); + Translate(const string&, const Hash&, Widget*); /** * Constructor. @@ -52,7 +52,7 @@ namespace bife { * @param name Name of the widget. * @param content Content of the widget. */ - Translate(const string&, Widget&); + Translate(const string&, Widget*); /** * Constructor. @@ -61,7 +61,7 @@ namespace bife { * @param content Content of the widget. * @param attrs Widget attributes. */ - Translate(const string&, Widget&, const Hash&); + Translate(const string&, Widget*, const Hash&); /** * Destructor. -- 2.43.0