diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-05-27 18:10:47 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-05-27 18:10:47 +0300 |
commit | 0dbb4c4ba8044aaf0346706ba735e58b4cfc13f7 (patch) | |
tree | 90ed4c8b02892caa8642236e9aed767af42581d4 | |
parent | 917d35d6cbea488f07596d0403d0bef8d6413f8a (diff) | |
download | manaplus-0dbb4c4ba8044aaf0346706ba735e58b4cfc13f7.tar.gz manaplus-0dbb4c4ba8044aaf0346706ba735e58b4cfc13f7.tar.bz2 manaplus-0dbb4c4ba8044aaf0346706ba735e58b4cfc13f7.tar.xz manaplus-0dbb4c4ba8044aaf0346706ba735e58b4cfc13f7.zip |
Improve a bit basiccontainer2.
-rw-r--r-- | src/gui/widgets/basiccontainer.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/basiccontainer2.cpp | 38 | ||||
-rw-r--r-- | src/gui/widgets/basiccontainer2.h | 26 |
3 files changed, 19 insertions, 47 deletions
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<Widget*> &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 |