00001 /* 00002 * Extended support for activating emotes 00003 * Copyright (C) 2009 Aethyra Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #ifndef EMOTECONTAINER_H 00023 #define EMOTECONTAINER_H 00024 00025 #include <list> 00026 #include <vector> 00027 00028 #include <guichan/mouselistener.hpp> 00029 #include <guichan/widget.hpp> 00030 #include <guichan/widgetlistener.hpp> 00031 00032 class AnimatedSprite; 00033 class Image; 00034 00035 namespace gcn { 00036 class SelectionListener; 00037 } 00038 00044 class EmoteContainer : public gcn::Widget, 00045 public gcn::MouseListener, 00046 public gcn::WidgetListener 00047 { 00048 public: 00052 EmoteContainer(); 00053 00057 virtual ~EmoteContainer(); 00058 00062 void draw(gcn::Graphics *graphics); 00063 00067 void widgetResized(const gcn::Event &event); 00068 00072 void mousePressed(gcn::MouseEvent &event); 00073 00077 int getSelectedEmote(); 00078 00082 void selectNone(); 00083 00088 void addSelectionListener(gcn::SelectionListener *listener) 00089 { 00090 mListeners.push_back(listener); 00091 } 00092 00097 void removeSelectionListener(gcn::SelectionListener *listener) 00098 { 00099 mListeners.remove(listener); 00100 } 00101 00102 private: 00107 void setSelectedEmoteIndex(int index); 00108 00112 void refindSelectedEmote(void); 00113 00117 void recalculateHeight(void); 00118 00122 void distributeValueChangedEvent(void); 00123 00124 std::vector<const AnimatedSprite*> mEmoteImg; 00125 Image *mSelImg; 00126 int mSelectedEmoteIndex; 00127 00128 int mMaxEmote; 00129 00130 std::list<gcn::SelectionListener*> mListeners; 00131 00132 static const int gridWidth; 00133 static const int gridHeight; 00134 }; 00135 00136 #endif