Team Fortress 2 Source Code as on 22/4/2020
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.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // Vkeylistview.cpp : implementation file
  9. //
  10. #include "stdafx.h"
  11. #include "vkeyedit.h"
  12. #include "Vkeylistview.h"
  13. #include <KeyValues.h>
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CVkeylistview
  21. IMPLEMENT_DYNCREATE(CVkeylistview, CListView)
  22. CVkeylistview::CVkeylistview()
  23. {
  24. }
  25. CVkeylistview::~CVkeylistview()
  26. {
  27. }
  28. BEGIN_MESSAGE_MAP(CVkeylistview, CListView)
  29. //{{AFX_MSG_MAP(CVkeylistview)
  30. // NOTE - the ClassWizard will add and remove mapping macros here.
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CVkeylistview drawing
  35. void CVkeylistview::OnDraw(CDC* pDC)
  36. {
  37. CDocument* pDoc = GetDocument();
  38. // TODO: add draw code here
  39. }
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CVkeylistview diagnostics
  42. #ifdef _DEBUG
  43. void CVkeylistview::AssertValid() const
  44. {
  45. CListView::AssertValid();
  46. }
  47. void CVkeylistview::Dump(CDumpContext& dc) const
  48. {
  49. CListView::Dump(dc);
  50. }
  51. #endif //_DEBUG
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CVkeylistview message handlers
  54. void CVkeylistview::OnInitialUpdate()
  55. {
  56. CListView::OnInitialUpdate();
  57. CListCtrl &theList = GetListCtrl();
  58. theList.DeleteColumn( 0 );
  59. theList.DeleteColumn( 0 );
  60. theList.InsertColumn( 0, _T("Name"), LVCFMT_LEFT, 200 );
  61. theList.InsertColumn( 1, _T("Value"), LVCFMT_LEFT, 800 );
  62. theList.SetExtendedStyle( LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES );
  63. }
  64. void CVkeylistview::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType)
  65. {
  66. // TODO: Add your specialized code here and/or call the base class
  67. CListView::CalcWindowRect(lpClientRect, nAdjustType);
  68. }
  69. BOOL CVkeylistview::PreCreateWindow(CREATESTRUCT& cs)
  70. {
  71. // TODO: Add your specialized code here and/or call the base class
  72. return CListView::PreCreateWindow(cs);
  73. }
  74. BOOL CVkeylistview::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
  75. {
  76. // TODO: Add your specialized code here and/or call the base class
  77. dwStyle |= LVS_REPORT|LVS_SINGLESEL|LVS_EDITLABELS|LVS_AUTOARRANGE;
  78. return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  79. }
  80. void CVkeylistview::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
  81. {
  82. KeyValues *kv = (KeyValues *)pHint;
  83. if ( !kv || lHint != 2 )
  84. return;
  85. CListCtrl &theList = GetListCtrl();
  86. theList.DeleteAllItems();
  87. KeyValues *subkey = kv->GetFirstValue();
  88. LVITEM lvi;
  89. int i = 0;
  90. while ( subkey )
  91. {
  92. lvi.mask = LVIF_TEXT;
  93. lvi.iItem = i;
  94. lvi.iSubItem = 0;
  95. lvi.pszText = (char*)subkey->GetName();
  96. theList.InsertItem(&lvi);
  97. lvi.iSubItem =1;
  98. lvi.pszText = (char*)subkey->GetString();
  99. theList.SetItem(&lvi);
  100. i++;
  101. subkey = subkey->GetNextValue();
  102. }
  103. }