void CXTPSkinObjectFrame::DrawFrame(CDC* pDC)
{
    if (m_bLockFrameDraw)
        return;

    CXTPWindowRect rc(this);
    rc.OffsetRect(-rc.TopLeft());

    GetSchema()->DrawThemeFrame(pDC, this);

    if (m_spi[SB_VERT].fVisible || m_spi[SB_HORZ].fVisible)
    {
        if (m_spi[SB_VERT].fVisible)
        {
            if (!m_pSBTrack || !m_pSBTrack->bTrackThumb)
                SetupScrollInfo(&m_spi[SB_VERT]);

            CXTPBufferDCEx dcMem(*pDC, m_spi[SB_VERT].rc);
            DrawScrollBar(&dcMem, &m_spi[SB_VERT]);
        }

        if (m_spi[SB_HORZ].fVisible)
        {
            if (!m_pSBTrack || !m_pSBTrack->bTrackThumb)
                SetupScrollInfo(&m_spi[SB_HORZ]);

            CXTPBufferDCEx dcMem(*pDC, m_spi[SB_HORZ].rc);
            DrawScrollBar(&dcMem, &m_spi[SB_HORZ]);
        }

        if (m_spi[SB_HORZ].fVisible && m_spi[SB_VERT].fVisible)
        {
            CRect rcSizeGripper(m_spi[SB_HORZ].rc.right, m_spi[SB_VERT].rc.bottom,
                                m_spi[SB_VERT].rc.right, m_spi[SB_HORZ].rc.bottom);

            if (GetExStyle() & WS_EX_LEFTSCROLLBAR)
            {
                rcSizeGripper.left = m_spi[SB_VERT].rc.left;
                rcSizeGripper.right = m_spi[SB_HORZ].rc.left;
            }

            pDC->FillSolidRect(rcSizeGripper, GetSchema()->GetScrollBarSizeBoxColor(this));

            if (IsSizeBox())
            {
                CXTPSkinManagerClass* pClassScrollBar = GetSkinManager()->GetSkinClass(this, _T("SCROLLBAR"));
                pClassScrollBar->DrawThemeBackground(pDC, SBP_SIZEBOX, SZB_RIGHTALIGN, rcSizeGripper);
            }
        }
    }
}
Exemplo n.º 2
0
void CElcSkinFrameBase::DrawClientBackground(CDC* pDC)
{
	if (!m_bDrawClientBackgnd)
		return;

	CRect rcClient, rcImage;
	::GetClientRect(m_hDerive, &rcClient);

	CElcMemDC dcMem(pDC, rcClient);

	// fill background
	dcMem.FillSolidRect(rcClient, m_skin.client.crBackgnd);

	if (m_skin.client.pane.image.pImage) 
	{
		for (CClientImagePosArray::iterator it = m_arrClientImagePos.begin();
			it != m_arrClientImagePos.end();
			it ++) 
		{
			rcImage = CalcRect(&rcClient, &(it->pos.point), &(it->pos.size));
			thePainter.DrawImageGDI(dcMem.GetSafeHdc(),
				&m_skin.client.pane.image,
				rcImage,
				0,
				0,
				1,
				0);
		}
	}

	dcMem.DrawMe();
}
Exemplo n.º 3
0
BOOL CXTPSkinObjectTab::OnEraseBkgnd(CDC* pDC)
{
	CXTPClientRect rc(this);
	CXTPBufferDC dcMem(pDC->GetSafeHdc(), rc);
	FillClient(&dcMem, rc);

	return TRUE;
}
Exemplo n.º 4
0
void CPictureCtrl::OnPaint(void)
{
 	CPaintDC dc(this);

	CxMemDC dcMem(dc,this,TRUE);
	
	dcMem.Fill(m_clrBkgnd);

	if (m_pImage == NULL)
		return;

	Gdiplus::Graphics grahics(dcMem.GetSafeHdc());
	

	if (m_nDrawFlag == 0)
	{
		grahics.DrawImage(m_pImage,0,0);
	}
	else if (m_nDrawFlag & DrawStretch)
	{
		const CRect &rc = dcMem.Rect();
		Gdiplus::Rect rect(rc.left,rc.top,rc.Width(),rc.Height());
		grahics.DrawImage(m_pImage,rect);
	}
	else 
	{
		const CRect &rc = dcMem.Rect();
		Gdiplus::Rect rect(rc.left,rc.top,rc.Width(),rc.Height());
		Gdiplus::Size size(m_pImage->GetWidth(),m_pImage->GetHeight());

		if (rect.Width<=size.Width || rect.Height<=size.Height)
		{
			grahics.DrawImage(m_pImage,0,0);
		}
		else
		{
			if (m_nDrawFlag & DrawHCenter)
				rect.X += (rect.Width-size.Width)/2;
			if (m_nDrawFlag & DrawVCenter)
				rect.Y += (rect.Height-size.Height)/2;
			rect.Width = size.Width;
			rect.Height = size.Height;

			grahics.DrawImage(m_pImage,rect);
		}
	}
}
Exemplo n.º 5
0
bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
                                    wxODAction act, wxODStatus stat)
{
    // first draw the label
    if ( !wxOwnerDrawn::OnDrawItem(dc, rc, act, stat) )
        return false;

    // now draw the check mark part
    wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
    HDC hdc = GetHdcOf(*impl);

    wxSize size = wxRendererNative::Get().GetCheckBoxSize(GetParent());

    // first create bitmap in a memory DC
    MemoryHDC hdcMem(hdc);
    CompatibleBitmap hBmpCheck(hdc, size.GetWidth(), size.GetHeight());

    // then draw a check mark into it
    {
        SelectInHDC selBmp(hdcMem, hBmpCheck);

        int flags = wxCONTROL_FLAT;
        if ( IsChecked() )
            flags |= wxCONTROL_CHECKED;

        wxDCTemp dcMem(hdcMem);
        wxRendererNative::Get().DrawCheckBox(GetParent(), dcMem, wxRect(size), flags);
    } // select hBmpCheck out of hdcMem

    // finally draw bitmap to screen

    // position of check mark bitmap
    int x = rc.GetX() + CHECKMARK_EXTRA_SPACE;
    int y = rc.GetY() + (rc.GetHeight() - size.GetHeight()) / 2;

    UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL;

    // checkmarks should not be mirrored in RTL layout
    DWORD oldLayout = impl->GetLayoutDirection() == wxLayout_RightToLeft ? LAYOUT_RTL : 0;
    if ( oldLayout & LAYOUT_RTL )
        ::SetLayout(hdc, oldLayout | LAYOUT_BITMAPORIENTATIONPRESERVED);
    wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState);
    if ( oldLayout & LAYOUT_RTL )
        ::SetLayout(hdc, oldLayout);

    return true;
}
Exemplo n.º 6
0
void CXTPSkinObjectTab::OnDraw(CDC* pDC)
{
	CRect rc = GetHeaderRect();
	DWORD dwStyle = GetStyle();

	if (IsRight(dwStyle))
	{
		rc.left -= 2;
	}
	else if (IsLeft(dwStyle))
	{
		rc.right += 2;
	}
	else if (IsBottom(dwStyle))
	{
		rc.top -= 2;
	}
	else
	{
		rc.bottom += 2;
	}

	CXTPBufferDC dcMem(*pDC, rc);
	FillClient(&dcMem, CXTPClientRect(this));

	if (m_bActiveX)
	{
		m_bPaint = TRUE;
		CXTPBufferDC dcMem2(*pDC, rc);
		DefWindowProc(WM_PAINT, (WPARAM)dcMem2.GetSafeHdc(), 0);
		dcMem2.Discard();
		m_bPaint = FALSE;
	}

	CTabCtrl* pTabCtrl = (CTabCtrl*)this;

	CXTPFontDC font(&dcMem, GetFont());
	dcMem.SetBkMode(TRANSPARENT);

	for (int iItem = 0; iItem < pTabCtrl->GetItemCount(); ++iItem)
	{
		DrawTab(&dcMem, iItem);
	}

	DrawTab(&dcMem, pTabCtrl->GetCurSel());
}
Exemplo n.º 7
0
void CXTPMarqueeCtrl::OnPaint()
{
    if (IsMarquee())
    {
        CXTPClientRect rcClient(this);

        CPaintDC dc(this);
        CXTPBufferDC dcMem(dc);

        OnDrawBackground(&dcMem, rcClient);
        OnDrawMarquee(&dcMem, rcClient);
    }
    else
    {
        CProgressCtrl::OnPaint();
    }
}
Exemplo n.º 8
0
void CTestPopupWnd::OnPaint()
{
	CPaintDC dc(this); 

	CRect rect;
	GetClientRect(rect);
	rect.bottom = rect.bottom / 2;

	CElcMemDC dcMem(&dc, rect);

	dcMem.FillSolidRect(rect, RGB(220,240,255));

	m_ImagePaintMgr.SetImagePos(2, CPoint(rect.Width() / 2, 20));
	m_ImagePaintMgr.Draw(&dcMem, rect);

	dcMem.DrawMe();
}
void CXTPSkinObjectToolBar::OnPaint()
{
	CXTPSkinObjectPaintDC dc(this); // device context for painting

	UpdateToolTipsPos();


	CRect rcClient;
	GetClientRect(&rcClient);

	CXTPBufferDC dcMem(dc, rcClient);

	if (IsSpecialSystemToolbar())
	{
		DefWindowProc(WM_PAINT, (WPARAM)dcMem.GetSafeHdc(), 0);
		return;
	}
	dcMem.FillSolidRect(rcClient, GetColor(COLOR_3DFACE));

	HFONT hFont = (HFONT)SendMessage(WM_GETFONT);
	HFONT hOldFont = (HFONT)::SelectObject(dcMem, hFont);


	NMTBCUSTOMDRAW tbcd;
	ZeroMemory(&tbcd, sizeof(NMTBCUSTOMDRAW));
	tbcd.nmcd.hdc = dcMem.GetSafeHdc();
	tbcd.nmcd.rc = rcClient;

	LRESULT dwCustom = CustomDrawNotify(CDDS_PREPAINT, &tbcd.nmcd);

	if (!(dwCustom & CDRF_SKIPDEFAULT))
	{
		DrawToolbarH(&dcMem);
	}

	if (dwCustom & CDRF_NOTIFYPOSTPAINT)
	{
		tbcd.nmcd.hdc = dcMem.GetSafeHdc();
		tbcd.nmcd.uItemState = 0;
		tbcd.nmcd.lItemlParam = 0;
		CustomDrawNotify(CDDS_POSTPAINT, &tbcd.nmcd);
	}


	::SelectObject(dcMem, hOldFont);
}
Exemplo n.º 10
0
//////////////////
// Create bitmap from contents of screen rectangle
// This must be called right after creating a bitmap using the
// default constructor; e.g.
//		WPBitmap foo;
//		foo.copyScreen(myrect);
//
void WPBitmap::copyScreen(WPRect &rc)
{
	WPDisplay dcScreen;		// the whole display

	// Intersect rectangle with screen dimensions
	WPRect rcScreen((WPWin*)NULL);
	rc &= rcScreen;

	// Initialize bitmap to appropriate size
	destroy();
	hobj = CreateCompatibleBitmap(dcScreen, rc.width(), rc.height());
	assert(hobj);
	del = TRUE;
	init();

	// Copy the bits
	WPMemDC dcMem(&dcScreen, this);
	WPRect rcDst(0,0,rc.width(),rc.height());
	dcMem.bitBlt(rcDst, dcScreen, rc.origin());
}
Exemplo n.º 11
0
void CElcSkinFrameBase::NcPaint()
{
	HDC hdc = ::GetWindowDC(m_hDerive);
	if (!hdc)
		return;

	::GetWindowRect(m_hDerive, &m_rect);
	m_rect.OffsetRect(-m_rect.left, -m_rect.top);

	CDC* pDC = CDC::FromHandle(hdc);
	CElcMemDC dcMem(pDC, m_rect);

	if (!m_hIcon) {
		m_hIcon = CWnd::FromHandle(m_hDerive)->GetIcon(FALSE);
	}

	if (::IsIconic(m_hDerive)) {
		DrawCaptionMin(&dcMem, m_hIcon);
	}
	else {
		CRect rcClient;
		rcClient.left = m_rect.left + m_nLeft;
		rcClient.top = m_rect.top + m_nCaption + m_nMenuBar;
		rcClient.right = m_rect.right - m_nRight;
		rcClient.bottom = m_rect.bottom - m_nBottom;

		dcMem.ExcludeClipRect(rcClient);

		DrawBorder(&dcMem, m_hIcon);
		DrawSkinMenuBar(&dcMem);

		pDC->ExcludeClipRect(rcClient);
	}

	dcMem.DrawMe();

	::ReleaseDC(m_hDerive, hdc);
}
Exemplo n.º 12
0
// CElcHeaderCtrl message handlers
void CElcHeaderCtrl::OnPaint() 
{
	CPaintDC dc(this);

	GetClientRect(m_rcClient);

	CElcMemDC dcMem(&dc, m_rcClient);
	dcMem.FillSolidRect(m_rcClient, RGB(255,255,255));
	CFont* pOldFont = dcMem.SelectObject(&m_ftText);

	if (m_skin.background.pImage 
		&& m_skin.separator.pImage 
		&& m_skin.sort.pImage)
	{
		DrawSkinHeader(&dcMem);
	}
	else
	{
		DrawSimpleHeader(&dcMem);
	}

	dcMem.SelectObject(pOldFont);
	dcMem.DrawMe();
}
Exemplo n.º 13
0
void CElcStatic::OnPaint()
{
	CPaintDC dc(this);

	DWORD dwStyle = GetStyle();
	DWORD dwStaticType = (dwStyle & SS_TYPEMASK);

	CRect rect;
	GetClientRect(rect);

	CElcMemDC dcMem(&dc, rect);

	if (m_bUseBackgndColor) {
		dcMem.FillSolidRect(rect, m_crBackgnd);
	}
	else if (GetParent()) {
		HBRUSH hBrush = (HBRUSH)GetParent()->SendMessage(WM_CTLCOLORSTATIC, (WPARAM)dcMem.GetSafeHdc(), (LPARAM)m_hWnd);
		if (hBrush)
			::FillRect(dcMem.GetSafeHdc(), rect, hBrush);
	}

	if (m_bUseTextColor) {
		dcMem.SetTextColor(m_crText);
	}

	if (m_pImage) {
		Graphics g(dcMem.GetSafeHdc());

		Rect rcImage(0, 0, m_pImage->GetWidth(), m_pImage->GetHeight());
		Rect rcDest;
		if (dwStyle & SS_CENTERIMAGE) {
			rcDest.X = rect.left + (rect.Width() - rcImage.Width) / 2;
			rcDest.Y = rect.top + (rect.Height() - rcImage.Height) / 2;
			rcDest.Width = rcImage.Width;
			rcDest.Height = rcImage.Height;
		}
		else {
			rcDest.X = rect.left;
			rcDest.Y = rect.top;
			rcDest.Width = rect.Width();
			rcDest.Height = rect.Height();
		}

		thePainter.DrawStretchImage(&g, m_pImage, &rcDest, &rcImage, 0);
	}
	else if (dwStaticType == SS_ICON
		|| dwStaticType == SS_BITMAP
		|| dwStaticType == SS_OWNERDRAW
		|| dwStaticType == SS_USERITEM
		|| dwStaticType == SS_ENHMETAFILE) 
	{
		// not support type
		// pls use SetImage() to replace
		ASSERT(0);
		return;
	}
	else if (dwStaticType == SS_BLACKRECT
		|| dwStaticType == SS_GRAYRECT
		|| dwStaticType == SS_WHITERECT
		|| dwStaticType == SS_BLACKFRAME
		|| dwStaticType == SS_GRAYFRAME
		|| dwStaticType == SS_WHITEFRAME)
	{
		// not support
		// pls use Standard MFC class : CStatic
		ASSERT(0);
		return;
	}
	else { 
		if (dwStaticType == SS_ETCHEDHORZ) {
			CPen pen1(PS_SOLID, 1, m_crEtched1);
			CPen * pOld = dcMem.SelectObject(&pen1);
			dcMem.MoveTo(rect.left, rect.top);
			dcMem.LineTo(rect.right - 2, rect.top);

			CPen pen2(PS_SOLID, 1, m_crEtched2);
			dcMem.SelectObject(&pen2);
			dcMem.MoveTo(rect.left + 2, rect.top+1);
			dcMem.LineTo(rect.right, rect.top+1);

			dcMem.SelectObject(&pOld);
		}
		else if (dwStaticType == SS_ETCHEDVERT) {
			CPen pen1(PS_SOLID, 1, m_crEtched1);
			CPen * pOld = dcMem.SelectObject(&pen1);
			dcMem.MoveTo(rect.left, rect.top);
			dcMem.LineTo(rect.left, rect.bottom - 2);

			CPen pen2(PS_SOLID, 1, m_crEtched2);
			dcMem.SelectObject(&pen2);
			dcMem.MoveTo(rect.left + 1, rect.top + 2);
			dcMem.LineTo(rect.left + 1, rect.bottom);

			dcMem.SelectObject(&pOld);
		}
		else if (dwStaticType == SS_ETCHEDFRAME) {
			// not implement
			// support later...
			ASSERT(0);
		}
		else {
			CFont* pOldFont = dcMem.SelectObject(GetFont());
			UINT nFormat = 0;
			
			if (dwStaticType == SS_LEFT) {
				nFormat = DT_LEFT | DT_NOFULLWIDTHCHARBREAK | DT_WORDBREAK;
			}
			else if (dwStaticType == SS_CENTER) {
				nFormat = DT_CENTER | DT_NOFULLWIDTHCHARBREAK | DT_WORDBREAK;
			}
			else if (dwStaticType == SS_RIGHT) {
				nFormat = DT_RIGHT | DT_NOFULLWIDTHCHARBREAK | DT_WORDBREAK;
			}
			else if (dwStaticType == SS_SIMPLE) {
				nFormat = DT_SINGLELINE | DT_VCENTER;
			}
			else if (dwStaticType == SS_LEFTNOWORDWRAP) {
				nFormat = DT_SINGLELINE;
			}

			/*
			// these codes are been commented because something errors are not been fiexd yet
			if (dwStyle & SS_ENDELLIPSIS) {
				nFormat |= DT_MODIFYSTRING | DT_END_ELLIPSIS | DT_WORD_ELLIPSIS;
			}
			if (dwStyle & SS_PATHELLIPSIS) {
				nFormat |= DT_MODIFYSTRING | DT_PATH_ELLIPSIS | DT_WORD_ELLIPSIS;
			}*/

			if (dwStyle & SS_NOPREFIX) {
				nFormat |= DT_NOPREFIX;
			}

			if (dwStyle & SS_EDITCONTROL) {
				nFormat |= DT_EDITCONTROL;
			}

			CString strText;
			GetWindowText(strText);
			dcMem.DrawText(strText, rect, nFormat);

			dcMem.SelectObject(pOldFont);
		}
	}

	dcMem.DrawMe();
}
Exemplo n.º 14
0
void CXTPSkinObjectProgress::OnDraw(CDC* pDC)
{
	CRect rcClient;
	GetClientRect(&rcClient);

	CXTPBufferDC dcMem(*pDC, rcClient);

	dcMem.FillSolidRect(rcClient, GetColor(COLOR_3DFACE));

	DWORD dwStyle = GetStyle();
	BOOL bVert = dwStyle & PBS_VERTICAL;
	int nBarPart = bVert ? PP_BARVERT : PP_BAR;
	int nChunkPart = bVert ? PP_CHUNKVERT : PP_CHUNK;

	CXTPSkinManagerClass* pClassProgress = GetSkinClass();
	pClassProgress->DrawThemeBackground(&dcMem, nBarPart, 0,  rcClient);

	CRect rc = rcClient;

	CRect rcMargins = pClassProgress->GetThemeRect(nBarPart, 0,  TMT_SIZINGMARGINS);

	rc.DeflateRect(rcMargins);

	int iWidth, dxBlock;

	if (GetStyle() & PBS_MARQUEE)
	{
		rcClient = rc;

		dxBlock = pClassProgress->GetThemeInt(0, 0, TMT_PROGRESSCHUNKSIZE, rc.Height() * 2 / 3);
		int dxSpace = pClassProgress->GetThemeInt(0, 0, TMT_PROGRESSSPACESIZE, 2);

		rc.left = m_nMarqueePos + rcClient.left;

		if (dxBlock == 1 && dxSpace == 0)
		{
			dxBlock = 8;

			rc.right = rc.left + 5 * dxBlock;

			if (rc.right > rcClient.right)
			{
				CRect rcPart(rcClient.left, rc.top, rcClient.left + rc.right - rcClient.right, rc.bottom);
				pClassProgress->DrawThemeBackground(&dcMem, nChunkPart, 0,  rcPart);

				rc.right = rcClient.right;
			}

			pClassProgress->DrawThemeBackground(&dcMem, nChunkPart, 0,  rc);
			return;
		}

		for (int i = 0; i < 5; i++)
		{
			if (rc.left >= rcClient.right)
				rc.left = rcClient.left;

			rc.right = rc.left + dxBlock;

			if (rc.right > rcClient.right)
				rc.right = rcClient.right;

			pClassProgress->DrawThemeBackground(&dcMem, nChunkPart, 0,  rc);
			rc.left = rc.right + dxSpace;
		}
		return;
	}

	PBRANGE range;
	SendMessage(PBM_GETRANGE, (WPARAM) FALSE, (LPARAM) &range);

	int iLow = range.iLow;
	int iHigh = range.iHigh;
	int iPos =  (int)SendMessage(PBM_GETPOS);


	if (bVert)
	{
		iWidth = rc.Height();
		dxBlock = (rcClient.right - rcClient.left) * 2 / 3;
	}
	else
	{
		iWidth = rc.Width();
		dxBlock = (rcClient.bottom - rcClient.top) * 2 / 3;
	}

	int x = MulDiv(iWidth, iPos - iLow, iHigh - iLow);

	dxBlock = pClassProgress->GetThemeInt(0, 0, TMT_PROGRESSCHUNKSIZE, dxBlock);
	int dxSpace = pClassProgress->GetThemeInt(0, 0, TMT_PROGRESSSPACESIZE, 2);


	if (dxBlock == 0)
		dxBlock = 1;

	if (dxBlock == 1 && dxSpace == 0)
	{
		if (bVert)
		{
			rc.top = rc.bottom - x;
		}
		else
		{
			rc.right = rc.left + x;
		}
		pClassProgress->DrawThemeBackground(&dcMem, nChunkPart, 0,  rc);
		return;
	}

	int nBlocks = (x + (dxBlock + dxSpace) - 1) / (dxBlock + dxSpace);

	for (int i = 0; i < nBlocks; i++)
	{
		if (bVert)
		{
			rc.top = rc.bottom - dxBlock;

			if (rc.bottom <= rcClient.top)
				break;

			if (rc.top <= rcClient.top)
				rc.top = rcClient.top + 1;

		}
		else
		{
			rc.right = rc.left + dxBlock;

			if (rc.left >= rcClient.right)
				break;

			if (rc.right >= rcClient.right)
				rc.right = rcClient.right - 1;
		}

		pClassProgress->DrawThemeBackground(&dcMem, nChunkPart, 0,  rc);


		if (bVert)
			rc.bottom = rc.top - dxSpace;
		else
			rc.left = rc.right + dxSpace;
	}
}
void CXTPSkinObjectTrackBar::OnDraw(CDC* pDC)
{
	CXTPClientRect rc(this);

	CXTPBufferDC dcMem(*pDC, rc);

	NMCUSTOMDRAW nm;
	ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
	nm.hdc = dcMem.GetSafeHdc();
	nm.dwDrawStage = CDDS_PREPAINT;
	nm.hdr.code = NM_CUSTOMDRAW;
	nm.hdr.hwndFrom = GetSafeHwnd();
	nm.hdr.idFrom = GetDlgCtrlID();

	LRESULT lrCdrf = GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);

	FillBackground(&dcMem, rc);


	if (::GetFocus() == m_hWnd && ((SendMessage(WM_QUERYUISTATE) & UISF_HIDEFOCUS) == 0))
	{
		dcMem.SetBkColor(GetColor(COLOR_BTNHIGHLIGHT));

		DrawFocusRect(dcMem, &rc);
	}

	FillDrawRect();

	if (lrCdrf & CDRF_NOTIFYITEMDRAW)
	{
		ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
		nm.hdc = dcMem.GetSafeHdc();
		nm.dwDrawStage = CDDS_ITEMPREPAINT;
		nm.dwItemSpec = TBCD_TICS;
		nm.hdr.code = NM_CUSTOMDRAW;
		nm.hdr.hwndFrom = GetSafeHwnd();
		nm.hdr.idFrom = GetDlgCtrlID();

		GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);
	}

	DrawTics(&dcMem);

	if (lrCdrf & CDRF_NOTIFYITEMDRAW)
	{
		ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
		nm.hdc = dcMem.GetSafeHdc();
		nm.dwDrawStage = CDDS_ITEMPOSTPAINT;
		nm.dwItemSpec = TBCD_TICS;
		nm.hdr.code = NM_CUSTOMDRAW;
		nm.hdr.hwndFrom = GetSafeHwnd();
		nm.hdr.idFrom = GetDlgCtrlID();

		GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);

		ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
		nm.hdc = dcMem.GetSafeHdc();
		nm.dwDrawStage = CDDS_ITEMPREPAINT;
		nm.dwItemSpec = TBCD_CHANNEL;
		nm.hdr.code = NM_CUSTOMDRAW;
		nm.hdr.hwndFrom = GetSafeHwnd();
		nm.hdr.idFrom = GetDlgCtrlID();

		GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);
	}

	DrawChannel(&dcMem);

	if (lrCdrf & CDRF_NOTIFYITEMDRAW)
	{
		ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
		nm.hdc = dcMem.GetSafeHdc();
		nm.dwDrawStage = CDDS_ITEMPOSTPAINT;
		nm.dwItemSpec = TBCD_CHANNEL;
		nm.hdr.code = NM_CUSTOMDRAW;
		nm.hdr.hwndFrom = GetSafeHwnd();
		nm.hdr.idFrom = GetDlgCtrlID();

		GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);

		ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
		nm.hdc = dcMem.GetSafeHdc();
		nm.dwDrawStage = CDDS_ITEMPREPAINT;
		nm.dwItemSpec = TBCD_THUMB;
		nm.hdr.code = NM_CUSTOMDRAW;
		nm.hdr.hwndFrom = GetSafeHwnd();
		nm.hdr.idFrom = GetDlgCtrlID();

		GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);
	}

	DrawThumb(&dcMem);

	if (lrCdrf & CDRF_NOTIFYITEMDRAW)
	{
		ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
		nm.hdc = dcMem.GetSafeHdc();
		nm.dwDrawStage = CDDS_ITEMPOSTPAINT;
		nm.dwItemSpec = TBCD_THUMB;
		nm.hdr.code = NM_CUSTOMDRAW;
		nm.hdr.hwndFrom = GetSafeHwnd();
		nm.hdr.idFrom = GetDlgCtrlID();

		GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);
	}

	if (lrCdrf & CDRF_NOTIFYPOSTPAINT)
	{
		ZeroMemory(&nm, sizeof(NMCUSTOMDRAW));
		nm.hdc = dcMem.GetSafeHdc();
		nm.dwDrawStage = CDDS_POSTPAINT;
		nm.hdr.code = NM_CUSTOMDRAW;
		nm.hdr.hwndFrom = GetSafeHwnd();
		nm.hdr.idFrom = GetDlgCtrlID();

		GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm);
	}
}
Exemplo n.º 16
0
void CXTPSkinObjectSpin::OnDraw(CDC* pDC)
{

	CRect rcClient;
	GetClientRect(&rcClient);

	CXTPBufferDC dcMem(*pDC, rcClient);

	DWORD dwStyle = GetStyle();

	int nLower = 0, nUpper = 0;
	SendMessage(UDM_GETRANGE32, (WPARAM) &nLower, (LPARAM) &nUpper);
	BOOL bEnabled = (nUpper != nLower) && IsWindowEnabled();
	HWND hWndBuddy = (HWND)SendMessage(UDM_GETBUDDY);

	if (hWndBuddy && bEnabled && !::IsWindowEnabled(hWndBuddy))
		bEnabled = FALSE;

	dcMem.FillSolidRect(rcClient, GetColor(COLOR_3DFACE));


	CRect rcBtn = rcClient;

	CXTPSkinManagerClass* pClassSpin = GetSkinClass();


	if (hWndBuddy && GetWindowLong(hWndBuddy, GWL_EXSTYLE) & WS_EX_CLIENTEDGE)
	{
		dcMem.FillSolidRect(rcClient, GetColor(COLOR_WINDOW));

		if (dwStyle & UDS_ALIGNRIGHT)
		{
			rcBtn.DeflateRect(0, 1, 1, 1);

			CXTPSkinManagerClass* pClassEdit = GetSkinManager()->GetSkinClass(this, _T("EDIT"));
			COLORREF clrBorderColor = pClassEdit->GetThemeColor(0, 0, TMT_BORDERCOLOR);
			dcMem.Draw3dRect(rcClient, clrBorderColor, clrBorderColor);
			dcMem.FillSolidRect(rcClient.left, rcClient.top + 1, 1, rcClient.Height() - 2, GetColor(COLOR_WINDOW));
		}
		else if (dwStyle & UDS_ALIGNLEFT)
		{
			rcBtn.DeflateRect(1, 1, 0, 1);

			CXTPSkinManagerClass* pClassEdit = GetSkinManager()->GetSkinClass(this, _T("EDIT"));
			COLORREF clrBorderColor = pClassEdit->GetThemeColor(0, 0, TMT_BORDERCOLOR);
			dcMem.Draw3dRect(rcClient, clrBorderColor, clrBorderColor);
			dcMem.FillSolidRect(rcClient.right - 1, rcClient.top + 1, 1, rcClient.Height() - 2, GetColor(COLOR_WINDOW));
		}
	}

	RECT rc = rcBtn;

	if (dwStyle & UDS_HORZ)
	{
		int nState = DNHZS_NORMAL;
		if (!bEnabled)
			nState = DNHZS_DISABLED;
		else if (m_nPressedButton == UD_HITDOWN && m_nHotButton == UD_HITDOWN)
			nState = DNHZS_PRESSED;
		else if ((m_nHotButton == UD_HITDOWN || m_nPressedButton == UD_HITDOWN)  && (m_nPressedButton != UD_HITUP))
			nState = DNHZS_HOT;

		rc.right = (rcBtn.right + rcBtn.left) / 2;
		pClassSpin->DrawThemeBackground(&dcMem, SPNP_DOWNHORZ, nState, &rc);


		nState = UPHZS_NORMAL;
		if (!bEnabled)
			nState = UPHZS_DISABLED;
		else if (m_nPressedButton == UD_HITUP && m_nHotButton == UD_HITUP)
			nState = UPHZS_PRESSED;
		else if ((m_nHotButton == UD_HITUP || m_nPressedButton == UD_HITUP) && (m_nPressedButton != UD_HITDOWN))
			nState = UPHZS_HOT;

		rc.left = rcBtn.right - (rc.right - rc.left); // handles odd-x case, too
		rc.right = rcBtn.right;
		pClassSpin->DrawThemeBackground(&dcMem, SPNP_UPHORZ, nState, &rc);

	}
	else
	{
		int nState = UPS_NORMAL;
		if (!bEnabled)
			nState = UPS_DISABLED;
		else if (m_nPressedButton == UD_HITUP && m_nHotButton == UD_HITUP)
			nState = UPS_PRESSED;
		else if ((m_nHotButton == UD_HITUP || m_nPressedButton == UD_HITUP) && (m_nPressedButton != UD_HITDOWN))
			nState = UPS_HOT;

		rc.bottom = (rcBtn.bottom + rcBtn.top) / 2;

		pClassSpin->DrawThemeBackground(&dcMem, SPNP_UP, nState, &rc);

		nState = DNS_NORMAL;
		if (!bEnabled)
			nState = DNS_DISABLED;
		else if (m_nPressedButton == UD_HITDOWN && m_nHotButton == UD_HITDOWN)
			nState = DNS_PRESSED;
		else if ((m_nHotButton == UD_HITDOWN || m_nPressedButton == UD_HITDOWN)  && (m_nPressedButton != UD_HITUP))
			nState = DNS_HOT;

		rc.top = rcBtn.bottom - (rc.bottom - rc.top); // handles odd-y case, too
		rc.bottom = rcBtn.bottom;
		pClassSpin->DrawThemeBackground(&dcMem, SPNP_DOWN, nState, &rc);
	}
}
Exemplo n.º 17
0
void CXTPDatePickerList::OnPaint()
{
	CPaintDC dcPaint(this); // device context for painting

	if (!m_pControl)
		return;

	CXTPClientRect rcClient(this);
	CXTPBufferDC dcMem(dcPaint, rcClient);

	m_dtSelMonth.SetStatus(COleDateTime::null);
	int nMonth = m_dtMiddleMonth.GetMonth();
	int nYear = m_dtMiddleMonth.GetYear();

	//if (nYear <= 1601 && nMonth <= 4)
	//{
	//  //no shifting
	//}
	//else if (nYear <= 1601 && nMonth <= 5)
	//  ShiftMonthDown(nYear, nMonth, m_nItemsAbove - 2);
	//else if (nYear <= 1601 && nMonth <= 6)
	//  ShiftMonthDown(nYear, nMonth, m_nItemsAbove - 1);
	//else
	//  ShiftMonthDown(nYear, nMonth, m_nItemsAbove);

	if (nYear <= 100 && nMonth <= 2)
	{
		//no shifting
	}
	else if (nYear <= 100 && nMonth <= 3)
		ShiftMonthDown(nYear, nMonth, m_nItemsAbove - 2);
	else if (nYear <= 100 && nMonth <= 4)
		ShiftMonthDown(nYear, nMonth, m_nItemsAbove - 1);
	else
		ShiftMonthDown(nYear, nMonth, m_nItemsAbove);

	CXTPDatePickerPaintManager* pPaintManager = m_pControl->GetPaintManager();
	// prepare DC
	CFont* pOldFont = dcMem.SelectObject(pPaintManager->GetListControlTextFont());
	int iPosY = 0;

	// fill background
	dcMem.FillSolidRect(rcClient, pPaintManager->GetListControlBackColor());
	dcMem.SetTextColor(pPaintManager->GetListControlTextColor());
	dcMem.SetBkMode(TRANSPARENT);

	CString strDisplayText;
	for (int nItem = 0; nItem < m_nItemsAbove + 1 + m_nItemsBelow; nItem++)
	{
		CRect rcItem;

		if (!m_pControl->m_strYearMonthFormat.IsEmpty())
		{
			strDisplayText = CXTPCalendarUtils::GetDateFormat(COleDateTime(nYear, nMonth, 1, 0, 0, 0), m_pControl->m_strYearMonthFormat);
		}
		else
		{
			strDisplayText.Format(_T("%s %d"), (LPCTSTR)m_pControl->GetMonthName(nMonth), nYear);
		}

		CSize szItem = dcMem.GetTextExtent(_T(" "), 1);
		szItem.cy += 3;

		rcItem.SetRect(0, iPosY, m_rcListControl.Width(), iPosY + szItem.cy);

		dcMem.DrawText(strDisplayText, rcItem, DT_SINGLELINE | DT_CENTER | DT_VCENTER);

		if (IsSelected(nItem, rcItem))
		{
			dcMem.InvertRect(rcItem);
			m_dtSelMonth.SetDate(nYear, nMonth, 1);
			m_dtSelMonth.SetStatus(COleDateTime::valid);
		}

		// next month
		ShiftMonthUp(nYear, nMonth, 1);

		iPosY += szItem.cy;
	}

	dcMem.SelectObject(pOldFont);
}
Exemplo n.º 18
0
bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
                            wxODAction WXUNUSED(act), wxODStatus stat)
{
    const MenuDrawData* data = MenuDrawData::Get();

    wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl();
    HDC hdc = GetHdcOf(*impl);

    RECT rect;
    wxCopyRectToRECT(rc, rect);

    int imgWidth = wxMax(GetMarginWidth(), data->CheckSize.cx);

    if ( IsOwnerDrawn() )
    {
        // font and colors to use
        wxFont font;
        GetFontToUse(font);

        wxColour colText, colBack;
        GetColourToUse(stat, colText, colBack);

        // calculate metrics of item parts
        RECT rcSelection = rect;
        data->ItemMargin.ApplyTo(rcSelection);

        RECT rcSeparator = rcSelection;
        data->SeparatorMargin.ApplyTo(rcSeparator);

        RECT rcGutter = rcSelection;
        rcGutter.right = data->ItemMargin.cxLeftWidth
                       + data->CheckBgMargin.cxLeftWidth
                       + data->CheckMargin.cxLeftWidth
                       + imgWidth
                       + data->CheckMargin.cxRightWidth
                       + data->CheckBgMargin.cxRightWidth;

        RECT rcText = rcSelection;
        rcText.left = rcGutter.right + data->TextBorder;

        // we draw the text label vertically centered, but this results in it
        // being 1px too low compared to native menus for some reason, fix it
        if ( data->MenuLayout() != MenuDrawData::FullTheme )
            rcText.top--;

#if wxUSE_UXTHEME
        // If a custom background colour is explicitly specified, we should use
        // it instead of the default theme background.
        wxUxThemeEngine* const theme = GetBackgroundColour().IsOk()
                                        ? NULL
                                        : MenuDrawData::GetUxThemeEngine();
        if ( theme )
        {
            POPUPITEMSTATES state;
            if ( stat & wxODDisabled )
            {
                state = (stat & wxODSelected) ? MPI_DISABLEDHOT
                                              : MPI_DISABLED;
            }
            else if ( stat & wxODSelected )
            {
                state = MPI_HOT;
            }
            else
            {
                state = MPI_NORMAL;
            }

            wxUxThemeHandle hTheme(GetMenu()->GetWindow(), L"MENU");

            if ( theme->IsThemeBackgroundPartiallyTransparent(hTheme,
                    MENU_POPUPITEM, state) )
            {
                theme->DrawThemeBackground(hTheme, hdc,
                                           MENU_POPUPBACKGROUND,
                                           0, &rect, NULL);
            }

            theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPGUTTER,
                                       0, &rcGutter, NULL);

            if ( IsSeparator() )
            {
                rcSeparator.left = rcGutter.right;
                theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPSEPARATOR,
                                           0, &rcSeparator, NULL);
                return true;
            }

            theme->DrawThemeBackground(hTheme, hdc, MENU_POPUPITEM,
                                       state, &rcSelection, NULL);

        }
        else
#endif // wxUSE_UXTHEME
        {
            if ( IsSeparator() )
            {
                DrawEdge(hdc, &rcSeparator, EDGE_ETCHED, BF_TOP);
                return true;
            }

            AutoHBRUSH hbr(colBack.GetPixel());
            SelectInHDC selBrush(hdc, hbr);
            ::FillRect(hdc, &rcSelection, hbr);
        }


        // draw text label
        // using native API because it recognizes '&'

        HDCTextColChanger changeTextCol(hdc, colText.GetPixel());
        HDCBgColChanger changeBgCol(hdc, colBack.GetPixel());
        HDCBgModeChanger changeBgMode(hdc, TRANSPARENT);

        SelectInHDC selFont(hdc, GetHfontOf(font));


        // item text name without mnemonic for calculating size
        wxString text = GetName();

        SIZE textSize;
        ::GetTextExtentPoint32(hdc, text.c_str(), text.length(), &textSize);

        // item text name with mnemonic
        text = GetItemLabel().BeforeFirst('\t');

        int flags = DST_PREFIXTEXT;
        // themes menu is using specified color for disabled labels
        if ( data->MenuLayout() == MenuDrawData::Classic &&
             (stat & wxODDisabled) && !(stat & wxODSelected) )
            flags |= DSS_DISABLED;

        if ( (stat & wxODHidePrefix) && !data->AlwaysShowCues )
            flags |= DSS_HIDEPREFIX;

        int x = rcText.left;
        int y = rcText.top + (rcText.bottom - rcText.top - textSize.cy) / 2;

        ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(text),
                    text.length(), x, y, 0, 0, flags);

        // ::SetTextAlign(hdc, TA_RIGHT) doesn't work with DSS_DISABLED or DSS_MONO
        // as the last parameter in DrawState() (at least with Windows98). So we have
        // to take care of right alignment ourselves.
        wxString accel = GetItemLabel().AfterFirst(wxT('\t'));
        if ( !accel.empty() )
        {
            SIZE accelSize;
            ::GetTextExtentPoint32(hdc, accel.c_str(), accel.length(), &accelSize);

            flags = DST_TEXT;
            // themes menu is using specified color for disabled labels
            if ( data->MenuLayout() == MenuDrawData::Classic &&
                 (stat & wxODDisabled) && !(stat & wxODSelected) )
                flags |= DSS_DISABLED;

            x = rcText.right - data->ArrowMargin.GetTotalX()
                                 - data->ArrowSize.cx
                                 - data->ArrowBorder;

            // right align accel on FullTheme menu, left otherwise
            if ( data->MenuLayout() == MenuDrawData::FullTheme)
                x -= accelSize.cx;
            else
                x -= m_parentMenu->GetMaxAccelWidth();

            y = rcText.top + (rcText.bottom - rcText.top - accelSize.cy) / 2;

            ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(accel),
                        accel.length(), x, y, 0, 0, flags);
        }
    }


    // draw the bitmap

    RECT rcImg;
    SetRect(&rcImg,
            rect.left   + data->ItemMargin.cxLeftWidth
                        + data->CheckBgMargin.cxLeftWidth
                        + data->CheckMargin.cxLeftWidth,
            rect.top    + data->ItemMargin.cyTopHeight
                        + data->CheckBgMargin.cyTopHeight
                        + data->CheckMargin.cyTopHeight,
            rect.left   + data->ItemMargin.cxLeftWidth
                        + data->CheckBgMargin.cxLeftWidth
                        + data->CheckMargin.cxLeftWidth
                        + imgWidth,
            rect.bottom - data->ItemMargin.cyBottomHeight
                        - data->CheckBgMargin.cyBottomHeight
                        - data->CheckMargin.cyBottomHeight);

    if ( IsCheckable() && !m_bmpChecked.IsOk() )
    {
        if ( stat & wxODChecked )
        {
            DrawStdCheckMark((WXHDC)hdc, &rcImg, stat);
        }
    }
    else
    {
        wxBitmap bmp;

        if ( stat & wxODDisabled )
        {
            bmp = GetDisabledBitmap();
        }

        if ( !bmp.IsOk() )
        {
            // for not checkable bitmaps we should always use unchecked one
            // because their checked bitmap is not set
            bmp = GetBitmap(!IsCheckable() || (stat & wxODChecked));

#if wxUSE_IMAGE
            if ( bmp.IsOk() && stat & wxODDisabled )
            {
                // we need to grey out the bitmap as we don't have any specific
                // disabled bitmap
                wxImage imgGrey = bmp.ConvertToImage().ConvertToGreyscale();
                if ( imgGrey.IsOk() )
                    bmp = wxBitmap(imgGrey);
            }
#endif // wxUSE_IMAGE
        }

        if ( bmp.IsOk() )
        {
            wxMemoryDC dcMem(&dc);
            dcMem.SelectObjectAsSource(bmp);

            // center bitmap
            int nBmpWidth  = bmp.GetWidth(),
                nBmpHeight = bmp.GetHeight();

            int x = rcImg.left + (imgWidth - nBmpWidth) / 2;
            int y = rcImg.top  + (rcImg.bottom - rcImg.top - nBmpHeight) / 2;
            dc.Blit(x, y, nBmpWidth, nBmpHeight, &dcMem, 0, 0, wxCOPY, true);
        }
    }

    return true;

}
Exemplo n.º 19
0
void CVCADialog::OnPaint()
{
	
	CPaintDC dc(this); // device context for painting

	CRect rc;
	GetClientRect( &rc );

	if(m_pEngine)
	{
		if( CEngine::VCA_ENGINE_STREAMING != m_pEngine->GetStatus() )
		{
			CMemDC dcMem( &dc );

			dcMem.FillSolidRect( rc, RGB(0,0,0));

			CBitmap bmp;
			bmp.LoadBitmap( IDB_NOSIGNAL );

			CDC dcBmp;
			dcBmp.CreateCompatibleDC( &dcMem );
			CBitmap *pOldBmp = dcBmp.SelectObject( &bmp );

			BITMAP bm;
			bmp.GetBitmap( &bm );

			int sml = min( rc.Width(), rc.Height() );
			int x, y;
			x = sml == rc.Width() ? 0 : (rc.Width() - sml)/2;
			y = sml == rc.Height() ? 0 : (rc.Height() - sml)/2;

			dcMem.StretchBlt( x, y, sml, sml, &dcBmp, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY );

			dcBmp.SelectObject( pOldBmp );

			bmp.DeleteObject();
		}
	}
	else
	{
		dc.FillSolidRect(rc,  RGB(0,0,0) );
		dc.SetTextColor( RGB( 255, 255, 255) );
		CString s = _T("");
		switch( m_eSourceStatus )
		{
			case SS_OK:	
			{
				s = _T("OK");
				dc.DrawText( s, &rc, DT_SINGLELINE | DT_VCENTER | DT_CENTER );
			}
			break;
			case SS_NOTASSIGNED:
			{
				s = _T("VIDEO SOURCE NOT ASSIGNED");
				dc.DrawText( s, &rc, DT_SINGLELINE | DT_VCENTER | DT_CENTER );
			}
			break;
			case SS_ERROR:	
			{
				s = _T("ERROR OPENING VIDEO SOURCE");
				dc.DrawText( s, &rc, DT_SINGLELINE | DT_VCENTER | DT_CENTER );

				rc.OffsetRect( 0, 30 );
				s.Format( _T("ENGINE: %d TYPE: %s"), m_iEngId, 
					IVCAVideoSource::GetSourceTypeStr( (IVCAVideoSource::eSOURCETYPE)CAPPConfigure::Instance()->GetAPPEngineInfo(m_iEngId)->tSourceData.SourceType) );
				dc.DrawText( s, &rc, DT_SINGLELINE | DT_VCENTER | DT_CENTER );
			}
			break;
		}
	}
}