MOUSE.H 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /***********************************************************************************************
  15. * *
  16. * Project Name : Westwood 32 Bit Library *
  17. * *
  18. * File Name : MOUSE.H *
  19. * *
  20. * Programmer : Philip W. Gorrow *
  21. * *
  22. * Start Date : 12/12/95 *
  23. * *
  24. * Last Update : December 12, 1995 [PWG] *
  25. * *
  26. *---------------------------------------------------------------------------------------------*
  27. * Functions: *
  28. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  29. #ifndef WW_MOUSE_H
  30. #define WW_MOUSE_H
  31. #include <gbuffer.h>
  32. class WWMouseClass {
  33. public:
  34. WWMouseClass(GraphicViewPortClass *scr, int mouse_max_width, int mouse_max_height);
  35. ~WWMouseClass();
  36. void *Set_Cursor(int xhotspot, int yhotspot, void *cursor);
  37. void Process_Mouse(void);
  38. void Hide_Mouse(void);
  39. void Show_Mouse(void);
  40. void Conditional_Hide_Mouse(int x1, int y1, int x2, int y2);
  41. void Conditional_Show_Mouse(void);
  42. int Get_Mouse_State(void);
  43. int Get_Mouse_X(void);
  44. int Get_Mouse_Y(void);
  45. void Get_Mouse_XY(int &x, int &y);
  46. //
  47. // The following two routines can be used to render the mouse onto a graphicbuffer
  48. // other than the hidpage.
  49. //
  50. void Draw_Mouse(GraphicViewPortClass *scr);
  51. void Erase_Mouse(GraphicViewPortClass *scr, int forced = FALSE);
  52. void Block_Mouse(GraphicBufferClass *buffer);
  53. void Unblock_Mouse(GraphicBufferClass *buffer);
  54. void Set_Cursor_Clip(void);
  55. void Clear_Cursor_Clip(void);
  56. private:
  57. enum {
  58. CONDHIDE = 1,
  59. CONDHIDDEN = 2,
  60. };
  61. void Low_Hide_Mouse(void);
  62. void Low_Show_Mouse(int x, int y);
  63. char *MouseCursor; // pointer to the mouse cursor in memory
  64. int MouseXHot; // X hot spot of the current mouse cursor
  65. int MouseYHot; // Y hot spot of the current mouse cursor
  66. int CursorWidth; // width of the mouse cursor in pixels
  67. int CursorHeight; // height of the mouse cursor in pixels
  68. char *MouseBuffer; // pointer to background buffer in memory
  69. int MouseBuffX; // pixel x mouse buffer was preserved at
  70. int MouseBuffY; // pixel y mouse buffer was preserved at
  71. int MaxWidth; // maximum width of mouse background buffer
  72. int MaxHeight; // maximum height of mouse background buffer
  73. int MouseCXLeft; // left x pos if conditional hide mouse in effect
  74. int MouseCYUpper; // upper y pos if conditional hide mouse in effect
  75. int MouseCXRight; // right x pos if conditional hide mouse in effect
  76. int MouseCYLower; // lower y pos if conditional hide mouse in effect
  77. char MCFlags; // conditional hide mouse flags
  78. char MCCount; // nesting count for conditional hide mouse
  79. GraphicViewPortClass *Screen; // pointer to the surface mouse was init'd with
  80. char * PrevCursor; // pointer to previous cursor shape
  81. int MouseUpdate;
  82. int State;
  83. char *EraseBuffer; // Buffer which holds background to restore to hidden page
  84. int EraseBuffX; // X position of the hidden page background
  85. int EraseBuffY; // Y position of the hidden page background
  86. int EraseBuffHotX; // X position of the hidden page background
  87. int EraseBuffHotY; // Y position of the hidden page background
  88. int EraseFlags; // Records whether mutex has been released
  89. CRITICAL_SECTION MouseCriticalSection; // Control for mouse re-enterancy
  90. unsigned TimerHandle;
  91. };
  92. extern "C" {
  93. void __cdecl Mouse_Shadow_Buffer(void *thisptr, GraphicViewPortClass *srcdst, void *buffer, int x, int y, int hotx, int hoty, int store);
  94. void __cdecl Draw_Mouse(void *thisptr, GraphicViewPortClass *srcdst, int x, int y);
  95. void * __cdecl ASM_Set_Mouse_Cursor(void * thisptr, int hotspotx, int hotspoty, VOID *cursor);
  96. };
  97. void Hide_Mouse(void);
  98. void Show_Mouse(void);
  99. void Conditional_Hide_Mouse(int x1, int y1, int x2, int y2);
  100. void Conditional_Show_Mouse(void);
  101. int Get_Mouse_State(void);
  102. void *Set_Mouse_Cursor(int hotx, int hoty, void *cursor);
  103. int Get_Mouse_X(void);
  104. int Get_Mouse_Y(void);
  105. #endif