PaneActionsView.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:4k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // PaneActionsView.cpp : implementation of the CPaneActionsView class
  2. //
  3. // This file is a part of the XTREME TOOLKIT PRO MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "PaneActions.h"
  22. #include "PaneActionsDoc.h"
  23. #include "PaneActionsView.h"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CPaneActionsView
  31. IMPLEMENT_DYNCREATE(CPaneActionsView, CListView)
  32. BEGIN_MESSAGE_MAP(CPaneActionsView, CListView)
  33. //{{AFX_MSG_MAP(CPaneActionsView)
  34. ON_WM_CREATE()
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CPaneActionsView construction/destruction
  39. CPaneActionsView::CPaneActionsView()
  40. {
  41. // TODO: add construction code here
  42. }
  43. CPaneActionsView::~CPaneActionsView()
  44. {
  45. }
  46. BOOL CPaneActionsView::PreCreateWindow(CREATESTRUCT& cs)
  47. {
  48. cs.style |= WS_CLIPCHILDREN|WS_CLIPSIBLINGS;
  49. return CListView::PreCreateWindow(cs);
  50. }
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CPaneActionsView drawing
  53. void CPaneActionsView::OnDraw(CDC* /*pDC*/)
  54. {
  55. }
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CPaneActionsView diagnostics
  58. #ifdef _DEBUG
  59. void CPaneActionsView::AssertValid() const
  60. {
  61. CListView::AssertValid();
  62. }
  63. void CPaneActionsView::Dump(CDumpContext& dc) const
  64. {
  65. CListView::Dump(dc);
  66. }
  67. CPaneActionsDoc* CPaneActionsView::GetDocument() // non-debug version is inline
  68. {
  69. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPaneActionsDoc)));
  70. return (CPaneActionsDoc*)m_pDocument;
  71. }
  72. #endif //_DEBUG
  73. /////////////////////////////////////////////////////////////////////////////
  74. // CPaneActionsView message handlers
  75. void CPaneActionsView::OnInitialUpdate()
  76. {
  77. CListView::OnInitialUpdate();
  78. CListCtrl& wndList = GetListCtrl();
  79. wndList.DeleteAllItems();
  80. }
  81. int CPaneActionsView::OnCreate(LPCREATESTRUCT lpCreateStruct)
  82. {
  83. if (CListView::OnCreate(lpCreateStruct) == -1)
  84. return -1;
  85. CListCtrl& wndList = GetListCtrl();
  86. wndList.ModifyStyle(0, LVS_REPORT);
  87. wndList.InsertColumn(0, _T("Action"), LVCFMT_LEFT, 300);
  88. wndList.InsertColumn(1, _T("Pane"), LVCFMT_LEFT, 100);
  89. wndList.InsertColumn(2, _T("Cancelable"), LVCFMT_CENTER, 100);
  90. wndList.InsertColumn(3, _T("Canceled"), LVCFMT_CENTER, 100);
  91. return 0;
  92. }
  93. void CPaneActionsView::AddAction(XTP_DOCKINGPANE_ACTION* pAction)
  94. {
  95. CListCtrl& wndList = GetListCtrl();
  96. if (!wndList.GetSafeHwnd())
  97. return;
  98. CString strAction = pAction->action < _countof(lpszActions)? lpszActions[pAction->action]: _T("Unknown");
  99. int nIndex = wndList.InsertItem(wndList.GetItemCount(), strAction, -1);
  100. wndList.SetItem(nIndex, 1, LVIF_TEXT, pAction->pPane->GetTitle(), 0, 0, 0, 0);
  101. BOOL bCancelable = (pAction->action % 2 == 0 && pAction->action < xtpPaneActionActivated)
  102. || (pAction->action == xtpPaneActionDetaching) || (pAction->action == xtpPaneActionDragging)
  103.  || (pAction->action == xtpPaneActionUnpinning) || (pAction->action == xtpPaneActionSplitterResizing);
  104. wndList.SetItem(nIndex, 2, LVIF_TEXT, bCancelable? _T("true"): _T("false"), 0, 0, 0, 0);
  105. if (bCancelable)
  106. wndList.SetItem(nIndex, 3, LVIF_TEXT, pAction->bCancel? _T("true"): _T("false"), 0, 0, 0, 0);
  107. }