00001 /********************************************************************************/ 00002 /* */ 00003 /* Netrinjo-Engine - a library for game-development */ 00004 /* Copyright (C) 1999, 2000, 2005 by Tobias Nadler and Georg Schnattinger */ 00005 /* */ 00006 /* This library is free software; you can redistribute it and/or */ 00007 /* modify it under the terms of the GNU Lesser General Public */ 00008 /* License as published by the Free Software Foundation; either */ 00009 /* version 2.1 of the License, or (at your option) any later version. */ 00010 /* */ 00011 /* This library is distributed in the hope that it will be useful, */ 00012 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 00013 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 00014 /* Lesser General Public License for more details. */ 00015 /* */ 00016 /* You should have received a copy of the GNU Lesser General Public */ 00017 /* License along with this library; if not, write to the Free Software */ 00018 /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00019 /* */ 00020 /********************************************************************************/ 00021 00022 #ifndef GUIMANAGER_H 00023 #define GUIMANAGER_H 00024 00025 #include <list> 00026 #include "SDL/SDL.h" 00027 #include "uiobject.h" 00028 #include "tinyxml.h" 00029 00036 class GuiElement; 00037 class UiManager; 00038 00046 class DECLSPEC GuiManager : public UiObject 00047 { 00048 public: 00055 DECLSPEC GuiManager( UiManager *parent, const char *name = "GuiManager" ); 00056 virtual DECLSPEC ~GuiManager(); 00057 00058 virtual const char *getClassName() { return "GuiManager"; } 00081 DECLSPEC bool init(TiXmlElement *el = NULL); 00087 DECLSPEC void setBaseElements(GuiElement *front, GuiElement *main); 00089 GuiElement *getFront() {return geFront;} 00091 GuiElement *getMain() {return geMain;} 00099 DECLSPEC void focus(GuiElement *el); 00105 DECLSPEC bool release(GuiElement *el); 00107 GuiElement *getFocus() {return geMouseFocus;} 00112 DECLSPEC void setCursor(GuiElement *cur); 00114 GuiElement *getCursor() { return geCursor; } 00121 DECLSPEC void cleanupElement(GuiElement *ge); 00122 00126 static GuiManager *the; 00134 DECLSPEC static GuiManager *getThe(); 00135 protected: 00136 virtual Uint32 onKeyDown( SDL_KeyboardEvent *ev ) {return 0;} 00137 virtual Uint32 onKeyUp( SDL_KeyboardEvent *ev ) {return 0;} 00138 virtual DECLSPEC Uint32 onMouseDown( SDL_MouseButtonEvent *ev ); 00139 virtual DECLSPEC Uint32 onMouseUp( SDL_MouseButtonEvent *ev ); 00140 virtual DECLSPEC Uint32 onMouseMotion(SDL_MouseMotionEvent *ev); 00141 virtual DECLSPEC Uint32 onFocus(FocusTypes gained); 00142 virtual DECLSPEC Uint32 onRelease(FocusTypes lost); 00143 virtual DECLSPEC Uint32 onFrame(); 00144 virtual Uint32 onThemeChanged( UiTheme *t ) {return 0;} 00145 virtual DECLSPEC void onDestroy(); 00146 00147 private: 00148 Uint32 nDisplayWidth; 00149 Uint32 nDisplayHeight; 00150 00151 // base element for the windows, buttons,... 00152 GuiElement *geMain; 00153 // base element for objects that appear in front of the windows: cursor, hints,... 00154 GuiElement *geFront; 00155 // the element, that currently has the mouse focus (changes when focus() or release() is called) 00156 GuiElement *geMouseFocus; 00157 // the element, over which the curser is 00158 GuiElement *geMouseOver; 00159 // the element that shows the mouse cursor 00160 GuiElement *geCursor; 00161 // currenly owning focustypes of UiManager 00162 FocusTypes ftCaptured; 00163 }; 00164 00165 #endif