예제 #1
0
BOOL CStartupView::SetButtonImage(CXTButton *btnButton, UINT uiID, CSize size) 
{
   CSize sz;
   CRect dimensions;
   btnButton->GetClientRect(dimensions);


   CXTPImageManagerIconHandle iconHandle;
   CXTPImageManagerIcon* pIcon; 
   // load icon
   iconHandle = pIcon->LoadBitmapFromResource(MAKEINTRESOURCE(uiID), NULL);
   pIcon = new CXTPImageManagerIcon(0, iconHandle.GetExtent().cx, iconHandle.GetExtent().cy);
      pIcon->SetNormalIcon(iconHandle);
      CMDTARGET_RELEASE(pIcon);

   sz.cx = size.cx;
   sz.cy = size.cy;
   // set icon to the button
   BOOL bIconSet = btnButton->SetIcon(sz,iconHandle,iconHandle);
   
   UINT uIcon[] = {(UINT)btnButton->GetDlgCtrlID()};
   m_pImageManager->SetIcons(uiID, uIcon, _countof(uIcon), size);

   return bIconSet;
}
예제 #2
0
void CXTPPopupControl::UpdateBitmapRegion()
{
	if (!GetSafeHwnd())
		return;

	m_bLayered = FALSE;

	if (m_nBackgroundBitmap <= 0)
	{
		SetWindowRgn(NULL, FALSE);
		return;
	}

	CXTPImageManagerIcon* pImage = m_pImageManager->GetImage(m_nBackgroundBitmap, 0);
	if (!pImage)
	{
		SetWindowRgn(NULL, FALSE);
		return;
	}

	if (pImage->IsAlpha())
	{
		SetWindowRgn(NULL, FALSE);

		SetRegionAlphaLayer(pImage);
	}
	else
	{
		HRGN hRgn = BitmapToRegion(pImage);
		if (!hRgn)
			return;

		SetWindowRgn(hRgn, FALSE);
	}
}
void CXTPFlowGraphDrawContext::DrawImage(CXTPFlowGraphImage* pImage, CRect rc)
{
	CXTPImageManagerIcon* pIcon = pImage->GetIcon();

	if (pIcon)
	{
		pIcon->Draw(CDC::FromHandle(m_hDC), rc.TopLeft(), rc.Size());
	}
}
void CSgSelectionPreparationBar::SetButtonImage(CXTPButton* pButton, UINT nID, CSize sz)
{
   AFX_MANAGE_STATE(AfxGetStaticModuleState());
   CXTPImageManagerIconHandle iconHandle;
   CXTPImageManagerIcon* pIcon; 
   // load icon
   iconHandle = pIcon->LoadBitmapFromResource(::AfxGetResourceHandle(), MAKEINTRESOURCE(nID), NULL);
   pIcon = new CXTPImageManagerIcon(0, iconHandle.GetExtent().cx, iconHandle.GetExtent().cy);
   pIcon->SetNormalIcon(iconHandle);
   pButton->SetIcon(sz,iconHandle,iconHandle);
   CMDTARGET_RELEASE(pIcon);
}
예제 #5
0
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();
}
예제 #6
0
void CXTPPopupItem::CenterIcon()
{
    m_ptOffset = CPoint(0, 0);

    CXTPImageManagerIcon* pIcon = GetImage();

    if (!pIcon)
        return;

    CSize sz = pIcon->GetExtent();
    CRect rc = GetRect();

    if (rc.Width() > sz.cx) m_ptOffset.x = rc.Width()/2 - sz.cx/2;
    if (rc.Height() > sz.cy) m_ptOffset.y = rc.Height()/2 - sz.cy/2;

}
void CXTPPopupPaintManager::DrawBackground(CDC* pDC, CXTPPopupControl* pControl, CRect rcClient)
{
	if (pControl->GetBackgroundBitmap() > 0)
	{
		CXTPImageManagerIcon* pImage = pControl->GetImageManager()->GetImage(pControl->GetBackgroundBitmap(), 0);
		if (pImage)
		{
			pImage->Draw(pDC, CPoint(0, 0));
		}

	}
	else
	{
		XTPDrawHelpers()->GradientFill(pDC, rcClient, m_clrBackground, TRUE);

		if (m_clrFrame.clrLight != (COLORREF)-1)
			pDC->Draw3dRect(rcClient, m_clrFrame.clrLight, m_clrFrame.clrDark);
	}
}
예제 #8
0
void CBackstagePageSave::InitButton(CXTPRibbonBackstageButton& btn)
{
	
	UINT nIDIcon = btn.GetDlgCtrlID();
	

	CXTPImageManagerIcon* pIcon = m_imagelist.GetImage(nIDIcon);
	ASSERT(pIcon);
	
	btn.SetIcon(pIcon->GetExtent(), pIcon);
	pIcon->InternalAddRef();
	
	btn.SetTextAlignment(BS_LEFT | BS_VCENTER);
	btn.SetImageAlignment(BS_LEFT | BS_VCENTER);
	
	
	btn.SetFlatStyle(TRUE);
	btn.ShowShadow(FALSE);	
	btn.SetTabStyle(TRUE);

}
예제 #9
0
void CXTPTaskPanelGroup::OnFillClient(CDC* pDC, CRect rc)
{
	if (m_nBackgroundImage != -1)
	{
		CXTPImageManagerIcon* pIcon = m_pPanel->GetImageManager()->GetImage(m_nBackgroundImage, ICON_BIG);

		if (!pIcon)
			return;

		CPoint pt(rc.left, rc.top);

		if (m_nBackgroundAlignemnt & DT_RIGHT)
			pt.x = rc.right - pIcon->GetWidth();
		else if (m_nBackgroundAlignemnt & DT_CENTER)
			pt.x = rc.CenterPoint().x - pIcon->GetWidth() / 2;

		if (m_nBackgroundAlignemnt & DT_BOTTOM)
			pt.y = rc.bottom - pIcon->GetHeight();
		else if (m_nBackgroundAlignemnt & DT_VCENTER)
			pt.y = rc.CenterPoint().y - pIcon->GetHeight() / 2;

		pIcon->Draw(pDC, pt);
	}
}
예제 #10
0
CSize CSkinTheme::DrawControlPopupParent(CDC* pDC, CXTPControl* pButton, BOOL bDraw)
{
	CRect rcButton = pButton->GetRect();
	XTPControlType controlType = pButton->GetType();
	CRect rcText(0, 0, 0, 0), rcShortcut(0, 0, 0, 0);
	BOOL bSelected = pButton->GetSelected(), 
		bEnabled = pButton->GetEnabled(), 
		bChecked = pButton->GetChecked();

	CSize szIcon = pButton->GetParent()->GetIconSize();
	CSize szImage(max(szIcon.cx + 4, m_nTextHeight), max(szIcon.cy + 4, m_nTextHeight));

	XTPButtonStyle buttonStyle = pButton->GetStyle();
	BOOL bDrawImage = (buttonStyle == xtpButtonAutomatic && controlType != xtpControlPopup) ||
		(buttonStyle == xtpButtonIcon) || (buttonStyle == xtpButtonIconAndCaption);

	ASSERT(controlType == xtpControlButton || controlType == xtpControlPopup); // implemented only.

	if (bDraw)
	{
		CRect rcSelection(rcButton.left, rcButton.top, rcButton.right, rcButton.bottom);
		CRect rcImageRect(rcButton.left, rcButton.top, rcButton.left + szImage.cx, rcButton.bottom);
		CRect rcCheck (CPoint(rcImageRect.left + rcImageRect.Width()/2 - 10, rcImageRect.top + rcImageRect.Height()/2 - 10), CSize(20, 20));

		COLORREF clrText = !bEnabled? 0x0099A8AC: bSelected? 0x0060524B: 0x0060524B;
		pDC->SetTextColor(clrText);
		pDC->SetBkMode (TRANSPARENT);

		if (bSelected)
		{
			// µ¯³ö²Ëµ¥
			Graphics graphics(pDC->GetSafeHdc());

			Rect rc, rc1;

			rc1.X = rcSelection.left;
			rc1.Y = rcSelection.top;
			rc1.Width = rcSelection.Width();
			rc1.Height = rcSelection.Height();

			rc = m_mapRect["PopupSeled"];

			rc1.X = rcSelection.left;
			rc1.Y = rcSelection.top;
			rc1.Width = rc.Width/3;
			rc1.Height = rcSelection.Height();			
			graphics.DrawImage(m_pImg, rc1, rc.GetLeft(), rc.GetTop(), rc.Width/3, rc.Height, UnitPixel, NULL, NULL);

			rc1.X = rcSelection.left+rc.Width/3;
			rc1.Y = rcSelection.top+0;
			rc1.Width = rcSelection.Width()-rc.Width/3*2;
			rc1.Height = rcSelection.Height();			
			graphics.DrawImage(m_pImg, rc1, rc.GetLeft()+rc.Width/3, rc.GetTop(), rc.Width/3, rc.Height, UnitPixel, NULL, NULL);

			rc1.X = rcSelection.left+rcSelection.Width()-rc.Width/3;
			rc1.Y = rcSelection.top+0;
			rc1.Width = rc.Width/3;
			rc1.Height = rcSelection.Height();			
			graphics.DrawImage(m_pImg, rc1, rc.GetRight()-rc.Width/3, rc.GetTop(), rc.Width/3, rc.Height, UnitPixel, NULL, NULL);


		}

		if (bChecked)
		{
			CRect rcCheck (CPoint(rcButton.left - 2, rcButton.top + rcButton.Height()/2 - 10), CSize(20, 20));
			DrawCheckMark(pDC, rcCheck, clrText);
		}

		CXTPImageManagerIcon* pImage = pButton->GetIconId() != 0 && bDrawImage? pButton->GetImage(szIcon.cx): NULL;
		if (pImage)
		{
			szIcon.cy = pImage->GetHeight() * szIcon.cx / pImage->GetWidth();
			// DrawRectangle(pDC, rcImageRect, bSelected, FALSE, bEnabled, bChecked, FALSE, FALSE);
			CPoint ptImage = CPoint(rcCheck.left + rcCheck.Width()/2 - szIcon.cx/2, rcCheck.top + rcCheck.Height()/2 - szIcon.cy/2);
			DrawImage(pDC, ptImage, szIcon, pImage, bSelected, FALSE, bEnabled, bChecked, FALSE, FALSE);
			rcSelection.left = rcImageRect.right + 1;
		}

		if (controlType == xtpControlPopup)
		{
			CPoint pt = CPoint(rcButton.right - 11, rcButton.CenterPoint().y);
			Triangle(pDC, CPoint(pt.x, pt.y - 3), CPoint(pt.x + 3, pt.y), CPoint(pt.x, pt.y + 3), clrText);
		}

		rcText.SetRect(rcButton.left + 24, rcButton.top, rcButton.right, rcButton.bottom);
		rcShortcut.SetRect(rcButton.left + 16 + 4, rcButton.top, rcButton.right - 19, rcButton.bottom);

	}

	pDC->DrawText(pButton->GetCaption(), &rcText, DT_SINGLELINE | DT_VCENTER | (!bDraw ? DT_CALCRECT : DT_END_ELLIPSIS) );

	if (controlType == xtpControlButton && pButton->GetShortcutText().GetLength() != 0 )
		pDC->DrawText(pButton->GetShortcutText(), &rcShortcut, DT_SINGLELINE | DT_VCENTER | (!bDraw ? DT_CALCRECT : DT_RIGHT) );

	return CSize(16 + 12 + rcText.Width() +  rcShortcut.Width() + 32, max(23, m_nTextHeight - 4));	
}
void CXTPHeaderCtrlTheme::OnDrawItemBitmap(LPDRAWITEMSTRUCT lpDIS, CRect& rcText, CXTPHeaderCtrl* pHeaderCtrl)
{
	ASSERT_VALID(pHeaderCtrl);

	HDITEM hdi;
	hdi.mask = HDI_BITMAP | HDI_FORMAT | HDI_IMAGE;
	pHeaderCtrl->GetItem(lpDIS->itemID, &hdi);

	HIMAGELIST hImageList = 0;
	int nIndex = -1;

	if (hdi.fmt & HDF_BITMAP && hdi.hbm != NULL)
	{
		hImageList = (HIMAGELIST)hdi.hbm;
		nIndex = 0;
	}
	else if (hdi.fmt & HDF_IMAGE)
	{
		hImageList = (HIMAGELIST)pHeaderCtrl->SendMessage(HDM_GETIMAGELIST);
		nIndex = hdi.iImage;
	}

	if (nIndex != -1 && (hdi.fmt & HDF_IMAGE) && pHeaderCtrl->GetImageManager())
	{
		CXTPImageManagerIcon* pIcon = pHeaderCtrl->GetImageManager()->GetImage(nIndex, 0);

		if (pIcon)
		{
			CRect rcItem(lpDIS->rcItem);
			CPoint point(rcText.left,  (rcItem.Height() - pIcon->GetHeight()) / 2);

			rcText.left += pIcon->GetWidth() + m_sizePadding.cx;

			XTPImageState imageState = (lpDIS->itemState & ODS_SELECTED) ? xtpImageChecked :
				(lpDIS->itemState & ODS_HOTLIGHT) ? xtpImageHot : xtpImageNormal;

			if (lpDIS->itemState == ODS_SELECTED)
				point.Offset(1, 1);

			if (point.x + pIcon->GetWidth() > lpDIS->rcItem.right)
				return;

			// draw image transparently.
			pIcon->Draw(CDC::FromHandle(lpDIS->hDC), point, pIcon->GetIcon(imageState));

			return;
		}
	}

	if (hImageList)
	{
		int cx, cy;
		if (::ImageList_GetIconSize(hImageList, &cx, &cy) && (nIndex < ImageList_GetImageCount(hImageList)))
		{
			CRect rcItem(lpDIS->rcItem);
			CPoint point(rcText.left,  (rcItem.Height() - cy) / 2);

			rcText.left += cx + m_sizePadding.cx;

			if (lpDIS->itemState == ODS_SELECTED)
				point.Offset(1, 1);

			if (point.x + cx > lpDIS->rcItem.right)
				return;

			// draw image transparently.
			::ImageList_Draw(hImageList, nIndex, lpDIS->hDC, point.x, point.y, ILD_TRANSPARENT);
		}
	}
}
예제 #12
0
void CXTPPopupPaintManager::DrawItem(CDC* pDC, CXTPPopupItem* pItem)
{
	CRect rc = pItem->GetRect();

	if (pItem->GetBackgroundColor() != (COLORREF)-1)
		pDC->FillSolidRect(rc, pItem->GetBackgroundColor());

	if (pItem->GetBorderColor() != (COLORREF)-1)
		pDC->Draw3dRect(rc, pItem->GetBorderColor(), pItem->GetBorderColor());

	CXTPImageManagerIcon* pIcon = pItem->GetImage();

	if (pIcon)
	{
		rc.OffsetRect(pItem->GetIconOffset());

		if (pItem->IsPressed() && pItem->IsSelected())
		{
			if (pItem->IsButton())
				DrawButton(pDC, pItem);

			pIcon->Draw(pDC, rc.TopLeft(), pIcon->GetCheckedIcon());
		}
		else if (pItem->IsSelected() || pItem->IsPressed())
		{
			if (pItem->IsButton())
				DrawButton(pDC, (CXTPPopupItem*)pItem);

			pIcon->Draw(pDC, rc.TopLeft(), pIcon->GetHotIcon());
		}
		else
		{
			pIcon->Draw(pDC, rc.TopLeft(), pIcon->GetIcon());
		}
		return;
	}

	if (pItem->IsButton())
		DrawButton(pDC, (CXTPPopupItem*)pItem);

	if (!pItem->GetCaption().IsEmpty())
	{
		CXTPRichRender* pRichRender = pItem->m_pRichRender;

		CFont fntUnderline;
		CFont* pFont = pItem->GetTextFont();

		if ((pItem->IsSelected() && pItem->IsHyperLink() && pItem->IsUnderline()) || pItem->IsBold())
		{
			LOGFONT lpLogFont;
			pFont->GetLogFont(&lpLogFont);
			lpLogFont.lfUnderline = (pItem->IsSelected() && pItem->IsHyperLink() && pItem->IsUnderline());
			lpLogFont.lfWeight = pItem->IsBold() ? FW_BOLD : FW_NORMAL;

			VERIFY(fntUnderline.CreateFontIndirect(&lpLogFont));
			pFont = &fntUnderline;
		}
		CRect rcText(pItem->GetRect());

		CXTPFontDC font(pDC, pFont);

		if (pRichRender)
		{
			pRichRender->DrawText(pDC, rcText);
		}
		else
		{
			if ((pItem->GetTextAlignment() & (DT_WORDBREAK | DT_VCENTER)) == (DT_WORDBREAK | DT_VCENTER))
			{
				CRect rcTextHeight(rcText.left, 0, rcText.right, 0);
				pDC->DrawText(pItem->GetCaption(), rcTextHeight, pItem->GetTextAlignment() | DT_CALCRECT);
				rcText.top = (rcText.top + rcText.bottom - rcTextHeight.bottom) / 2;
			}

			pDC->SetBkMode(TRANSPARENT);
			pDC->SetTextColor(pItem->GetTextColor() == (COLORREF)-1 ? m_clrText : pItem->GetTextColor());

			pDC->DrawText(pItem->GetCaption(), rcText, pItem->GetTextAlignment());
		}
	}
}