TargetAreaDlg.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*************************************************************************************************\
  2. TargetAreaDlg.cpp : Implementation of the TargetAreaDlg component.
  3. //---------------------------------------------------------------------------//
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. //===========================================================================//
  6. \*************************************************************************************************/
  7. #include "resource.h"
  8. #include <stdlib.h>
  9. #include <assert.h>
  10. #include "EString.h"
  11. #include "TargetAreaDlg.h"
  12. #include "Objective.h"
  13. #include "EditorInterface.h"
  14. //-------------------------------------------------------------------------------------------------
  15. TargetAreaDlg::TargetAreaDlg( float &targetCenterX, float &targetCenterY, float &targetRadius ):CDialog(IDD_TARGET_AREA)
  16. {
  17. m_pTargetCenterX = &targetCenterX;
  18. m_pTargetCenterY = &targetCenterY;
  19. m_pTargetRadius = &targetRadius;
  20. m_pTargetCenterXEditBox = 0;
  21. m_pTargetCenterYEditBox = 0;
  22. m_pTargetRadiusEditBox = 0;
  23. m_pCancelButton = 0;
  24. m_pOKButton = 0;
  25. }
  26. BOOL TargetAreaDlg::OnInitDialog()
  27. {
  28. m_pTargetCenterXEditBox = (CEdit *)GetDlgItem(IDC_TARGET_AREA_CENTER_X_EDIT);
  29. assert( m_pTargetCenterXEditBox );
  30. m_pTargetCenterYEditBox = (CEdit *)GetDlgItem(IDC_TARGET_AREA_CENTER_Y_EDIT);
  31. assert( m_pTargetCenterYEditBox );
  32. m_pTargetRadiusEditBox = (CEdit *)GetDlgItem(IDC_TARGET_AREA_RADIUS_EDIT);
  33. assert( m_pTargetRadiusEditBox );
  34. m_pCancelButton = (CButton *)GetDlgItem(IDCANCEL);
  35. assert( m_pCancelButton );
  36. m_pOKButton = (CButton *)GetDlgItem(IDOK);
  37. assert( m_pOKButton );
  38. EString tmpStr;
  39. tmpStr.Format("%.3f", (*m_pTargetCenterX));
  40. m_pTargetCenterXEditBox->SetWindowText(tmpStr.Data());
  41. tmpStr.Format("%.3f", (*m_pTargetCenterY));
  42. m_pTargetCenterYEditBox->SetWindowText(tmpStr.Data());
  43. tmpStr.Format("%.3f", (*m_pTargetRadius));
  44. m_pTargetRadiusEditBox->SetWindowText(tmpStr.Data());
  45. return 1;
  46. }
  47. BOOL TargetAreaDlg::OnCommand(WPARAM wParam, LPARAM lParam) // called by child controls to inform of an event
  48. {
  49. assert( m_pCancelButton );
  50. assert( m_pOKButton );
  51. return inherited::OnCommand(wParam, lParam);
  52. }
  53. void TargetAreaDlg::OnCancel()
  54. {
  55. EndDialog(IDCANCEL);
  56. }
  57. void TargetAreaDlg::OnOK()
  58. {
  59. CString tmpCStr;
  60. int result;
  61. float tmpFloat;
  62. m_pTargetCenterXEditBox->GetWindowText(tmpCStr);
  63. result = sscanf(tmpCStr.GetBuffer(0), "%f", &tmpFloat);
  64. if (1 == result) {
  65. (*m_pTargetCenterX) = tmpFloat;
  66. }
  67. m_pTargetCenterYEditBox->GetWindowText(tmpCStr);
  68. result = sscanf(tmpCStr.GetBuffer(0), "%f", &tmpFloat);
  69. if (1 == result) {
  70. (*m_pTargetCenterY) = tmpFloat;
  71. }
  72. m_pTargetRadiusEditBox->GetWindowText(tmpCStr);
  73. result = sscanf(tmpCStr.GetBuffer(0), "%f", &tmpFloat);
  74. if (1 == result) {
  75. (*m_pTargetRadius) = tmpFloat;
  76. }
  77. EndDialog(IDOK);
  78. }
  79. //-------------------------------------------------------------------------------------------------
  80. TargetAreaDlg::~TargetAreaDlg()
  81. {
  82. }
  83. //*************************************************************************************************
  84. // end of file ( TargetAreaDlg.cpp )