Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // syncfiledialog.cpp : implementation file
  9. //
  10. #include "stdafx.h"
  11. #include "hammer.h"
  12. #include "dialogwithcheckbox.h"
  13. #include "mapdoc.h"
  14. #include "p4lib/ip4.h"
  15. #include "options.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include <tier0/memdbgon.h>
  18. IMPLEMENT_DYNAMIC(CDialogWithCheckbox, CDialog)
  19. //-----------------------------------------------------------------------------
  20. // Purpose:
  21. // Input :
  22. // Output :
  23. //-----------------------------------------------------------------------------
  24. CDialogWithCheckbox::CDialogWithCheckbox( const char *pszTitleText, const char *pszDialogText, const char *pszCheckboxText, bool bCheckState, bool bDisabled, CWnd* pParent /*=NULL*/ )
  25. : CDialog(CDialogWithCheckbox::IDD, pParent)
  26. , m_strCheckboxText(_T(""))
  27. , m_strDialogText(_T(""))
  28. {
  29. m_bDefaultCheckState = bCheckState;
  30. m_bCheckMark = false;
  31. m_bClickedOk = false;
  32. m_bCheckMarkDisabled = bDisabled;
  33. m_strTitleText = pszTitleText;
  34. m_strDialogText = pszDialogText;
  35. m_strCheckboxText = pszCheckboxText;
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Purpose:
  39. // Input :
  40. // Output :
  41. //-----------------------------------------------------------------------------
  42. CDialogWithCheckbox::~CDialogWithCheckbox()
  43. {
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Purpose:
  47. // Input :
  48. // Output :
  49. //-----------------------------------------------------------------------------
  50. void CDialogWithCheckbox::DoDataExchange(CDataExchange* pDX)
  51. {
  52. CDialog::DoDataExchange(pDX);
  53. DDX_Control(pDX, IDC_DIALOG_ICON, m_IconControl);
  54. DDX_Control(pDX, IDC_CHECKMARK_CONTROL, m_CheckmarkControl);
  55. DDX_Text(pDX, IDC_DIALOG_TEXT, m_strDialogText);
  56. DDX_Text(pDX, IDC_CHECKMARK_TEXT, m_strCheckboxText);
  57. }
  58. BEGIN_MESSAGE_MAP(CDialogWithCheckbox, CDialog)
  59. ON_BN_CLICKED(IDOK, &CDialogWithCheckbox::OnBnClickedOk)
  60. ON_BN_CLICKED(IDCANCEL, &CDialogWithCheckbox::OnBnClickedCancel)
  61. END_MESSAGE_MAP()
  62. //-----------------------------------------------------------------------------
  63. // Purpose:
  64. // Input :
  65. // Output :
  66. //-----------------------------------------------------------------------------
  67. void CDialogWithCheckbox::OnBnClickedOk()
  68. {
  69. m_bCheckMark = ( m_CheckmarkControl.GetCheck() ? true : false );
  70. m_bClickedOk = true;
  71. OnOK();
  72. }
  73. //-----------------------------------------------------------------------------
  74. // Purpose:
  75. // Input :
  76. // Output :
  77. //-----------------------------------------------------------------------------
  78. void CDialogWithCheckbox::OnBnClickedCancel()
  79. {
  80. m_bCheckMark = false;
  81. m_bClickedOk = false;
  82. OnCancel();
  83. }
  84. //-----------------------------------------------------------------------------
  85. // Purpose:
  86. // Input :
  87. // Output :
  88. //-----------------------------------------------------------------------------
  89. BOOL CDialogWithCheckbox::OnInitDialog()
  90. {
  91. CDialog::OnInitDialog();
  92. SetWindowText( m_strTitleText );
  93. m_CheckmarkControl.SetCheck( m_bDefaultCheckState );
  94. if ( m_bCheckMarkDisabled )
  95. {
  96. m_CheckmarkControl.EnableWindow( false );
  97. // also disable the caption next to the checkbox
  98. GetDlgItem( IDC_CHECKMARK_TEXT )->EnableWindow( false );
  99. }
  100. HICON Icon = ::LoadIcon( NULL, MAKEINTRESOURCE( IDI_ERROR ) );
  101. m_IconControl.SetIcon( Icon );
  102. return TRUE;
  103. }
  104. bool CDialogWithCheckbox::IsCheckboxChecked()
  105. {
  106. if ( m_bCheckMark )
  107. {
  108. return true;
  109. }
  110. return false;
  111. }