AxisListCtrl.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // AxisListCtrl.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #ifdef _DEBUG
  16. #undef new
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CAxisListCtrl
  23. CAxisListCtrl::CAxisListCtrl()
  24. {
  25. }
  26. CAxisListCtrl::~CAxisListCtrl()
  27. {
  28. }
  29. BEGIN_MESSAGE_MAP(CAxisListCtrl, CListCtrl)
  30. //{{AFX_MSG_MAP(CAxisListCtrl)
  31. ON_WM_LBUTTONDOWN()
  32. ON_WM_KEYUP()
  33. ON_WM_KEYDOWN()
  34. ON_WM_SETFOCUS()
  35. ON_WM_KILLFOCUS()
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CAxisListCtrl message handlers
  40. void CAxisListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
  41. {
  42. // remember current state of controler's attributes
  43. ((CDlgPlayerControls *)GetParent())->UpdateData( TRUE);
  44. CListCtrl::OnLButtonDown(nFlags, point);
  45. // set state of new controler's attributes
  46. ((CDlgPlayerControls *)GetParent())->UpdateData(FALSE);
  47. }
  48. void CAxisListCtrl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
  49. {
  50. // remember current state of controler's attributes
  51. ((CDlgPlayerControls *)GetParent())->UpdateData( TRUE);
  52. CListCtrl::OnKeyUp(nChar, nRepCnt, nFlags);
  53. // set state of new controler's attributes
  54. ((CDlgPlayerControls *)GetParent())->UpdateData(FALSE);
  55. }
  56. void CAxisListCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  57. {
  58. // remember current state of controler's attributes
  59. ((CDlgPlayerControls *)GetParent())->UpdateData( TRUE);
  60. CListCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
  61. // set state of new controler's attributes
  62. ((CDlgPlayerControls *)GetParent())->UpdateData(FALSE);
  63. }
  64. void CAxisListCtrl::OnSetFocus(CWnd* pOldWnd)
  65. {
  66. // get selected action
  67. INDEX iSelectedAction = GetNextItem( -1, LVNI_DROPHILITED);
  68. // if none is selected (initial state)
  69. if( iSelectedAction == -1)
  70. {
  71. iSelectedAction = 0;
  72. SetItemState( iSelectedAction, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
  73. }
  74. else
  75. {
  76. // clear hilighted state
  77. SetItemState( iSelectedAction, 0, LVIS_DROPHILITED);
  78. }
  79. CListCtrl::OnSetFocus(pOldWnd);
  80. }
  81. void CAxisListCtrl::OnKillFocus(CWnd* pNewWnd)
  82. {
  83. CListCtrl::OnKillFocus(pNewWnd);
  84. // get selected action
  85. INDEX iSelectedAction = GetNextItem( -1, LVNI_SELECTED);
  86. // set hilighted state
  87. SetItemState( iSelectedAction, LVIS_DROPHILITED, LVIS_DROPHILITED);
  88. }
  89. BOOL CAxisListCtrl::PreTranslateMessage(MSG* pMsg)
  90. {
  91. // if return pressed
  92. if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
  93. {
  94. ((CDlgPlayerControls *)GetParent())->m_comboControlerAxis.SetFocus();
  95. // don't translate messages
  96. return TRUE;
  97. }
  98. return CListCtrl::PreTranslateMessage(pMsg);
  99. }