ProgressBarProperties.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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: ProgressBarProperties.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: ProgressBarProperties.cpp
  36. //
  37. // Created: Colin Day, August 2001
  38. //
  39. // Desc: Progress bar 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/GadgetProgressBar.h"
  49. // DEFINES ////////////////////////////////////////////////////////////////////
  50. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  51. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  52. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  53. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  54. ///////////////////////////////////////////////////////////////////////////////
  55. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  56. ///////////////////////////////////////////////////////////////////////////////
  57. // progressBarPropertiesCallback ==============================================
  58. /** Dialog callback for properties */
  59. //=============================================================================
  60. static LRESULT CALLBACK progressBarPropertiesCallback( 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( PROGRESS_BAR_ENABLED_LEFT );
  98. GadgetProgressBarSetEnabledImageLeft( window, info->image );
  99. GadgetProgressBarSetEnabledColor( window, info->color );
  100. GadgetProgressBarSetEnabledBorderColor( window, info->borderColor );
  101. info = GetStateInfo( PROGRESS_BAR_ENABLED_RIGHT );
  102. GadgetProgressBarSetEnabledImageRight( window, info->image );
  103. info = GetStateInfo( PROGRESS_BAR_ENABLED_CENTER );
  104. GadgetProgressBarSetEnabledImageCenter( window, info->image );
  105. info = GetStateInfo( PROGRESS_BAR_ENABLED_SMALL_CENTER );
  106. GadgetProgressBarSetEnabledImageSmallCenter( window, info->image );
  107. info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_LEFT );
  108. GadgetProgressBarSetEnabledBarImageLeft( window, info->image );
  109. GadgetProgressBarSetEnabledBarColor( window, info->color );
  110. GadgetProgressBarSetEnabledBarBorderColor( window, info->borderColor );
  111. info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_RIGHT );
  112. GadgetProgressBarSetEnabledBarImageRight( window, info->image );
  113. info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_CENTER );
  114. GadgetProgressBarSetEnabledBarImageCenter( window, info->image );
  115. info = GetStateInfo( PROGRESS_BAR_ENABLED_BAR_SMALL_CENTER );
  116. GadgetProgressBarSetEnabledBarImageSmallCenter( window, info->image );
  117. // ----------------------------------------------------------------
  118. info = GetStateInfo( PROGRESS_BAR_DISABLED_LEFT );
  119. GadgetProgressBarSetDisabledImageLeft( window, info->image );
  120. GadgetProgressBarSetDisabledColor( window, info->color );
  121. GadgetProgressBarSetDisabledBorderColor( window, info->borderColor );
  122. info = GetStateInfo( PROGRESS_BAR_DISABLED_RIGHT );
  123. GadgetProgressBarSetDisabledImageRight( window, info->image );
  124. info = GetStateInfo( PROGRESS_BAR_DISABLED_CENTER );
  125. GadgetProgressBarSetDisabledImageCenter( window, info->image );
  126. info = GetStateInfo( PROGRESS_BAR_DISABLED_SMALL_CENTER );
  127. GadgetProgressBarSetDisabledImageSmallCenter( window, info->image );
  128. info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_LEFT );
  129. GadgetProgressBarSetDisabledBarImageLeft( window, info->image );
  130. GadgetProgressBarSetDisabledBarColor( window, info->color );
  131. GadgetProgressBarSetDisabledBarBorderColor( window, info->borderColor );
  132. info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_RIGHT );
  133. GadgetProgressBarSetDisabledBarImageRight( window, info->image );
  134. info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_CENTER );
  135. GadgetProgressBarSetDisabledBarImageCenter( window, info->image );
  136. info = GetStateInfo( PROGRESS_BAR_DISABLED_BAR_SMALL_CENTER );
  137. GadgetProgressBarSetDisabledBarImageSmallCenter( window, info->image );
  138. // ----------------------------------------------------------------
  139. info = GetStateInfo( PROGRESS_BAR_HILITE_LEFT );
  140. GadgetProgressBarSetHiliteImageLeft( window, info->image );
  141. GadgetProgressBarSetHiliteColor( window, info->color );
  142. GadgetProgressBarSetHiliteBorderColor( window, info->borderColor );
  143. info = GetStateInfo( PROGRESS_BAR_HILITE_RIGHT );
  144. GadgetProgressBarSetHiliteImageRight( window, info->image );
  145. info = GetStateInfo( PROGRESS_BAR_HILITE_CENTER );
  146. GadgetProgressBarSetHiliteImageCenter( window, info->image );
  147. info = GetStateInfo( PROGRESS_BAR_HILITE_SMALL_CENTER );
  148. GadgetProgressBarSetHiliteImageSmallCenter( window, info->image );
  149. info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_LEFT );
  150. GadgetProgressBarSetHiliteBarImageLeft( window, info->image );
  151. GadgetProgressBarSetHiliteBarColor( window, info->color );
  152. GadgetProgressBarSetHiliteBarBorderColor( window, info->borderColor );
  153. info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_RIGHT );
  154. GadgetProgressBarSetHiliteBarImageRight( window, info->image );
  155. info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_CENTER );
  156. GadgetProgressBarSetHiliteBarImageCenter( window, info->image );
  157. info = GetStateInfo( PROGRESS_BAR_HILITE_BAR_SMALL_CENTER );
  158. GadgetProgressBarSetHiliteBarImageSmallCenter( window, info->image );
  159. } // end if
  160. DestroyWindow( hWndDialog );
  161. break;
  162. } // end OK
  163. // --------------------------------------------------------------------
  164. case IDCANCEL:
  165. {
  166. DestroyWindow( hWndDialog );
  167. break;
  168. } // end cancel
  169. } // end switch( LOWORD( wParam ) )
  170. return 0;
  171. } // end of WM_COMMAND
  172. // ------------------------------------------------------------------------
  173. case WM_CLOSE:
  174. {
  175. DestroyWindow( hWndDialog );
  176. return 0;
  177. } // end close
  178. // ------------------------------------------------------------------------
  179. default:
  180. return 0;
  181. } // end of switch
  182. } // end progressBarPropertiesCallback
  183. ///////////////////////////////////////////////////////////////////////////////
  184. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  185. ///////////////////////////////////////////////////////////////////////////////
  186. // InitProgressBarPropertiesDialog ============================================
  187. /** Bring up the progress bar properties dialog */
  188. //=============================================================================
  189. HWND InitProgressBarPropertiesDialog( GameWindow *window )
  190. {
  191. HWND dialog;
  192. // create the dialog box
  193. dialog = CreateDialog( TheEditor->getInstance(),
  194. (LPCTSTR)PROGRESS_BAR_PROPERTIES_DIALOG,
  195. TheEditor->getWindowHandle(),
  196. (DLGPROC)progressBarPropertiesCallback );
  197. if( dialog == NULL )
  198. return NULL;
  199. // do the common initialization
  200. CommonDialogInitialize( window, dialog );
  201. //
  202. // store in the image and color table the values for this putton
  203. //
  204. const Image *image;
  205. Color color, borderColor;
  206. // --------------------------------------------------------------------------
  207. image = GadgetProgressBarGetEnabledImageLeft( window );
  208. color = GadgetProgressBarGetEnabledColor( window );
  209. borderColor = GadgetProgressBarGetEnabledBorderColor( window );
  210. StoreImageAndColor( PROGRESS_BAR_ENABLED_LEFT, image, color, borderColor );
  211. image = GadgetProgressBarGetEnabledImageRight( window );
  212. StoreImageAndColor( PROGRESS_BAR_ENABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  213. image = GadgetProgressBarGetEnabledImageCenter( window );
  214. StoreImageAndColor( PROGRESS_BAR_ENABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  215. image = GadgetProgressBarGetEnabledImageSmallCenter( window );
  216. StoreImageAndColor( PROGRESS_BAR_ENABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  217. image = GadgetProgressBarGetEnabledBarImageLeft( window );
  218. color = GadgetProgressBarGetEnabledBarColor( window );
  219. borderColor = GadgetProgressBarGetEnabledBarBorderColor( window );
  220. StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_LEFT, image, color, borderColor );
  221. image = GadgetProgressBarGetEnabledBarImageRight( window );
  222. StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  223. image = GadgetProgressBarGetEnabledBarImageCenter( window );
  224. StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  225. image = GadgetProgressBarGetEnabledBarImageSmallCenter( window );
  226. StoreImageAndColor( PROGRESS_BAR_ENABLED_BAR_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  227. // --------------------------------------------------------------------------
  228. image = GadgetProgressBarGetDisabledImageLeft( window );
  229. color = GadgetProgressBarGetDisabledColor( window );
  230. borderColor = GadgetProgressBarGetDisabledBorderColor( window );
  231. StoreImageAndColor( PROGRESS_BAR_DISABLED_LEFT, image, color, borderColor );
  232. image = GadgetProgressBarGetDisabledImageRight( window );
  233. StoreImageAndColor( PROGRESS_BAR_DISABLED_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  234. image = GadgetProgressBarGetDisabledImageCenter( window );
  235. StoreImageAndColor( PROGRESS_BAR_DISABLED_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  236. image = GadgetProgressBarGetDisabledImageSmallCenter( window );
  237. StoreImageAndColor( PROGRESS_BAR_DISABLED_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  238. image = GadgetProgressBarGetDisabledBarImageLeft( window );
  239. color = GadgetProgressBarGetDisabledBarColor( window );
  240. borderColor = GadgetProgressBarGetDisabledBarBorderColor( window );
  241. StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_LEFT, image, color, borderColor );
  242. image = GadgetProgressBarGetDisabledBarImageRight( window );
  243. StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  244. image = GadgetProgressBarGetDisabledBarImageCenter( window );
  245. StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  246. image = GadgetProgressBarGetDisabledBarImageSmallCenter( window );
  247. StoreImageAndColor( PROGRESS_BAR_DISABLED_BAR_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  248. // --------------------------------------------------------------------------
  249. image = GadgetProgressBarGetHiliteImageLeft( window );
  250. color = GadgetProgressBarGetHiliteColor( window );
  251. borderColor = GadgetProgressBarGetHiliteBorderColor( window );
  252. StoreImageAndColor( PROGRESS_BAR_HILITE_LEFT, image, color, borderColor );
  253. image = GadgetProgressBarGetHiliteImageRight( window );
  254. StoreImageAndColor( PROGRESS_BAR_HILITE_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  255. image = GadgetProgressBarGetHiliteImageCenter( window );
  256. StoreImageAndColor( PROGRESS_BAR_HILITE_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  257. image = GadgetProgressBarGetHiliteImageSmallCenter( window );
  258. StoreImageAndColor( PROGRESS_BAR_HILITE_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  259. image = GadgetProgressBarGetHiliteBarImageLeft( window );
  260. color = GadgetProgressBarGetHiliteBarColor( window );
  261. borderColor = GadgetProgressBarGetHiliteBarBorderColor( window );
  262. StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_LEFT, image, color, borderColor );
  263. image = GadgetProgressBarGetHiliteBarImageRight( window );
  264. StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_RIGHT, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  265. image = GadgetProgressBarGetHiliteBarImageCenter( window );
  266. StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  267. image = GadgetProgressBarGetHiliteBarImageSmallCenter( window );
  268. StoreImageAndColor( PROGRESS_BAR_HILITE_BAR_SMALL_CENTER, image, WIN_COLOR_UNDEFINED, WIN_COLOR_UNDEFINED );
  269. // select the button enabled state for display
  270. SwitchToState( PROGRESS_BAR_ENABLED_LEFT, dialog );
  271. //
  272. // initialize the dialog with values from the window
  273. //
  274. return dialog;
  275. } // end InitProgressBarPropertiesDialog