Beispiel #1
0
///////////////////////////////////////////////////////////////////////////////
// DrawItem
void CSHeaderCtrl::DrawItem(CDC* pDC, CRect rect, LPHDITEM lphdi)
{
	ASSERT( (lphdi->mask & HDI_FORMAT) && (lphdi->mask & HDI_IMAGE) );

	//From left to right: check box, text, sort image
	int iWidth = 0;

	//1. Draw CheckBox
	iWidth = DrawCheckBox(pDC, rect, lphdi);
	rect.left += (iWidth != 0) ? iWidth + m_nSpace : 0;

	//Reserve the space for sort image
	int r = rect.right;
	BOOL bHasSortImage = HasSortImage(lphdi->iImage);
	if(bHasSortImage)
	{
		rect.right -= (m_sizeImage.cx + m_nSpace);
	}

	//2. Draw Text
	iWidth = DrawText(pDC, rect, lphdi);
	rect.left += (iWidth != 0) ? iWidth + m_nSpace : 0;

	if(bHasSortImage)
	{
		rect.right = r;

		//3. Draw Sort image
		iWidth = DrawSortImage(pDC, rect, lphdi);
		rect.left += (iWidth != 0) ? iWidth + m_nSpace : 0;
	}
}
Beispiel #2
0
void Config_Render(bool force)
{
	int x, y;
	
	if (force) configdirty = 2;
	if (!configdirty) return;
	configdirty--;
	
	ClearFramebuffer();
	DrawText(2, 2, RGB(255, 255, 255), "blargSNES config");
	
	y = 2 + 12 + 10;
	
	DrawCheckBox(10, y, RGB(255,255,255), "Hardware renderer", Config.HardwareRenderer);
	
	y += 26;
	
	DrawText(10, y+1, RGB(255,255,255), "Scaling:");
	x = 10 + MeasureText("Scaling:") + 6;
	
	char* scalemodes[] = {"1:1", "Fullscreen", "Cropped", "4:3", "Cropped 4:3"};
	int themode = Config.ScaleMode;
	if (themode < 0 || themode > 4) themode = 0;
	DrawButton(x, y-3, 140, RGB(255,255,255), scalemodes[themode]);
	
	
	DrawButton(10, 212, 0, RGB(255,128,128), "Cancel");
	DrawButton(-10, 212, 0, RGB(128,255,128), "Save changes");
}
Beispiel #3
0
void cMenu::DrawMenu()
{
	//Body Stuff.
	GradientRect(10, 10, 300, 20, Grey, DGrey);
	DrawFilledRectangle(10,30,300,280,DGrey);
	DrawNonFilledRectangle(10,10,300,300,Outline);
	PrintText("Mentranium", 100,20,White,Font.g_pFont);
	
	//Tabs.
	sizeoftab = 291 / (TabCount);
	DrawNonFilledRectangle(15,61, sizeoftab * TabCount, 243,Outline);
	for (int i = 0; i < TabCount; i++)
	{
		DrawTab(i, 15 + (i*sizeoftab), 41,sizeoftab);
	}
	
	//Checks.
	int d = 0;
	for(int i = 0; i < CheckCount; i++)
	{
		if(ActiveName == Checks[i].Parent)
		{
			DrawCheckBox(i,30, 70 + (d*20));
			d++;
		}
	}

	//Sliders.
	d = 0;
	for(int i = 0; i < SliderCount; i++)
	{
		if(ActiveName == Sliders[i].Parent)
		{
			DrawSlider(i,150, 100 + (d*40));
			d++;
		}
	}

	//Text Boxes.
	d = 0;
	for(int i = 0; i < TextBoxCount; i++)
	{
		if(ActiveName == TextBoxes[i].Parent)
		{
			DrawTextBox(i,150, 100 + (d*40));
			d++;
		}
	}
}
Beispiel #4
0
void CSListCtrl::DrawItem(int nItem, int nSubItem, CDC* pDC)
{
	//Color
	COLORREF crText  = m_crWindowText;
	COLORREF crBkgnd = m_crWindow;
	GetDrawColors(nItem, nSubItem, crText, crBkgnd);
	
	//Rectangle
	CRect rect;
	GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, rect);

	//Paint background
	CRect rcTemp = rect;
	rcTemp.bottom -= 1;
	pDC->FillSolidRect(&rcTemp, crBkgnd);

	//Sub Item data
	CListSubItemData* pSubItemData = GetSubItemData(nItem, nSubItem);
	ASSERT(pSubItemData);

	//1. Draw Check Box
	if(pSubItemData->m_nCheckState != SHC_NONE_CHECK_BOX)
	{
		DrawCheckBox(nItem, nSubItem, pDC);
	}

	//2. Draw Image
	if(pSubItemData->m_pListImage != NULL)
	{
		DrawImage(nItem, nSubItem, pDC);
	}

	//3. Draw Text or Progress
	if(pSubItemData->m_pListPrgsBar != NULL)
	{
		DrawProgressBar(nItem, nSubItem, pDC);
	}
	else
	{
		DrawText(nItem, nSubItem, pDC);
	}	
}
void CBCGPDateTimeCtrl::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
{
	ASSERT (lpDIS != NULL);
	ASSERT (lpDIS->CtlType == ODT_BUTTON);

	CDC* pDC = CDC::FromHandle (lpDIS->hDC);
	ASSERT_VALID (pDC);

	CBCGPDefaultLocale dl;

	CRect rectClient = lpDIS->rcItem;

	if (m_colorBackground != (COLORREF)-1)
	{
		pDC->FillSolidRect (&rectClient, m_colorBackground);
	}
	else
	{
		pDC->FillSolidRect (&rectClient, 
			IsWindowEnabled () ? globalData.clrWindow : globalData.clrBtnFace);
	}

	pDC->SetBkMode (TRANSPARENT);

	CFont* pPrevFont = m_hFont == NULL ?
		(CFont*) pDC->SelectStockObject (DEFAULT_GUI_FONT) :
		pDC->SelectObject (CFont::FromHandle (m_hFont));
	ASSERT (pPrevFont != NULL);

	if (!m_bDrawDateTimeOnly)
	{
		// Draw check box:
		DrawCheckBox (pDC, lpDIS->itemState);
	}

	// Draw date/time parts:
	int iStart = m_bCheckBoxIsAvailable ? 1 : 0;

	for (int i = iStart; i < m_iPartsNumber; i ++)
	{
		CString str;
		
		if (m_arPartsOrder [i] == YEAR)
		{
			str.Format(_T("%04d"), m_Date.GetYear());
		}
		else
		{
			str = m_Date.Format (GetPartFormat (i));
		}

		CRect rect = m_arPartRects [i];

		if (m_bIsChecked && m_bShowSelection && i == m_iPartNum)	// Selected part
		{
			CRect rectFill = rect;
			pDC->DrawText (str, rectFill, 
				DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_CALCRECT);

			int iOffset = (m_rectText.Height () - rectFill.Height ()) / 2;

			rectFill.OffsetRect ((rect.Width () - rectFill.Width ()) / 2, iOffset);

			pDC->FillSolidRect (rectFill, globalData.clrHilite);
			pDC->SetTextColor (globalData.clrTextHilite);
		}
		else
		{
			pDC->SetTextColor (m_bIsChecked && IsWindowEnabled () ? 
					(m_colorText == (COLORREF)-1 ? globalData.clrWindowText : m_colorText) : 
					globalData.clrGrayedText);
		}

		pDC->DrawText (str, rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);

		//-----------------
		// Draw separator:
		//-----------------
		if (i < m_iPartsNumber - 1)
		{
			CString strSeparator = _T(" ");

			if (IsDatePart (i) && IsDatePart (i + 1))
			{
				strSeparator = m_strDateSeparator;
			}

			if (IsTimePart (i) && IsTimePart (i + 1))
			{
				strSeparator = m_strTimeSeparator;
			}
		
			rect.left = m_arPartRects [i].right;
			rect.right = m_arPartRects [i + 1].left;

			pDC->SetTextColor (m_bIsChecked && IsWindowEnabled () ? 
					(m_colorText == (COLORREF)-1 ? globalData.clrWindowText : m_colorText) : 
					globalData.clrGrayedText);
			pDC->DrawText (strSeparator, rect, DT_SINGLELINE | DT_VCENTER);
		}
	}

	if (!m_bDrawDateTimeOnly)
	{
		// Draw "Drop Date combo" button:
		DrawDateDropButton (pDC, lpDIS->itemState);
	}

	pDC->SelectObject (pPrevFont);

	if (::IsWindow (m_wndSpin.GetSafeHwnd ()))
	{
		m_wndSpin.RedrawWindow ();
	}
}
Beispiel #6
0
//--------------------------------------------------------------------------------------
// Name: NuiMenu::Render()
// Desc: Renders the menu items and the cursor.
//--------------------------------------------------------------------------------------
VOID NuiMenu::Render() const
{
    assert( m_pd3dDevice != NULL );

    // Nothing to render.
    if( m_pMenuItemList == NULL )
    {
        return;
    }

    // Render each item in listed order
    for( DWORD dwItemIndex = 0; dwItemIndex < m_dwItemCount; ++ dwItemIndex )
    {
        // Only render items that aren't hidden
        if( ! m_pMenuItemList[ dwItemIndex ].bHidden )
        {
            switch( m_pMenuItemList[ dwItemIndex ].eItemType )
            {
            // Render a button. Buttons are shown in different colors depending on whether they are disabled,
            // selectable or selected
            case NUI_MENU_ITEM_BUTTON:
            {
                D3DCOLOR color = m_settings.staticColor;
                if( m_pMenuItemList[ dwItemIndex ].dwItemID == m_dwHoveredItemID )
                {
                    color = m_settings.selectedColor;
                }
                else if( m_pMenuItemList[ dwItemIndex ].bEnabled && ! m_bIsDisabled )
                {
                    color = m_settings.selectableColor;
                }

                DrawButton( &m_pMenuItemList[ dwItemIndex ].Location, m_pMenuItemList[ dwItemIndex ].szText, color );
                break;
            }

            // Render a check box. Check boxes are shown in different colors depending on whether they are disabled,
            // selectable or selected
            case NUI_MENU_ITEM_CHECK_BOX:
            {
                D3DCOLOR color = m_settings.staticColor;
                if( m_pMenuItemList[ dwItemIndex ].dwItemID == m_dwHoveredItemID )
                {
                    color = m_settings.selectedColor;
                }
                else if( m_pMenuItemList[ dwItemIndex ].bEnabled && ! m_bIsDisabled )
                {
                    color = m_settings.selectableColor;
                }


                DrawCheckBox( &m_pMenuItemList[ dwItemIndex ].Location, m_pMenuItemList[ dwItemIndex ].szText, color, m_pMenuItemList[ dwItemIndex ].fValue > 0.0f );
                break;
            }

            case NUI_MENU_ITEM_FRAME:
                DrawFrame( &m_pMenuItemList[ dwItemIndex ].Location, m_settings.staticColor );
                break;

            case NUI_MENU_ITEM_PANEL:
                DrawPanel( &m_pMenuItemList[ dwItemIndex ].Location, m_settings.panelColor );
                break;

            case NUI_MENU_ITEM_PROGRESS_BAR:
                DrawProgressBar( &m_pMenuItemList[ dwItemIndex ].Location, m_pMenuItemList[ dwItemIndex ].fValue, m_settings.staticColor );
                break;

            case NUI_MENU_ITEM_SPINNER:
                DrawSpinner( &m_pMenuItemList[ dwItemIndex ].Location, m_pMenuItemList[ dwItemIndex ].fValue, m_settings.staticColor );
                break;

            case NUI_MENU_ITEM_TEXT:
                DrawText( &m_pMenuItemList[ dwItemIndex ].Location, m_pMenuItemList[ dwItemIndex ].szText, m_settings.staticColor, m_pMenuItemList[ dwItemIndex ].dwValue );
                break;

            default:
                assert( false );
                break;
            }
        }
    }

    // Add an alignment grid on top of the menu, if requested.
    if( m_settings.bDrawGuide )
    {
        DrawAlignmentGrid();
    }

    // Draw the cursor last, unless the whole menu is disabled
    if( ! m_bIsDisabled )
    {
        DrawCursor();
    }

}
Beispiel #7
0
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;
}