CHECKBOX.CPP 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. /* $Header: /CounterStrike/CHECKBOX.CPP 1 3/03/97 10:24a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : CHECKBOX.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 05/26/95 *
  26. * *
  27. * Last Update : July 6, 1996 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * CheckBoxClass::Action -- Handles a button action on a checkbox object. *
  32. * CheckBoxClass::Draw_Me -- Draws the checkbox imagery. *
  33. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  34. #include "function.h"
  35. #include "checkbox.h"
  36. /***********************************************************************************************
  37. * CheckBoxClass::Draw_Me -- Draws the checkbox imagery. *
  38. * *
  39. * This routine will draw the checkbox either filled or empty as necessary. *
  40. * *
  41. * INPUT: forced -- Should the check box be drawn even if it doesn't think it needs to? *
  42. * *
  43. * OUTPUT: Was the check box rendered? *
  44. * *
  45. * WARNINGS: none *
  46. * *
  47. * HISTORY: *
  48. * 07/01/1995 JLB : Created. *
  49. *=============================================================================================*/
  50. int CheckBoxClass::Draw_Me(int forced)
  51. {
  52. if (ToggleClass::Draw_Me(forced)) {
  53. Hide_Mouse();
  54. Draw_Box(X, Y, Width, Height, BOXSTYLE_DOWN, false);
  55. LogicPage->Fill_Rect(X+1, Y+1, X+Width-2, Y+Height-2, DKGREY);
  56. if (IsOn) {
  57. LogicPage->Fill_Rect(X+1, Y+1, X+Width-2, Y+Height-2, LTGREEN);
  58. }
  59. Show_Mouse();
  60. return(true);
  61. }
  62. return(false);
  63. }
  64. /***********************************************************************************************
  65. * CheckBoxClass::Action -- Handles a button action on a checkbox object. *
  66. * *
  67. * This routine will detect if the mouse has been clicked on the checkbox object. If so, *
  68. * the check box state will be toggled. *
  69. * *
  70. * INPUT: flags -- The event flags that resulted in this routine being called. *
  71. * *
  72. * key -- The key that resulted in this routine being called. *
  73. * *
  74. * OUTPUT: bool; Should normal processing occur? *
  75. * *
  76. * WARNINGS: none *
  77. * *
  78. * HISTORY: *
  79. * 07/06/1996 JLB : Created. *
  80. *=============================================================================================*/
  81. int CheckBoxClass::Action(unsigned flags, KeyNumType & key)
  82. {
  83. if (flags & LEFTRELEASE) {
  84. if (IsOn) {
  85. Turn_Off();
  86. } else {
  87. Turn_On();
  88. }
  89. }
  90. return(ToggleClass::Action(flags, key));
  91. }