From 0dbb4c4ba8044aaf0346706ba735e58b4cfc13f7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 May 2015 18:10:47 +0300 Subject: Improve a bit basiccontainer2. --- src/gui/widgets/basiccontainer.h | 2 +- src/gui/widgets/basiccontainer2.cpp | 38 ++++++++++++------------------------- src/gui/widgets/basiccontainer2.h | 26 ++++++------------------- 3 files changed, 19 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/basiccontainer.h b/src/gui/widgets/basiccontainer.h index ec4a39115..eb115777c 100644 --- a/src/gui/widgets/basiccontainer.h +++ b/src/gui/widgets/basiccontainer.h @@ -134,7 +134,6 @@ class BasicContainer notfinal : public Widget, Widget *findFirstWidget(const std::set &list); - protected: /** * Adds a widget to the basic container. * @@ -158,6 +157,7 @@ class BasicContainer notfinal : public Widget, */ virtual void clear(); + protected: /** * Draws the children widgets of the basic container. * diff --git a/src/gui/widgets/basiccontainer2.cpp b/src/gui/widgets/basiccontainer2.cpp index 11fca50b3..cc0158d9a 100644 --- a/src/gui/widgets/basiccontainer2.cpp +++ b/src/gui/widgets/basiccontainer2.cpp @@ -82,10 +82,11 @@ BasicContainer2::~BasicContainer2() void BasicContainer2::draw(Graphics* graphics) { BLOCK_START("BasicContainer2::draw") - if (isOpaque()) + if (mOpaque) { - graphics->setColor(getBaseColor()); - graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight())); + graphics->setColor(mBaseColor); + graphics->fillRectangle(Rect(0, 0, + mDimension.width, mDimension.height)); } drawChildren(graphics); @@ -97,41 +98,26 @@ void BasicContainer2::safeDraw(Graphics* graphics) BLOCK_START("BasicContainer2::draw") if (isOpaque()) { - graphics->setColor(getBaseColor()); - graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight())); + graphics->setColor(mBaseColor); + graphics->fillRectangle(Rect(0, 0, + mDimension.width, mDimension.height)); } safeDrawChildren(graphics); BLOCK_END("BasicContainer2::draw") } -void BasicContainer2::setOpaque(bool opaque) -{ - mOpaque = opaque; -} - -bool BasicContainer2::isOpaque() const -{ - return mOpaque; -} - void BasicContainer2::add(Widget* widget) { + // +++ need move all add() calls from constructors + // and after this method can be deleted + // and virtual moved to basiccontainer BasicContainer::add(widget); } -void BasicContainer2::addXY(Widget* widget, int x, int y) +void BasicContainer2::addXY(Widget* widget, + const int x, const int y) { widget->setPosition(x, y); BasicContainer::add(widget); } - -void BasicContainer2::remove(Widget* widget) -{ - BasicContainer::remove(widget); -} - -void BasicContainer2::clear() -{ - BasicContainer::clear(); -} diff --git a/src/gui/widgets/basiccontainer2.h b/src/gui/widgets/basiccontainer2.h index 435f00c43..7243e68d3 100644 --- a/src/gui/widgets/basiccontainer2.h +++ b/src/gui/widgets/basiccontainer2.h @@ -102,7 +102,8 @@ class BasicContainer2: public BasicContainer * @param opaque True if the container should be opaque, false otherwise. * @see isOpaque */ - void setOpaque(bool opaque); + void setOpaque(bool opaque) + { mOpaque = opaque; } /** * Checks if the container is opaque or not. @@ -110,7 +111,8 @@ class BasicContainer2: public BasicContainer * @return True if the container is opaque, false otherwise. * @see setOpaque */ - bool isOpaque() const; + bool isOpaque() const + { return mOpaque; } /** * Adds a widget to the container. @@ -130,24 +132,8 @@ class BasicContainer2: public BasicContainer * @param y The y coordinate for the widget. * @see remove, clear */ - virtual void addXY(Widget* widget, int x, int y); - - /** - * Removes a widget from the Container. - * - * @param widget The widget to remove. - * @throws Exception when the widget has not been added to the - * container. - * @see add, clear - */ - void remove(Widget* widget) override; - - /** - * Clears the container of all widgets. - * - * @see add, remove - */ - void clear() override; + void addXY(Widget* widget, + const int x, const int y); // Inherited from Widget -- cgit v1.2.3-60-g2f50