CmWindowEventUtilities.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __OgreWindowEventUtils_H__
  25. #define __OgreWindowEventUtils_H__
  26. #include "CmPrerequisites.h"
  27. #include <boost/signals.hpp>
  28. #if CM_PLATFORM == CM_PLATFORM_WIN32
  29. # define WIN32_LEAN_AND_MEAN
  30. # if !defined(NOMINMAX) && defined(_MSC_VER)
  31. # define NOMINMAX // required to stop windows.h messing up std::min
  32. # endif
  33. # include <windows.h>
  34. # include <windowsx.h>
  35. #elif CM_PLATFORM == CM_PLATFORM_APPLE && !defined(__LP64__)
  36. # include <Carbon/Carbon.h>
  37. #endif
  38. #define WM_CM_HIDECURSOR WM_USER + 101
  39. #define WM_CM_SHOWCURSOR WM_USER + 102
  40. namespace CamelotFramework
  41. {
  42. /**
  43. @Remarks
  44. Utility class to handle Window Events/Pumping/Messages
  45. */
  46. class CM_EXPORT WindowEventUtilities
  47. {
  48. public:
  49. /**
  50. @Remarks
  51. Call this once per frame if not using Root:startRendering(). This will update all registered
  52. RenderWindows (If using external Windows, you can optionally register those yourself)
  53. */
  54. static void messagePump();
  55. /**
  56. @Remarks
  57. Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
  58. external windows here too if needed.
  59. @param window
  60. The RenderWindow to monitor
  61. */
  62. static void _addRenderWindow(RenderWindow* window);
  63. /**
  64. @Remarks
  65. Called by RenderWindows upon creation for Ogre generated windows. You are free to add your
  66. external windows here too if needed.
  67. @param window
  68. The RenderWindow to remove from list
  69. */
  70. static void _removeRenderWindow(RenderWindow* window);
  71. #if CM_PLATFORM == CM_PLATFORM_WIN32
  72. //! Internal winProc (RenderWindow's use this when creating the Win32 Window)
  73. static LRESULT CALLBACK _WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  74. #elif CM_PLATFORM == CM_PLATFORM_APPLE && !defined __OBJC__ && !defined(__LP64__)
  75. //! Internal UPP Window Handler (RenderWindow's use this when creating the OS X Carbon Window
  76. static OSStatus _CarbonWindowHandler(EventHandlerCallRef nextHandler, EventRef event, void* wnd);
  77. #endif
  78. typedef Vector<RenderWindow*>::type Windows;
  79. static Windows _msWindows;
  80. static boost::signal<void(const Int2&)> onMouseMoved;
  81. static boost::signal<void(float)> onMouseWheelScrolled;
  82. static boost::signal<void(UINT32)> onCharInput;
  83. };
  84. /** @} */
  85. /** @} */
  86. }
  87. #endif