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

对话框与窗口

开发平台:

Visual C++

  1. // XTPRibbonPopups.cpp : implementation file
  2. //
  3. // This file is a part of the XTREME RIBBON 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/XTPImageManager.h"
  23. #include "Common/XTPResourceManager.h"
  24. #include "Common/XTPPropExchange.h"
  25. #include "Common/XTPToolTipContext.h"
  26. #include "CommandBars/resource.h"
  27. #include "CommandBars/XTPShortcutManager.h"
  28. #include "CommandBars/XTPCommandBars.h"
  29. #include "CommandBars/XTPPopupBar.h"
  30. #include "CommandBars/XTPControlExt.h"
  31. #include "CommandBars/XTPMouseManager.h"
  32. #include "CommandBars/XTPControlPopup.h"
  33. #include "CommandBars/XTPControlButton.h"
  34. #include "CommandBars/XTPOffice2007FrameHook.h"
  35. #include "CommandBars/XTPCustomizeTools.h"
  36. #include "XTPRibbonTab.h"
  37. #include "XTPRibbonTheme.h"
  38. #include "XTPRibbonQuickAccessControls.h"
  39. #include "XTPRibbonGroups.h"
  40. #include "XTPRibbonGroup.h"
  41. #include "XTPRibbonControlTab.h"
  42. #include "XTPRibbonBar.h"
  43. #include "XTPRibbonSystemButton.h"
  44. #ifdef _DEBUG
  45. #define new DEBUG_NEW
  46. #undef THIS_FILE
  47. static char THIS_FILE[] = __FILE__;
  48. #endif
  49. #define IDSYS_SCROLL 17821
  50. class CXTPRibbonScrollableBar::CControlGroupsScroll : public CXTPControlButton
  51. {
  52. public:
  53. CControlGroupsScroll(BOOL bScrollLeft)
  54. {
  55. SetFlags(xtpFlagSkipFocus | xtpFlagNoMovable);
  56. m_bScrollLeft = bScrollLeft;
  57. }
  58. void Draw(CDC* pDC)
  59. {
  60. ((CXTPRibbonTheme*)GetParent()->GetPaintManager())->DrawRibbonScrollButton(pDC, this, m_bScrollLeft);
  61. }
  62. virtual void OnClick(BOOL /*bKeyboard  = FALSE */, CPoint /*pt  = CPoint */)
  63. {
  64. if (GetKeyState(VK_LBUTTON) >= 0)
  65. return;
  66. m_bPressed = TRUE;
  67. CXTPRibbonScrollableBar* pScrollableBar = GetScrollableBar(m_pParent);
  68. pScrollableBar->OnGroupsScroll(m_bScrollLeft);
  69. int cmsTimer = GetDoubleClickTime() * 4 / 5;
  70. m_pParent->SetTimer(IDSYS_SCROLL, cmsTimer, NULL);
  71. BOOL bFirst = TRUE;
  72. m_pParent->SetCapture();
  73. while (::GetCapture() == m_pParent->GetSafeHwnd() && IsVisible())
  74. {
  75. MSG msg;
  76. if (!::GetMessage(&msg, NULL, 0, 0))
  77. {
  78. AfxPostQuitMessage((int)msg.wParam);
  79. break;
  80. }
  81. if (msg.message == WM_TIMER && msg.wParam == IDSYS_SCROLL)
  82. {
  83. pScrollableBar->OnGroupsScroll(m_bScrollLeft);
  84. if (bFirst)
  85. {
  86. cmsTimer = GetDoubleClickTime() / 10;
  87. m_pParent->SetTimer(IDSYS_SCROLL, cmsTimer, NULL);
  88. }
  89. bFirst = FALSE;
  90. }
  91. else if (msg.message == WM_LBUTTONUP)
  92. {
  93. break;
  94. }
  95. else
  96. {
  97. TranslateMessage(&msg);
  98. DispatchMessage(&msg);
  99. }
  100. }
  101. ReleaseCapture();
  102. m_pParent->KillTimer(IDSYS_SCROLL);
  103. m_bPressed = FALSE;
  104. if (!IsVisible()) m_bSelected = FALSE;
  105. RedrawParent(FALSE);
  106. }
  107. protected:
  108. BOOL m_bScrollLeft;
  109. };
  110. CXTPRibbonBarMorePopupToolBar::CXTPRibbonBarMorePopupToolBar(CXTPRibbonBar* pRibbonBar)
  111. {
  112. m_bTrackOnHover = FALSE;
  113. m_rcBorders = CRect(3, 3, 3, 3);
  114. m_pRibbonBar = pRibbonBar;
  115. }
  116. IMPLEMENT_DYNAMIC(CXTPRibbonBarMorePopupToolBar, CXTPPopupToolBar)
  117. void CXTPRibbonBarMorePopupToolBar::FillCommandBarEntry(CDC* pDC)
  118. {
  119. CXTPRibbonTheme* pPaintManager = (CXTPRibbonTheme*)GetPaintManager();
  120. pPaintManager->FillMorePopupToolBarEntry(pDC, this);
  121. }
  122. CSize CXTPRibbonBarMorePopupToolBar::GetIconSize() const
  123. {
  124. return m_pRibbonBar->GetIconSize();
  125. }
  126. CSize CXTPRibbonBarMorePopupToolBar::GetButtonSize() const
  127. {
  128. return m_pRibbonBar->GetButtonSize();
  129. }
  130. CXTPRibbonScrollableBar::CXTPRibbonScrollableBar()
  131. {
  132. m_pParent = NULL;
  133. m_pControlScrollGroupsLeft = NULL;
  134. m_pControlScrollGroupsRight = NULL;
  135. m_pHighlightedGroup = NULL;
  136. m_nGroupsScrollPos = 0;
  137. }
  138. void CXTPRibbonScrollableBar::InitScrollableBar(CXTPCommandBar* pParent)
  139. {
  140. m_pControlScrollGroupsRight = pParent->GetControls()->Add(new CControlGroupsScroll(FALSE));
  141. m_pControlScrollGroupsLeft = pParent->GetControls()->Add(new CControlGroupsScroll(TRUE));
  142. m_nGroupsScrollPos = 0;
  143. m_pParent = pParent;
  144. }
  145. void CXTPRibbonScrollableBar::ShowScrollableRect(CXTPRibbonGroups* pGroups, CRect rc)
  146. {
  147. int nGroupsScrollPos = pGroups->GetScrollPos();
  148. CRect rcGroups(GetGroupsRect());
  149. if (rc.left < 12 && m_pControlScrollGroupsLeft->IsVisible())
  150. {
  151. nGroupsScrollPos = nGroupsScrollPos + rc.left - 12;
  152. if (nGroupsScrollPos < 0) nGroupsScrollPos = 0;
  153. }
  154. else if (rc.right > rcGroups.right && m_pControlScrollGroupsRight->IsVisible())
  155. {
  156. nGroupsScrollPos = nGroupsScrollPos + rc.right - rcGroups.Width() + 12;
  157. if (nGroupsScrollPos < 0) nGroupsScrollPos = 0;
  158. }
  159. if (nGroupsScrollPos != m_nGroupsScrollPos)
  160. {
  161. m_nGroupsScrollPos = nGroupsScrollPos;
  162. pGroups->GetParentTab()->GetParent()->OnRecalcLayout();
  163. }
  164. }
  165. void CXTPRibbonScrollableBar::EnableGroupsScroll(BOOL bScrollLeft, BOOL bScrollRight)
  166. {
  167. ASSERT(m_pControlScrollGroupsRight);
  168. ASSERT(m_pControlScrollGroupsLeft);
  169. if (!m_pControlScrollGroupsRight || !m_pControlScrollGroupsLeft)
  170. return;
  171. CRect rcGroups(GetGroupsRect());
  172. if (bScrollLeft)
  173. {
  174. m_pControlScrollGroupsLeft->SetHideFlag(xtpHideScroll, FALSE);
  175. m_pControlScrollGroupsLeft->SetRect(CRect(rcGroups.left - 1, rcGroups.top, rcGroups.left + 12, rcGroups.bottom));
  176. }
  177. else
  178. {
  179. m_pControlScrollGroupsLeft->SetHideFlag(xtpHideScroll, TRUE);
  180. }
  181. if (bScrollRight)
  182. {
  183. m_pControlScrollGroupsRight->SetHideFlag(xtpHideScroll, FALSE);
  184. m_pControlScrollGroupsRight->SetRect(CRect(rcGroups.right - 12, rcGroups.top, rcGroups.right + 1, rcGroups.bottom));
  185. }
  186. else
  187. {
  188. m_pControlScrollGroupsRight->SetHideFlag(xtpHideScroll, TRUE);
  189. }
  190. }
  191. //////////////////////////////////////////////////////////////////////////
  192. // CXTPRibbonTabPopupToolBar
  193. CXTPRibbonTabPopupToolBar::CXTPRibbonTabPopupToolBar(CXTPRibbonTab* pRibbonTab)
  194. {
  195. InitScrollableBar(this);
  196. m_pRibbonBar = pRibbonTab->GetRibbonBar();
  197. m_pRibbonTab = (CXTPRibbonTab*)pRibbonTab->GetRuntimeClass()->CreateObject();
  198. m_pRibbonTab->m_pParent = this;
  199. m_pRibbonTab->m_pRibbonBar = m_pRibbonBar;
  200. m_pRibbonTab->Copy(pRibbonTab);
  201. m_pRibbonTab->SetRect(pRibbonTab->GetRect());
  202. m_bTrackOnHover = FALSE;
  203. SetFlags(xtpFlagSmartLayout);
  204. EnableAnimation(m_pRibbonBar->IsAnimationEnabled());
  205. }
  206. CXTPRibbonTabPopupToolBar::~CXTPRibbonTabPopupToolBar()
  207. {
  208. m_pRibbonTab->OnRemoved();
  209. m_pRibbonTab->InternalRelease();
  210. }
  211. CRect CXTPRibbonTabPopupToolBar::GetGroupsRect() const
  212. {
  213. return m_rcGroups;
  214. }
  215. void CXTPRibbonTabPopupToolBar::OnGroupsScroll(BOOL bScrollLeft)
  216. {
  217. int nGroupsScrollPos = m_pRibbonTab->GetGroups()->GetScrollPos();
  218. SetPopuped(-1);
  219. HideKeyboardTips();
  220. if (bScrollLeft)
  221. {
  222. nGroupsScrollPos -= 40;
  223. if (nGroupsScrollPos < 0)
  224. nGroupsScrollPos = 0;
  225. }
  226. else
  227. {
  228. nGroupsScrollPos += 40;
  229. }
  230. if (nGroupsScrollPos != m_nGroupsScrollPos)
  231. {
  232. m_nGroupsScrollPos = nGroupsScrollPos;
  233. OnRecalcLayout();
  234. }
  235. }
  236. void CXTPRibbonTabPopupToolBar::EnsureVisible(CXTPControl* pControl)
  237. {
  238. if (pControl->GetRibbonGroup() &&
  239. (m_pControlScrollGroupsLeft->IsVisible() || m_pControlScrollGroupsRight->IsVisible()))
  240. {
  241. ShowScrollableRect(m_pRibbonTab->GetGroups(), pControl->GetRect());
  242. }
  243. }
  244. void CXTPRibbonTabPopupToolBar::CreateKeyboardTips()
  245. {
  246. CreateGroupKeyboardTips(m_pRibbonTab);
  247. }
  248. CSize CXTPRibbonTabPopupToolBar::CalcDynamicLayout(int, DWORD /*nMode*/)
  249. {
  250. CRect rcRibbonBar;
  251. m_pRibbonBar->GetWindowRect(rcRibbonBar);
  252. CRect rcRibbonTab = m_pRibbonTab->GetRect();
  253. m_pRibbonBar->ClientToScreen(rcRibbonTab);
  254. CRect rcWork = XTPMultiMonitor()->GetWorkArea(rcRibbonTab);
  255. int nHeight = m_pRibbonBar->CalcGroupsHeight();
  256. int nWidth = rcRibbonBar.Width();
  257. m_ptPopup.y = m_rcExclude.bottom;
  258. m_ptPopup.x = rcRibbonBar.left;
  259. if (m_ptPopup.x < rcWork.left)
  260. {
  261. nWidth -= rcWork.left - m_ptPopup.x;
  262. m_ptPopup.x = rcWork.left;
  263. }
  264. if (m_ptPopup.x + nWidth > rcWork.right)
  265. {
  266. nWidth = rcWork.right - m_ptPopup.x - 4;
  267. }
  268. if (m_ptPopup.y + nHeight > rcWork.bottom)
  269. {
  270. m_ptPopup.y = m_rcExclude.top - nHeight;
  271. }
  272. CClientDC dc(this);
  273. CXTPFontDC font(&dc, GetPaintManager()->GetCommandBarFont(this));
  274. UpdateShortcuts();
  275. m_rcGroups.SetRect(0, 0, nWidth, nHeight);
  276. m_pRibbonTab->GetGroups()->CalcDynamicSize(&dc, m_rcGroups.Width(), LM_COMMIT,
  277. CRect(m_rcGroups.left + 4, m_rcGroups.top + 3, 6, 3));
  278. m_rcTearOffGripper.SetRectEmpty();
  279. return CSize(nWidth, nHeight);
  280. }
  281. void CXTPRibbonTabPopupToolBar::DrawCommandBar(CDC* pDC, CRect rcClipBox)
  282. {
  283. CXTPRibbonTheme* pPaintManager = (CXTPRibbonTheme*)GetPaintManager();
  284. pPaintManager->FillTabPopupToolBar(pDC, this);
  285. pPaintManager->FillGroupRect(pDC, m_pRibbonTab, m_rcGroups);
  286. pDC->SetBkMode(TRANSPARENT);
  287. CXTPRibbonGroups* pGroups = m_pRibbonTab->GetGroups();
  288. for (int i = 0; i < pGroups->GetCount(); i++)
  289. {
  290. CXTPRibbonGroup* pGroup = pGroups->GetAt(i);
  291. if (pGroup->IsVisible() && CRect().IntersectRect(rcClipBox, pGroup->GetRect()))
  292. {
  293. pGroup->Draw(pDC, rcClipBox);
  294. }
  295. }
  296. if (m_pControlScrollGroupsLeft->IsVisible())
  297. {
  298. m_pControlScrollGroupsLeft->Draw(pDC);
  299. }
  300. if (m_pControlScrollGroupsRight->IsVisible())
  301. {
  302. m_pControlScrollGroupsRight->Draw(pDC);
  303. }
  304. }
  305. CSize CXTPRibbonTabPopupToolBar::GetButtonSize() const
  306. {
  307. return m_pRibbonBar->GetButtonSize();
  308. }
  309. CSize CXTPRibbonTabPopupToolBar::GetIconSize() const
  310. {
  311. return m_pRibbonBar->GetIconSize();
  312. }
  313. CRect CXTPRibbonTabPopupToolBar::CalculatePopupRect(CPoint ptPopup, CSize sz)
  314. {
  315. return CRect(ptPopup, sz);
  316. }
  317. CXTPRibbonGroup* CXTPRibbonTabPopupToolBar::HitTestGroup(CPoint point) const
  318. {
  319. if (!m_rcGroups.PtInRect(point))
  320. return NULL;
  321. return m_pRibbonTab->GetGroups()->HitTest(point);
  322. }
  323. BOOL CXTPRibbonTabPopupToolBar::IsKeyboardCuesVisible() const
  324. {
  325. return m_pRibbonBar->IsKeyboardCuesVisible();
  326. }
  327. void CXTPRibbonTabPopupToolBar::OnKeyboardTip(CXTPCommandBarKeyboardTip* pTip)
  328. {
  329. CXTPControl* pControl = DYNAMIC_DOWNCAST(CXTPControl, pTip->m_pOwner);
  330. if (pControl)
  331. {
  332. if (pTip->m_bVisible == FALSE && pControl->GetHideFlags() == xtpHideWrap)
  333. {
  334. CXTPRibbonGroup* pGroup = pControl->GetRibbonGroup();
  335. if (pGroup && pGroup->GetControlGroupPopup())
  336. {
  337. EnsureVisible(pGroup->GetControlGroupPopup());
  338. pGroup->GetControlGroupPopup()->OnUnderlineActivate();
  339. int nIndex = pGroup->IndexOf(pControl);
  340. CXTPCommandBar* pPopupToolBar = pGroup->GetControlGroupPopup()->GetCommandBar();
  341. if (pPopupToolBar && pPopupToolBar->IsTrackingMode() && nIndex >= 0 &&
  342. nIndex < pPopupToolBar->GetControlCount())
  343. {
  344. pPopupToolBar->GetControl(nIndex)->OnUnderlineActivate();
  345. }
  346. }
  347. return;
  348. }
  349. if (pControl->IsVisible())
  350. {
  351. pControl->OnUnderlineActivate();
  352. }
  353. return;
  354. }
  355. }
  356. BEGIN_MESSAGE_MAP(CXTPRibbonTabPopupToolBar, CXTPPopupToolBar)
  357. //{{AFX_MSG_MAP(CXTPRibbonBar)
  358. ON_WM_MOUSEMOVE()
  359. ON_MESSAGE_VOID(WM_MOUSELEAVE, OnMouseLeave)
  360. //}}AFX_MSG_MAP
  361. END_MESSAGE_MAP()
  362. void CXTPRibbonScrollableBar::HighlightGroup(CXTPRibbonGroup* pHighlightedGroup)
  363. {
  364. if (m_pHighlightedGroup)
  365. {
  366. CRect rcRedraw(m_pHighlightedGroup->GetRect());
  367. m_pHighlightedGroup = NULL;
  368. m_pParent->Redraw(rcRedraw);
  369. }
  370. m_pHighlightedGroup = pHighlightedGroup;
  371. if (m_pHighlightedGroup)
  372. {
  373. m_pParent->Redraw(m_pHighlightedGroup->GetRect());
  374. }
  375. }
  376. void CXTPRibbonTabPopupToolBar::OnMouseMove(UINT nFlags, CPoint point)
  377. {
  378. CXTPCommandBars* pCommandBars = GetCommandBars ();
  379. CXTPMouseManager* pMouseManager = pCommandBars->GetMouseManager();
  380. BOOL bMouseLocked = pMouseManager->IsMouseLocked() || !pMouseManager->IsTopParentActive(m_hWnd)
  381. || pMouseManager->IsTrackedLock(this) || m_nPopuped != -1;
  382. CXTPRibbonGroup* pHighlightedGroup = bMouseLocked || !m_pRibbonBar->GetRibbonPaintManager()->m_bHotTrackingGroups ?
  383. NULL : HitTestGroup(point);
  384. if (pHighlightedGroup != m_pHighlightedGroup)
  385. {
  386. HighlightGroup(pHighlightedGroup);
  387. if (m_pHighlightedGroup)
  388. {
  389. pMouseManager->TrackMouseLeave(*this);
  390. }
  391. }
  392. CXTPPopupToolBar::OnMouseMove(nFlags, point);
  393. }
  394. BOOL CXTPRibbonTabPopupToolBar::SetTrackingMode(int bMode, BOOL bSelectFirst, BOOL bKeyboard)
  395. {
  396. HighlightGroup(NULL);
  397. return CXTPPopupToolBar::SetTrackingMode(bMode, bSelectFirst, bKeyboard);
  398. }
  399. void CXTPRibbonTabPopupToolBar::OnMouseLeave()
  400. {
  401. HighlightGroup(NULL);
  402. CXTPPopupToolBar::OnMouseLeave();
  403. }
  404. BOOL CXTPRibbonTabPopupToolBar::ProcessSpecialKey(XTPSpecialKey key)
  405. {
  406. if (key != xtpKeyEscape)
  407. HideKeyboardTips();
  408. if (CXTPRibbonScrollableBar::ProcessSpecialKey(key))
  409. return TRUE;
  410. if (key == xtpKeyEscape && !m_pRibbonBar->m_bKeyboardSelect)
  411. {
  412. GetCommandBars()->ClosePopups();
  413. return TRUE;
  414. }
  415. return CXTPPopupToolBar::ProcessSpecialKey(key);
  416. }
  417. INT_PTR CXTPRibbonTabPopupToolBar::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
  418. {
  419. INT_PTR nHit = CXTPPopupToolBar::OnToolHitTest(point, pTI);
  420. if (nHit == -1)
  421. return -1;
  422. if (pTI != NULL && pTI->cbSize == sizeof(XTP_TOOLTIP_TOOLINFO_EX) && m_pToolTipContext
  423. && m_pToolTipContext->IsShowTitleAndDescription())
  424. {
  425. XTP_TOOLTIP_CONTEXT* tc = ((XTP_TOOLTIP_TOOLINFO_EX*)pTI)->pToolInfo;
  426. if (tc && tc->pObject && ((CXTPControl*)tc->pObject)->GetRibbonGroup())
  427. {
  428. tc->rcExclude = m_rcGroups;
  429. }
  430. }
  431. return nHit;
  432. }
  433. IMPLEMENT_DYNAMIC(CXTPRibbonTabPopupToolBar, CXTPPopupToolBar)
  434. CXTPRibbonScrollableBar* AFX_CDECL GetScrollableBar(CXTPCommandBar* pCommandBar)
  435. {
  436. if (pCommandBar->IsRibbonBar())
  437. return (CXTPRibbonScrollableBar*)(CXTPRibbonBar*)(pCommandBar);
  438. if (pCommandBar->IsKindOf(RUNTIME_CLASS(CXTPRibbonTabPopupToolBar)))
  439. return (CXTPRibbonScrollableBar*)(CXTPRibbonTabPopupToolBar*)(pCommandBar);
  440. if (pCommandBar->IsKindOf(RUNTIME_CLASS(CXTPRibbonGroupPopupToolBar)))
  441. return (CXTPRibbonScrollableBar*)(CXTPRibbonGroupPopupToolBar*)(pCommandBar);
  442. return 0;
  443. }
  444. //////////////////////////////////////////////////////////////////////////
  445. // CXTPRibbonGroupPopupToolBar
  446. IMPLEMENT_XTP_COMMANDBAR(CXTPRibbonGroupPopupToolBar, CXTPPopupToolBar)
  447. CXTPRibbonGroupPopupToolBar::CXTPRibbonGroupPopupToolBar(CXTPRibbonGroup* pRibbonGroup /*= NULL*/)
  448. {
  449. if (!pRibbonGroup)
  450. {
  451. m_pRibbonBar = NULL;
  452. m_pRibbonGroup = NULL;
  453. m_pParentGroup = NULL;
  454. return;
  455. }
  456. m_pParent = this;
  457. m_pRibbonBar = pRibbonGroup->GetRibbonBar();
  458. m_pRibbonGroup = (CXTPRibbonGroup*)pRibbonGroup->GetRuntimeClass()->CreateObject();
  459. m_pRibbonGroup->m_pParent = this;
  460. m_pRibbonGroup->m_pRibbonBar = m_pRibbonBar;
  461. m_pParentGroup = pRibbonGroup;
  462. m_pRibbonGroup->OnGroupAdded();
  463. m_pRibbonGroup->Copy(pRibbonGroup);
  464. int nHeight = m_pRibbonBar->GetRibbonPaintManager()->GetGroupCaptionHeight();
  465. m_rcBorders.SetRect(2, 2, 3, nHeight + 1);
  466. m_bTrackOnHover = FALSE;
  467. SetFlags(xtpFlagSmartLayout);
  468. EnableAnimation(m_pRibbonBar->IsAnimationEnabled());
  469. }
  470. CXTPRibbonGroupPopupToolBar::~CXTPRibbonGroupPopupToolBar()
  471. {
  472. m_pRibbonGroup->OnGroupRemoved();
  473. m_pRibbonGroup->InternalRelease();
  474. }
  475. CSize CXTPRibbonGroupPopupToolBar::CalcDynamicLayout(int, DWORD /*nMode*/)
  476. {
  477. m_bDynamicLayout = TRUE;
  478. CClientDC dc(this);
  479. CXTPFontDC font(&dc, GetPaintManager()->GetCommandBarFont(this));
  480. UpdateShortcuts();
  481. int nGroupHeight = m_pRibbonBar->CalcGroupsHeight();
  482. m_pRibbonGroup->OnBeforeCalcSize(&dc);
  483. int nWidth = m_pRibbonGroup->OnCalcDynamicSize(&dc);
  484. m_pRibbonGroup->OnAdjustBorders(nWidth, CRect(0, 0, 0, 0));
  485. m_pRibbonGroup->OnAfterCalcSize();
  486. m_rcTearOffGripper.SetRectEmpty();
  487. m_bDynamicLayout = FALSE;
  488. return CSize(nWidth + m_rcBorders.left + m_rcBorders.right, nGroupHeight - 7);
  489. }
  490. void CXTPRibbonGroupPopupToolBar::DrawCommandBar(CDC* pDC, CRect rcClipBox)
  491. {
  492. m_pRibbonBar->GetRibbonPaintManager()->FillGroupPopupToolBar(pDC, m_pRibbonGroup, this);
  493. m_pRibbonGroup->Draw(pDC, rcClipBox);
  494. }
  495. void CXTPRibbonGroupPopupToolBar::CreateKeyboardTips()
  496. {
  497. if (!m_pParentGroup)
  498. return;
  499. CXTPRibbonTab* pSelectedTab = m_pParentGroup->GetParentTab();
  500. for (int i = 0; i < pSelectedTab->GetGroups()->GetCount(); i++)
  501. {
  502. CXTPRibbonGroup* pGroup = pSelectedTab->GetGroups()->GetAt(i);
  503. BOOL bVisible = pGroup->IsVisible() && m_pParentGroup == pGroup;
  504. if (bVisible)
  505. {
  506. pGroup = m_pRibbonGroup;
  507. }
  508. for (int j = 0; j < pGroup->GetCount(); j++)
  509. {
  510. CXTPControl* pControl = pGroup->GetAt(j);
  511. CreateControlKeyboardTips(pControl, NULL, bVisible);
  512. }
  513. if ((pGroup->GetControlGroupOption()->GetHideFlags() & xtpHideGeneric) == 0)
  514. {
  515. CreateControlKeyboardTips(pGroup->GetControlGroupOption(), NULL, bVisible);
  516. }
  517. CreateControlKeyboardTips(pGroup->GetControlGroupPopup(), _T("Z"), bVisible);
  518. }
  519. }
  520. CXTPRibbonGroup* CXTPRibbonGroupPopupToolBar::HitTestGroup(CPoint point) const
  521. {
  522. if (m_pRibbonGroup && m_pRibbonGroup->GetRect().PtInRect(point))
  523. return m_pRibbonGroup;
  524. return NULL;
  525. }
  526. CSize CXTPRibbonGroupPopupToolBar::GetIconSize() const
  527. {
  528. return m_pRibbonBar->GetIconSize();
  529. }
  530. CSize CXTPRibbonGroupPopupToolBar::GetButtonSize() const
  531. {
  532. return m_pRibbonBar->GetButtonSize();
  533. }
  534. void CXTPRibbonGroupPopupToolBar::OnGroupsScroll(BOOL /*bScrollLeft*/)
  535. {
  536. }
  537. CRect CXTPRibbonGroupPopupToolBar::GetGroupsRect() const
  538. {
  539. return CXTPClientRect(this);
  540. }
  541. BOOL CXTPRibbonGroupPopupToolBar::ProcessSpecialKey(XTPSpecialKey key)
  542. {
  543. if (key != xtpKeyEscape)
  544. HideKeyboardTips();
  545. if (CXTPRibbonScrollableBar::ProcessSpecialKey(key))
  546. return TRUE;
  547. return CXTPPopupToolBar::ProcessSpecialKey(key);
  548. }
  549. BEGIN_MESSAGE_MAP(CXTPRibbonGroupPopupToolBar, CXTPPopupToolBar)
  550. //{{AFX_MSG_MAP(CXTPRibbonBar)
  551. ON_WM_MOUSEMOVE()
  552. ON_MESSAGE_VOID(WM_MOUSELEAVE, OnMouseLeave)
  553. //}}AFX_MSG_MAP
  554. END_MESSAGE_MAP()
  555. void CXTPRibbonGroupPopupToolBar::OnMouseMove(UINT nFlags, CPoint point)
  556. {
  557. CXTPCommandBars* pCommandBars = GetCommandBars ();
  558. CXTPMouseManager* pMouseManager = pCommandBars->GetMouseManager();
  559. BOOL bMouseLocked = pMouseManager->IsMouseLocked() || !pMouseManager->IsTopParentActive(m_hWnd)
  560. || pMouseManager->IsTrackedLock(this) || m_nPopuped != -1;
  561. CXTPRibbonGroup* pHighlightedGroup = bMouseLocked || !m_pRibbonBar->GetRibbonPaintManager()->m_bHotTrackingGroups ?
  562. NULL : m_pRibbonGroup;
  563. if (pHighlightedGroup != m_pHighlightedGroup)
  564. {
  565. HighlightGroup(pHighlightedGroup);
  566. if (m_pHighlightedGroup)
  567. {
  568. pMouseManager->TrackMouseLeave(*this);
  569. }
  570. }
  571. CXTPPopupToolBar::OnMouseMove(nFlags, point);
  572. }
  573. BOOL CXTPRibbonGroupPopupToolBar::SetTrackingMode(int bMode, BOOL bSelectFirst, BOOL bKeyboard)
  574. {
  575. HighlightGroup(NULL);
  576. return CXTPPopupToolBar::SetTrackingMode(bMode, bSelectFirst, bKeyboard);
  577. }
  578. void CXTPRibbonGroupPopupToolBar::OnMouseLeave()
  579. {
  580. HighlightGroup(NULL);
  581. CXTPPopupToolBar::OnMouseLeave();
  582. }
  583. BOOL CXTPRibbonGroupPopupToolBar::IsKeyboardCuesVisible() const
  584. {
  585. return m_pRibbonBar->IsKeyboardCuesVisible();
  586. }