CheckBoxProperties.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*
  2. ** Command & Conquer Generals(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: CheckBoxProperties.cpp ///////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: GUIEdit
  34. //
  35. // File name: CheckBoxProperties.cpp
  36. //
  37. // Created: Colin Day, August 2001
  38. //
  39. // Desc: Check box properties
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  44. // USER INCLUDES //////////////////////////////////////////////////////////////
  45. #include "GUIEdit.h"
  46. #include "Properties.h"
  47. #include "Resource.h"
  48. #include "GameClient/GadgetCheckBox.h"
  49. // DEFINES ////////////////////////////////////////////////////////////////////
  50. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  51. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  52. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  53. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  54. ///////////////////////////////////////////////////////////////////////////////
  55. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  56. ///////////////////////////////////////////////////////////////////////////////
  57. // checkBoxPropertiesCallback =================================================
  58. /** Dialog callback for properties */
  59. //=============================================================================
  60. static LRESULT CALLBACK checkBoxPropertiesCallback( HWND hWndDialog,
  61. UINT message,
  62. WPARAM wParam,
  63. LPARAM lParam )
  64. {
  65. Int returnCode;
  66. //
  67. // handle any common messages between all property dialogs cause they
  68. // are designed to have controls doing the same functionality
  69. // and names
  70. //
  71. if( HandleCommonDialogMessages( hWndDialog, message,
  72. wParam, lParam, &returnCode ) == TRUE )
  73. return returnCode;
  74. switch( message )
  75. {
  76. // ------------------------------------------------------------------------
  77. case WM_COMMAND:
  78. {
  79. // Int notifyCode = HIWORD( wParam ); // notification code
  80. Int controlID = LOWORD( wParam ); // control ID
  81. // HWND hWndControl = (HWND)lParam; // control window handle
  82. switch( controlID )
  83. {
  84. // --------------------------------------------------------------------
  85. case IDOK:
  86. {
  87. GameWindow *window = TheEditor->getPropertyTarget();
  88. // sanity
  89. if( window )
  90. {
  91. ImageAndColorInfo *info;
  92. // save the common properties
  93. if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
  94. break;
  95. // save the image and color data
  96. // ----------------------------------------------------------------
  97. info = GetStateInfo( CHECK_BOX_ENABLED );
  98. GadgetCheckBoxSetEnabledImage( window, info->image );
  99. GadgetCheckBoxSetEnabledColor( window, info->color );
  100. GadgetCheckBoxSetEnabledBorderColor( window, info->borderColor );
  101. info = GetStateInfo( CHECK_BOX_ENABLED_UNCHECKED_BOX );
  102. GadgetCheckBoxSetEnabledUncheckedBoxImage( window, info->image );
  103. GadgetCheckBoxSetEnabledUncheckedBoxColor( window, info->color );
  104. GadgetCheckBoxSetEnabledUncheckedBoxBorderColor( window, info->borderColor );
  105. info = GetStateInfo( CHECK_BOX_ENABLED_CHECKED_BOX );
  106. GadgetCheckBoxSetEnabledCheckedBoxImage( window, info->image );
  107. GadgetCheckBoxSetEnabledCheckedBoxColor( window, info->color );
  108. GadgetCheckBoxSetEnabledCheckedBoxBorderColor( window, info->borderColor );
  109. // ----------------------------------------------------------------
  110. info = GetStateInfo( CHECK_BOX_DISABLED );
  111. GadgetCheckBoxSetDisabledImage( window, info->image );
  112. GadgetCheckBoxSetDisabledColor( window, info->color );
  113. GadgetCheckBoxSetDisabledBorderColor( window, info->borderColor );
  114. info = GetStateInfo( CHECK_BOX_DISABLED_UNCHECKED_BOX );
  115. GadgetCheckBoxSetDisabledUncheckedBoxImage( window, info->image );
  116. GadgetCheckBoxSetDisabledUncheckedBoxColor( window, info->color );
  117. GadgetCheckBoxSetDisabledUncheckedBoxBorderColor( window, info->borderColor );
  118. info = GetStateInfo( CHECK_BOX_DISABLED_CHECKED_BOX );
  119. GadgetCheckBoxSetDisabledCheckedBoxImage( window, info->image );
  120. GadgetCheckBoxSetDisabledCheckedBoxColor( window, info->color );
  121. GadgetCheckBoxSetDisabledCheckedBoxBorderColor( window, info->borderColor );
  122. // ----------------------------------------------------------------
  123. info = GetStateInfo( CHECK_BOX_HILITE );
  124. GadgetCheckBoxSetHiliteImage( window, info->image );
  125. GadgetCheckBoxSetHiliteColor( window, info->color );
  126. GadgetCheckBoxSetHiliteBorderColor( window, info->borderColor );
  127. info = GetStateInfo( CHECK_BOX_HILITE_UNCHECKED_BOX );
  128. GadgetCheckBoxSetHiliteUncheckedBoxImage( window, info->image );
  129. GadgetCheckBoxSetHiliteUncheckedBoxColor( window, info->color );
  130. GadgetCheckBoxSetHiliteUncheckedBoxBorderColor( window, info->borderColor );
  131. info = GetStateInfo( CHECK_BOX_HILITE_CHECKED_BOX );
  132. GadgetCheckBoxSetHiliteCheckedBoxImage( window, info->image );
  133. GadgetCheckBoxSetHiliteCheckedBoxColor( window, info->color );
  134. GadgetCheckBoxSetHiliteCheckedBoxBorderColor( window, info->borderColor );
  135. } // end if
  136. DestroyWindow( hWndDialog );
  137. break;
  138. } // end OK
  139. // --------------------------------------------------------------------
  140. case IDCANCEL:
  141. {
  142. DestroyWindow( hWndDialog );
  143. break;
  144. } // end cancel
  145. } // end switch( LOWORD( wParam ) )
  146. return 0;
  147. } // end of WM_COMMAND
  148. // ------------------------------------------------------------------------
  149. case WM_CLOSE:
  150. {
  151. DestroyWindow( hWndDialog );
  152. return 0;
  153. } // end close
  154. // ------------------------------------------------------------------------
  155. default:
  156. return 0;
  157. } // end of switch
  158. } // end checkBoxPropertiesCallback
  159. ///////////////////////////////////////////////////////////////////////////////
  160. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  161. ///////////////////////////////////////////////////////////////////////////////
  162. // InitCheckBoxPropertiesDialog ===============================================
  163. /** Bring up the check box properties dialog */
  164. //=============================================================================
  165. HWND InitCheckBoxPropertiesDialog( GameWindow *window )
  166. {
  167. HWND dialog;
  168. // create the dialog box
  169. dialog = CreateDialog( TheEditor->getInstance(),
  170. (LPCTSTR)CHECK_BOX_PROPERTIES_DIALOG,
  171. TheEditor->getWindowHandle(),
  172. (DLGPROC)checkBoxPropertiesCallback );
  173. if( dialog == NULL )
  174. return NULL;
  175. // do the common initialization
  176. CommonDialogInitialize( window, dialog );
  177. //
  178. // store in the image and color table the values for this putton
  179. //
  180. const Image *image;
  181. Color color, borderColor;
  182. // --------------------------------------------------------------------------
  183. image = GadgetCheckBoxGetEnabledImage( window );
  184. color = GadgetCheckBoxGetEnabledColor( window );
  185. borderColor = GadgetCheckBoxGetEnabledBorderColor( window );
  186. StoreImageAndColor( CHECK_BOX_ENABLED, image, color, borderColor );
  187. image = GadgetCheckBoxGetEnabledUncheckedBoxImage( window );
  188. color = GadgetCheckBoxGetEnabledUncheckedBoxColor( window );
  189. borderColor = GadgetCheckBoxGetEnabledUncheckedBoxBorderColor( window );
  190. StoreImageAndColor( CHECK_BOX_ENABLED_UNCHECKED_BOX, image, color, borderColor );
  191. image = GadgetCheckBoxGetEnabledCheckedBoxImage( window );
  192. color = GadgetCheckBoxGetEnabledCheckedBoxColor( window );
  193. borderColor = GadgetCheckBoxGetEnabledCheckedBoxBorderColor( window );
  194. StoreImageAndColor( CHECK_BOX_ENABLED_CHECKED_BOX, image, color, borderColor );
  195. // --------------------------------------------------------------------------
  196. image = GadgetCheckBoxGetDisabledImage( window );
  197. color = GadgetCheckBoxGetDisabledColor( window );
  198. borderColor = GadgetCheckBoxGetDisabledBorderColor( window );
  199. StoreImageAndColor( CHECK_BOX_DISABLED, image, color, borderColor );
  200. image = GadgetCheckBoxGetDisabledUncheckedBoxImage( window );
  201. color = GadgetCheckBoxGetDisabledUncheckedBoxColor( window );
  202. borderColor = GadgetCheckBoxGetDisabledUncheckedBoxBorderColor( window );
  203. StoreImageAndColor( CHECK_BOX_DISABLED_UNCHECKED_BOX, image, color, borderColor );
  204. image = GadgetCheckBoxGetDisabledCheckedBoxImage( window );
  205. color = GadgetCheckBoxGetDisabledCheckedBoxColor( window );
  206. borderColor = GadgetCheckBoxGetDisabledCheckedBoxBorderColor( window );
  207. StoreImageAndColor( CHECK_BOX_DISABLED_CHECKED_BOX, image, color, borderColor );
  208. // --------------------------------------------------------------------------
  209. image = GadgetCheckBoxGetHiliteImage( window );
  210. color = GadgetCheckBoxGetHiliteColor( window );
  211. borderColor = GadgetCheckBoxGetHiliteBorderColor( window );
  212. StoreImageAndColor( CHECK_BOX_HILITE, image, color, borderColor );
  213. image = GadgetCheckBoxGetHiliteUncheckedBoxImage( window );
  214. color = GadgetCheckBoxGetHiliteUncheckedBoxColor( window );
  215. borderColor = GadgetCheckBoxGetHiliteUncheckedBoxBorderColor( window );
  216. StoreImageAndColor( CHECK_BOX_HILITE_UNCHECKED_BOX, image, color, borderColor );
  217. image = GadgetCheckBoxGetHiliteCheckedBoxImage( window );
  218. color = GadgetCheckBoxGetHiliteCheckedBoxColor( window );
  219. borderColor = GadgetCheckBoxGetHiliteCheckedBoxBorderColor( window );
  220. StoreImageAndColor( CHECK_BOX_HILITE_CHECKED_BOX, image, color, borderColor );
  221. // select the button enabled state for display
  222. SwitchToState( CHECK_BOX_ENABLED, dialog );
  223. //
  224. // initialize the dialog with values from the window
  225. //
  226. return dialog;
  227. } // end InitCheckBoxPropertiesDialog