GG
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  virtual void Exit(int code);
153 
156  boost::signal<void ()> HandleSystemEventsSignal;
157 
159  boost::signal<void (X, Y)> WindowResizedSignal;
160 
163  boost::signal<void ()> WindowClosedSignal;
164 
166  static OgreGUI* GetGUI();
167 
168 protected:
169  virtual void RenderBegin();
170  virtual void RenderEnd();
171  virtual void Run();
172  virtual void HandleSystemEvents();
173  virtual void Enter2DMode();
174  virtual void Exit2DMode();
175 
176 private:
177  virtual void postRenderTargetUpdate(const Ogre::RenderTargetEvent& event);
178  virtual void windowResized(Ogre::RenderWindow* window);
179  virtual void windowClosed(Ogre::RenderWindow* window);
180 
181  Ogre::RenderWindow* m_window;
182  mutable Ogre::Timer m_timer;
183  Ogre::SharedPtr<Ogre::DataStream> m_config_file_data;
184 };
185 
186 } // namespace GG
187 
188 #endif