Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreWindowEventUtilities.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 5.8 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __OgreWindowEventUtils_H__
29#define __OgreWindowEventUtils_H__
30
31#include "OgrePrerequisites.h"
32#include "OgrePlatform.h"
33#include "OgreCommon.h"
34#include "OgreHeaderPrefix.h"
35
36#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
37#  if !defined(WIN32_LEAN_AND_MEAN)
38#   define WIN32_LEAN_AND_MEAN
39#  endif
40#  if !defined(NOMINMAX) && defined(_MSC_VER)
41#       define NOMINMAX // required to stop windows.h messing up std::min
42#  endif
43#  include <windows.h>
44#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && !defined(__LP64__)
45#  include <Carbon/Carbon.h>
46#endif
47
48
49
50namespace Ogre
51{
52        /** \addtogroup Core
53        *  @{
54        */
55        /** \addtogroup RenderSystem
56        *  @{
57        */
58        /**
59        @remarks
60                Callback class used to send out window events to client app
61        */
62        class _OgreExport WindowEventListener
63        {
64        public:
65                virtual ~WindowEventListener() {}
66
67                /**
68                @remarks
69                        Window has moved position
70                @param rw
71                        The RenderWindow which created this events
72                */
73                virtual void windowMoved(RenderWindow* rw)
74                { (void)rw; }
75
76                /**
77                @remarks
78                        Window has resized
79                @param rw
80                        The RenderWindow which created this events
81                */
82                virtual void windowResized(RenderWindow* rw)
83                { (void)rw; }
84
85                /**
86                @remarks
87                        Window is closing (Only triggered if user pressed the [X] button)
88                @param rw
89                        The RenderWindow which created this events
90                @return True will close the window(default).
91                */
92                virtual bool windowClosing(RenderWindow* rw)
93                { (void)rw; return true; }
94
95                /**
96                @remarks
97                        Window has been closed (Only triggered if user pressed the [X] button)
98                @param rw
99                        The RenderWindow which created this events
100                @note
101                        The window has not actually close yet when this event triggers. It's only closed after
102                        all windowClosed events are triggered. This allows apps to deinitialise properly if they
103                        have services that needs the window to exist when deinitialising.
104                */
105                virtual void windowClosed(RenderWindow* rw)
106                { (void)rw; }
107
108                /**
109                @remarks
110                        Window has lost/gained focus
111                @param rw
112                        The RenderWindow which created this events
113                */
114                virtual void windowFocusChange(RenderWindow* rw)
115                { (void)rw; }
116        };
117
118        /**
119        @remarks
120                Utility class to handle Window Events/Pumping/Messages
121        */
122        class _OgreExport WindowEventUtilities
123        {
124        public:
125                /**
126                @remarks
127                        Call this once per frame if not using Root:startRendering(). This will update all registered
128                        RenderWindows (If using external Windows, you can optionally register those yourself)
129                */
130                static void messagePump();
131
132                /**
133                @remarks
134                        Add a listener to listen to renderwindow events (multiple listener's per renderwindow is fine)
135                        The same listener can listen to multiple windows, as the Window Pointer is sent along with
136                        any messages.
137                @param window
138                        The RenderWindow you are interested in monitoring
139                @param listener
140                        Your callback listener
141                */
142                static void addWindowEventListener( RenderWindow* window, WindowEventListener* listener );
143
144                /**
145                @remarks
146                        Remove previously added listener
147                @param window
148                        The RenderWindow you registered with
149                @param listener
150                        The listener registered
151                */
152                static void removeWindowEventListener( RenderWindow* window, WindowEventListener* listener );
153
154                /**
155                @remarks
156                        Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
157                        external windows here too if needed.
158                @param window
159                        The RenderWindow to monitor
160                */
161                static void _addRenderWindow(RenderWindow* window);
162
163                /**
164                @remarks
165                        Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
166                        external windows here too if needed.
167                @param window
168                        The RenderWindow to remove from list
169                */
170                static void _removeRenderWindow(RenderWindow* window);
171
172#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
173                //! Internal winProc (RenderWindow's use this when creating the Win32 Window)
174                static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
175#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && !defined __OBJC__ && !defined(__LP64__)
176        //! Internal UPP Window Handler (RenderWindow's use this when creating the OS X Carbon Window
177        static OSStatus _CarbonWindowHandler(EventHandlerCallRef nextHandler, EventRef event, void* wnd);
178#endif
179
180                //These are public only so GLXProc can access them without adding Xlib headers header
181                typedef multimap<RenderWindow*, WindowEventListener*>::type WindowEventListeners;
182                static WindowEventListeners _msListeners;
183                static RenderWindowList _msWindows;
184        };
185        /** @} */
186        /** @} */
187}
188
189#include "OgreHeaderSuffix.h"
190
191#endif
Note: See TracBrowser for help on using the repository browser.