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.

142 lines
3.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "stdafx.h"
  8. #include "SelectModeDlgBar.h"
  9. #include "ControlBarIDs.h"
  10. #include "MapDoc.h"
  11. #include "Selection.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include <tier0/memdbgon.h>
  14. BEGIN_MESSAGE_MAP(CSelectModeDlgBar, CHammerBar)
  15. //{{AFX_MSG_MAP(CSelectModeDlgBar)
  16. ON_BN_CLICKED(IDC_GROUPS, OnGroups)
  17. ON_BN_CLICKED(IDC_OBJECTS, OnObjects)
  18. ON_BN_CLICKED(IDC_SOLIDS, OnSolids)
  19. ON_UPDATE_COMMAND_UI(IDC_GROUPS, UpdateControlGroups)
  20. ON_UPDATE_COMMAND_UI(IDC_OBJECTS, UpdateControlObjects)
  21. ON_UPDATE_COMMAND_UI(IDC_SOLIDS, UpdateControlSolids)
  22. //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24. //-----------------------------------------------------------------------------
  25. // Purpose:
  26. // Input : pParentWnd -
  27. // Output : Returns TRUE on success, FALSE on failure.
  28. //-----------------------------------------------------------------------------
  29. BOOL CSelectModeDlgBar::Create(CWnd *pParentWnd)
  30. {
  31. if (!CHammerBar::Create(pParentWnd, IDD_SELECT_MODE_BAR, CBRS_RIGHT, IDCB_SELECT_MODE_BAR))
  32. {
  33. return FALSE;
  34. }
  35. SetWindowText("Selection Mode");
  36. return TRUE;
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. // Input : pCmdUI -
  41. //-----------------------------------------------------------------------------
  42. void CSelectModeDlgBar::UpdateControlGroups(CCmdUI *pCmdUI)
  43. {
  44. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  45. if (pDoc != NULL)
  46. {
  47. pCmdUI->Enable(TRUE);
  48. pCmdUI->SetCheck(pDoc->GetSelection()->GetMode() == selectGroups);
  49. }
  50. else
  51. {
  52. pCmdUI->Enable(FALSE);
  53. }
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. //-----------------------------------------------------------------------------
  58. void CSelectModeDlgBar::UpdateControlObjects(CCmdUI *pCmdUI)
  59. {
  60. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  61. if (pDoc != NULL)
  62. {
  63. pCmdUI->Enable(TRUE);
  64. pCmdUI->SetCheck(pDoc->GetSelection()->GetMode() == selectObjects);
  65. }
  66. else
  67. {
  68. pCmdUI->Enable(FALSE);
  69. }
  70. }
  71. //-----------------------------------------------------------------------------
  72. // Purpose:
  73. //-----------------------------------------------------------------------------
  74. void CSelectModeDlgBar::UpdateControlSolids(CCmdUI *pCmdUI)
  75. {
  76. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  77. if (pDoc != NULL)
  78. {
  79. pCmdUI->Enable(TRUE);
  80. pCmdUI->SetCheck(pDoc->GetSelection()->GetMode() == selectSolids);
  81. }
  82. else
  83. {
  84. pCmdUI->Enable(FALSE);
  85. }
  86. }
  87. //-----------------------------------------------------------------------------
  88. // Purpose:
  89. //-----------------------------------------------------------------------------
  90. void CSelectModeDlgBar::OnGroups(void)
  91. {
  92. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  93. if (pDoc != NULL)
  94. {
  95. pDoc->GetSelection()->SetMode(selectGroups);
  96. ((CButton *)GetDlgItem(IDC_GROUPS))->SetCheck(TRUE);
  97. }
  98. }
  99. //-----------------------------------------------------------------------------
  100. // Purpose:
  101. //-----------------------------------------------------------------------------
  102. void CSelectModeDlgBar::OnObjects(void)
  103. {
  104. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  105. if (pDoc != NULL)
  106. {
  107. pDoc->GetSelection()->SetMode(selectObjects);
  108. ((CButton *)GetDlgItem(IDC_OBJECTS))->SetCheck(TRUE);
  109. }
  110. }
  111. //-----------------------------------------------------------------------------
  112. // Purpose:
  113. //-----------------------------------------------------------------------------
  114. void CSelectModeDlgBar::OnSolids(void)
  115. {
  116. CMapDoc *pDoc = CMapDoc::GetActiveMapDoc();
  117. if (pDoc != NULL)
  118. {
  119. pDoc->GetSelection()->SetMode(selectSolids);
  120. ((CButton *)GetDlgItem(IDC_SOLIDS))->SetCheck(TRUE);
  121. }
  122. }