$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 /* _______ __ __ __ ______ __ __ _______ __ __ 00002 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ 00003 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / 00004 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / 00005 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / 00006 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / 00007 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ 00008 * 00009 * Copyright (c) 2004, 2005 darkbits Js_./ 00010 * Per Larsson a.k.a finalman _RqZ{a<^_aa 00011 * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a// 00012 * _Qhm`] _f "'c 1!5m 00013 * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[ 00014 * .)j(] .d_/ '-( P . S 00015 * License: (BSD) <Td/Z <fP"5(\"??"\a. .L 00016 * Redistribution and use in source and _dV>ws?a-?' ._/L #' 00017 * binary forms, with or without )4d[#7r, . ' )d`)[ 00018 * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam' 00019 * that the following conditions are met: j<<WP+k/);. _W=j f 00020 * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$ 00021 * retain the above copyright notice, ]E.pYY(Q]>. a J@\ 00022 * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a 00023 * following disclaimer. 4'_uomm\. )L);-4 (3= 00024 * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[ 00025 * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m 00026 * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/ 00027 * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m 00028 * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]' 00029 * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W" 00030 * 3. Neither the name of Guichan nor the :$we` _! + _/ . j? 00031 * names of its contributors may be used =3)= _f (_yQmWW$#( " 00032 * to endorse or promote products derived - W, sQQQQmZQ#Wwa].. 00033 * from this software without specific (js, \[QQW$QWW#?!V"". 00034 * prior written permission. ]y:.<\.. . 00035 * -]n w/ ' [. 00036 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ ! 00037 * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , ' 00038 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- % 00039 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r 00040 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La 00041 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L 00042 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a 00043 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'., 00044 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?" 00045 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. . 00046 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _, 00047 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^ 00048 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00049 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00050 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00051 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 00052 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00053 */ 00054 00055 #ifndef GCN_WIDGET_HPP 00056 #define GCN_WIDGET_HPP 00057 00058 #include <list> 00059 #include <string> 00060 00061 #include "guichan/actionlistener.h" 00062 #include "guichan/color.h" 00063 #include "guichan/defaultfont.h" 00064 #include "guichan/font.h" 00065 #include "guichan/graphics.h" 00066 #include "guichan/keyinput.h" 00067 #include "guichan/keylistener.h" 00068 #include "guichan/mouseinput.h" 00069 #include "guichan/mouselistener.h" 00070 #include "guichan/rectangle.h" 00071 #include "guichan/platform.h" 00072 00073 namespace gcn 00074 { 00075 /* 00076 * Exists for the widget class to compile. 00077 */ 00078 class FocusHandler; 00079 00080 /* 00081 * Exists for the widget class to compile. 00082 */ 00083 class BasicContainer; 00084 00093 class GCN_CORE_DECLSPEC Widget 00094 { 00095 public: 00101 Widget(); 00102 00106 virtual ~Widget(); 00107 00117 virtual void draw(Graphics* graphics) = 0; 00118 00127 virtual void drawBorder(Graphics*) { } 00128 00135 virtual void logic() { } 00136 00143 virtual BasicContainer* getParent() const; 00144 00150 virtual void setWidth(int width); 00151 00157 virtual int getWidth() const; 00158 00164 virtual void setHeight(int height); 00165 00171 virtual int getHeight() const; 00172 00179 virtual void setSize(int width, int height); 00180 00186 virtual void setX(int x); 00187 00193 virtual int getX() const; 00194 00200 virtual void setY(int y); 00201 00207 virtual int getY() const; 00208 00215 virtual void setPosition(int x, int y); 00216 00222 virtual void setDimension(const Rectangle& dimension); 00223 00232 virtual void setBorderSize(unsigned int borderSize); 00233 00242 virtual unsigned int getBorderSize() const; 00243 00249 virtual const Rectangle& getDimension() const; 00250 00256 virtual void setFocusable(bool focusable); 00257 00263 virtual bool isFocusable() const; 00264 00270 virtual bool hasFocus() const; 00271 00278 virtual void setEnabled(bool enabled); 00279 00285 virtual bool isEnabled() const; 00286 00290 virtual void lostFocus() { setDirty(true); }; 00291 00295 virtual void gotFocus() { setDirty(true); }; 00296 00302 virtual bool hasMouse() const; 00303 00309 virtual void setVisible(bool visible); 00310 00316 virtual bool isVisible() const; 00317 00324 virtual void setBaseColor(const Color& color); 00325 00331 virtual const Color& getBaseColor() const; 00332 00338 virtual void setForegroundColor(const Color& color); 00339 00345 virtual const Color& getForegroundColor() const; 00346 00352 virtual void setBackgroundColor(const Color& color); 00353 00359 virtual const Color& getBackgroundColor() const; 00360 00366 virtual void setDisabledColor(const Color& color); 00367 00373 virtual const Color& getDisabledColor() const; 00374 00384 virtual void _mouseInputMessage(const MouseInput& mouseInput); 00385 00395 virtual bool _keyInputMessage(const KeyInput& keyInput); 00396 00400 virtual void hotKeyPress() {} 00401 00405 virtual void hotKeyRelease() {} 00406 00414 virtual void _mouseInMessage(); 00415 00423 virtual void _mouseOutMessage(); 00424 00429 virtual void requestFocus(); 00430 00434 virtual void requestMoveToTop(); 00435 00439 virtual void requestMoveToBottom(); 00440 00450 virtual void _setFocusHandler(FocusHandler* focusHandler); 00451 00461 virtual FocusHandler* _getFocusHandler(); 00462 00470 virtual void addActionListener(ActionListener* actionListener); 00471 00477 virtual void removeActionListener(ActionListener* actionListener); 00478 00485 virtual void addMouseListener(MouseListener* mouseListener); 00486 00492 virtual void removeMouseListener(MouseListener* mouseListener); 00493 00500 virtual void addKeyListener(KeyListener* keyListener); 00501 00507 virtual void removeKeyListener(KeyListener* keyListener); 00508 00520 virtual void setEventId(const std::string& eventId); 00521 00527 virtual const std::string& getEventId() const; 00528 00535 virtual void getAbsolutePosition(int& x, int& y) const; 00536 00546 virtual void _setParent(BasicContainer* parent); 00547 00556 Font *getFont() const; 00557 00563 static void setGlobalFont(Font* font); 00564 00570 virtual void setFont(Font* font); 00571 00577 virtual void fontChanged() { } 00578 00582 virtual int getHotKey() const { return mHotKey; } 00583 00587 virtual void setHotKey(const int key); 00588 virtual void setHotKey(const char *key); 00589 00596 static bool widgetExists(const Widget* widget); 00597 00606 virtual bool isTabInEnabled() const; 00607 00616 virtual void setTabInEnabled(bool enabled); 00617 00626 virtual bool isTabOutEnabled() const; 00627 00636 virtual void setTabOutEnabled(bool enabled); 00637 00645 virtual bool isDragged() const; 00646 00654 virtual void requestModalFocus(); 00655 00660 virtual void releaseModalFocus(); 00661 00665 virtual bool hasModalFocus() const; 00666 00667 virtual void setDirty(bool dirty); 00668 virtual bool getDirty() const; 00669 00670 00671 protected: 00675 void generateAction(); 00676 00677 typedef std::list<MouseListener*> MouseListenerList; 00678 MouseListenerList mMouseListeners; 00679 typedef MouseListenerList::iterator MouseListenerIterator; 00680 00681 typedef std::list<KeyListener*> KeyListenerList; 00682 KeyListenerList mKeyListeners; 00683 typedef KeyListenerList::iterator KeyListenerIterator; 00684 00685 typedef std::list<ActionListener*> ActionListenerList; 00686 ActionListenerList mActionListeners; 00687 typedef ActionListenerList::iterator ActionListenerIterator; 00688 00689 Color mForegroundColor; 00690 Color mBackgroundColor; 00691 Color mBaseColor; 00692 Color mDisabledColor; 00693 FocusHandler* mFocusHandler; 00694 BasicContainer* mParent; 00695 Rectangle mDimension; 00696 unsigned int mBorderSize; 00697 std::string mEventId; 00698 int mClickTimeStamp; 00699 int mClickCount; 00700 int mClickButton; 00701 bool mHasMouse; 00702 bool mFocusable; 00703 bool mVisible; 00704 bool mTabIn; 00705 bool mTabOut; 00706 bool mEnabled; 00707 00708 Font* mCurrentFont; 00709 int mHotKey; 00710 static DefaultFont mDefaultFont; 00711 static Font* mGlobalFont; 00712 static std::list<Widget*> mWidgets; 00713 bool mDirty; 00714 }; 00715 } 00716 00717 #endif // end GCN_WIDGET_HPP 00718 00719 /* 00720 * yakslem - "I have a really great idea! Why not have an 00721 * interesting and funny quote or story at the 00722 * end of every source file." 00723 * finalman - "Yeah - good idea! .... do you know any funny 00724 * quotes?" 00725 * yakslem - "Well.. I guess not. I just thought it would be 00726 * fun to tell funny quotes." 00727 * finalman - "That's not a very funny quote. But i believe 00728 * pointless quotes are funny in their own pointless 00729 * way." 00730 * yakslem - "...eh...ok..." 00731 */