GG: SDLGUI.h Source File

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

SDLGUI.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3 Copyright (C) 2003-2008 T. Zachary Laine
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License
7 as published by the Free Software Foundation; either version 2.1
8 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA
19
20 If you do not wish to comply with the terms of the LGPL please
21 contact the author as other terms are available for a fee.
22
23 Zach Laine
24 whatwasthataddress@gmail.com */
25
29 #ifndef _GG_SDLGUI_h_
30 #define _GG_SDLGUI_h_
31
32 #include <GG/GUI.h>
33
34 #include <SDL/SDL.h>
35
36
37 #ifdef _MSC_VER
38 # ifdef GiGiSDL_EXPORTS
39 # define GG_SDL_API __declspec(dllexport)
40 # else
41 # define GG_SDL_API __declspec(dllimport)
42 # endif
43 #else
44 # define GG_SDL_API
45 #endif
46
47 namespace GG {
48
82 class GG_SDL_API SDLGUI : public GG::GUI
83 {
84 public:
86 explicit SDLGUI(int w = 1024, int h = 768, bool calc_FPS = false, const std::string& app_name = "GG");
87 virtual ~SDLGUI();
89
91 virtual X AppWidth() const;
92 virtual Y AppHeight() const;
93 virtual unsigned int Ticks() const;
95
97 void operator()();
98 virtual void Exit(int code);
99
100 virtual void Enter2DMode() = 0;
101 virtual void Exit2DMode() = 0;
103
104 static SDLGUI* GetGUI();
105 static GG::Key GGKeyFromSDLKey(const SDL_keysym& key);
106
107 protected:
108 void SetAppSize(const GG::Pt& size);
109
110 // these are called at the beginning of the gui's execution
111 virtual void SDLInit();
112 virtual void GLInit();
113 virtual void Initialize() = 0;
114
115 virtual void HandleSystemEvents();
116 virtual void HandleNonGGEvent(const SDL_Event& event);
117
118 virtual void RenderBegin();
119 virtual void RenderEnd();
120
121 // these are called at the end of the gui's execution
122 virtual void FinalCleanup();
123 virtual void SDLQuit();
124
125 virtual void Run();
126
127 private:
128 X m_app_width;
129 Y m_app_height;
130 };
131
132 } // namespace GG
133
134 #endif
135