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

对话框与窗口

开发平台:

Visual C++

  1. // DockingPaneManager.cpp: implementation of the CDockingPaneManager 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 "DockingContainers.h"
  22. #include "DockingPaneManager.h"
  23. #ifdef _DEBUG
  24. #undef THIS_FILE
  25. static char THIS_FILE[]=__FILE__;
  26. #define new DEBUG_NEW
  27. #endif
  28. //////////////////////////////////////////////////////////////////////////
  29. // CDockingPaneTabbedContainer
  30. CDockingPaneTabbedContainer::CDockingPaneTabbedContainer(CXTPDockingPaneLayout* pLayout)
  31. : CXTPDockingPaneTabbedContainer(pLayout)
  32. {
  33. GetCaptionButtons()->Add(new CXTPDockingPaneCaptionButton(IDS_ABOUT, this));
  34. EnableToolTips();
  35. }
  36. void CDockingPaneTabbedContainer::OnCaptionButtonClick(CXTPDockingPaneCaptionButton* pButton)
  37. {
  38. CXTPDockingPaneTabbedContainer::OnCaptionButtonClick(pButton);
  39. if (pButton->GetID() == IDS_ABOUT)
  40. {
  41. ((CDockingContainersApp*)AfxGetApp())->OnAppAbout();
  42. }
  43. }
  44. BOOL CDockingPaneTabbedContainer::IsCaptionButtonVisible(CXTPDockingPaneCaptionButton* pButton)
  45. {
  46. if (pButton->GetID() == IDS_ABOUT)
  47. return DYNAMIC_DOWNCAST(CXTPDockingPaneMiniWnd, GetParentFrame()) == 0;
  48. return CXTPDockingPaneTabbedContainer::IsCaptionButtonVisible(pButton);
  49. }
  50. //////////////////////////////////////////////////////////////////////////
  51. // CDockingPaneMiniWnd
  52. CDockingPaneMiniWnd::CDockingPaneMiniWnd(CXTPDockingPaneLayout* pLayout)
  53. : CXTPDockingPaneMiniWnd(pLayout)
  54. {
  55. GetCaptionButtons()->Add(new CXTPDockingPaneCaptionButton(IDS_ABOUT, this));
  56. }
  57. void CDockingPaneMiniWnd::OnCaptionButtonClick(CXTPDockingPaneCaptionButton* pButton)
  58. {
  59. CXTPDockingPaneMiniWnd::OnCaptionButtonClick(pButton);
  60. if (pButton->GetID() == IDS_ABOUT)
  61. {
  62. ((CDockingContainersApp*)AfxGetApp())->OnAppAbout();
  63. }
  64. }
  65. BEGIN_MESSAGE_MAP(CDockingPaneMiniWnd, CXTPDockingPaneMiniWnd)
  66. ON_WM_NCRBUTTONDOWN()
  67. END_MESSAGE_MAP()
  68. void CDockingPaneMiniWnd::OnNcRButtonDown(UINT nHitTest, CPoint point)
  69. {
  70. if (nHitTest == HTCAPTION)
  71. {
  72. CXTPPopupBar* pPopupBar = CXTPPopupBar::CreatePopupBar(((CXTPMDIFrameWnd*)AfxGetMainWnd())->GetCommandBars());
  73. CXTPDockingPaneManager* pManager = GetDockingPaneManager();
  74. POSITION pos = pManager->GetPaneList().GetHeadPosition();
  75. while (pos)
  76. {
  77. CXTPDockingPane* pPane = pManager->GetPaneList().GetNext(pos);
  78. CXTPControl* pControl = pPopupBar->GetControls()->Add(xtpControlButton, pPane->GetID());
  79. pControl->SetCaption(pPane->GetTitle());
  80. pControl->SetFlags(xtpFlagManualUpdate);
  81. }
  82. UINT nID = CXTPCommandBars::TrackPopupMenu(pPopupBar, TPM_RETURNCMD, point.x, point.y, AfxGetMainWnd());
  83. if (nID > 0)
  84. {
  85. pManager->ShowPane(nID);
  86. }
  87. pPopupBar->InternalRelease();
  88. }
  89. CXTPDockingPaneMiniWnd::OnNcRButtonDown(nHitTest, point);
  90. }
  91. //////////////////////////////////////////////////////////////////////////
  92. // CDockingPanePaintManager
  93. CDockingPanePaintManager::CDockingPanePaintManager()
  94. {
  95. m_nSplitterSize = 6;
  96. }
  97. void DrawAboutGlyph(CDC* pDC, CPoint pt, COLORREF clr)
  98. {
  99. CXTPPenDC pen(*pDC, clr);
  100. POINT pts[] = {
  101. { pt.x - 1, pt.y - 2 }, { pt.x , pt.y - 3 },    { pt.x + 2, pt.y - 3 },
  102. { pt.x + 3, pt.y - 2 }, { pt.x + 3, pt.y -1 },  { pt.x + 1, pt.y + 1 },
  103. { pt.x + 1, pt.y + 3 }};
  104. pDC->Polyline(&pts[0], sizeof(pts) / sizeof(POINT));
  105. pDC->SetPixel(pt.x + 1, pt.y + 4, clr);
  106. }
  107. void CDockingPanePaintManager::RoundRect(CDC* pDC, CRect rc, COLORREF clr)
  108. {
  109. CXTPBrushDC brush(*pDC, clr);
  110. CXTPPenDC pen(*pDC, GetXtremeColor(XPCOLOR_MENUBAR_BORDER));
  111. pDC->RoundRect(rc.left, rc.top, rc.right, rc.bottom, 6, 6);
  112. }
  113. void CDockingPanePaintManager::DrawCaptionButtonEntry(CDC* pDC, CXTPDockingPaneCaptionButton* pButton, CPoint pt, COLORREF clrButton)
  114. {
  115. if (pButton->GetID() == IDS_ABOUT)
  116. {
  117. DrawAboutGlyph(pDC, CPoint(pt.x - 2, pt.y - 1), clrButton);
  118. DrawAboutGlyph(pDC, CPoint(pt.x - 1, pt.y -1), clrButton);
  119. }
  120. else
  121. {
  122. CXTPDockingPaneOffice2003Theme::DrawCaptionButtonEntry(pDC, pButton, pt, clrButton);
  123. }
  124. }
  125. void CDockingPanePaintManager::DrawCaptionButton(CDC* pDC, CXTPDockingPaneCaptionButton* pButton, COLORREF clrText)
  126. {
  127. if (m_bLunaTheme)
  128. {
  129. CXTPDockingPaneOffice2003Theme::DrawCaptionButton(pDC, pButton, clrText);
  130. return;
  131. }
  132. CRect rc(pButton->GetRect());
  133. if (pButton->IsSelected())
  134. RoundRect(pDC, rc, m_clrNormalCaption.clrLight);
  135. if (pButton->IsPressed())
  136. RoundRect(pDC, rc, m_clrNormalCaption.clrDark);
  137. DrawCaptionButtonEntry(pDC, pButton, rc.CenterPoint(), clrText);
  138. }
  139. void CDockingPanePaintManager::DrawSplitter(CDC& dc, CXTPDockingPaneSplitterWnd* pSplitter)
  140. {
  141. CXTPClientRect rc(pSplitter);
  142. dc.FillSolidRect(rc, GetXtremeColor(XPCOLOR_3DFACE));
  143. if (!pSplitter->IsHorizontal())
  144. {
  145. for (int y = 1; y < rc.Height() - 1; y += 4)
  146. {
  147. dc.FillSolidRect(3, y + 1, 2, 2, GetXtremeColor(COLOR_BTNHIGHLIGHT));
  148. dc.FillSolidRect(2, y, 2, 2, GetXtremeColor(XPCOLOR_TOOLBAR_GRIPPER));
  149. }
  150. }
  151. else
  152. {
  153. for (int x = 1; x < rc.Width() - 1; x += 4)
  154. {
  155. dc.FillSolidRect(x + 1, 3, 2, 2, GetXtremeColor(COLOR_BTNHIGHLIGHT));
  156. dc.FillSolidRect(x, 2, 2, 2, GetXtremeColor(XPCOLOR_TOOLBAR_GRIPPER));
  157. }
  158. }
  159. }
  160. //////////////////////////////////////////////////////////////////////
  161. // CDockingPaneManager
  162. CDockingPaneManager::CDockingPaneManager()
  163. {
  164. }
  165. CDockingPaneManager::~CDockingPaneManager()
  166. {
  167. }
  168. CXTPDockingPaneBase* CDockingPaneManager::OnCreatePane(XTPDockingPaneType type, CXTPDockingPaneLayout* pLayout)
  169. {
  170. if (type == xtpPaneTypeTabbedContainer)
  171. return new CDockingPaneTabbedContainer(pLayout);
  172. if (type == xtpPaneTypeMiniWnd)
  173. return new CDockingPaneMiniWnd(pLayout);
  174. return CXTPDockingPaneManager::OnCreatePane(type, pLayout);
  175. }