dialogcontrol.cpp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/wwui/dialogcontrol.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 10/26/01 12:07p $*
  29. * *
  30. * $Revision:: 13 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "dialogcontrol.h"
  36. #include "dialogbase.h"
  37. #include "mousemgr.h"
  38. #include "dialogmgr.h"
  39. #include "render2d.h"
  40. #include "stylemgr.h"
  41. ////////////////////////////////////////////////////////////////
  42. //
  43. // DialogControlClass
  44. //
  45. ////////////////////////////////////////////////////////////////
  46. DialogControlClass::DialogControlClass (void) :
  47. Rect (0, 0, 0, 0),
  48. ClientRect (0, 0, 0, 0),
  49. Style (0),
  50. ID (0),
  51. Parent (NULL),
  52. HasFocus (false),
  53. IsDirty (true),
  54. WantsFocus (true),
  55. AdviseSink (NULL),
  56. IsEnabled (true),
  57. IsVisible (true),
  58. IsEmbedded (false),
  59. TextColor (0, 0, 0),
  60. IsTextColorOverridden (false)
  61. {
  62. INT32_TO_VRGB (StyleMgrClass::Get_Text_Color (), TextColor);
  63. return ;
  64. }
  65. ////////////////////////////////////////////////////////////////
  66. //
  67. // ~DialogControlClass
  68. //
  69. ////////////////////////////////////////////////////////////////
  70. DialogControlClass::~DialogControlClass (void)
  71. {
  72. //
  73. // Remove the input focus if this control has it
  74. //
  75. if (DialogMgrClass::Get_Focus () == this) {
  76. DialogMgrClass::Set_Focus (NULL);
  77. }
  78. return ;
  79. }
  80. ////////////////////////////////////////////////////////////////
  81. //
  82. // Set_Focus
  83. //
  84. ////////////////////////////////////////////////////////////////
  85. void
  86. DialogControlClass::Set_Focus (void)
  87. {
  88. DialogMgrClass::Set_Focus (this);
  89. return ;
  90. }
  91. ////////////////////////////////////////////////////////////////
  92. //
  93. // On_Set_Cursor
  94. //
  95. ////////////////////////////////////////////////////////////////
  96. void
  97. DialogControlClass::On_Set_Cursor (const Vector2 & /*mouse_pos*/)
  98. {
  99. MouseMgrClass::Set_Cursor (MouseMgrClass::CURSOR_ARROW);
  100. return ;
  101. }
  102. ////////////////////////////////////////////////////////////////
  103. //
  104. // Set_Capture
  105. //
  106. ////////////////////////////////////////////////////////////////
  107. void
  108. DialogControlClass::Set_Capture (void)
  109. {
  110. DialogMgrClass::Set_Capture (this);
  111. return ;
  112. }
  113. ////////////////////////////////////////////////////////////////
  114. //
  115. // Release_Capture
  116. //
  117. ////////////////////////////////////////////////////////////////
  118. void
  119. DialogControlClass::Release_Capture (void)
  120. {
  121. DialogMgrClass::Release_Capture ();
  122. return ;
  123. }
  124. ////////////////////////////////////////////////////////////////
  125. //
  126. // Set_Window_Pos
  127. //
  128. ////////////////////////////////////////////////////////////////
  129. void
  130. DialogControlClass::Set_Window_Pos (const Vector2 &pos)
  131. {
  132. float width = Rect.Width ();
  133. float height = Rect.Height ();
  134. //
  135. // Recalculate the window's bounding rectangle
  136. //
  137. Rect.Left = (int)pos.X;
  138. Rect.Top = (int)pos.Y;
  139. Rect.Right = (int)(Rect.Left + width);
  140. Rect.Bottom = (int)(Rect.Top + height);
  141. //
  142. // Let the control recalculate anything it needs
  143. //
  144. Update_Client_Rect ();
  145. return ;
  146. }
  147. ////////////////////////////////////////////////////////////////
  148. //
  149. // Center_Mouse
  150. //
  151. ////////////////////////////////////////////////////////////////
  152. void
  153. DialogControlClass::Center_Mouse (void)
  154. {
  155. //
  156. // Put the mouse cursor in the middle of this control
  157. //
  158. /*Vector3 mouse_pos = DialogMgrClass::Get_Mouse_Pos ();
  159. mouse_pos.X = Rect.Left + int(Rect.Width () / 2);
  160. mouse_pos.Y = Rect.Top + int(Rect.Height () / 2);
  161. DialogMgrClass::Set_Mouse_Pos (mouse_pos);*/
  162. return ;
  163. }
  164. ////////////////////////////////////////////////////////////////
  165. //
  166. // Enable
  167. //
  168. ////////////////////////////////////////////////////////////////
  169. void
  170. DialogControlClass::Enable (bool onoff)
  171. {
  172. if (onoff != IsEnabled) {
  173. IsEnabled = onoff;
  174. Set_Dirty ();
  175. //
  176. // Remove the focus (if necessary)
  177. //
  178. if (IsEnabled == false && DialogMgrClass::Get_Focus () == this) {
  179. DialogMgrClass::Set_Focus (NULL);
  180. }
  181. }
  182. return ;
  183. }