From 9bca06b1c7c121f410766ad99b91075902ce24c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 00:36:17 +0300 Subject: move selectionlistener from base into listeners. --- src/gui/base/selectionlistener.hpp | 117 ---------------------------------- src/gui/base/widgets/listbox.cpp | 2 +- src/gui/base/widgets/listbox.hpp | 4 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 12 ++-- src/gui/widgets/tabs/setup_colors.cpp | 2 +- src/gui/widgets/tabs/setup_colors.h | 4 +- src/gui/windowmenu.cpp | 2 +- src/gui/windowmenu.h | 4 +- src/gui/windows/buydialog.cpp | 6 +- src/gui/windows/buydialog.h | 4 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/inventorywindow.h | 4 +- src/gui/windows/selldialog.cpp | 4 +- src/gui/windows/selldialog.h | 4 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/serverdialog.h | 4 +- src/gui/windows/shopwindow.cpp | 2 +- src/gui/windows/shopwindow.h | 4 +- src/gui/windows/tradewindow.cpp | 2 +- src/gui/windows/tradewindow.h | 4 +- src/listeners/selectionlistener.h | 114 +++++++++++++++++++++++++++++++++ 24 files changed, 152 insertions(+), 159 deletions(-) delete mode 100644 src/gui/base/selectionlistener.hpp create mode 100644 src/listeners/selectionlistener.h diff --git a/src/gui/base/selectionlistener.hpp b/src/gui/base/selectionlistener.hpp deleted file mode 100644 index b1a4d73ba..000000000 --- a/src/gui/base/selectionlistener.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The ManaPlus Client - * 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 . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GCN_SELECTIONLISTENER_HPP -#define GCN_SELECTIONLISTENER_HPP - -#include - -#include "gui/base/selectionevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for selection events from widgets. - * - * @see ListBox::addSelectionListener, - * ListBox::removeSelectionListener, - * DropDown::addSelectionListener, - * DropDown::removeSelectionListener - * @author Olof Naessén - * @since 0.8.0 - */ - class SelectionListener - { - public: - /** - * Destructor. - */ - virtual ~SelectionListener() - { } - - /** - * Called when the value of a selection has been changed in a Widget. - * It is used to be able to recieve a notification that a value has - * been changed. - * - * @param event The event of the value change. - * @since 0.8.0 - */ - virtual void valueChanged(const SelectionEvent& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of SelectionListener, - * therefore its constructor is protected. - */ - SelectionListener() - { } - }; -} // namespace gcn - -#endif // end GCN_SELECTIONLISTENER_HPP diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 3ae4caa91..7f46b4b10 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -72,7 +72,7 @@ #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/mouseinput.hpp" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index 793aba840..61c8486bb 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -72,10 +72,10 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" +class SelectionListener; + namespace gcn { - class SelectionListener; - /** * An implementation of a list box where an item can be selected. * diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index efb3235a4..1aed0dfe1 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -61,7 +61,7 @@ DropDown::DropDown(const Widget2 *const widget, KeyListener(), MouseListener(), FocusListener(), - gcn::SelectionListener(), + SelectionListener(), Widget2(widget), mPopup(new PopupList(this, listModel, extended, modal)), mShadowColor(getThemeColor(Theme::DROPDOWN_SHADOW)), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 7d645a478..692b341ca 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -32,7 +32,7 @@ #include "listeners/focuslistener.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "localconsts.h" @@ -55,7 +55,7 @@ class DropDown final : public ActionListener, public KeyListener, public MouseListener, public FocusListener, - public gcn::SelectionListener, + public SelectionListener, public Widget2 { public: diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 40c87d272..036cb6c1b 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -47,7 +47,7 @@ #include "resources/image.h" #include "gui/base/font.hpp" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 77d7e1c28..74ae72a23 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -39,11 +39,7 @@ class Image; class Inventory; class Item; class ItemPopup; - -namespace gcn -{ - class SelectionListener; -} +class SelectionListener; /** * An item container. Used to show items in inventory and trade dialog. @@ -116,14 +112,14 @@ class ItemContainer final : public gcn::Widget, * Adds a listener to the list that's notified each time a change to * the selection occurs. */ - void addSelectionListener(gcn::SelectionListener *listener) + void addSelectionListener(SelectionListener *listener) { mSelectionListeners.push_back(listener); } /** * Removes a listener from the list that's notified each time a change * to the selection occurs. */ - void removeSelectionListener(gcn::SelectionListener *listener) + void removeSelectionListener(SelectionListener *listener) { mSelectionListeners.remove(listener); } void setFilter(const int tag); @@ -192,7 +188,7 @@ class ItemContainer final : public gcn::Widget, gcn::Color mEquipedColor2; gcn::Color mUnEquipedColor; gcn::Color mUnEquipedColor2; - typedef std::list SelectionListenerList; + typedef std::list SelectionListenerList; typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; int mGridColumns; diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 1094f5e29..fadea948a 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -47,7 +47,7 @@ const char *const Setup_Colors::rawmsg = Setup_Colors::Setup_Colors(const Widget2 *const widget) : SetupTab(widget), - gcn::SelectionListener(), + SelectionListener(), mColorBox(new ListBox(this, userPalette, "")), mScroll(new ScrollArea(mColorBox, true, "setup_colors_background.xml")), mPreview(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h index 38f0f2687..0bcc9c7f0 100644 --- a/src/gui/widgets/tabs/setup_colors.h +++ b/src/gui/widgets/tabs/setup_colors.h @@ -24,7 +24,7 @@ #include "gui/widgets/tabs/setuptab.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include @@ -37,7 +37,7 @@ class TextField; class TextPreview; class Setup_Colors final : public SetupTab, - public gcn::SelectionListener + public SelectionListener { public: explicit Setup_Colors(const Widget2 *const widget); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index aeef201e7..631fe3437 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -45,7 +45,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : Container(widget), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), MouseListener(), mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "") : nullptr), diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 0b613fce9..b472be579 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -29,7 +29,7 @@ #include "gui/widgets/button.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "localconsts.h" @@ -78,7 +78,7 @@ struct ButtonText final class WindowMenu final : public Container, public ConfigListener, public ActionListener, - public gcn::SelectionListener, + public SelectionListener, public MouseListener { public: diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 2d6d7d9db..def60b942 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -194,7 +194,7 @@ BuyDialog::BuyDialog() : // TRANSLATORS: buy dialog name Window(_("Create items"), false, nullptr, "buy.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(-2), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(), mSortModel(nullptr), mSortDropDown(nullptr) @@ -206,7 +206,7 @@ BuyDialog::BuyDialog(const int npcId) : // TRANSLATORS: buy dialog name Window(_("Buy"), false, nullptr, "buy.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(), mSortModel(nullptr), mSortDropDown(nullptr) @@ -218,7 +218,7 @@ BuyDialog::BuyDialog(std::string nick) : // TRANSLATORS: buy dialog name Window(_("Buy"), false, nullptr, "buy.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick), mSortModel(new SortListModelBuy), mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")) diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index ef51c04b2..9e493b91e 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class DropDown; @@ -46,7 +46,7 @@ class Slider; */ class BuyDialog final : public Window, public ActionListener, - public gcn::SelectionListener + public SelectionListener { public: /** diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 9e2c1a6ff..7066a9c8e 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -103,7 +103,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): Window("Inventory", false, nullptr, "inventory.xml"), ActionListener(), KeyListener(), - gcn::SelectionListener(), + SelectionListener(), InventoryListener(), mInventory(inventory), mItems(new ItemContainer(this, mInventory)), diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 066d0d6d5..2d5ec6191 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -31,7 +31,7 @@ #include "listeners/actionlistener.h" #include "listeners/keylistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class DropDown; @@ -53,7 +53,7 @@ class TextPopup; class InventoryWindow final : public Window, public ActionListener, public KeyListener, - public gcn::SelectionListener, + public SelectionListener, public InventoryListener, public DepricatedListener { diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 888a2432d..9db7bda27 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -54,7 +54,7 @@ SellDialog::SellDialog(const int npcId) : // TRANSLATORS: sell dialog name Window(_("Sell"), false, nullptr, "sell.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { init(); @@ -64,7 +64,7 @@ SellDialog::SellDialog(const std::string &nick): // TRANSLATORS: sell dialog name Window(_("Sell"), false, nullptr, "sell.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { init(); diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h index c23112f8a..f1747ca7e 100644 --- a/src/gui/windows/selldialog.h +++ b/src/gui/windows/selldialog.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class Item; @@ -43,7 +43,7 @@ class Slider; */ class SellDialog final : public Window, private ActionListener, - private gcn::SelectionListener + private SelectionListener { public: /** diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index a307b043e..32e838ac3 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -246,7 +246,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo, Window(_("Choose Your Server"), false, nullptr, "server.xml"), ActionListener(), KeyListener(), - gcn::SelectionListener(), + SelectionListener(), mMutex(), mDescription(new Label(this, std::string())), // TRANSLATORS: servers dialog button diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index afcdf1643..c01f8dd08 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -33,7 +33,7 @@ #include "listeners/actionlistener.h" #include "listeners/keylistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "gui/base/listmodel.hpp" @@ -94,7 +94,7 @@ class ServersListModel final : public gcn::ListModel class ServerDialog final : public Window, public ActionListener, public KeyListener, - public gcn::SelectionListener + public SelectionListener { public: /** diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 1485f18c9..7e50e4c37 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -72,7 +72,7 @@ ShopWindow::ShopWindow(): // TRANSLATORS: shop window name Window(_("Personal Shop"), false, nullptr, "shop.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), // TRANSLATORS: shop window button mCloseButton(new Button(this, _("Close"), "close", this)), mBuyShopItems(new ShopItems), diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 606080986..9149b79cb 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class CheckBox; @@ -44,7 +44,7 @@ class ShopListBox; */ class ShopWindow final : public Window, public ActionListener, - public gcn::SelectionListener + public SelectionListener { public: enum ShopMode diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 6a9f9a8af..a5b7f1a47 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -68,7 +68,7 @@ TradeWindow::TradeWindow(): // TRANSLATORS: trade window caption Window(_("Trade: You"), false, nullptr, "trade.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), mMyItemContainer(new ItemContainer(this, mMyInventory.get())), diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index 69ba64ed7..c5e1d7e8f 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include @@ -44,7 +44,7 @@ class TextField; */ class TradeWindow final : public Window, private ActionListener, - private gcn::SelectionListener + private SelectionListener { public: /** diff --git a/src/listeners/selectionlistener.h b/src/listeners/selectionlistener.h new file mode 100644 index 000000000..e258440e6 --- /dev/null +++ b/src/listeners/selectionlistener.h @@ -0,0 +1,114 @@ +/* + * The ManaPlus Client + * 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 . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name of Guichan nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef GCN_SELECTIONLISTENER_HPP +#define GCN_SELECTIONLISTENER_HPP + +#include + +#include "gui/base/selectionevent.hpp" + +#include "localconsts.h" + +/** + * Interface for listening for selection events from widgets. + * + * @see ListBox::addSelectionListener, + * ListBox::removeSelectionListener, + * DropDown::addSelectionListener, + * DropDown::removeSelectionListener + * @author Olof Naessén + * @since 0.8.0 + */ +class SelectionListener +{ + public: + /** + * Destructor. + */ + virtual ~SelectionListener() + { } + + /** + * Called when the value of a selection has been changed in a Widget. + * It is used to be able to recieve a notification that a value has + * been changed. + * + * @param event The event of the value change. + * @since 0.8.0 + */ + virtual void valueChanged(const gcn::SelectionEvent &event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of SelectionListener, + * therefore its constructor is protected. + */ + SelectionListener() + { } +}; + +#endif // end GCN_SELECTIONLISTENER_HPP -- cgit v1.2.3-70-g09d2