1 /* _______ __ __ __ ______ __ __ _______ __ __ 2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ 3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / 4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / 5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / 6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / 7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ 8 * 9 * Copyright (c) 2004, 2005, 2006, 2007 Olof Naess�n and Per Larsson 10 * 11 * Js_./ 12 * Per Larsson a.k.a finalman _RqZ{a<^_aa 13 * Olof Naess�n a.k.a jansem/yakslem _asww7!uY`> )\a// 14 * _Qhm`] _f "'c 1!5m 15 * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ 16 * .)j(] .d_/ '-( P . S 17 * License: (BSD) <Td/Z <fP"5(\"??"\a. .L 18 * Redistribution and use in source and _dV>ws?a-?' ._/L #' 19 * binary forms, with or without )4d[#7r, . ' )d`)[ 20 * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' 21 * that the following conditions are met: j<<WP+k/);. _W=j f 22 * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ 23 * retain the above copyright notice, ]E.pYY(Q]>. a J@\ 24 * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a 25 * following disclaimer. 4'_uomm\. )L);-4 (3= 26 * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ 27 * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m 28 * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ 29 * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m 30 * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' 31 * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" 32 * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? 33 * names of its contributors may be used =3)= _f (_yQmWW$#( " 34 * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. 35 * from this software without specific (js, \[QQW$QWW#?!V"". 36 * prior written permission. ]y:.<\.. . 37 * -]n w/ ' [. 38 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! 39 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' 40 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % 41 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r 42 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La 43 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L 44 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a 45 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., 46 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" 47 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . 48 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, 49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ 50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 51 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 53 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 54 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 55 */ 56 57 #ifndef GCN_BASICCONTAINER_HPP 58 #define GCN_BASICCONTAINER_HPP 59 60 #include <list> 61 62 #include "guichan/deathlistener.hpp" 63 #include "guichan/platform.hpp" 64 #include "guichan/widget.hpp" 65 66 namespace gcn 67 { 68 /** 69 * Implements basic container behaviour. Most container will suffice by 70 * inheriting from this class. 71 * 72 * @see Container 73 */ 74 class GCN_CORE_DECLSPEC BasicContainer : public Widget, public DeathListener 75 { 76 public: 77 /** 78 * Destructor 79 */ 80 virtual ~BasicContainer(); 81 82 83 // Inherited from Widget 84 85 virtual void moveToTop(Widget* widget); 86 87 virtual void moveToBottom(Widget* widget); 88 89 virtual Rectangle getChildrenArea(); 90 91 virtual void focusNext(); 92 93 virtual void focusPrevious(); 94 95 virtual void logic(); 96 97 virtual void _setFocusHandler(FocusHandler* focusHandler); 98 99 virtual void setInternalFocusHandler(FocusHandler* focusHandler); 100 101 virtual void showWidgetPart(Widget* widget, Rectangle area); 102 103 virtual Widget *getWidgetAt(int x, int y); 104 105 106 // Inherited from DeathListener 107 108 virtual void death(const Event& event); 109 110 protected: 111 /** 112 * Adds a widget to the basic container. 113 * 114 * @param widget the widget to add. 115 */ 116 virtual void add(Widget* widget); 117 118 /** 119 * Removes a widget from the basic container. 120 * 121 * @param widget the widget to remove. 122 */ 123 virtual void remove(Widget* widget); 124 125 /** 126 * Clears the basic container from all widgets. 127 */ 128 virtual void clear(); 129 130 /** 131 * Draws children widgets. 132 * 133 * @param graphics a Graphics object to draw with. 134 */ 135 virtual void drawChildren(Graphics* graphics); 136 137 /** 138 * Calls logic for children widgets. 139 */ 140 virtual void logicChildren(); 141 142 typedef std::list<Widget *> WidgetList; 143 typedef WidgetList::iterator WidgetListIterator; 144 typedef WidgetList::reverse_iterator WidgetListReverseIterator; 145 146 WidgetList mWidgets; 147 }; 148 } 149 150 #endif // end GCN_BASICCONTAINER_HPP 151