void CXTPReportRecordItemPreview::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics) { ASSERT(pDrawArgs->pControl); if (!pDrawArgs->pControl) return; if (!pDrawArgs->pControl->GetPaintManager()->OnDrawAction(pDrawArgs)) return; CString strText = pMetrics->strText; // draw item text if (!strText.IsEmpty()) { CRect rcItem(pDrawArgs->rcItem); CRect& rcIndent = pDrawArgs->pControl->GetPaintManager()->m_rcPreviewIndent; rcItem.DeflateRect(rcIndent.left, rcIndent.top, rcIndent.right, rcIndent.bottom); if (m_pMarkupUIElement) { XTPMarkupSetDefaultFont(XTPMarkupElementContext(m_pMarkupUIElement), (HFONT)pMetrics->pFont->GetSafeHandle(), pMetrics->clrForeground); XTPMarkupMeasureElement(m_pMarkupUIElement, rcItem.Width(), INT_MAX); XTPMarkupRenderElement(m_pMarkupUIElement, pDrawArgs->pDC->GetSafeHdc(), &rcItem); } else { pDrawArgs->pDC->DrawText(strText, rcItem, DT_WORDBREAK | DT_LEFT | DT_NOPREFIX); } } }
int CXTPReportColumn::GetCaptionWidth(CDC* pDC) { int nTextWidth = pDC->GetTextExtent(m_strName).cx; if (m_pMarkupUIElement) { //CSize szText = XTPMarkupMeasureElement(m_pMarkupUIElement, m_rcColumn.Width(), INT_MAX); CSize szText = XTPMarkupMeasureElement(m_pMarkupUIElement, nTextWidth, INT_MAX); nTextWidth = szText.cx; } return nTextWidth; }
void CXTPPopupItem::CalculateHeight() { if (m_pRichRender) { return; } if (m_pUIElement) { XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), COLORREF_NULL); CSize sz = XTPMarkupMeasureElement(m_pUIElement, m_rcItem.Width()); m_rcItem.right = m_rcItem.left + sz.cx; m_rcItem.bottom = m_rcItem.top + sz.cy; return; } CXTPImageManagerIcon* pIcon = GetImage(); if (pIcon) { m_rcItem.bottom = m_rcItem.top + pIcon->GetHeight(); return; } CWindowDC dc(NULL); CRect rcText(0, 0, m_rcItem.Width(), 0); CFont fntUnderline; CFont* pFont = GetTextFont(); if (IsHyperLink() && IsUnderline() || IsBold()) { LOGFONT lpLogFont; pFont->GetLogFont(&lpLogFont); lpLogFont.lfUnderline = (IsHyperLink() && IsUnderline()); lpLogFont.lfWeight = IsBold() ? FW_BOLD : FW_NORMAL; VERIFY(fntUnderline.CreateFontIndirect(&lpLogFont)); pFont = &fntUnderline; } CXTPFontDC font(&dc, pFont); dc.DrawText(m_strCaption, rcText, m_nAlign | DT_CALCRECT); m_rcItem.bottom = m_rcItem.top + rcText.Height(); }
int CXTPReportRecordItemPreview::GetPreviewHeight(CDC* pDC, CXTPReportRow* pRow, int nWidth) { int nHeight = 0; XTP_REPORTRECORDITEM_METRICS* pMetrics = new XTP_REPORTRECORDITEM_METRICS; pMetrics->strText = GetPreviewText(); pRow->FillMetrics(NULL, this, pMetrics); CString strPreviewText = pMetrics->strText; if (strPreviewText.IsEmpty()) { pMetrics->InternalRelease(); return 0; } CXTPReportControl* pControl = pRow->GetControl(); int nIndentWidth = pControl->GetHeaderIndent(); CRect& rcIndent = pControl->GetPaintManager()->m_rcPreviewIndent; CRect rcPreviewItem(nIndentWidth + rcIndent.left, 0, nWidth - rcIndent.right, 0); if (m_pMarkupUIElement) { // Calculate Markup item height XTPMarkupSetDefaultFont(XTPMarkupElementContext(m_pMarkupUIElement), (HFONT)pMetrics->pFont->GetSafeHandle(), pMetrics->clrForeground); CSize szMarkup = XTPMarkupMeasureElement(m_pMarkupUIElement, rcPreviewItem.Width(), INT_MAX); nHeight = szMarkup.cy + rcIndent.top + rcIndent.bottom; } else { // Calculate height of a usual text CXTPFontDC font(pDC, pMetrics->pFont); int nMaxPreviewLines = pControl->GetPaintManager()->GetPreviewLinesCount(pDC, rcPreviewItem, strPreviewText); int nFontHeight = pDC->GetTextExtent(_T(" "), 1).cy; nHeight = nFontHeight * nMaxPreviewLines + rcIndent.top + rcIndent.bottom; } // Cleanup pMetrics->InternalRelease(); return nHeight; }
void CXTPPopupItem::FitToContent() { if (m_pRichRender) { CWindowDC dc(NULL); CSize sz = m_pRichRender->GetTextExtent(&dc, m_rcItem.Width()); m_rcItem.right = m_rcItem.left + sz.cx; m_rcItem.bottom = m_rcItem.top + sz.cy; return; } if (m_pUIElement) { XTPMarkupSetDefaultFont(m_pControl->GetMarkupContext(), (HFONT)GetTextFont()->GetSafeHandle(), COLORREF_NULL); CSize sz = XTPMarkupMeasureElement(m_pUIElement, m_rcItem.Width()); m_rcItem.right = m_rcItem.left + sz.cx; m_rcItem.bottom = m_rcItem.top + sz.cy; return; } CalculateWidth(); CalculateHeight(); }
int CDocStructRecordItem::Draw(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (pDrawArgs->pDC == NULL || pDrawArgs->pControl == NULL || pDrawArgs->pRow == NULL || pDrawArgs->pItem == NULL) { ASSERT(FALSE); return 0; } int offSet = 0; CDC* pDC = pDrawArgs->pDC; int nTreeDepth = pDrawArgs->pRow->GetTreeDepth(); int nLeftIndent = pDrawArgs->pControl->GetIndent(nTreeDepth); CRect rcRow = pDrawArgs->pRow->GetRect(); nTreeDepth == 0 ? offSet = 0 : offSet = 0; CXTPOffice2007Image *pImage = XTPOffice2007Images()->LoadFile(_T("PUSHBUTTON")); ASSERT(pImage); int nState = 0; if (pDrawArgs->pRow->IsSelected() == TRUE) { nState = 2; } CDocStructRecord* pRecord = (CDocStructRecord*)GetRecord(); if (pRecord) { int nCurrentLayout = pRecord->m_nCurrentLayout; if (nCurrentLayout == DocumentStructureLayout(Thumbnail)) { rcRow.left += nTreeDepth * TREE_DEPTH_OFFSET; rcRow.top += 2; rcRow.bottom -= 2; rcRow.right -= nTreeDepth * TREE_DEPTH_OFFSET; } else { rcRow.left += 0; //nLeftIndent + offSet; } if (pImage) { // Draw a blue rectangle that surrounds all child items to show that an item is part of a group. if (nCurrentLayout == DocumentStructureLayout(Thumbnail) && pDrawArgs->pRow->GetParentRow() != NULL) { int nTopRow = pDrawArgs->pControl->GetTopRowIndex(); int nVisibleRows = GetReportAreaRows(pDrawArgs->pControl, pDrawArgs->pControl->GetTopRowIndex(), TRUE); CXTPReportRow *pTopRow = pDrawArgs->pControl->GetRows()->GetAt(nTopRow); if (pTopRow != NULL) { if (pTopRow->GetTreeDepth() > 1 && pTopRow == pDrawArgs->pRow) { for (int i = 1; i < pTopRow->GetTreeDepth(); i++) { int iExpandedChildsHeight = GetExpandedChildsHeight(pDrawArgs->pControl, pDrawArgs->pRow->GetParentRow()->GetRecord()); CRect rcParentRect(pTopRow->GetRect()); bool bReset = false; for (int j = nTopRow; j < nTopRow + nVisibleRows ; j++) { int iRowLevel = pDrawArgs->pControl->GetRows()->GetAt(j)->GetTreeDepth(); if (iRowLevel >= i+1) { if (bReset == false) { iExpandedChildsHeight = 0; bReset = true; } iExpandedChildsHeight += pDrawArgs->pControl->GetPaintManager()->GetRowHeight(NULL, pDrawArgs->pControl->GetRows()->GetAt(j)); } else { break; } } rcParentRect.bottom = iExpandedChildsHeight < pDrawArgs->pControl->GetReportRectangle().bottom ? iExpandedChildsHeight : pDrawArgs->pControl->GetReportRectangle().bottom + 2; rcParentRect.left += i * TREE_DEPTH_OFFSET; rcParentRect.right -= i * TREE_DEPTH_OFFSET; pImage->DrawImage(pDC, rcParentRect, pImage->GetSource(0, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } } } } // Draw an orange/blue image over item. if ((nCurrentLayout == DocumentStructureLayout(Thumbnail)) ||((nCurrentLayout == DocumentStructureLayout(Compact)) && nState == 2)) { if (pRecord->IsPage()) { pImage->DrawImage(pDC, rcRow, pImage->GetSource(nState, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } else { // take tree depth and draw button images of tree depth size. CRect newRowOffset(rcRow); if (pDrawArgs->pRow->GetTreeDepth() != 0 && nCurrentLayout == DocumentStructureLayout(Thumbnail)) { newRowOffset.bottom += GetExpandedChildsHeight(pDrawArgs->pControl, pDrawArgs->pRow->GetRecord()); if ( pDrawArgs->pRow->IsExpanded() == TRUE ) { newRowOffset.bottom += 1; } pImage->DrawImage(pDC, newRowOffset, pImage->GetSource(0, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } if (pDrawArgs->pRow->GetTreeDepth() == 0) { pImage->DrawImage(pDC, rcRow, pImage->GetSource(nState, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } if (nState == 2) { pImage->DrawImage(pDC, rcRow, pImage->GetSource(nState, 5), CRect(4, 4, 4, 4), COLORREF_NULL); } } } } pDC->SetBkMode(TRANSPARENT); if (nCurrentLayout == DocumentStructureLayout(Thumbnail) && pRecord->IsPage()) { int x = rcRow.left + RECORD_ITEM_OFFSET; int y = rcRow.top + RECORD_ITEM_OFFSET; int nWidth = rcRow.Width() - 2*RECORD_ITEM_OFFSET; int nHeight = nWidth * 3/4; if (nWidth > rcRow.Width()) { nWidth = rcRow.Width(); } CRect rcThumb; rcThumb.SetRect(x, y, x + nWidth, y + nHeight); if (pRecord->m_pContainer != NULL) { pRecord->m_pContainer->DrawThumbWhiteboard(pRecord->m_pvData, rcThumb, pDC); } } } // Code taken from CXTPReportControlItem::Draw - but a bit modified m_pControl = pDrawArgs->pControl; CRect& rcItem = pDrawArgs->rcItem; CXTPReportPaintManager* pPaintManager = pDrawArgs->pControl->GetPaintManager(); CRgn rgn; rgn.CreateRectRgn(rcItem.left, rcItem.top - 1, rcItem.right, rcItem.bottom); if (!pDC->IsPrinting()) { pDC->SelectClipRgn(&rgn); } XTP_REPORTRECORDITEM_METRICS* pMetrics = new XTP_REPORTRECORDITEM_METRICS(); pMetrics->strText = GetCaption(pDrawArgs->pColumn); pDrawArgs->pRow->GetItemMetrics(pDrawArgs, pMetrics); ASSERT(pMetrics->pFont); ASSERT(pMetrics->clrForeground != XTP_REPORT_COLOR_DEFAULT); int nItemGlyphs = rcItem.left; // draw tree inside item rect (see also HitTest function) if (pDrawArgs->pColumn && pDrawArgs->pColumn->IsTreeColumn()) { int nTreeDepth = pDrawArgs->pRow->GetTreeDepth() - pDrawArgs->pRow->GetGroupLevel(); if (nTreeDepth > 0) { nTreeDepth++; } rcItem.left += pDrawArgs->pControl->GetIndent(nTreeDepth); BOOL bHasChildren = pDrawArgs->pControl->IsVirtualMode() ? pDrawArgs->pRow->GetTreeDepth() == 0 && (pMetrics->nVirtRowFlags & xtpVirtRowHasChildren) : pDrawArgs->pRow->HasChildren(); CRect rcBitmap(rcItem); CSize sizeBitmap = pPaintManager->DrawCollapsedBitmap(NULL, pDrawArgs->pRow, rcBitmap); int nIconAlign = pDrawArgs->nTextAlign & xtpColumnIconMask; // horizontal alignment switch (nIconAlign) { case xtpColumnIconRight: rcBitmap.left = rcBitmap.right - sizeBitmap.cx - 2; break; case xtpColumnIconLeft: rcBitmap.right = rcBitmap.left + sizeBitmap.cx + 2; break; } // vertical alignment switch (nIconAlign) { case xtpColumnIconTop: rcBitmap.bottom = rcBitmap.top + sizeBitmap.cy + 2; break; case xtpColumnIconBottom: rcBitmap.top = rcBitmap.bottom - sizeBitmap.cy - 2; break; } bool bDrawArrow = false; if (bHasChildren || (pRecord->IsDocument() && !pRecord->IsEmptyDocument())) { bDrawArrow = true; } if (pRecord->IsDocument() && !pRecord->IsLoadedDocument()) { pDrawArgs->pRow->SetExpanded(FALSE); } sizeBitmap = pPaintManager->DrawCollapsedBitmap(bDrawArrow ? pDC : NULL, pDrawArgs->pRow, rcBitmap); if (!pDC->IsPrinting() && bHasChildren) { pDrawArgs->pRow->SetCollapseRect(rcBitmap); } // Draw a custom image at the left side of the record item if (pPaintManager->GetRuntimeClass() == RUNTIME_CLASS(CXTPDocumentStructurePaintManager)) { if (pRecord->IsChapter() || pRecord->IsDocument()) { CRect rcBitmap(rcItem); if (((CDocStructRecord*) pDrawArgs->pRow->GetRecord())->m_nCurrentLayout == DocumentStructureLayout(Thumbnail)) { rcBitmap.left += 15; rcBitmap.top -= 5; CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDC, pDrawArgs->pRow, rcBitmap, m_nImageIndex); rcItem.left += sizeBitmap.cx + 35; } else { rcBitmap.left += 18; CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDC, pDrawArgs->pRow, rcBitmap, m_nImageIndex); rcItem.left += sizeBitmap.cx + 25; } } else { if (((CDocStructRecord*) pDrawArgs->pRow->GetRecord())->m_nCurrentLayout == DocumentStructureLayout(Compact)) { rcBitmap.left += 15; CSize csBitmap = ((CXTPDocumentStructurePaintManager*)pPaintManager)->DrawCustomBitmap(pDC, pDrawArgs->pRow, rcBitmap, m_nImageIndex); rcItem.left += sizeBitmap.cx + 10; } rcItem.left += sizeBitmap.cx + 2; } } } COLORREF clrText = XTPOffice2007Images()->GetImageColor(_T("LISTBOX"), _T("NormalText")); pDC->SetTextColor(clrText); CFont* pOldFont = (CFont*)pDC->SelectObject(pMetrics->pFont); if (pMetrics->clrBackground != XTP_REPORT_COLOR_DEFAULT) { pDC->SetBkColor(pMetrics->clrBackground); } else { pDC->SetBkColor(pPaintManager->m_clrControlBack); } if (m_bHasCheckbox) { DrawCheckBox(pDrawArgs, rcItem); } // Do the draw bitmap pDC, rcItem, GetIconIndex() if (pMetrics->nItemIcon != XTP_REPORT_NOICON || GetIconIndex() != XTP_REPORT_NOICON) { pPaintManager->DrawItemBitmap(pDrawArgs, rcItem, pMetrics->nItemIcon != XTP_REPORT_NOICON ? pMetrics->nItemIcon : GetIconIndex()); } nItemGlyphs = (rcItem.left - nItemGlyphs); OnDrawControls(pDrawArgs, rcItem); if (rcItem.Width()) { OnDrawCaption(pDrawArgs, pMetrics); } int nItemTextWidth = nItemGlyphs + 7; if (m_pMarkupUIElement) { nItemTextWidth += XTPMarkupMeasureElement(m_pMarkupUIElement, rcItem.Width(), INT_MAX).cx; } else { nItemTextWidth += pDC->GetTextExtent(pMetrics->strText).cx; } pDC->SelectObject(pOldFont); pMetrics->InternalRelease(); if (!pDC->IsPrinting()) { pDC->SelectClipRgn(NULL); } return nItemTextWidth; }
void CXTPReportRecordItemPercentNumber::OnDrawCaption(XTP_REPORTRECORDITEM_DRAWARGS* pDrawArgs, XTP_REPORTRECORDITEM_METRICS* pMetrics) { ASSERT(pDrawArgs->pItem == this); CString sTxt = pMetrics->strText; if (sTxt.Find('%') > -1) { sTxt.Replace(_T("%"), _T("")); int iTxt = _ttoi(sTxt); if (m_bPercentCompleteDisplay) { iTxt = max(0, iTxt); iTxt = min(100, iTxt); pMetrics->strText.Format(_T("%d"), iTxt); CDC* pDC = pDrawArgs->pDC; if (pDC) { CRect rc = pDrawArgs->rcItem; rc.DeflateRect(2, 2, 2, 2); int W = rc.Width(); if (pMetrics->nColumnAlignment == xtpColumnTextLeft) rc.right = rc.left + W * iTxt / 100; else if (pMetrics->nColumnAlignment == xtpColumnTextRight) rc.left = rc.right - W * iTxt / 100; else if (pMetrics->nColumnAlignment == xtpColumnTextCenter) { rc.left += W * (100 - iTxt) / 200; rc.right -= W * (100 - iTxt) / 200; } if (pDrawArgs->pControl && pDrawArgs->pControl->GetPaintManager() && pDrawArgs->pControl->GetPaintManager()->m_bShowNonActiveInPlaceButton) rc.right -= rc.Height(); pDC->FillSolidRect(rc, m_clr); //CRgn rgnEvent; //rgnEvent.CreateRoundRectRgn(rc.left, rc.top, rc.right, rc.bottom, 7, 7); //CXTPPaintManagerColorGradient* pGrad = new CXTPPaintManagerColorGradient(m_clr); //pDC->SelectClipRgn(&rgnEvent); //CRect rcBk = rc; //rcBk.DeflateRect(0, 1, 0, 1); //XTPDrawHelpers()->GradientFill(pDC, &rcBk, *pGrad, FALSE); //pDC->SelectClipRgn(NULL); //delete pGrad; } } } if (m_pMarkupUIElement) { CRect rcItem = pDrawArgs->rcItem; rcItem.DeflateRect(2, 1, 2, 0); XTPMarkupSetDefaultFont(XTPMarkupElementContext(m_pMarkupUIElement), (HFONT)pMetrics->pFont->GetSafeHandle(), pMetrics->clrForeground); XTPMarkupMeasureElement(m_pMarkupUIElement, rcItem.Width(), INT_MAX); XTPMarkupRenderElement(m_pMarkupUIElement, pDrawArgs->pDC->GetSafeHdc(), &rcItem); } else { pDrawArgs->pControl->GetPaintManager()->DrawItemCaption(pDrawArgs, pMetrics); } }
int CXTPTabPaintManager::DrawSingleButtonIconAndText(CDC* pDC, CXTPTabManagerItem* pItem, CRect rcItem, BOOL bDraw) { CXTPTabManager* pManager = pItem->GetTabManager(); XTPTabLayoutStyle layout = pManager->GetLayout(); BOOL bVertical = !pManager->IsHorizontalPosition(); if (layout == xtpTabLayoutRotated) bVertical = !bVertical; CString strItem = pItem->GetCaption(); CFont* pFont = m_bBoldSelected && pItem->IsSelected() && pManager->IsActive() ? GetBoldFont(bVertical) : GetFont(bVertical); CXTPFontDC fnt(pDC, pFont); CSize szIcon(m_szIcon); BOOL bDrawIcon = pManager->DrawIcon(pDC, 0, pItem, FALSE, szIcon); BOOL bDrawText = layout != xtpTabLayoutCompressed || pItem->IsSelected(); int nNavigateButtonsLength = 0; if (bDrawText && pItem->GetNavigateButtons()->GetSize() > 0) { nNavigateButtonsLength = 0; for (int i = 0; i < (int)pItem->GetNavigateButtons()->GetSize(); i++) { CXTPTabManagerNavigateButton* pButton = pItem->GetNavigateButtons()->GetAt(i); if (pManager->IsNavigateButtonVisible(pButton)) { CSize sz = pButton->GetSize(); nNavigateButtonsLength += bVertical ? sz.cy : sz.cx; } } if (nNavigateButtonsLength > 0) nNavigateButtonsLength += 3; } if (bDraw) { if (nNavigateButtonsLength > 0) { m_pColorSet->SetTextColor(pDC, pItem); if (bVertical) rcItem.bottom -= 3; else rcItem.right -= 3; for (int i = (int)pItem->GetNavigateButtons()->GetSize() - 1; i >= 0; i--) { CXTPTabManagerNavigateButton* pButton = pItem->GetNavigateButtons()->GetAt(i); if (pManager->IsNavigateButtonVisible(pButton)) { CSize szButton = pButton->GetSize(); if (!bVertical) { pButton->SetRect(CRect(rcItem.right - szButton.cx, rcItem.CenterPoint().y + szButton.cy / 2 - szButton.cy, rcItem.right, rcItem.CenterPoint().y + szButton.cy / 2)); rcItem.right -= szButton.cx; } else { pButton->SetRect(CRect(rcItem.CenterPoint().x - szButton.cx / 2, rcItem.bottom - szButton.cy, rcItem.CenterPoint().x - szButton.cx / 2 + szButton.cx, rcItem.bottom)); rcItem.bottom -= szButton.cy; } pItem->GetNavigateButtons()->GetAt(i)->Draw(pDC); } } } m_pColorSet->SetTextColor(pDC, pItem); CRect rcFocus(rcItem); if (bVertical) { int nAvailLength = pItem->GetButtonLength() - pItem->GetContentLength(); if (nAvailLength > 0) { rcItem.DeflateRect(0, nAvailLength / 2); } rcItem.top += m_rcButtonTextPadding.left + m_rcButtonMargin.left; if (pManager->GetPosition() == xtpTabPositionRight) rcItem.DeflateRect(m_rcButtonMargin.bottom, 0, m_rcButtonMargin.top, 0); else rcItem.DeflateRect(m_rcButtonMargin.top, 0, m_rcButtonMargin.bottom, 0); if (bDrawIcon) { CPoint pt(rcItem.CenterPoint().x - szIcon.cx/2, rcItem.top - 1); if (rcItem.Height() > szIcon.cy) pManager->DrawIcon(pDC, pt, pItem, TRUE, szIcon); rcItem.top += szIcon.cy + 2; } if (bDrawText && rcItem.bottom > rcItem.top + 8) { CSize szText = pDC->GetTextExtent(strItem); rcItem.left = rcItem.right - (rcItem.Width() - szText.cy - (pManager->GetPosition() == xtpTabPositionRight ? 1 : 0)) / 2; rcItem.right = rcItem.left + rcItem.Height(); rcItem.bottom -= m_rcButtonMargin.right + max(0, m_rcButtonTextPadding.right - 4); if (!m_bDrawTextNoPrefix) StripMnemonics(strItem); if (m_bDrawTextPathEllipsis) { DrawTextPathEllipsis(pDC, pManager, strItem, rcItem, DT_SINGLELINE | DT_NOCLIP | DT_NOPREFIX); } else { m_pAppearanceSet->DrawText(pDC, pManager, strItem, &rcItem, DT_SINGLELINE | DT_NOCLIP | DT_NOPREFIX | (m_bDrawTextEndEllipsis ? DT_END_ELLIPSIS : 0)); } } } else { int nAvailLength = pItem->GetButtonLength() - pItem->GetContentLength(); if (nAvailLength > 0) { rcItem.DeflateRect(nAvailLength / 2, 0); } rcItem.left += m_rcButtonTextPadding.left + m_rcButtonMargin.left; if (pManager->GetPosition() == xtpTabPositionBottom) rcItem.DeflateRect(0, m_rcButtonMargin.bottom, 0, m_rcButtonMargin.top); else rcItem.DeflateRect(0, m_rcButtonMargin.top, 0, m_rcButtonMargin.bottom); if (bDrawIcon) { CPoint pt(rcItem.left - 1, rcItem.CenterPoint().y - szIcon.cy/2); if (rcItem.Width() > szIcon.cx) pManager->DrawIcon(pDC, pt, pItem, TRUE, szIcon); rcItem.left += szIcon.cx + 2; } if (bDrawText && rcItem.right > rcItem.left) { rcItem.right -= m_rcButtonTextPadding.right + m_rcButtonMargin.right - (bDrawIcon ? 2 : 0); if (pItem->GetMarkupUIElement()) { XTPMarkupSetDefaultFont(pItem->GetTabManager()->GetMarkupContext(), (HFONT)pFont->GetSafeHandle(), pDC->GetTextColor()); CRect rcText(rcItem); if (m_nDrawTextFormat & DT_VCENTER) { CSize szText = XTPMarkupMeasureElement(pItem->GetMarkupUIElement()); rcText.top = (rcText.top + rcText.bottom - szText.cy) / 2; rcText.bottom = rcText.top + szText.cy; } XTPMarkupRenderElement(pItem->GetMarkupUIElement(), pDC->GetSafeHdc(), rcText); } else if (m_bDrawTextPathEllipsis) { DrawTextPathEllipsis(pDC, pManager, strItem, rcItem, DT_SINGLELINE | m_nDrawTextFormat | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0)); } else { if (m_bDrawTextHidePrefix) StripMnemonics(strItem); m_pAppearanceSet->DrawText(pDC, pManager, strItem, rcItem, DT_SINGLELINE | m_nDrawTextFormat | (m_bDrawTextHidePrefix || m_bDrawTextNoPrefix ? DT_NOPREFIX : 0) | (m_bDrawTextEndEllipsis ? DT_END_ELLIPSIS : 0)); } } } if (pItem->IsFocused()) { DrawFocusRect(pDC, pItem, rcFocus); } return 0; } else { if (layout == xtpTabLayoutFixed) { return _GetButtonLength(m_nFixedTabWidth, m_nMinTabWidth, m_nMaxTabWidth); } if (layout == xtpTabLayoutCompressed) { if (!bDrawText) return _GetButtonLength(8 + (bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth) ; CXTPFontDC fntItems(pDC, m_bBoldSelected && pManager->IsActive() ? GetBoldFont(bVertical) : GetFont(bVertical)); int nLength = 0; for (int i = 0; i < pManager->GetItemCount(); i++) { CRect rcItemText(0, 0, 0, 0); m_pAppearanceSet->DrawText(pDC, pManager, pManager->GetItem(i)->GetCaption(), rcItemText, DT_SINGLELINE | DT_CALCRECT | DT_NOCLIP | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0)); nLength = max(nLength, rcItemText.Width()); } return _GetButtonLength(nNavigateButtonsLength + nLength + m_rcButtonTextPadding.left + m_rcButtonTextPadding.right + (!bDrawIcon ? 0: bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth); } CSize szText(0); if (pItem->GetMarkupUIElement()) { XTPMarkupSetDefaultFont(pManager->GetMarkupContext(), (HFONT)pFont->GetSafeHandle(), pDC->GetTextColor()); szText = XTPMarkupMeasureElement(pItem->GetMarkupUIElement()); } else { m_pAppearanceSet->DrawText(pDC, pManager, strItem, rcItem, DT_SINGLELINE | DT_CALCRECT | DT_NOCLIP | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0)); szText = rcItem.Size(); } return _GetButtonLength(nNavigateButtonsLength + szText.cx + m_rcButtonTextPadding.left + m_rcButtonTextPadding.right + (!bDrawIcon ? 0: bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth); } }