PushButtonProperties.cpp 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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: PushButtonProperties.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: PushButtonProperties.cpp
  36. //
  37. // Created: Colin Day, August 2001
  38. //
  39. // Desc: Push button 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/GadgetPushButton.h"
  49. // DEFINES ////////////////////////////////////////////////////////////////////
  50. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  51. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  52. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  53. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  54. ///////////////////////////////////////////////////////////////////////////////
  55. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  56. ///////////////////////////////////////////////////////////////////////////////
  57. // pushButtonPropertiesCallback ===============================================
  58. /** Dialog callback for properties */
  59. //=============================================================================
  60. static LRESULT CALLBACK pushButtonPropertiesCallback( 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( BUTTON_ENABLED );
  98. GadgetButtonSetEnabledImage( window, info->image );
  99. GadgetButtonSetEnabledColor( window, info->color );
  100. GadgetButtonSetEnabledBorderColor( window, info->borderColor );
  101. info = GetStateInfo( BUTTON_ENABLED_PUSHED );
  102. GadgetButtonSetEnabledSelectedImage( window, info->image );
  103. GadgetButtonSetEnabledSelectedColor( window, info->color );
  104. GadgetButtonSetEnabledSelectedBorderColor( window, info->borderColor );
  105. // ----------------------------------------------------------------
  106. info = GetStateInfo( BUTTON_DISABLED );
  107. GadgetButtonSetDisabledImage( window, info->image );
  108. GadgetButtonSetDisabledColor( window, info->color );
  109. GadgetButtonSetDisabledBorderColor( window, info->borderColor );
  110. info = GetStateInfo( BUTTON_DISABLED_PUSHED );
  111. GadgetButtonSetDisabledSelectedImage( window, info->image );
  112. GadgetButtonSetDisabledSelectedColor( window, info->color );
  113. GadgetButtonSetDisabledSelectedBorderColor( window, info->borderColor );
  114. // ----------------------------------------------------------------
  115. info = GetStateInfo( BUTTON_HILITE );
  116. GadgetButtonSetHiliteImage( window, info->image );
  117. GadgetButtonSetHiliteColor( window, info->color );
  118. GadgetButtonSetHiliteBorderColor( window, info->borderColor );
  119. info = GetStateInfo( BUTTON_HILITE_PUSHED );
  120. GadgetButtonSetHiliteSelectedImage( window, info->image );
  121. GadgetButtonSetHiliteSelectedColor( window, info->color );
  122. GadgetButtonSetHiliteSelectedBorderColor( window, info->borderColor );
  123. UnsignedInt bit;
  124. bit = WIN_STATUS_RIGHT_CLICK;
  125. window->winClearStatus( bit );
  126. if( IsDlgButtonChecked( hWndDialog, CHECK_RIGHT_CLICK ) )
  127. window->winSetStatus( bit );
  128. } // end if
  129. DestroyWindow( hWndDialog );
  130. break;
  131. } // end OK
  132. // --------------------------------------------------------------------
  133. case IDCANCEL:
  134. {
  135. DestroyWindow( hWndDialog );
  136. break;
  137. } // end cancel
  138. } // end switch( LOWORD( wParam ) )
  139. return 0;
  140. } // end of WM_COMMAND
  141. // ------------------------------------------------------------------------
  142. case WM_CLOSE:
  143. {
  144. DestroyWindow( hWndDialog );
  145. return 0;
  146. } // end close
  147. // ------------------------------------------------------------------------
  148. default:
  149. return 0;
  150. } // end of switch
  151. } // end pushButtonPropertiesCallback
  152. ///////////////////////////////////////////////////////////////////////////////
  153. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  154. ///////////////////////////////////////////////////////////////////////////////
  155. // InitPushButtonPropertiesDialog =============================================
  156. /** Bring up the push button properties dialog */
  157. //=============================================================================
  158. HWND InitPushButtonPropertiesDialog( GameWindow *window )
  159. {
  160. HWND dialog;
  161. // create the dialog box
  162. dialog = CreateDialog( TheEditor->getInstance(),
  163. (LPCTSTR)PUSH_BUTTON_PROPERTIES_DIALOG,
  164. TheEditor->getWindowHandle(),
  165. (DLGPROC)pushButtonPropertiesCallback );
  166. if( dialog == NULL )
  167. return NULL;
  168. // do the common initialization
  169. CommonDialogInitialize( window, dialog );
  170. //
  171. // store in the image and color table the values for this putton
  172. //
  173. const Image *image;
  174. Color color, borderColor;
  175. image = GadgetButtonGetEnabledImage( window );
  176. color = GadgetButtonGetEnabledColor( window );
  177. borderColor = GadgetButtonGetEnabledBorderColor( window );
  178. StoreImageAndColor( BUTTON_ENABLED, image, color, borderColor );
  179. image = GadgetButtonGetEnabledSelectedImage( window );
  180. color = GadgetButtonGetEnabledSelectedColor( window );
  181. borderColor = GadgetButtonGetEnabledSelectedBorderColor( window );
  182. StoreImageAndColor( BUTTON_ENABLED_PUSHED, image, color, borderColor );
  183. image = GadgetButtonGetDisabledImage( window );
  184. color = GadgetButtonGetDisabledColor( window );
  185. borderColor = GadgetButtonGetDisabledBorderColor( window );
  186. StoreImageAndColor( BUTTON_DISABLED, image, color, borderColor );
  187. image = GadgetButtonGetDisabledSelectedImage( window );
  188. color = GadgetButtonGetDisabledSelectedColor( window );
  189. borderColor = GadgetButtonGetDisabledSelectedBorderColor( window );
  190. StoreImageAndColor( BUTTON_DISABLED_PUSHED, image, color, borderColor );
  191. image = GadgetButtonGetHiliteImage( window );
  192. color = GadgetButtonGetHiliteColor( window );
  193. borderColor = GadgetButtonGetHiliteBorderColor( window );
  194. StoreImageAndColor( BUTTON_HILITE, image, color, borderColor );
  195. image = GadgetButtonGetHiliteSelectedImage( window );
  196. color = GadgetButtonGetHiliteSelectedColor( window );
  197. borderColor = GadgetButtonGetHiliteSelectedBorderColor( window );
  198. StoreImageAndColor( BUTTON_HILITE_PUSHED, image, color, borderColor );
  199. // select the button enabled state for display
  200. SwitchToState( BUTTON_ENABLED, dialog );
  201. //
  202. // initialize the dialog with values from the window
  203. //
  204. if( BitTest( window->winGetStatus(), WIN_STATUS_RIGHT_CLICK ) )
  205. CheckDlgButton( dialog, CHECK_RIGHT_CLICK, BST_CHECKED );
  206. return dialog;
  207. } // end InitPushButtonPropertiesDialog