IMessaging.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. //-----------------------------------------------------------------------------
  19. //
  20. // $LogFile$
  21. // $Revision: 1.1.2.1 $
  22. // $Author: ttimo $
  23. // $Date: 2000/02/04 22:59:34 $
  24. // $Log: IMessaging.h,v $
  25. // Revision 1.1.2.1 2000/02/04 22:59:34 ttimo
  26. // messaging API preview
  27. //
  28. //
  29. // DESCRIPTION:
  30. // interface for all-purpose messaging in Radiant
  31. #ifndef __IMESSAGING_H_
  32. #define __IMESSAGING_H_
  33. // this one can be hooked in the GL window procs for customizing GUI through plugins
  34. class IWindowListener
  35. {
  36. public:
  37. // Increment the number of references to this object
  38. virtual void IncRef () = 0;
  39. // Decrement the reference count
  40. virtual void DecRef () = 0;
  41. // since Radiant is MFC we don't use a WNDPROC, we wrap the MFC handlers
  42. // the handler is called first, if returns false Radiant continues processing
  43. //++timo maybe add more later ? OnKeyUp and OnKeyDown for instance
  44. //++timo TODO: add handlers everywhere
  45. virtual bool OnLButtonDown(UINT nFlags, int x, int y) = 0;
  46. virtual bool OnMButtonDown(UINT nFlags, int x, int y) = 0;
  47. virtual bool OnRButtonDown(UINT nFlags, int x, int y) = 0;
  48. virtual bool OnLButtonUp(UINT nFlags, int x, int y) = 0;
  49. virtual bool OnMButtonUp(UINT nFlags, int x, int y) = 0;
  50. virtual bool OnRButtonUp(UINT nFlags, int x, int y) = 0;
  51. virtual bool OnMouseMove(UINT nFlags, int x, int y) = 0;
  52. };
  53. // various Radiant messages --------
  54. // this one holds the total number of supported messages (this is used to allocate structs)
  55. #define RADIANT_MSGCOUNT 3
  56. // they start with a 0, can be indexed in an array
  57. // something was selected / deselected
  58. #define RADIANT_SELECTION 0
  59. // a brush face was selected / deselected
  60. #define RADIANT_SFACE 1
  61. // current texture / shader changed
  62. #define RADIANT_TEXTURE 2
  63. // this one can be used to listen for Radiant-specific events
  64. class IListener
  65. {
  66. public:
  67. // Increment the number of references to this object
  68. virtual void IncRef () = 0;
  69. // Decrement the reference count
  70. virtual void DecRef () = 0;
  71. // message is one of the RADIANT_* consts
  72. virtual void DispatchRadiantMsg( int Msg ) = 0;
  73. };
  74. // this one is provided by Radiant, it's a wrapper for some usefull functions
  75. class IXYWndWrapper
  76. {
  77. public:
  78. virtual void SnapToGrid( int x1, int y1, vec3_t pt ) = 0;
  79. };
  80. // define a GUID for this interface so plugins can access and reference it
  81. // {41FD005C-D36B-11d3-A3E9-0004AC96D4C3}
  82. static const GUID QERMessaging_GUID =
  83. { 0x41fd005c, 0xd36b, 0x11d3, { 0xa3, 0xe9, 0x0, 0x4, 0xac, 0x96, 0xd4, 0xc3 } };
  84. // will hook the given IWindowListener to the XY window and increment the ref count
  85. //++timo TODO: add hooking in the CAM view and Z view
  86. typedef void (WINAPI* PFN_QERAPP_HOOKWINDOW) (IWindowListener *);
  87. // will unhook the given IWindowListener
  88. typedef void (WINAPI* PFN_QERAPP_UNHOOKWINDOW) (IWindowListener *);
  89. // to retrieve the IXYWndWrapper
  90. typedef IXYWndWrapper* (WINAPI* PFN_QERAPP_GETXYWNDWRAPPER) ();
  91. // will hook a given listener into Radiant listening for the given message and increment ref count
  92. // call several times to listen for several messages
  93. typedef void (WINAPI* PFN_QERAPP_HOOKLISTENER) (IListener *, int Msg);
  94. // will unhook the listener and return the number of messages the given listener was removed from
  95. typedef int (WINAPI* PFN_QERAPP_UNHOOKLISTENER)(IListener *);
  96. struct _QERMessagingTable
  97. {
  98. int m_nSize;
  99. PFN_QERAPP_HOOKWINDOW m_pfnHookWindow;
  100. PFN_QERAPP_UNHOOKWINDOW m_pfnUnHookWindow;
  101. PFN_QERAPP_GETXYWNDWRAPPER m_pfnGetXYWndWrapper;
  102. PFN_QERAPP_HOOKLISTENER m_pfnHookListener;
  103. PFN_QERAPP_UNHOOKLISTENER m_pfnUnHookListener;
  104. };
  105. #endif