diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-14 21:43:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-14 21:43:42 +0300 |
commit | 916a53ec6e9eda8711ae7c2e9296463728370751 (patch) | |
tree | ad4288b80344f4535b7101515ce4da3d51ac3766 | |
parent | da267acc2fd56ec20a52a87c76d1abeeb7a5376d (diff) | |
download | plus-916a53ec6e9eda8711ae7c2e9296463728370751.tar.gz plus-916a53ec6e9eda8711ae7c2e9296463728370751.tar.bz2 plus-916a53ec6e9eda8711ae7c2e9296463728370751.tar.xz plus-916a53ec6e9eda8711ae7c2e9296463728370751.zip |
Move containerplacer into separate file.
37 files changed, 143 insertions, 46 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 290468537..de9dad9f7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -133,6 +133,8 @@ SET(SRCS gui/widgets/colorpage.h gui/widgets/container.cpp gui/widgets/container.h + gui/widgets/containerplacer.cpp + gui/widgets/containerplacer.h gui/widgets/desktop.cpp gui/widgets/desktop.h gui/widgets/dropdown.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 9d8554701..ca884fd03 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -223,6 +223,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/colorpage.h \ gui/widgets/container.cpp \ gui/widgets/container.h \ + gui/widgets/containerplacer.cpp \ + gui/widgets/containerplacer.h \ gui/widgets/desktop.cpp \ gui/widgets/desktop.h \ gui/widgets/dropdown.cpp \ diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 85480db3a..6b21dac3b 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -32,6 +32,7 @@ #include "gui/popups/textpopup.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" diff --git a/src/gui/widgets/containerplacer.cpp b/src/gui/widgets/containerplacer.cpp new file mode 100644 index 000000000..1e9ac98ff --- /dev/null +++ b/src/gui/widgets/containerplacer.cpp @@ -0,0 +1,40 @@ +/* + * The ManaPlus Client + * Copyright (C) 2007-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "gui/widgets/containerplacer.h" + +#include "gui/widgets/basiccontainer2.h" +#include "gui/widgets/layout.h" + +#include "debug.h" + +ContainerPlacer ContainerPlacer::at(const int x, const int y) +{ + return ContainerPlacer(mContainer, &mCell->at(x, y)); +} + +LayoutCell &ContainerPlacer::operator() + (const int x, const int y, Widget *const wg, const int w, const int h) +{ + mContainer->add(wg); + return mCell->place(wg, x, y, w, h); +} diff --git a/src/gui/widgets/containerplacer.h b/src/gui/widgets/containerplacer.h new file mode 100644 index 000000000..379b2583d --- /dev/null +++ b/src/gui/widgets/containerplacer.h @@ -0,0 +1,67 @@ +/* + * The ManaPlus Client + * Copyright (C) 2007-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_WIDGETS_CONTAINERPLACER_H +#define GUI_WIDGETS_CONTAINERPLACER_H + +#include "localconsts.h" + +class BasicContainer2; +class LayoutCell; +class Widget; + +/** + * This class is a helper for adding widgets to nested tables in a window. + */ +class ContainerPlacer final +{ + public: + explicit ContainerPlacer(BasicContainer2 *c = nullptr, + LayoutCell *lc = nullptr) : + mContainer(c), + mCell(lc) + {} + + /** + * Gets the pointed cell. + */ + LayoutCell &getCell() A_WARN_UNUSED + { return *mCell; } + + /** + * Returns a placer for the same container but to an inner cell. + */ + ContainerPlacer at(const int x, const int y) A_WARN_UNUSED; + + /** + * Adds the given widget to the container and places it in the layout. + * @see LayoutArray::place + */ + LayoutCell &operator()(const int x, const int y, Widget *const wg, + const int w = 1, const int h = 1); + + private: + BasicContainer2 *mContainer; + LayoutCell *mCell; +}; + +#endif // GUI_WIDGETS_CONTAINERPLACER_H diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 410c8188e..d2f09864b 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -32,18 +32,6 @@ #include "debug.h" -ContainerPlacer ContainerPlacer::at(const int x, const int y) -{ - return ContainerPlacer(mContainer, &mCell->at(x, y)); -} - -LayoutCell &ContainerPlacer::operator() - (const int x, const int y, Widget *const wg, const int w, const int h) -{ - mContainer->add(wg); - return mCell->place(wg, x, y, w, h); -} - LayoutCell::~LayoutCell() { if (mType == ARRAY) diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index c9092f8bd..bf41e1c8e 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -32,40 +32,6 @@ class LayoutCell; class Widget; /** - * This class is a helper for adding widgets to nested tables in a window. - */ -class ContainerPlacer final -{ - public: - explicit ContainerPlacer(BasicContainer2 *c = nullptr, - LayoutCell *lc = nullptr) : - mContainer(c), mCell(lc) - {} - - /** - * Gets the pointed cell. - */ - LayoutCell &getCell() A_WARN_UNUSED - { return *mCell; } - - /** - * Returns a placer for the same container but to an inner cell. - */ - ContainerPlacer at(const int x, const int y) A_WARN_UNUSED; - - /** - * Adds the given widget to the container and places it in the layout. - * @see LayoutArray::place - */ - LayoutCell &operator()(const int x, const int y, Widget *const wg, - const int w = 1, const int h = 1); - - private: - BasicContainer2 *mContainer; - LayoutCell *mCell; -}; - -/** * This class contains a rectangular array of cells. */ class LayoutArray final diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index a8cf28bea..f4f47d19d 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -23,6 +23,7 @@ #include "gui/widgets/layouthelper.h" #include "gui/widgets/basiccontainer2.h" +#include "gui/widgets/containerplacer.h" #include "debug.h" diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index 78e34f419..1877e1940 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -27,6 +27,8 @@ #include "listeners/widgetlistener.h" +class ContainerPlacer; + /** * A helper class for adding a layout to a Guichan container widget. The layout * will register itself as a widget listener and relayout the widgets in the diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index daf8ed8d2..9a4927dc9 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -33,6 +33,7 @@ #include "gui/models/soundsmodel.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp index 7ac88ab0a..897ae5d2a 100644 --- a/src/gui/widgets/tabs/setup_chat.cpp +++ b/src/gui/widgets/tabs/setup_chat.cpp @@ -24,6 +24,7 @@ #include "gui/windows/chatwindow.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 53260ff01..83b4c6c2a 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -26,6 +26,7 @@ #include "gui/userpalette.h" #include "gui/widgets/browserbox.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/listbox.h" diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 74ee7a3dc..a22392fca 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -34,6 +34,7 @@ #include "gui/windows/okdialog.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/listbox.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index eb7e163f0..385c29cf4 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -30,6 +30,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp index b30b84c16..05a8af2a2 100644 --- a/src/gui/widgets/tabs/setup_mods.cpp +++ b/src/gui/widgets/tabs/setup_mods.cpp @@ -24,6 +24,7 @@ #include "configuration.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/setupitem.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp index c00f68eef..2142d13f9 100644 --- a/src/gui/widgets/tabs/setup_other.cpp +++ b/src/gui/widgets/tabs/setup_other.cpp @@ -24,6 +24,7 @@ #include "gui/models/namesmodel.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/setupitem.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp index dad054e83..c7c1edef8 100644 --- a/src/gui/widgets/tabs/setup_perfomance.cpp +++ b/src/gui/widgets/tabs/setup_perfomance.cpp @@ -24,6 +24,7 @@ #include "gui/models/namesmodel.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp index 441ebba58..728c7e1a9 100644 --- a/src/gui/widgets/tabs/setup_players.cpp +++ b/src/gui/widgets/tabs/setup_players.cpp @@ -22,6 +22,7 @@ #include "gui/widgets/tabs/setup_players.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 613e2c7f0..c6b820ec0 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -31,6 +31,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 6994939fc..9e1eb558d 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -32,6 +32,7 @@ #include "gui/models/themesmodel.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index eab39ccb0..bb6f0ea42 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -23,6 +23,7 @@ #include "gui/models/namesmodel.h" #include "gui/models/touchactionmodel.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/setuptouchitem.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index 7d6ac9fc3..9ecec5981 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -32,6 +32,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/listbox.h" diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index fa4e2f4ef..d9f3ec4cf 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -23,6 +23,7 @@ #include "gui/models/namesmodel.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 7e34476d0..1348b055c 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -78,6 +78,7 @@ #include "gui/skin.h" #include "gui/viewport.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layout.h" #include "resources/cursor.h" diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index f8e87e846..0d2349143 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -32,6 +32,7 @@ #include "gui/models/sortlistmodelbuy.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 33c46d4cd..1984bacd7 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -42,6 +42,7 @@ #include "gui/widgets/characterdisplay.h" #include "gui/widgets/characterviewnormal.h" #include "gui/widgets/characterviewsmall.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layout.h" #include "net/logindata.h" diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index c29abf090..26514575b 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -33,6 +33,7 @@ #include "gui/windows/setupwindow.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/layouthelper.h" diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 080e44850..ffce4ee8b 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -41,6 +41,7 @@ #include "gui/windows/tradewindow.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/icon.h" #include "gui/widgets/inttextfield.h" diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index fdaccc2d9..3b4191178 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -33,6 +33,7 @@ #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layout.h" #include "gui/widgets/extendedlistbox.h" #include "gui/widgets/itemlinkhandler.h" diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index bc93bb2ae..9ed503664 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -34,6 +34,7 @@ #include "gui/viewport.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/layout.h" #include "gui/widgets/button.h" #include "gui/widgets/radiobutton.h" diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 6d3cf9d9f..e1c78141b 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -31,6 +31,7 @@ #include "gui/windows/okdialog.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/passwordfield.h" diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 1b9f1ec85..b317d6f54 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -33,6 +33,7 @@ #include "gui/models/shopitems.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 0afe6f90c..1c2afe9e8 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -31,6 +31,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index ae0c4fe80..fa0fd3378 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -40,6 +40,7 @@ #include "gui/windows/setupwindow.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/progressbar.h" diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 29e1bd81e..dce17dede 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -32,6 +32,7 @@ #include "gui/models/targettypemodel.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 985ebdfad..60ef9255b 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -40,6 +40,7 @@ #include "gui/windows/setupwindow.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/itemcontainer.h" #include "gui/widgets/label.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 249748d43..0884f5f7a 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -31,6 +31,7 @@ #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" +#include "gui/widgets/containerplacer.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/progressbar.h" |