CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::HitTest(CPoint pt, CRect* lpRect) const { if (!IsExpanded()) return NULL; int nOffset = m_pPanel->GetScrollOffset() - m_nCaptionHeight - m_rcGroupCurrent.top + GetScrollOffsetPos(); pt.y += nOffset; for (int i = 0; i < GetItemCount(); i++) { CXTPTaskPanelGroupItem* pItem = GetAt(i); CRect rcItem = pItem->GetItemRect(); if (rcItem.PtInRect(pt) && pItem->IsVisible()) { if (lpRect) { rcItem.OffsetRect(0, -nOffset); *lpRect = rcItem; } return pItem; } } return NULL; }
BOOL CXTPTaskPanelGroup::IsScrollButtonEnabled(BOOL bScrollButtonUp) const { CXTPTaskPanelGroupItem* pLastVisibleItem = (CXTPTaskPanelGroupItem*)m_pItems->GetLastVisibleItem(); if (pLastVisibleItem == NULL) return FALSE; if (bScrollButtonUp) return m_nScrollOffset != 0; CRect rcItem(pLastVisibleItem->GetItemRect()); return rcItem.bottom - GetScrollOffsetPos() > m_rcGroupTarget.Height() - m_nCaptionHeight; }
void CXTPTaskPanelGroup::EnsureVisible(CXTPTaskPanelGroupItem* pItem, BOOL bUpdateScrollButtons /*= TRUE*/) { if (m_pPanel->IsExplorerBehaviour() || GetItemCount() == 0 || !IsExpanded()) return; if (!pItem || pItem->GetItemGroup() != this || !pItem->IsVisible()) return; int nIndex = pItem->GetIndex(); if (m_nScrollOffset > nIndex) { SetOffsetItem(nIndex, bUpdateScrollButtons); return; } CRect rcItem(pItem->GetItemRect()); if (rcItem.bottom - GetScrollOffsetPos() > m_nExpandedClientHeight) { int nTopMargin = GetPaintManager()->GetGroupInnerMargins(this).top; if (rcItem.top - GetScrollOffsetPos() <= nTopMargin) return; int nScrollOffset = m_nScrollOffset + 1; for (; nScrollOffset <= nIndex; nScrollOffset++) { CXTPTaskPanelGroupItem* pItemScroll = GetAt(nScrollOffset); if (!pItemScroll || !pItemScroll->IsVisible()) continue; int nScrollOffsetPos = pItemScroll->GetItemRect().top - nTopMargin; if (rcItem.bottom - nScrollOffsetPos <= m_nExpandedClientHeight) break; if (rcItem.top - nScrollOffsetPos <= nTopMargin) break; } SetOffsetItem(nScrollOffset, bUpdateScrollButtons); } }