PresetPropSheet.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. ** Command & Conquer Renegade(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. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/PresetPropSheet.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 6/13/00 2:53p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "stdafx.h"
  36. #include "presetpropsheet.h"
  37. #include "parameterinheritancedialog.h"
  38. /////////////////////////////////////////////////////////////////////////////
  39. // Local constants
  40. /////////////////////////////////////////////////////////////////////////////
  41. static const int BORDER_BUTTON_X = 6;
  42. static const int BORDER_BUTTON_Y = 6;
  43. static const int BORDER_TAB_X = 6;
  44. static const int BORDER_TAB_Y = 6;
  45. /////////////////////////////////////////////////////////////////////////////
  46. //
  47. // OnInitDialog
  48. //
  49. /////////////////////////////////////////////////////////////////////////////
  50. BOOL
  51. PresetPropSheetClass::OnInitDialog (void)
  52. {
  53. //
  54. // Get the dimensions of the buttons
  55. //
  56. CRect button_rect;
  57. ::GetWindowRect (::GetDlgItem (m_hWnd, IDCANCEL), &button_rect);
  58. ScreenToClient (&button_rect);
  59. //
  60. // Create a new button
  61. //
  62. ::CreateWindow ( "BUTTON",
  63. "OK && Propagate...",
  64. WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
  65. 0, 0,
  66. (button_rect.Width () * 3) / 2, button_rect.Height (),
  67. m_hWnd,
  68. (HMENU)IDC_PROPAGATE,
  69. ::AfxGetInstanceHandle (),
  70. NULL);
  71. //
  72. // Set the new button's font
  73. //
  74. SendDlgItemMessage (IDC_PROPAGATE, WM_SETFONT, ::SendMessage (m_hWnd, WM_GETFONT, 0, 0L));
  75. //
  76. // Disable the button if we are in read-only mode
  77. //
  78. if (Is_Read_Only ()) {
  79. ::EnableWindow (::GetDlgItem (m_hWnd, IDC_PROPAGATE), FALSE);
  80. }
  81. return EditorPropSheetClass::OnInitDialog ();
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. //
  85. // Reposition_Buttons
  86. //
  87. /////////////////////////////////////////////////////////////////////////////
  88. void
  89. PresetPropSheetClass::Reposition_Buttons (int cx, int cy)
  90. {
  91. //
  92. // Get the dimensions of the buttons
  93. //
  94. CRect button_rect;
  95. ::GetWindowRect (::GetDlgItem (m_hWnd, IDCANCEL), &button_rect);
  96. ScreenToClient (&button_rect);
  97. //
  98. // Reposition the OK and Cancel buttons
  99. //
  100. int first_width = ((button_rect.Width () * 3) / 2);
  101. ::SetWindowPos (::GetDlgItem (m_hWnd, IDC_PROPAGATE),
  102. NULL,
  103. (cx - first_width) - BORDER_BUTTON_X,
  104. (cy - button_rect.Height ()) - BORDER_BUTTON_Y,
  105. 0,
  106. 0,
  107. SWP_NOZORDER | SWP_NOSIZE);
  108. ::SetWindowPos (::GetDlgItem (m_hWnd, IDCANCEL),
  109. NULL,
  110. (cx - (button_rect.Width () + first_width)) - (BORDER_BUTTON_X * 3),
  111. (cy - button_rect.Height ()) - BORDER_BUTTON_Y,
  112. 0,
  113. 0,
  114. SWP_NOZORDER | SWP_NOSIZE);
  115. ::SetWindowPos (::GetDlgItem (m_hWnd, IDC_OK),
  116. NULL,
  117. (cx - ((button_rect.Width () * 2) + first_width)) - (BORDER_BUTTON_X * 4),
  118. (cy - button_rect.Height ()) - BORDER_BUTTON_Y,
  119. 0,
  120. 0,
  121. SWP_NOZORDER | SWP_NOSIZE);
  122. return ;
  123. }
  124. /////////////////////////////////////////////////////////////////////////////
  125. //
  126. // OnCommand
  127. //
  128. /////////////////////////////////////////////////////////////////////////////
  129. BOOL
  130. PresetPropSheetClass::OnCommand (WPARAM wParam, LPARAM lParam)
  131. {
  132. //
  133. // If the user clicked the propagate button, then save the
  134. // preset changes and display the dialog
  135. //
  136. if ( LOWORD (wParam) == IDC_PROPAGATE &&
  137. HIWORD (wParam) == BN_CLICKED)
  138. {
  139. if (Apply_Changes ()) {
  140. //
  141. // Show the propagation dialog
  142. //
  143. ParameterInheritanceDialogClass dialog (this);
  144. dialog.Set_Preset (m_Preset);
  145. dialog.DoModal ();
  146. //
  147. // Close the property sheet
  148. //
  149. EndDialog (IDOK);
  150. }
  151. }
  152. return EditorPropSheetClass::OnCommand (wParam, lParam);
  153. }