GG: OgreGUI.h Source File

GG

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

- File List
- File Members

OgreGUI.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3 Copyright (C) 2007 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_OgreGUI_h_
30 #define _GG_OgreGUI_h_
31
32 #ifdef __APPLE__
33 /* prevents OpenTransportProviders.h (a system header in Mac SDKs)
34 from trying to enum what's already defined by related headers */
35 #undef TCP_NODELAY
36 #undef TCP_MAXSEG
37 #undef TCP_NOTIFY_THRESHOLD
38 #undef TCP_ABORT_THRESHOLD
39 #undef TCP_CONN_NOTIFY_THRESHOLD
40 #undef TCP_CONN_ABORT_THRESHOLD
41 #undef TCP_OOBINLINE
42 #undef TCP_URGENT_PTR_TYPE
43 #undef TCP_KEEPALIVE
44 #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 // workaround by Apple to avoid conflicting macro names, fixes compile error
45 #include <Carbon/Carbon.h>
46 #endif
47
48 #include <OgreDataStream.h>
49 #include <OgreRenderTargetListener.h>
50 #include <OgreSharedPtr.h>
51 #include <OgreTimer.h>
52 #include <OgreWindowEventUtilities.h>
53
54 #include <GG/GUI.h>
55
56 #include <boost/filesystem/path.hpp>
57
58 #ifdef _MSC_VER
59 # ifdef GiGiOgre_EXPORTS
60 # define GG_OGRE_API __declspec(dllexport)
61 # else
62 # define GG_OGRE_API __declspec(dllimport)
63 # endif
64 #else
65 # define GG_OGRE_API
66 #endif
67
68 namespace Ogre {
69 class RenderWindow;
70 }
71
72 namespace GG {
73
125 class GG_OGRE_API OgreGUI :
126 public GUI,
127 public Ogre::RenderTargetListener,
128 public Ogre::WindowEventListener
129 {
130 public:
134 explicit OgreGUI(Ogre::RenderWindow* window,
135 const boost::filesystem::path& config_file_path = boost::filesystem::path());
136
138 virtual ~OgreGUI();
139
141 virtual boost::shared_ptr<ModalEventPump> CreateModalEventPump(bool& done);
142
143 virtual unsigned int Ticks() const;
144 virtual X AppWidth() const;
145 virtual Y AppHeight() const;
146
150 const Ogre::SharedPtr<Ogre::DataStream>& ConfigFileStream() const;
151
152 Ogre::RenderWindow* GetRenderWindow() const { return m_window; }
153
154 virtual void Exit(int code);
155
158 boost::signal<void ()> HandleSystemEventsSignal;
159
161 boost::signal<void (X, Y)> WindowMovedSignal;
162
164 boost::signal<void (X, Y)> WindowResizedSignal;
165
168 boost::signal<void ()> WindowClosingSignal;
169
172 boost::signal<void ()> WindowClosedSignal;
173
176 boost::signal<void ()> FocusChangedSignal;
177
179 static OgreGUI* GetGUI();
180
181 protected:
182 virtual void RenderBegin();
183 virtual void RenderEnd();
184 virtual void Run();
185 virtual void HandleSystemEvents();
186 virtual void Enter2DMode();
187 virtual void Exit2DMode();
188
189 private:
190 virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& event);
191 virtual void windowMoved(Ogre::RenderWindow* window);
192 virtual void windowResized(Ogre::RenderWindow* window);
193 virtual bool windowClosing(Ogre::RenderWindow* window);
194 virtual void windowClosed(Ogre::RenderWindow* window);
195 virtual void windowFocusChange(Ogre::RenderWindow* window);
196
197 Ogre::RenderWindow* m_window;
198 mutable Ogre::Timer m_timer;
199 Ogre::SharedPtr<Ogre::DataStream> m_config_file_data;
200 };
201
202 } // namespace GG
203
204 #endif