StaticTextProperties.cpp 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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: StaticTextProperties.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: StaticTextSliderProperties.cpp
  36. //
  37. // Created: Colin Day, August 2001
  38. //
  39. // Desc: Static text 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/GadgetStaticText.h"
  49. #include "GameClient/Gadget.h"
  50. // DEFINES ////////////////////////////////////////////////////////////////////
  51. // PRIVATE TYPES //////////////////////////////////////////////////////////////
  52. ///////////////////////////////////////////////////////////////////////////////
  53. // PRIVATE DATA ///////////////////////////////////////////////////////////////
  54. ///////////////////////////////////////////////////////////////////////////////
  55. static Bool currCentered = FALSE;
  56. // PUBLIC DATA ////////////////////////////////////////////////////////////////
  57. // PRIVATE PROTOTYPES /////////////////////////////////////////////////////////
  58. ///////////////////////////////////////////////////////////////////////////////
  59. // PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
  60. ///////////////////////////////////////////////////////////////////////////////
  61. // staticTextPropertiesCallback ===============================================
  62. /** Dialog callback for properties */
  63. //=============================================================================
  64. static LRESULT CALLBACK staticTextPropertiesCallback( HWND hWndDialog,
  65. UINT message,
  66. WPARAM wParam,
  67. LPARAM lParam )
  68. {
  69. Int returnCode;
  70. //
  71. // handle any common messages between all property dialogs cause they
  72. // are designed to have controls doing the same functionality
  73. // and names
  74. //
  75. if( HandleCommonDialogMessages( hWndDialog, message,
  76. wParam, lParam, &returnCode ) == TRUE )
  77. return returnCode;
  78. switch( message )
  79. {
  80. // ------------------------------------------------------------------------
  81. case WM_COMMAND:
  82. {
  83. // Int notifyCode = HIWORD( wParam ); // notification code
  84. Int controlID = LOWORD( wParam ); // control ID
  85. // HWND hWndControl = (HWND)lParam; // control window handle
  86. switch( controlID )
  87. {
  88. // --------------------------------------------------------------------
  89. case BUTTON_CENTERED:
  90. {
  91. currCentered = 1 - currCentered;
  92. if( currCentered == TRUE )
  93. SetDlgItemText( hWndDialog, BUTTON_CENTERED, "Yes" );
  94. else
  95. SetDlgItemText( hWndDialog, BUTTON_CENTERED, "No" );
  96. break;
  97. } // end centered
  98. // --------------------------------------------------------------------
  99. case IDOK:
  100. {
  101. GameWindow *window = TheEditor->getPropertyTarget();
  102. // sanity
  103. if( window )
  104. {
  105. ImageAndColorInfo *info;
  106. // save the common properties
  107. if( SaveCommonDialogProperties( hWndDialog, window ) == FALSE )
  108. break;
  109. // save the image and color data
  110. // ----------------------------------------------------------------
  111. info = GetStateInfo( STATIC_TEXT_ENABLED );
  112. GadgetStaticTextSetEnabledImage( window, info->image );
  113. GadgetStaticTextSetEnabledColor( window, info->color );
  114. GadgetStaticTextSetEnabledBorderColor( window, info->borderColor );
  115. // ----------------------------------------------------------------
  116. info = GetStateInfo( STATIC_TEXT_DISABLED );
  117. GadgetStaticTextSetDisabledImage( window, info->image );
  118. GadgetStaticTextSetDisabledColor( window, info->color );
  119. GadgetStaticTextSetDisabledBorderColor( window, info->borderColor );
  120. // ----------------------------------------------------------------
  121. info = GetStateInfo( STATIC_TEXT_HILITE );
  122. GadgetStaticTextSetHiliteImage( window, info->image );
  123. GadgetStaticTextSetHiliteColor( window, info->color );
  124. GadgetStaticTextSetHiliteBorderColor( window, info->borderColor );
  125. // text data
  126. TextData *textData = (TextData *)window->winGetUserData();
  127. textData->centered = currCentered;
  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 staticTextPropertiesCallback
  152. ///////////////////////////////////////////////////////////////////////////////
  153. // PUBLIC FUNCTIONS ///////////////////////////////////////////////////////////
  154. ///////////////////////////////////////////////////////////////////////////////
  155. // InitStaticTextPropertiesDialog =============================================
  156. /** Bring up the static text properties dialog */
  157. //=============================================================================
  158. HWND InitStaticTextPropertiesDialog( GameWindow *window )
  159. {
  160. HWND dialog;
  161. // create the dialog box
  162. dialog = CreateDialog( TheEditor->getInstance(),
  163. (LPCTSTR)STATIC_TEXT_PROPERTIES_DIALOG,
  164. TheEditor->getWindowHandle(),
  165. (DLGPROC)staticTextPropertiesCallback );
  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. // --------------------------------------------------------------------------
  176. image = GadgetStaticTextGetEnabledImage( window );
  177. color = GadgetStaticTextGetEnabledColor( window );
  178. borderColor = GadgetStaticTextGetEnabledBorderColor( window );
  179. StoreImageAndColor( STATIC_TEXT_ENABLED, image, color, borderColor );
  180. // --------------------------------------------------------------------------
  181. image = GadgetStaticTextGetDisabledImage( window );
  182. color = GadgetStaticTextGetDisabledColor( window );
  183. borderColor = GadgetStaticTextGetDisabledBorderColor( window );
  184. StoreImageAndColor( STATIC_TEXT_DISABLED, image, color, borderColor );
  185. // --------------------------------------------------------------------------
  186. image = GadgetStaticTextGetHiliteImage( window );
  187. color = GadgetStaticTextGetHiliteColor( window );
  188. borderColor = GadgetStaticTextGetHiliteBorderColor( window );
  189. StoreImageAndColor( STATIC_TEXT_HILITE, image, color, borderColor );
  190. // text data
  191. TextData *textData = (TextData *)window->winGetUserData();
  192. if( textData->centered )
  193. SetDlgItemText( dialog, BUTTON_CENTERED, "Yes" );
  194. else
  195. SetDlgItemText( dialog, BUTTON_CENTERED, "No" );
  196. currCentered = textData->centered;
  197. // select the button enabled state for display
  198. SwitchToState( STATIC_TEXT_ENABLED, dialog );
  199. return dialog;
  200. } // end InitStaticTextPropertiesDialog