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_WINDOW_HPP 58 #define GCN_WINDOW_HPP 59 60 #include <string> 61 62 #include "guichan/mouselistener.hpp" 63 #include "guichan/platform.hpp" 64 #include "guichan/widgets/container.hpp" 65 66 namespace gcn 67 { 68 /** 69 * A movable window which can contain another Widgets. 70 */ 71 class GCN_CORE_DECLSPEC Window : public Container, 72 public MouseListener 73 { 74 public: 75 /** 76 * Constructor. 77 */ 78 Window(); 79 80 /** 81 * Constructor. 82 * 83 * @param caption the Window caption. 84 */ 85 Window(const std::string& caption); 86 87 /** 88 * Destructor. 89 */ 90 virtual ~Window(); 91 92 /** 93 * Sets the Window caption. 94 * 95 * @param caption the Window caption. 96 */ 97 virtual void setCaption(const std::string& caption); 98 99 /** 100 * Gets the Window caption. 101 * 102 * @return the Window caption. 103 */ 104 virtual const std::string& getCaption() const; 105 106 /** 107 * Sets the alignment for the caption. 108 * 109 * @param alignment Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT. 110 */ 111 virtual void setAlignment(unsigned int alignment); 112 113 /** 114 * Gets the alignment for the caption. 115 * 116 * @return alignment of caption. 117 */ 118 virtual unsigned int getAlignment() const; 119 120 /** 121 * Sets the padding of the window which is the distance between the 122 * window border and the content. 123 * 124 * @param padding the padding value. 125 */ 126 virtual void setPadding(unsigned int padding); 127 128 /** 129 * Gets the padding. 130 * 131 * @return the padding value. 132 */ 133 virtual unsigned int getPadding() const; 134 135 /** 136 * Sets the title bar height. 137 * 138 * @param height the title height value. 139 */ 140 virtual void setTitleBarHeight(unsigned int height); 141 142 /** 143 * Gets the title bar height. 144 * 145 * @return the title bar height. 146 */ 147 virtual unsigned int getTitleBarHeight(); 148 149 /** 150 * Sets the Window to be moveble. 151 * 152 * @param movable true or false. 153 */ 154 virtual void setMovable(bool movable); 155 156 /** 157 * Check if the window is movable. 158 * 159 * @return true or false. 160 */ 161 virtual bool isMovable() const; 162 163 /** 164 * Sets the Window to be opaque. If it's not opaque, the content area 165 * will not be filled with a color. 166 * 167 * @param opaque true or false. 168 */ 169 virtual void setOpaque(bool opaque); 170 171 /** 172 * Checks if the Window is opaque. 173 * 174 * @return true or false. 175 */ 176 virtual bool isOpaque(); 177 178 /** 179 * Resizes the container to fit the content exactly. 180 */ 181 virtual void resizeToContent(); 182 183 184 // Inherited from BasicContainer 185 186 virtual Rectangle getChildrenArea(); 187 188 189 // Inherited from Widget 190 191 virtual void draw(Graphics* graphics); 192 193 virtual void drawBorder(Graphics* graphics); 194 195 196 // Inherited from MouseListener 197 198 virtual void mousePressed(MouseEvent& mouseEvent); 199 200 virtual void mouseDragged(MouseEvent& mouseEvent); 201 202 protected: 203 std::string mCaption; 204 unsigned int mAlignment; 205 unsigned int mPadding; 206 unsigned int mTitleBarHeight; 207 bool mMovable; 208 bool mOpaque; 209 int mDragOffsetX; 210 int mDragOffsetY; 211 bool mIsMoving; 212 }; 213 } 214 215 #endif // end GCN_WINDOW_HPP 216