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

对话框与窗口

开发平台:

Visual C++

  1. // XTPDockingPaneTabbedContainer.cpp : implementation of the CXTPDockingPaneTabbedContainer class.
  2. //
  3. // This file is a part of the XTREME DOCKINGPANE 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 "Resource.h"
  22. #include "Common/XTPResourceManager.h"
  23. #include "Common/XTPVC80Helpers.h"
  24. #include "Common/XTPDrawHelpers.h"
  25. #include "Common/XTPToolTipContext.h"
  26. #include "TabManager/XTPTabManager.h"
  27. #include "XTPDockingPaneTabbedContainer.h"
  28. #include "XTPDockingPane.h"
  29. #include "XTPDockingPaneContext.h"
  30. #include "XTPDockingPaneManager.h"
  31. #include "XTPDockingPanePaintManager.h"
  32. #include "XTPDockingPaneLayout.h"
  33. #include "XTPDockingPaneAutoHidePanel.h"
  34. #include "XTPDockingPaneMiniWnd.h"
  35. #include "XTPDockingPaneSplitterContainer.h"
  36. #include "XTPDockingPaneSidePanel.h"
  37. #ifdef _DEBUG
  38. #define new DEBUG_NEW
  39. #undef THIS_FILE
  40. static char THIS_FILE[] = __FILE__;
  41. #endif
  42. //////////////////////////////////////////////////////////////////////////
  43. // CTabManagerDropTarget
  44. class CXTPDockingPaneTabbedContainer::CContainerDropTarget : public COleDropTarget
  45. {
  46. virtual DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* /*pDataObject*/, DWORD /*dwKeyState*/, CPoint point)
  47. {
  48. CXTPDockingPaneTabbedContainer* pControl = (CXTPDockingPaneTabbedContainer*)pWnd;
  49. ASSERT_VALID(pControl);
  50. if (!pControl->GetPaintManager()->m_bSelectOnDragOver)
  51. return DROPEFFECT_NONE;
  52. CXTPTabManagerItem* pItem = pControl->CXTPTabManager::HitTest(point);
  53. if (pItem)
  54. {
  55. CXTPDockingPane* pPane = pControl->GetItemPane(pItem->GetIndex());
  56. if (pControl->GetSelected() != pPane)
  57. {
  58. pControl->SelectPane(pPane, FALSE, FALSE);
  59. }
  60. }
  61. return DROPEFFECT_NONE;
  62. }
  63. };
  64. // CXTPDockingPaneTabbedContainer
  65. void CXTPDockingPaneTabbedContainer::RedrawControl(LPCRECT lpRect, BOOL /*bAnimate*/)
  66. {
  67. if (!m_bLockReposition)
  68. {
  69. if (GetSafeHwnd()) InvalidateRect(lpRect, FALSE);
  70. }
  71. }
  72. void CXTPDockingPaneTabbedContainer::Reposition()
  73. {
  74. if (!m_bLockReposition)
  75. {
  76. GetDockingPaneManager()->RedrawPanes();
  77. }
  78. }
  79. CXTPTabPaintManager* CXTPDockingPaneTabbedContainer::GetPaintManager() const
  80. {
  81. return CXTPDockingPaneBase::GetPaintManager()->GetTabPaintManager();
  82. }
  83. void CXTPDockingPaneTabbedContainer::SetPaintManager(CXTPTabPaintManager* /*pPaintManager*/)
  84. {
  85. }
  86. BOOL CXTPDockingPaneTabbedContainer::DrawIcon(CDC* pDC, CPoint pt, CXTPTabManagerItem* pItem, BOOL bDraw, CSize& szIcon) const
  87. {
  88. if (!pItem)
  89. return TRUE;
  90. if (!CXTPDockingPaneBase::GetPaintManager()->GetTabPaintManager()->m_bShowIcons)
  91. return FALSE;
  92. CXTPImageManagerIcon* pImage = ((CXTPDockingPane*)pItem->GetData())->GetIcon(szIcon.cx);
  93. if (!pImage)
  94. return FALSE;
  95. if (!bDraw)
  96. {
  97. return TRUE;
  98. }
  99. pItem->DrawImage(pDC, CRect(pt, szIcon), pImage);
  100. return TRUE;
  101. }
  102. IMPLEMENT_DYNAMIC(CXTPDockingPaneTabbedContainer, CWnd)
  103. CXTPDockingPaneTabbedContainer::CXTPDockingPaneTabbedContainer(CXTPDockingPaneLayout* pLayout)
  104. : CXTPDockingPaneBaseContainer(xtpPaneTypeTabbedContainer, pLayout)
  105. {
  106. m_pSelectedPane = 0;
  107. m_pTrackingPane = 0;
  108. m_bLockReposition = FALSE;
  109. m_bActive = FALSE;
  110. m_bTitleVisible = TRUE;
  111. m_bDelayRedraw = FALSE;
  112. m_pCaptionButtons = new CXTPDockingPaneCaptionButtons();
  113. m_pCaptionButtons->Add(new CXTPDockingPaneCaptionButton(XTP_IDS_DOCKINGPANE_CLOSE, this));
  114. m_pCaptionButtons->Add(new CXTPDockingPaneCaptionButton(XTP_IDS_DOCKINGPANE_MAXIMIZE, this));
  115. m_pCaptionButtons->Add(new CXTPDockingPaneCaptionButton(XTP_IDS_DOCKINGPANE_RESTORE, this));
  116. m_pCaptionButtons->Add(new CXTPDockingPaneCaptionButton(XTP_IDS_DOCKINGPANE_AUTOHIDE, this));
  117. m_pCaptionButtons->Add(new CXTPDockingPaneCaptionButton(XTP_IDS_DOCKINGPANE_MENU, this));
  118. m_pDropTarget = new CContainerDropTarget();
  119. m_bMaximized = FALSE;
  120. EnableAutomation();
  121. }
  122. CXTPDockingPaneCaptionButton* CXTPDockingPaneTabbedContainer::GetCloseButton() const
  123. {
  124. return FindCaptionButton(XTP_IDS_DOCKINGPANE_CLOSE);
  125. }
  126. CXTPDockingPaneCaptionButton* CXTPDockingPaneTabbedContainer::GetPinButton() const
  127. {
  128. return FindCaptionButton(XTP_IDS_DOCKINGPANE_AUTOHIDE);
  129. }
  130. void CXTPDockingPaneTabbedContainer::Init(CXTPDockingPane* pPane, CWnd* pFrame)
  131. {
  132. ASSERT(pPane);
  133. if (!pPane)
  134. return;
  135. m_pDockingSite = pFrame;
  136. m_szDocking = pPane->m_szDocking;
  137. m_rcWindow = pPane->m_rcWindow;
  138. _InsertPane(pPane);
  139. SelectPane(pPane);
  140. }
  141. CXTPDockingPaneTabbedContainer::~CXTPDockingPaneTabbedContainer()
  142. {
  143. if (m_hWnd) DestroyWindow();
  144. delete m_pDropTarget;
  145. }
  146. void CXTPDockingPaneTabbedContainer::SetDockingSite(CWnd* pFrame)
  147. {
  148. m_pDockingSite = pFrame;
  149. if (m_hWnd && !pFrame->GetSafeHwnd())
  150. {
  151. pFrame = GetDockingPaneManager()->GetSite();
  152. }
  153. if (m_hWnd)
  154. {
  155. if (GetParent() != pFrame) CWnd::SetParent(pFrame);
  156. }
  157. POSITION pos = GetHeadPosition();
  158. while (pos)
  159. {
  160. CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos);
  161. pPane->SetDockingSite(m_pDockingSite);
  162. }
  163. }
  164. BOOL CXTPDockingPaneTabbedContainer::IsTabsVisible() const
  165. {
  166. return m_hWnd && !DYNAMIC_DOWNCAST(CXTPDockingPaneAutoHideWnd, GetParent())
  167. && (GetItemCount() > 1 || CXTPDockingPaneBase::GetPaintManager()->m_bDrawSingleTab);
  168. }
  169. void CXTPDockingPaneTabbedContainer::InvalidatePane(BOOL bSelectionChanged)
  170. {
  171. if (!GetSafeHwnd())
  172. return;
  173. if (m_pParentContainer == 0)
  174. return;
  175. if (m_bLockReposition)
  176. return;
  177. m_bLockReposition += 1;
  178. OnTabsChanged();
  179. m_bLockReposition -= 1;
  180. CRect rect = m_rcWindow;
  181. CXTPDockingPaneBase::GetPaintManager()->AdjustClientRect(this, rect, TRUE);
  182. if (bSelectionChanged)
  183. {
  184. POSITION pos = GetHeadPosition();
  185. while (pos)
  186. {
  187. CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos);
  188. pPane->ShowWindow(m_pSelectedPane == pPane);
  189. pPane->OnSizeParent(m_pDockingSite, rect, 0);
  190. }
  191. }
  192. Invalidate(FALSE);
  193. m_pParentContainer->InvalidatePane(bSelectionChanged);
  194. }
  195. void CXTPDockingPaneTabbedContainer::OnSizeParent(CWnd* pParent, CRect rect, LPVOID lParam)
  196. {
  197. AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
  198. ASSERT(!IsEmpty());
  199. SetDockingSite(pParent);
  200. m_rcWindow = rect;
  201. if (lpLayout == 0 || lpLayout->hDWP != NULL)
  202. {
  203. CRect rectOld;
  204. ::GetWindowRect(m_hWnd, rectOld);
  205. HWND hWndParent = ::GetParent(m_hWnd);
  206. ::ScreenToClient(hWndParent, &rectOld.TopLeft());
  207. ::ScreenToClient(hWndParent, &rectOld.BottomRight());
  208. if (rectOld != rect || m_bDelayRedraw)
  209. {
  210. SetWindowPos(&CWnd::wndBottom, rect.left, rect.top, rect.Width(), rect.Height(), 0);
  211. Invalidate(FALSE);
  212. m_bDelayRedraw = FALSE;
  213. }
  214. else
  215. {
  216. SetWindowPos(&CWnd::wndBottom, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOMOVE | SWP_NOSIZE);
  217. }
  218. m_bLockReposition += 1;
  219. OnTabsChanged();
  220. m_bLockReposition -= 1;
  221. GetPinButton()->SetState(IsHidden() ? xtpPanePinVisible | xtpPanePinPushed: DYNAMIC_DOWNCAST(CXTPDockingPaneMiniWnd, pParent) == 0 ? xtpPanePinVisible : 0);
  222. CXTPDockingPaneBase::GetPaintManager()->AdjustClientRect(this, rect, TRUE);
  223. POSITION pos = GetHeadPosition();
  224. while (pos)
  225. {
  226. CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos);
  227. pPane->ShowWindow(m_pSelectedPane == pPane);
  228. pPane->OnSizeParent(pParent, rect, lParam);
  229. }
  230. }
  231. }
  232. void CXTPDockingPaneTabbedContainer::OnTabsChanged()
  233. {
  234. if (!m_hWnd)
  235. return;
  236. m_bLockReposition += 1;
  237. DeleteAllItems();
  238. POSITION pos = GetHeadPosition();
  239. while (pos)
  240. {
  241. CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos);
  242. CXTPTabManagerItem* pItem = AddItem(GetItemCount());
  243. if (m_pSelectedPane == pPane) SetSelectedItem(pItem);
  244. pItem->SetCaption(pPane->GetShortTitle());
  245. pItem->SetColor(pPane->GetItemColor());
  246. pItem->SetTooltip(pPane->GetTitle());
  247. pItem->SetEnabled(pPane->GetEnabled() & xtpPaneEnableClient);
  248. pItem->SetData((DWORD_PTR)pPane);
  249. }
  250. //////////////////////////////////////////////////////////////////////////
  251. m_pCaptionButtons->CheckForMouseOver(CPoint(-1, -1));
  252. m_bLockReposition -= 1;
  253. }
  254. void CXTPDockingPaneTabbedContainer::CreateContainer()
  255. {
  256. SAFE_CALLPTR(m_pParentContainer, CreateContainer());
  257. if (!m_hWnd)
  258. {
  259. Create(_T("XTPDockingPaneTabbedContainer"), _T(""), WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), GetDockingSite(), 0);
  260. m_pDropTarget->Register(this);
  261. }
  262. }
  263. void CXTPDockingPaneTabbedContainer::_InsertPane(CXTPDockingPane* pPane, BOOL bSetFocus)
  264. {
  265. ASSERT(m_pLayout);
  266. if (!m_pLayout)
  267. return;
  268. if (!m_hWnd && !m_pLayout->IsUserLayout())
  269. {
  270. CreateContainer();
  271. }
  272. m_lstPanes.AddTail(pPane);
  273. pPane->SetParentContainer(this);
  274. pPane->SetDockingSite(GetDockingSite());
  275. m_bDelayRedraw = TRUE;
  276. GetDockingPaneManager()->RecalcFrameLayout(this, TRUE);
  277. SelectPane(pPane, bSetFocus);
  278. SAFE_CALLPTR(m_pParentContainer, OnChildContainerChanged(this));
  279. }
  280. void CXTPDockingPaneTabbedContainer::RemovePane(CXTPDockingPaneBase* pPane)
  281. {
  282. ASSERT(pPane->GetContainer() == this);
  283. POSITION pos = m_lstPanes.Find((CXTPDockingPane*)pPane);
  284. ASSERT(pos);
  285. m_lstPanes.RemoveAt(pos);
  286. OnTabsChanged();
  287. pPane->SetParentContainer(NULL);
  288. m_pParentContainer->OnChildContainerChanged(this);
  289. if (m_lstPanes.IsEmpty())
  290. {
  291. if (m_bActive)
  292. {
  293. GetDockingPaneManager()->GetSite()->SetFocus();
  294. m_bActive = FALSE;
  295. GetDockingPaneManager()->OnActivatePane(FALSE, m_pSelectedPane);
  296. }
  297. DestroyWindow();
  298. }
  299. m_bDelayRedraw = TRUE;
  300. GetDockingPaneManager()->RecalcFrameLayout(this, TRUE);
  301. if (pPane == m_pSelectedPane)
  302. {
  303. SelectPane((CXTPDockingPane*)GetLastPane());
  304. }
  305. }
  306. BEGIN_MESSAGE_MAP(CXTPDockingPaneTabbedContainer, CWnd)
  307. ON_WM_PAINT()
  308. ON_MESSAGE(WM_PRINTCLIENT, OnPrintClient)
  309. ON_WM_LBUTTONDOWN()
  310. ON_WM_RBUTTONDOWN()
  311. ON_WM_RBUTTONUP()
  312. ON_WM_MOUSEMOVE()
  313. ON_WM_LBUTTONUP()
  314. ON_WM_CAPTURECHANGED()
  315. ON_WM_LBUTTONDBLCLK()
  316. ON_MESSAGE_VOID(WM_MOUSELEAVE, OnMouseLeave)
  317. ON_MESSAGE(WM_HELPHITTEST, OnHelpHitTest)
  318. ON_WM_DESTROY()
  319. ON_WM_SETCURSOR()
  320. ON_MESSAGE(WM_GETOBJECT, OnGetObject)
  321. END_MESSAGE_MAP()
  322. // CXTPDockingPaneTabbedContainer message handlers
  323. void CXTPDockingPaneTabbedContainer::OnDestroy()
  324. {
  325. CWnd::OnDestroy();
  326. }
  327. void CXTPDockingPaneTabbedContainer::DeletePane()
  328. {
  329. InternalRelease();
  330. }
  331. void CXTPDockingPaneTabbedContainer::OnFinalRelease()
  332. {
  333. if (m_hWnd != NULL)
  334. DestroyWindow();
  335. CCmdTarget::OnFinalRelease();
  336. }
  337. BOOL CXTPDockingPaneTabbedContainer::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
  338. {
  339. if (GetDockingPaneManager()->m_bShowSizeCursorWhileDragging)
  340. {
  341. POINT pt;
  342. GetCursorPos(&pt);
  343. ScreenToClient(&pt);
  344. if (CXTPDockingPaneBase::GetPaintManager()->GetCaptionGripperRect(this).PtInRect(pt))
  345. {
  346. SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZEALL));
  347. return TRUE;
  348. }
  349. }
  350. return CWnd::OnSetCursor(pWnd, nHitTest, message);
  351. }
  352. LRESULT CXTPDockingPaneTabbedContainer::OnPrintClient(WPARAM wParam, LPARAM /*lParam*/)
  353. {
  354. CDC* pDC = CDC::FromHandle((HDC)wParam);
  355. if (pDC)
  356. {
  357. CXTPClientRect rc(this);
  358. CXTPDockingPaneBase::GetPaintManager()->DrawPane(pDC, this, rc);
  359. }
  360. return TRUE;
  361. }
  362. void CXTPDockingPaneTabbedContainer::OnPaint()
  363. {
  364. CPaintDC dcPaint(this);
  365. CXTPClientRect rc(this);
  366. CXTPBufferDC dc(dcPaint);
  367. CXTPDockingPaneBase::GetPaintManager()->DrawPane(&dc, this, rc);
  368. }
  369. void CXTPDockingPaneTabbedContainer::ShowTitle(BOOL bShow)
  370. {
  371. if (m_bTitleVisible != bShow)
  372. {
  373. m_bTitleVisible = bShow;
  374. m_bDelayRedraw = TRUE;
  375. GetDockingPaneManager()->RecalcFrameLayout(this, TRUE);
  376. }
  377. }
  378. BOOL CXTPDockingPaneTabbedContainer::IsTitleVisible() const
  379. {
  380. return m_bTitleVisible &&
  381. (m_pSelectedPane && ((m_pSelectedPane->GetOptions() & xtpPaneNoCaption) == 0)) &&
  382. CXTPDockingPaneBase::GetPaintManager()->m_bShowCaption;
  383. }
  384. CString CXTPDockingPaneTabbedContainer::GetTitle() const
  385. {
  386. return m_pSelectedPane ? m_pSelectedPane->GetTitle() : _T("");
  387. }
  388. void CXTPDockingPaneTabbedContainer::OnFocusChanged()
  389. {
  390. if (!GetSafeHwnd() || IsEmpty())
  391. return;
  392. CWnd* pFocus = GetFocus();
  393. BOOL bActive = (pFocus->GetSafeHwnd() && (pFocus == this || IsChild(pFocus) ||
  394. (pFocus->GetOwner()->GetSafeHwnd() && IsChild(pFocus->GetOwner()))));
  395. if (bActive != m_bActive)
  396. {
  397. m_bActive = bActive;
  398. GetDockingPaneManager()->OnActivatePane(bActive, m_pSelectedPane);
  399. Invalidate(FALSE);
  400. }
  401. else if (m_bActive && GetDockingPaneManager()->GetActivePane() != m_pSelectedPane)
  402. {
  403. GetDockingPaneManager()->OnActivatePane(bActive, m_pSelectedPane);
  404. }
  405. }
  406. #define DOCKINGPANE_HITCAPTION -2
  407. int CXTPDockingPaneTabbedContainer::HitTest(CPoint point) const
  408. {
  409. CXTPClientRect rc(this);
  410. if (IsTitleVisible())
  411. {
  412. if (rc.PtInRect(point))
  413. {
  414. CXTPDockingPaneBase::GetPaintManager()->AdjustCaptionRect(this, rc);
  415. if (!rc.PtInRect(point))
  416. {
  417. return DOCKINGPANE_HITCAPTION;
  418. }
  419. }
  420. }
  421. if (IsTabsVisible())
  422. {
  423. CXTPTabManagerItem* pItem = CXTPTabManager::HitTest(point);
  424. return pItem ? pItem->GetIndex() : -1;
  425. }
  426. return -1;
  427. }
  428. CXTPTabManagerItem* CXTPDockingPaneTabbedContainer::GetPaneTab(CXTPDockingPane* pPane) const
  429. {
  430. for (int i = 0; i < GetItemCount(); i++)
  431. {
  432. if (GetItemPane(i) == pPane)
  433. return GetItem(i);
  434. }
  435. return NULL;
  436. }
  437. void CXTPDockingPaneTabbedContainer::SelectPane(CXTPDockingPane* pPane, BOOL bSetFocus, BOOL bDelayRedraw)
  438. {
  439. if (m_pSelectedPane != pPane)
  440. {
  441. m_pSelectedPane = pPane;
  442. if (bDelayRedraw)
  443. {
  444. m_bDelayRedraw = TRUE;
  445. GetDockingPaneManager()->RecalcFrameLayout(this, TRUE);
  446. SAFE_CALLPTR(m_pParentContainer, OnChildContainerChanged(this));
  447. }
  448. else
  449. {
  450. InvalidatePane(TRUE);
  451. }
  452. CXTPTabManager::EnsureVisible(GetPaneTab(m_pSelectedPane));
  453. }
  454. if (bSetFocus)
  455. {
  456. if (m_bActive) GetDockingPaneManager()->OnActivatePane(TRUE, m_pSelectedPane);
  457. SAFE_CALLPTR(pPane, SetFocus());
  458. }
  459. }
  460. void CXTPDockingPaneTabbedContainer::OnRButtonUp(UINT /*nFlags*/, CPoint point)
  461. {
  462. XTP_DOCKINGPANE_CLICK menu;
  463. menu.pContainer = this;
  464. menu.pPane = GetItemPane(HitTest(point));
  465. if (!menu.pPane) menu.pPane = m_pSelectedPane;
  466. ClientToScreen(&point);
  467. menu.pt = point;
  468. menu.rcExclude.SetRectEmpty();
  469. if (GetDockingPaneManager()->NotifyOwner(XTP_DPN_CONTEXTMENU, (LPARAM)&menu))
  470. return;
  471. }
  472. void CXTPDockingPaneTabbedContainer::OnRButtonDown(UINT /*nFlags*/, CPoint point)
  473. {
  474. int nHit = HitTest(point);
  475. if (nHit >= 0)
  476. {
  477. SelectPane(GetItemPane(nHit));
  478. GetDockingPaneManager()->RecalcFrameLayout(this);
  479. }
  480. if (m_pSelectedPane)
  481. m_pSelectedPane->SetFocus();
  482. else
  483. SetFocus();
  484. GetDockingPaneManager()->UpdatePanes();
  485. GetDockingPaneManager()->NotifyOwner(XTP_DPN_RCLICK, (LPARAM)(CXTPDockingPaneBase*)this);
  486. }
  487. void CXTPDockingPaneTabbedContainer::OnCaptionLButtonDown(CPoint point)
  488. {
  489. _RestoreFocus();
  490. if (GetKeyState(VK_LBUTTON) < 0)
  491. {
  492. if (GetDockingPaneManager()->NotifyAction(xtpPaneActionDragging, m_pSelectedPane))
  493. return;
  494. CXTPDockingPaneContext* pContext = GetDockingPaneManager()->GetDockingContext();
  495. pContext->Drag(this, point);
  496. }
  497. }
  498. void CXTPDockingPaneTabbedContainer::NormalizeDockingSize()
  499. {
  500. XTPDockingPaneDirection direction = GetDockingPaneManager()->GetPaneDirection(this);
  501. BOOL bHoriz = (direction == xtpPaneDockLeft) || (direction == xtpPaneDockRight);
  502. if (bHoriz) m_szDocking.cx = m_rcWindow.Width();
  503. else m_szDocking.cy = m_rcWindow.Height();
  504. POSITION pos = GetHeadPosition();
  505. while (pos)
  506. {
  507. CXTPDockingPaneBase* pPane = GetNext(pos);
  508. if (!pPane->IsEmpty())
  509. {
  510. if (bHoriz) pPane->m_szDocking.cx = m_szDocking.cx;
  511. else pPane->m_szDocking.cy = m_szDocking.cy;
  512. }
  513. }
  514. }
  515. void CXTPDockingPaneTabbedContainer::OnCaptionButtonClick(CXTPDockingPaneCaptionButton* pButton)
  516. {
  517. CXTPDockingPane* pSelectedPane = m_pSelectedPane;
  518. CXTPDockingPaneManager* pManager = GetDockingPaneManager();
  519. switch (pButton->GetID())
  520. {
  521. case XTP_IDS_DOCKINGPANE_CLOSE:
  522. if (pManager->m_bCloseGroupOnButtonClick)
  523. {
  524. POSITION pos = m_lstPanes.GetTailPosition();
  525. while (pos)
  526. {
  527. CXTPDockingPane* pPane = (CXTPDockingPane*)m_lstPanes.GetPrev(pos);
  528. if ((pPane->GetOptions() & xtpPaneNoCloseable) != 0)
  529. continue;
  530. pPane->InternalAddRef();
  531. if (!pManager->NotifyAction(xtpPaneActionClosing, pPane))
  532. {
  533. pPane->Close();
  534. pManager->NotifyAction(xtpPaneActionClosed, pPane);
  535. }
  536. pPane->InternalRelease();
  537. }
  538. }
  539. else if (pSelectedPane)
  540. {
  541. pSelectedPane->InternalAddRef();
  542. if (!pManager->NotifyAction(xtpPaneActionClosing, pSelectedPane))
  543. {
  544. pSelectedPane->Close();
  545. pManager->NotifyAction(xtpPaneActionClosed, pSelectedPane);
  546. }
  547. pSelectedPane->InternalRelease();
  548. }
  549. break;
  550. case XTP_IDS_DOCKINGPANE_AUTOHIDE:
  551. if (!IsHidden())
  552. {
  553. if (!pManager->NotifyAction(xtpPaneActionUnpinning, pSelectedPane))
  554. {
  555. GetDockingSite()->SetFocus();
  556. NormalizeDockingSize();
  557. pSelectedPane->Hide();
  558. pManager->NotifyAction(xtpPaneActionUnpinned, pSelectedPane);
  559. }
  560. }
  561. else
  562. {
  563. GetDockingPaneManager()->ToggleDocking(pManager->m_bHideGroupOnButtonClick ?
  564. (CXTPDockingPaneBase*)this : (CXTPDockingPaneBase*)pSelectedPane);
  565. }
  566. break;
  567. case XTP_IDS_DOCKINGPANE_MAXIMIZE:
  568. Maximize();
  569. break;
  570. case XTP_IDS_DOCKINGPANE_RESTORE:
  571. Restore();
  572. break;
  573. }
  574. }
  575. BOOL CXTPDockingPaneTabbedContainer::OnCaptionButtonDown(CXTPDockingPaneCaptionButton* pButton)
  576. {
  577. switch (pButton->GetID())
  578. {
  579. case XTP_IDS_DOCKINGPANE_MENU:
  580. if (m_pSelectedPane)
  581. {
  582. InternalAddRef();
  583. CXTPDockingPaneManager* pManager = GetDockingPaneManager();
  584. XTP_DOCKINGPANE_CLICK menu;
  585. menu.pContainer = this;
  586. menu.rcExclude = pButton->GetRect();
  587. ClientToScreen(&menu.rcExclude);
  588. menu.pt = GetExStyle() & WS_EX_LAYOUTRTL ? CPoint(menu.rcExclude.right, menu.rcExclude.bottom) : CPoint(menu.rcExclude.left, menu.rcExclude.bottom);
  589. menu.pPane = m_pSelectedPane;
  590. pButton->m_bPressed = TRUE;
  591. Invalidate(FALSE);
  592. pManager->NotifyOwner(XTP_DPN_CONTEXTMENU, (LPARAM)&menu);
  593. pButton->m_bPressed = FALSE;
  594. if (m_hWnd) Invalidate(FALSE);
  595. InternalRelease();
  596. }
  597. return TRUE;
  598. }
  599. return FALSE;
  600. }
  601. void CXTPDockingPaneTabbedContainer::_RestoreFocus()
  602. {
  603. if (m_pSelectedPane)
  604. m_pSelectedPane->SetFocus();
  605. else
  606. SetFocus();
  607. GetDockingPaneManager()->UpdatePanes();
  608. }
  609. void CXTPDockingPaneTabbedContainer::OnLButtonDown(UINT /*nFlags*/, CPoint point)
  610. {
  611. CXTPDockingPaneCaptionButton* pButton = HitTestCaptionButton(point);
  612. if (pButton)
  613. {
  614. _RestoreFocus();
  615. if (m_pSelectedPane && OnCaptionButtonDown(pButton))
  616. return;
  617. if (pButton->Click(this, point) && m_pSelectedPane)
  618. {
  619. OnCaptionButtonClick(pButton);
  620. }
  621. return;
  622. }
  623. if (IsTabsVisible() && PerformClick(m_hWnd, point, TRUE))
  624. return;
  625. int nHit = HitTest(point);
  626. if (nHit == DOCKINGPANE_HITCAPTION && !IsHidden())
  627. {
  628. ClientToScreen(&point);
  629. OnCaptionLButtonDown(point);
  630. }
  631. else if (nHit >= 0)
  632. {
  633. CXTPDockingPane* pPane = GetItemPane(nHit);
  634. if (GetDockingPaneManager()->NotifyAction(xtpPaneActionDragging, pPane))
  635. {
  636. SelectPane(pPane, TRUE, FALSE);
  637. PerformMouseMove(m_hWnd, point);
  638. Invalidate(FALSE);
  639. return;
  640. }
  641. m_lstRects.RemoveAll();
  642. for (int j = 0; j < GetItemCount(); j++)
  643. {
  644. CRect rc(GetItem(j)->GetRect());
  645. m_lstRects.Add(rc);
  646. }
  647. m_pTrackingPane = pPane;
  648. SelectPane(m_pTrackingPane, TRUE, FALSE);
  649. PerformMouseMove(m_hWnd, point);
  650. SetCapture();
  651. Invalidate(FALSE);
  652. }
  653. else
  654. {
  655. _RestoreFocus();
  656. }
  657. }
  658. CXTPDockingPane* CXTPDockingPaneTabbedContainer::GetItemPane(int nIndex) const
  659. {
  660. return nIndex >= 0 ? (CXTPDockingPane*)GetItem(nIndex)->GetData() : NULL;
  661. }
  662. void CXTPDockingPaneTabbedContainer::OnLButtonDblClk(UINT /*nFlags*/, CPoint point)
  663. {
  664. if (PerformClick(m_hWnd, point, TRUE))
  665. return;
  666. if (HitTestCaptionButton(point))
  667. return;
  668. int nHit = HitTest(point);
  669. if (nHit == DOCKINGPANE_HITCAPTION)
  670. {
  671. CXTPDockingPane* pSelected = GetSelected();
  672. if (IsHidden() && pSelected && ((pSelected->GetOptions() & xtpPaneNoHideable) != 0))
  673. return;
  674. if (!IsHidden() && pSelected && ((pSelected->GetOptions() & xtpPaneNoFloatableByCaptionDoubleClick) != 0))
  675. return;
  676. GetDockingPaneManager()->ToggleDocking(this);
  677. }
  678. else if (nHit >= 0)
  679. {
  680. CXTPDockingPane* pPane = GetItemPane(nHit);
  681. if ((pPane->GetOptions() & xtpPaneNoFloatableByTabDoubleClick) == 0)
  682. {
  683. GetDockingPaneManager()->ToggleDocking(pPane);
  684. }
  685. }
  686. }
  687. void CXTPDockingPaneTabbedContainer::_Swap(CXTPDockingPane* p1, CXTPDockingPane* p2)
  688. {
  689. POSITION pos1 = m_lstPanes.Find(p1);
  690. POSITION pos2 = m_lstPanes.Find(p2);
  691. ASSERT(pos1 && pos2);
  692. m_lstPanes.SetAt(pos1, p2);
  693. m_lstPanes.SetAt(pos2, p1);
  694. }
  695. void CXTPDockingPaneTabbedContainer::OnMouseMove(UINT nFlags, CPoint point)
  696. {
  697. PerformMouseMove(m_hWnd, point);
  698. if (m_pTrackingPane)
  699. {
  700. for (int i = 0; i < m_lstRects.GetSize(); i++)
  701. {
  702. if (GetItemPane(i) != m_pTrackingPane && m_lstRects[i].PtInRect(point))
  703. {
  704. _Swap(GetItemPane(i), m_pTrackingPane);
  705. InvalidatePane(TRUE);
  706. return;
  707. }
  708. }
  709. if (CXTPTabManager::HitTest(point) == NULL)
  710. {
  711. if (GetDockingPaneManager()->NotifyAction(xtpPaneActionDetaching, m_pTrackingPane))
  712. return;
  713. ASSERT(m_pSelectedPane == m_pTrackingPane);
  714. m_pTrackingPane = NULL;
  715. ReleaseCapture();
  716. ClientToScreen(&point);
  717. CXTPDockingPaneContext* pContext = GetDockingPaneManager()->GetDockingContext();
  718. pContext->Drag(m_pSelectedPane, point);
  719. }
  720. }
  721. else
  722. {
  723. m_pCaptionButtons->CheckForMouseOver(point);
  724. }
  725. CWnd::OnMouseMove(nFlags, point);
  726. }
  727. void CXTPDockingPaneTabbedContainer::OnMouseLeave()
  728. {
  729. OnMouseMove(0, CPoint(-1, -1));
  730. }
  731. void CXTPDockingPaneTabbedContainer::OnLButtonUp(UINT nFlags, CPoint point)
  732. {
  733. if (m_pTrackingPane)
  734. {
  735. m_pTrackingPane = NULL;
  736. if (GetCapture() == this) ReleaseCapture();
  737. }
  738. CWnd::OnLButtonUp(nFlags, point);
  739. }
  740. void CXTPDockingPaneTabbedContainer::OnCaptureChanged(CWnd* pWnd)
  741. {
  742. m_pTrackingPane = NULL;
  743. CWnd::OnCaptureChanged(pWnd);
  744. }
  745. void CXTPDockingPaneTabbedContainer::OnParentContainerChanged(CXTPDockingPaneBase* pContainer)
  746. {
  747. m_pDockingSite = pContainer->m_pDockingSite;
  748. m_bTitleVisible = TRUE;
  749. if (pContainer->GetType() == xtpPaneTypeAutoHidePanel)
  750. {
  751. if (m_hWnd) ShowWindow(SW_HIDE); //?
  752. }
  753. }
  754. BOOL CXTPDockingPaneTabbedContainer::CanAttach(CRect& rcClient, CPoint pt) const
  755. {
  756. CRect rcTitle(rcClient);
  757. BOOL bVertical = IsCaptionVertical();
  758. if (m_bTitleVisible)
  759. {
  760. if (bVertical)
  761. {
  762. rcClient.left += CXTPDockingPaneBase::GetPaintManager()->GetCaptionHeight() + 3;
  763. }
  764. else
  765. {
  766. rcClient.top += CXTPDockingPaneBase::GetPaintManager()->GetCaptionHeight() + 3;
  767. }
  768. }
  769. else
  770. {
  771. SAFE_CALLPTR(m_pDockingSite, GetWindowRect(rcTitle));
  772. }
  773. if (bVertical)
  774. {
  775. rcTitle.right = rcClient.left;
  776. }
  777. else
  778. {
  779. rcTitle.bottom = rcClient.top;
  780. }
  781. if (rcTitle.PtInRect(pt))
  782. return TRUE;
  783. if (IsTabsVisible())
  784. {
  785. CRect rcTabs(rcClient);
  786. rcClient.bottom -= CXTPDockingPaneBase::GetPaintManager()->GetTabsHeight();
  787. rcTabs.top = rcClient.bottom;
  788. if (rcTabs.PtInRect(pt))
  789. return TRUE;
  790. }
  791. return FALSE;
  792. }
  793. void CXTPDockingPaneTabbedContainer::Copy(CXTPDockingPaneBase* pCloneBase, CXTPPaneToPaneMap* pMap, DWORD dwIgnoredOptions)
  794. {
  795. CXTPDockingPaneTabbedContainer* pClone = (CXTPDockingPaneTabbedContainer*)pCloneBase;
  796. ASSERT(pClone);
  797. if (!pClone)
  798. return;
  799. m_bActive = FALSE;
  800. m_pDockingSite = GetDockingPaneManager()->GetSite();
  801. m_pSelectedPane = m_pTrackingPane = NULL;
  802. m_rcWindow = pClone->m_rcWindow;
  803. m_szDocking = pClone->m_szDocking;
  804. m_bTitleVisible = TRUE;
  805. m_bLockReposition = FALSE;
  806. if (pClone->m_pLayout != m_pLayout)
  807. {
  808. m_bMaximized = pClone->m_bMaximized;
  809. }
  810. CXTPDockingPane* pSelected = NULL;
  811. if (pMap)
  812. {
  813. POSITION pos = pClone->GetHeadPosition();
  814. while (pos)
  815. {
  816. CXTPDockingPane* pPane = (CXTPDockingPane*)pClone->GetNext(pos);
  817. CXTPDockingPane* pNewPane = (CXTPDockingPane*)pPane->Clone(m_pLayout, pMap);
  818. if (pClone->GetSelected() == pPane) pSelected = pNewPane;
  819. _InsertPane(pNewPane);
  820. }
  821. }
  822. else
  823. {
  824. POSITION pos = pClone->m_lstPanes.GetHeadPosition();
  825. while (pos)
  826. {
  827. CXTPDockingPane* pPane = (CXTPDockingPane*)pClone->GetNext(pos);
  828. ASSERT(pPane->GetType() == xtpPaneTypeDockingPane);
  829. if ((((CXTPDockingPane*)pPane)->GetOptions() & dwIgnoredOptions) == 0)
  830. {
  831. if (pClone->GetSelected() == pPane && pSelected == NULL) pSelected = pPane;
  832. pPane->m_pParentContainer->RemovePane(pPane);
  833. _InsertPane(pPane);
  834. }
  835. }
  836. }
  837. if (pSelected) SelectPane(pSelected, FALSE);
  838. }
  839. BOOL CXTPDockingPaneTabbedContainer::IsHidden() const
  840. {
  841. return GetContainer() && GetContainer()->GetType() == xtpPaneTypeAutoHidePanel;
  842. }
  843. void CXTPDockingPaneTabbedContainer::Show(BOOL bSetFocus)
  844. {
  845. if (m_pSelectedPane &&m_pParentContainer &&
  846. m_pParentContainer->GetType() == xtpPaneTypeAutoHidePanel)
  847. {
  848. ((CXTPDockingPaneAutoHidePanel*)m_pParentContainer)->ShowPane(m_pSelectedPane, bSetFocus);
  849. }
  850. else if (DYNAMIC_DOWNCAST(CXTPDockingPaneMiniWnd, GetParentFrame()))
  851. {
  852. ((CXTPDockingPaneMiniWnd*)GetParentFrame())->Expand();
  853. }
  854. }
  855. void CXTPDockingPaneTabbedContainer::ShowPane(CXTPDockingPane* pPane, BOOL bSetFocus)
  856. {
  857. ASSERT(pPane);
  858. if (m_pParentContainer && m_pParentContainer->GetType() == xtpPaneTypeAutoHidePanel)
  859. {
  860. ((CXTPDockingPaneAutoHidePanel*)m_pParentContainer)->ShowPane(pPane, bSetFocus);
  861. }
  862. else
  863. {
  864. SelectPane(pPane, bSetFocus);
  865. if (DYNAMIC_DOWNCAST(CXTPDockingPaneMiniWnd, GetParentFrame()))
  866. ((CXTPDockingPaneMiniWnd*)GetParentFrame())->Expand();
  867. if (m_pParentContainer && m_pParentContainer->GetType() == xtpPaneTypeSidePanel)
  868. {
  869. ((CXTPDockingPaneSidePanel*)m_pParentContainer)->Expand();
  870. }
  871. }
  872. }
  873. BOOL CXTPDockingPaneTabbedContainer::IsAllowMaximize() const
  874. {
  875. if (!m_pParentContainer || m_pParentContainer->GetType() != xtpPaneTypeSplitterContainer)
  876. return FALSE;
  877. if (!GetDockingPaneManager()->IsCaptionMaximizeButtonsVisible())
  878. return FALSE;
  879. CXTPDockingPaneBaseList lst;
  880. ((CXTPDockingPaneSplitterContainer*)m_pParentContainer)->FindChildPane(xtpPaneTypeTabbedContainer, &lst);
  881. return lst.GetCount() > 1;
  882. }
  883. void CXTPDockingPaneTabbedContainer::Maximize()
  884. {
  885. if (!m_pDockingSite || !m_pParentContainer)
  886. return;
  887. CXTPDockingPaneBaseList lst;
  888. ((CXTPDockingPaneSplitterContainer*)m_pParentContainer)->FindChildPane(xtpPaneTypeTabbedContainer, &lst);
  889. POSITION pos = lst.GetHeadPosition();
  890. while (pos)
  891. {
  892. CXTPDockingPaneTabbedContainer* pTabbedContainer = (CXTPDockingPaneTabbedContainer*)lst.GetNext(pos);
  893. pTabbedContainer->m_bMaximized = pTabbedContainer == this;
  894. }
  895. GetDockingPaneManager()->RecalcFrameLayout(this);
  896. }
  897. void CXTPDockingPaneTabbedContainer::Restore()
  898. {
  899. if (!m_pDockingSite || !m_pParentContainer)
  900. return;
  901. m_bMaximized = FALSE;
  902. GetDockingPaneManager()->RecalcFrameLayout(this);
  903. }
  904. BOOL CXTPDockingPaneTabbedContainer::IsPaneMaximized() const
  905. {
  906. if (!IsAllowMaximize())
  907. return FALSE;
  908. return m_bMaximized;
  909. }
  910. BOOL CXTPDockingPaneTabbedContainer::IsPaneRestored() const
  911. {
  912. if (!IsAllowMaximize())
  913. return FALSE;
  914. return !m_bMaximized;
  915. }
  916. BOOL CXTPDockingPaneTabbedContainer::IsPaneMinimized() const
  917. {
  918. if (m_bMaximized)
  919. return FALSE;
  920. if (!m_pParentContainer || m_pParentContainer->GetType() != xtpPaneTypeSplitterContainer)
  921. return FALSE;
  922. if (!GetDockingPaneManager()->IsCaptionMaximizeButtonsVisible())
  923. return FALSE;
  924. CXTPDockingPaneBaseList lst;
  925. ((CXTPDockingPaneSplitterContainer*)m_pParentContainer)->FindChildPane(xtpPaneTypeTabbedContainer, &lst);
  926. POSITION pos = lst.GetHeadPosition();
  927. while (pos)
  928. {
  929. CXTPDockingPaneTabbedContainer* pTabbedContainer = (CXTPDockingPaneTabbedContainer*)lst.GetNext(pos);
  930. if (pTabbedContainer->m_bMaximized)
  931. return TRUE;
  932. }
  933. return FALSE;
  934. }
  935. BOOL CXTPDockingPaneTabbedContainer::IsCaptionButtonVisible(CXTPDockingPaneCaptionButton* pButton)
  936. {
  937. if (pButton->GetID() == XTP_IDS_DOCKINGPANE_CLOSE)
  938. return m_pSelectedPane && ((m_pSelectedPane->GetOptions() & xtpPaneNoCloseable) == 0);
  939. if (pButton->GetID() == XTP_IDS_DOCKINGPANE_AUTOHIDE)
  940. return m_pSelectedPane && ((m_pSelectedPane->GetOptions() & xtpPaneNoHideable) == 0) && (pButton->GetState() & xtpPanePinVisible);
  941. if (pButton->GetID() == XTP_IDS_DOCKINGPANE_MAXIMIZE)
  942. return IsPaneRestored();
  943. if (pButton->GetID() == XTP_IDS_DOCKINGPANE_RESTORE)
  944. return IsPaneMaximized();
  945. if (pButton->GetID() == XTP_IDS_DOCKINGPANE_MENU)
  946. return m_pSelectedPane && (m_pSelectedPane->GetOptions() & xtpPaneHasMenuButton);
  947. return TRUE;
  948. }
  949. LRESULT CXTPDockingPaneTabbedContainer::OnHelpHitTest(WPARAM, LPARAM lParam)
  950. {
  951. CXTPDockingPane* pPane = GetSelected();
  952. CPoint point((DWORD)lParam);
  953. int nHit = HitTest(point);
  954. if (nHit >= 0)
  955. {
  956. pPane = GetItemPane(nHit);
  957. }
  958. if (!pPane)
  959. return 0;
  960. int nIDHelp = pPane->m_nIDHelp;
  961. if (nIDHelp == 0)
  962. {
  963. pPane->m_hwndChild ? (int)::GetDlgCtrlID(pPane->m_hwndChild): 0;
  964. }
  965. if (nIDHelp == 0)
  966. {
  967. nIDHelp = pPane->GetID();
  968. }
  969. return HID_BASE_RESOURCE + nIDHelp;
  970. }
  971. CXTPDockingPaneCaptionButton* CXTPDockingPaneTabbedContainer::HitTestCaptionButton(CPoint point) const
  972. {
  973. if (IsTitleVisible())
  974. {
  975. for (int i = 0; i < m_pCaptionButtons->GetSize(); i++)
  976. {
  977. CXTPDockingPaneCaptionButton* pButton = m_pCaptionButtons->GetAt(i);
  978. if (pButton->PtInRect(point))
  979. return pButton->IsEnabled() ? pButton : NULL;
  980. }
  981. }
  982. return NULL;
  983. }
  984. INT_PTR CXTPDockingPaneTabbedContainer::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
  985. {
  986. ASSERT_VALID(this);
  987. ASSERT(::IsWindow(m_hWnd));
  988. // check child windows first by calling CControlBar
  989. INT_PTR nHit = CWnd::OnToolHitTest(point, pTI);
  990. if (nHit != -1)
  991. return nHit;
  992. CXTPDockingPaneCaptionButton* pButton = HitTestCaptionButton(point);
  993. if (pButton)
  994. {
  995. nHit = (INT_PTR)pButton->GetID();
  996. CString strTip;
  997. XTPResourceManager()->LoadString(&strTip, (UINT)nHit);
  998. if (strTip.GetLength() == 0)
  999. return -1;
  1000. CXTPToolTipContext::FillInToolInfo(pTI, m_hWnd, pButton->GetRect(), nHit, strTip);
  1001. return nHit;
  1002. }
  1003. return PerformToolHitTest(m_hWnd, point, pTI);
  1004. }
  1005. void CXTPDockingPaneTabbedContainer::AdjustMinMaxInfoClientRect(LPMINMAXINFO pMinMaxInfo, BOOL bCaptionOnly) const
  1006. {
  1007. CRect rc(0, 0, 1000, 1000);
  1008. if (bCaptionOnly)
  1009. {
  1010. CXTPDockingPaneBase::GetPaintManager()->AdjustCaptionRect(this, rc);
  1011. }
  1012. else
  1013. {
  1014. CXTPDockingPaneBase::GetPaintManager()->AdjustClientRect((CXTPDockingPaneTabbedContainer*)this, rc, FALSE);
  1015. }
  1016. pMinMaxInfo->ptMinTrackSize.x += 1000 - rc.Width();
  1017. pMinMaxInfo->ptMinTrackSize.y += 1000 - rc.Height();
  1018. pMinMaxInfo->ptMaxTrackSize.x += 1000 - rc.Width();
  1019. pMinMaxInfo->ptMaxTrackSize.y += 1000 - rc.Height();
  1020. }
  1021. void CXTPDockingPaneTabbedContainer::GetMinMaxInfo(LPMINMAXINFO pMinMaxInfo) const
  1022. {
  1023. CXTPDockingPaneBase::GetMinMaxInfo(pMinMaxInfo);
  1024. if (IsEmpty())
  1025. return;
  1026. if (IsPaneMinimized())
  1027. {
  1028. if (((CXTPDockingPaneSplitterContainer*)m_pParentContainer)->IsHoriz())
  1029. pMinMaxInfo->ptMaxTrackSize.x = 0;
  1030. else
  1031. pMinMaxInfo->ptMaxTrackSize.y = 0;
  1032. AdjustMinMaxInfoClientRect(pMinMaxInfo, FALSE);
  1033. }
  1034. else
  1035. {
  1036. POSITION pos = GetHeadPosition();
  1037. while (pos)
  1038. {
  1039. CXTPDockingPaneBase* pPane = GetNext(pos);
  1040. MINMAXINFO info;
  1041. pPane->GetMinMaxInfo(&info);
  1042. pMinMaxInfo->ptMinTrackSize.x = max(pMinMaxInfo->ptMinTrackSize.x, info.ptMinTrackSize.x);
  1043. pMinMaxInfo->ptMinTrackSize.y = max(pMinMaxInfo->ptMinTrackSize.y, info.ptMinTrackSize.y);
  1044. pMinMaxInfo->ptMaxTrackSize.x = min(pMinMaxInfo->ptMaxTrackSize.x, info.ptMaxTrackSize.x);
  1045. pMinMaxInfo->ptMaxTrackSize.y = min(pMinMaxInfo->ptMaxTrackSize.y, info.ptMaxTrackSize.y);
  1046. }
  1047. AdjustMinMaxInfoClientRect(pMinMaxInfo);
  1048. }
  1049. }
  1050. BOOL CXTPDockingPaneTabbedContainer::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  1051. {
  1052. CXTPDockingPaneManager* pManager = GetDockingPaneManager();
  1053. if (pManager)
  1054. {
  1055. pManager->GetToolTipContext()->FilterToolTipMessage(this, message, wParam, lParam);
  1056. }
  1057. return CWnd::OnWndMsg(message, wParam, lParam, pResult);
  1058. }
  1059. BOOL CXTPDockingPaneTabbedContainer::IsCaptionVertical() const
  1060. {
  1061. CXTPDockingPaneManager* pManager = GetDockingPaneManager();
  1062. switch (pManager->GetCaptionDirection())
  1063. {
  1064. case xtpPaneCaptionHorizontal:
  1065. return FALSE;
  1066. case xtpPaneCaptionAutoBySize:
  1067. return m_rcWindow.Width() > m_rcWindow.Height();
  1068. case xtpPaneCaptionAutoByPosition:
  1069. XTPDockingPaneDirection direction = pManager->GetPaneDirection(this);
  1070. return (direction == xtpPaneDockTop) || (direction == xtpPaneDockBottom);
  1071. }
  1072. return TRUE;
  1073. }
  1074. //////////////////////////////////////////////////////////////////////////
  1075. // Accessible
  1076. CCmdTarget* CXTPDockingPaneTabbedContainer::GetAccessible()
  1077. {
  1078. return this;
  1079. }
  1080. HRESULT CXTPDockingPaneTabbedContainer::GetAccessibleParent(IDispatch* FAR* ppdispParent)
  1081. {
  1082. *ppdispParent = NULL;
  1083. if (GetSafeHwnd())
  1084. {
  1085. return AccessibleObjectFromWindow(GetSafeHwnd(), OBJID_WINDOW, IID_IDispatch, (void**)ppdispParent);
  1086. }
  1087. return E_FAIL;
  1088. }
  1089. HRESULT CXTPDockingPaneTabbedContainer::GetAccessibleChildCount(long FAR* pChildCount)
  1090. {
  1091. if (pChildCount == 0)
  1092. return E_INVALIDARG;
  1093. *pChildCount = GetItemCount() + 1;
  1094. return S_OK;
  1095. }
  1096. HRESULT CXTPDockingPaneTabbedContainer::GetAccessibleChild(VARIANT varChild, IDispatch* FAR* ppdispChild)
  1097. {
  1098. *ppdispChild = NULL;
  1099. int nChild = GetChildIndex(&varChild);
  1100. if (nChild == 1 && GetSelected())
  1101. return AccessibleObjectFromWindow(GetSelected()->m_hwndChild, OBJID_WINDOW, IID_IDispatch, (void**)ppdispChild);
  1102. if (nChild > 1 && nChild <= GetItemCount() + 1)
  1103. {
  1104. CXTPDockingPane* pPane = GetItemPane(nChild - 2);
  1105. if (pPane)
  1106. {
  1107. *ppdispChild = pPane->GetIDispatch(TRUE);
  1108. }
  1109. }
  1110. return S_OK;
  1111. }
  1112. HRESULT CXTPDockingPaneTabbedContainer::GetAccessibleName(VARIANT varChild, BSTR* pszName)
  1113. {
  1114. int nChild = GetChildIndex(&varChild);
  1115. if (nChild == CHILDID_SELF || nChild == -1)
  1116. {
  1117. *pszName = SysAllocString(L"XTPDockingPaneTabbedContainer");
  1118. return S_OK;
  1119. }
  1120. return E_INVALIDARG;
  1121. }
  1122. HRESULT CXTPDockingPaneTabbedContainer::GetAccessibleRole(VARIANT varChild, VARIANT* pvarRole)
  1123. {
  1124. pvarRole->vt = VT_EMPTY;
  1125. int nChild = GetChildIndex(&varChild);
  1126. if (nChild == CHILDID_SELF)
  1127. {
  1128. pvarRole->vt = VT_I4;
  1129. pvarRole->lVal = ROLE_SYSTEM_PAGETABLIST;
  1130. return S_OK;
  1131. }
  1132. return E_INVALIDARG;
  1133. }
  1134. HRESULT CXTPDockingPaneTabbedContainer::GetAccessibleState(VARIANT /*varChild*/, VARIANT* pvarState)
  1135. {
  1136. pvarState->vt = VT_I4;
  1137. pvarState->lVal = 0;
  1138. return S_OK;
  1139. }
  1140. HRESULT CXTPDockingPaneTabbedContainer::AccessibleLocation(long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varChild)
  1141. {
  1142. *pxLeft = *pyTop = *pcxWidth = *pcyHeight = 0;
  1143. if (!GetSafeHwnd())
  1144. return S_OK;
  1145. int nChild = GetChildIndex(&varChild);
  1146. if (nChild != CHILDID_SELF)
  1147. return E_INVALIDARG;
  1148. CRect rc;
  1149. GetWindowRect(&rc);
  1150. *pxLeft = rc.left;
  1151. *pyTop = rc.top;
  1152. *pcxWidth = rc.Width();
  1153. *pcyHeight = rc.Height();
  1154. return S_OK;
  1155. }
  1156. HRESULT CXTPDockingPaneTabbedContainer::AccessibleHitTest(long xLeft, long yTop, VARIANT* pvarID)
  1157. {
  1158. if (pvarID == NULL)
  1159. return E_INVALIDARG;
  1160. pvarID->vt = VT_EMPTY;
  1161. if (!GetSafeHwnd())
  1162. return S_FALSE;
  1163. if (!CXTPWindowRect(this).PtInRect(CPoint(xLeft, yTop)))
  1164. return S_FALSE;
  1165. CPoint pt(xLeft, yTop);
  1166. ScreenToClient(&pt);
  1167. int nItem = HitTest(pt);
  1168. if (nItem == DOCKINGPANE_HITCAPTION)
  1169. {
  1170. pvarID->vt = VT_I4;
  1171. pvarID->lVal = 0;
  1172. return S_OK;
  1173. }
  1174. if (nItem == -1)
  1175. {
  1176. pvarID->vt = VT_DISPATCH;
  1177. if (GetSelected())
  1178. return AccessibleObjectFromWindow(GetSelected()->m_hwndChild, OBJID_WINDOW, IID_IDispatch, (void**)&pvarID->pdispVal);
  1179. return S_FALSE;
  1180. }
  1181. pvarID->vt = VT_DISPATCH;
  1182. pvarID->pdispVal = GetItemPane(nItem)->GetIDispatch(TRUE);
  1183. return S_OK;
  1184. }
  1185. LRESULT CXTPDockingPaneTabbedContainer::OnGetObject(WPARAM wParam, LPARAM lParam)
  1186. {
  1187. if (lParam != OBJID_CLIENT)
  1188. return (LRESULT)Default();
  1189. LPUNKNOWN lpUnknown = GetInterface(&IID_IAccessible);
  1190. if (!lpUnknown)
  1191. return E_FAIL;
  1192. return LresultFromObject(IID_IAccessible, wParam, lpUnknown);
  1193. }
  1194. BEGIN_INTERFACE_MAP(CXTPDockingPaneTabbedContainer, CCmdTarget)
  1195. INTERFACE_PART(CXTPDockingPaneTabbedContainer, IID_IAccessible, ExternalAccessible)
  1196. END_INTERFACE_MAP()