Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreWindowEventUtilities.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 4.5 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-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __OgreWindowEventUtils_H__
30#define __OgreWindowEventUtils_H__
31
32#include "OgrePrerequisites.h"
33#include "OgrePlatform.h"
34
35#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
36#  define WIN32_LEAN_AND_MEAN
37#  include <windows.h>
38#endif
39
40namespace Ogre
41{
42        /**
43        @Remarks
44                Callback class used to send out window events to client app
45        */
46        class _OgreExport WindowEventListener
47        {
48        public:
49                virtual ~WindowEventListener() {};
50
51                /**
52                @Remarks
53                        Window has moved position
54                @param rw
55                        The RenderWindow which created this events
56                */
57                virtual void windowMoved(RenderWindow* rw)   {}
58
59                /**
60                @Remarks
61                        Window has resized
62                @param rw
63                        The RenderWindow which created this events
64                */
65                virtual void windowResized(RenderWindow* rw) {}
66
67                /**
68                @Remarks
69                        Window has been closed
70                @param rw
71                        The RenderWindow which created this events
72                */
73                virtual void windowClosed(RenderWindow* rw)  {}
74
75                /**
76                @Remarks
77                        Window has lost/gained focuw
78                @param rw
79                        The RenderWindow which created this events
80                */
81                virtual void windowFocusChange(RenderWindow* rw) {}
82        };
83
84        /**
85        @Remarks
86                Utility class to handle Window Events/Pumping/Messages
87        */
88        class _OgreExport WindowEventUtilities
89        {
90        public:
91                /**
92                @Remarks
93                        Call this once per frame if not using Root:startRendering(). This will update all registered
94                        RenderWindows (If using external Windows, you can optionally register those yourself)
95                */
96                static void messagePump();
97
98                /**
99                @Remarks
100                        Add a listener to listen to renderwindow events (multiple listener's per renderwindow is fine)
101                        The same listener can listen to multiple windows, as the Window Pointer is sent along with
102                        any messages.
103                @param window
104                        The RenderWindow you are interested in monitoring
105                @param listner
106                        Your callback listener
107                */
108                static void addWindowEventListener( RenderWindow* window, WindowEventListener* listener );
109
110                /**
111                @Remarks
112                        Remove previously added listener
113                @param window
114                        The RenderWindow you registered with
115                @param listner
116                        The listener registered
117                */
118                static void removeWindowEventListener( RenderWindow* window, WindowEventListener* listener );
119
120                /**
121                @Remarks
122                        Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
123                        external windows here too if needed.
124                @param window
125                        The RenderWindow to monitor
126                */
127                static void _addRenderWindow(RenderWindow* window);
128
129                /**
130                @Remarks
131                        Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
132                        external windows here too if needed.
133                @param window
134                        The RenderWindow to remove from list
135                */
136                static void _removeRenderWindow(RenderWindow* window);
137
138#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
139                //! Internal winProc (RenderWindow's use this when creating the Win32 Window)
140                static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
141#endif
142
143                //These are public only so GLXProc can access them without adding Xlib headers header
144                typedef std::multimap<RenderWindow*, WindowEventListener*> WindowEventListeners;
145                static WindowEventListeners _msListeners;
146
147                typedef std::vector<RenderWindow*> Windows;
148                static Windows _msWindows;
149        };
150}
151#endif
Note: See TracBrowser for help on using the repository browser.