GG
|
00001 // -*- C++ -*- 00002 /* GG is a GUI for SDL and OpenGL. 00003 Copyright (C) 2003-2008 T. Zachary Laine 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public License 00007 as published by the Free Software Foundation; either version 2.1 00008 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00018 02111-1307 USA 00019 00020 If you do not wish to comply with the terms of the LGPL please 00021 contact the author as other terms are available for a fee. 00022 00023 Zach Laine 00024 whatwasthataddress@gmail.com */ 00025 00029 #ifndef _GG_SDLGUI_h_ 00030 #define _GG_SDLGUI_h_ 00031 00032 #include <GG/GUI.h> 00033 00034 #include <SDL/SDL.h> 00035 00036 00037 #ifdef _MSC_VER 00038 # ifdef GiGiSDL_EXPORTS 00039 # define GG_SDL_API __declspec(dllexport) 00040 # else 00041 # define GG_SDL_API __declspec(dllimport) 00042 # endif 00043 #else 00044 # define GG_SDL_API 00045 #endif 00046 00047 namespace GG { 00048 00082 class GG_SDL_API SDLGUI : public GG::GUI 00083 { 00084 public: 00086 explicit SDLGUI(int w = 1024, int h = 768, bool calc_FPS = false, const std::string& app_name = "GG"); 00087 virtual ~SDLGUI(); 00089 00091 virtual X AppWidth() const; 00092 virtual Y AppHeight() const; 00093 virtual unsigned int Ticks() const; 00095 00097 void operator()(); 00098 virtual void Exit(int code); 00099 00100 virtual void Enter2DMode() = 0; 00101 virtual void Exit2DMode() = 0; 00103 00104 static SDLGUI* GetGUI(); 00105 static GG::Key GGKeyFromSDLKey(const SDL_keysym& key); 00106 00107 protected: 00108 void SetAppSize(const GG::Pt& size); 00109 00110 // these are called at the beginning of the gui's execution 00111 virtual void SDLInit(); 00112 virtual void GLInit(); 00113 virtual void Initialize() = 0; 00114 00115 virtual void HandleSystemEvents(); 00116 virtual void HandleNonGGEvent(const SDL_Event& event); 00117 00118 virtual void RenderBegin(); 00119 virtual void RenderEnd(); 00120 00121 // these are called at the end of the gui's execution 00122 virtual void FinalCleanup(); 00123 virtual void SDLQuit(); 00124 00125 virtual void Run(); 00126 00127 private: 00128 X m_app_width; 00129 Y m_app_height; 00130 }; 00131 00132 } // namespace GG 00133 00134 #endif // _GG_SDLGUI_h_ 00135