예제 #1
0
void CWidgetSplitter::DrawSplitterBar(CDCHandle dc)
{
TRY_CATCH

	RECT rect;
	if ( GetSplitterBarRect(&rect) )
	{
		RECT rc;
		GetClientRect(&rc);
		HRGN rgnWnd = CreateRectRgnIndirect(&rc);
		HRGN rgnBar = CreateRectRgnIndirect(&rect);
		CombineRgn(rgnWnd,rgnWnd,rgnBar,RGN_XOR);

		rc = rect;
		rc.left = rect.left + (rect.right - rect.left)/2;
		rc.right = rc.left + 1;

		HRGN rgnLine = CreateRectRgnIndirect(&rc);
		CombineRgn(rgnWnd,rgnWnd,rgnLine,RGN_OR);

		SetWindowRgn(rgnWnd,TRUE);

		DeleteObject(rgnBar);
		DeleteObject(rgnLine);
		DeleteObject(rgnWnd);

		dc.MoveTo(rc.left,rc.top);
		dc.LineTo(rc.left,rc.bottom);
	}

CATCH_THROW()
}
예제 #2
0
void CMenuSkin::DrawColumnSepLine(CDCHandle dc, const RECT &rcClient, int iLineX)
{
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, CSkinProperty::GetColor(Skin_Property_Menu_Vertical_Sep_Color));
	dc.SelectPen(pen);
	dc.MoveTo(iLineX, rcClient.top + GetMenuMarginDelta());
	dc.LineTo(iLineX, rcClient.bottom - GetMenuMarginDelta());
}
예제 #3
0
void CAnimMixer::drawBar(sInt mode)
{
	CDCHandle dc = GetDC();
  CPen timePen;

  timePen.CreatePen(PS_SOLID, 3, RGB(255, 0, 0)^RGB(128, 128, 128));
  CPenHandle oldPen = dc.SelectPen(timePen);
  int op = dc.SetROP2(R2_XORPEN);

  CRect rc;
  GetClientRect(&rc);
  rc.left += 4;
  rc.top += 45;
  rc.right -= 4;

	if (mode != 2)
	{
		if (m_timeBarPos != -0x7fffffff)
		{
			dc.MoveTo(m_timeBarPos, rc.bottom - 1);
			dc.LineTo(m_timeBarPos, rc.top + 1);
			m_timeBarPos = -0x7fffffff;
		}
	}
  
	if (mode != 1)
	{
		m_timeBarPos = mapTime(m_curFrame);
		
		dc.MoveTo(m_timeBarPos, rc.bottom - 1);
		dc.LineTo(m_timeBarPos, rc.top + 1);
	}
  
  dc.SelectPen(oldPen);
  dc.SetROP2(op);

	ReleaseDC(dc);
}
예제 #4
0
LRESULT CAnimMixer::OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	drawBar(1);

  CDCHandle dc = (HDC) wParam;

	// prepare...
	CRect rc;
  GetClientRect(&rc);

	CFontHandle oldFont = dc.SelectFont(AtlGetDefaultGuiFont());
	dc.SetTextColor(RGB(0, 0, 0));
	dc.SetBkMode(TRANSPARENT);

	CPen blackPen;
	blackPen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	CPenHandle oldPen = dc.SelectPen(blackPen);

	// fill background
	dc.FillSolidRect(&rc, RGB(174, 169, 167));

	// draw tl bar at y 45
	dc.MoveTo(mapTime(0), 45);
	dc.LineTo(rc.right, 45);

	// track grid
	CPen pen_grid;
	pen_grid.CreatePen(PS_DOT, 1, RGB(174*3/4, 169*3/4, 167*3/4)^RGB(174, 169, 167));

	dc.SelectPen(pen_grid);
	dc.SetROP2(R2_XORPEN);
	dc.SetBkColor(RGB(0, 0, 0));
	dc.SetBkMode(TRANSPARENT);

	for (sInt trackY=46+22; trackY<rc.bottom; trackY+=22)
	{
		dc.MoveTo(mapTime(0), trackY);
		dc.LineTo(rc.right, trackY);
	}

	// bar marks
	dc.SetROP2(R2_COPYPEN);
	dc.SelectPen(blackPen);

	const sF32 xstep = 60000.0f / g_graph->m_bpmRate;
	const sF32 ixstep = g_graph->m_bpmRate / (60000.0f * m_frameStep);
	const sInt xms = (m_startPixel) * ixstep;
	const sInt xme = (m_startPixel + rc.right) * ixstep;

	LOGFONT lf;
	((CFontHandle) AtlGetDefaultGuiFont()).GetLogFont(lf);

	if (lf.lfHeight<0)
		lf.lfHeight=MulDiv(-lf.lfHeight, dc.GetDeviceCaps(LOGPIXELSY), 72);

	for (sInt i=fr::maximum(xms-1,0); i<=xme+1; i++)
	{
		const sInt xpos=mapTime(i*xstep);

		const sInt beat=i&3;

		dc.MoveTo(xpos, 45);
		dc.LineTo(xpos, 37-(beat==0)*2);

		TCHAR buf[32];
		sprintf(buf, "%d.%d", i/4, beat);

		dc.SetTextAlign(TA_BOTTOM|(i?TA_CENTER:TA_LEFT));
		dc.TextOut(xpos, 35, buf);

		if (!beat)
		{
			dc.MoveTo(xpos, rc.bottom);
			dc.LineTo(xpos, 45);
		}
	}

	dc.SelectPen(oldPen);
	dc.SelectFont(oldFont);

  return 1;
}
void CButtonST::DrawItem(UINT ctrlID, LPDRAWITEMSTRUCT lpDIS)
{
	CDCHandle pDC = lpDIS->hDC;

	CPenHandle	pOldPen;

	// Checkbox or Radiobutton style ?
	if (m_bIsCheckBox)
		{
		m_bIsPressed  =  (lpDIS->itemState & ODS_SELECTED) || m_nCheck;
		}
	// Normal button OR other button style ...
	else
		{
		m_bIsPressed = (lpDIS->itemState & ODS_SELECTED);
		}

	m_bIsFocused  = (lpDIS->itemState & ODS_FOCUS) != 0;
	m_bIsDisabled = (lpDIS->itemState & ODS_DISABLED) != 0;
	
	CRect itemRect = lpDIS->rcItem;

	pDC.SetBkMode(TRANSPARENT);

	if (!m_bIsFlat)
		{
		if (m_bIsFocused || GetDefault())
			{
			CBrush br;
			br.CreateSolidBrush(RGB(0,0,0));  
			pDC.FrameRect(&itemRect, br);
			itemRect.DeflateRect(1, 1);
			}
		}

	// Prepare draw... paint button background

	// Draw transparent?
	if (m_bDrawTransparent)
		{
		PaintBk(pDC);
		}
	else
		{
		OnDrawBackground(pDC, &itemRect);
		}

	// Draw pressed button
	if (m_bIsPressed)
		{
		if (m_bIsFlat)
			{
			if (m_bDrawBorder)
				{
				OnDrawBorder(pDC, &itemRect);
				}
			}
		else    
			{
			CBrush brBtnShadow;
			brBtnShadow.CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
			pDC.FrameRect(&itemRect, brBtnShadow);
			}
		}
	else // ...else draw non pressed button
		{
		CPen penBtnHiLight; // White
		CPen pen3DLight;       // Light gray
		CPen penBtnShadow;   // Dark gray
		CPen pen3DDKShadow; // Black

		penBtnHiLight.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNHILIGHT)); // White
		pen3DLight.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DLIGHT));       // Light gray
		penBtnShadow.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNSHADOW));   // Dark gray
		pen3DDKShadow.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DDKSHADOW)); // Black

		if (m_bIsFlat)
			{
			if (m_bMouseOnButton && m_bDrawBorder)
				{
				pDC.Draw3dRect(itemRect, ::GetSysColor(COLOR_BTNHILIGHT), ::GetSysColor(COLOR_BTNSHADOW));
				}
			}
		else
			{
			// Draw top-left borders
			// White line
			pOldPen = pDC.SelectPen(penBtnHiLight);
			pDC.MoveTo(itemRect.left, itemRect.bottom-1);
			pDC.LineTo(itemRect.left, itemRect.top);
			pDC.LineTo(itemRect.right, itemRect.top);
			// Light gray line
			pDC.SelectPen(pen3DLight);
			pDC.MoveTo(itemRect.left+1, itemRect.bottom-1);
			pDC.LineTo(itemRect.left+1, itemRect.top+1);
			pDC.LineTo(itemRect.right, itemRect.top+1);
			// Draw bottom-right borders
			// Black line
			pDC.SelectPen(pen3DDKShadow);
			pDC.MoveTo(itemRect.left, itemRect.bottom-1);
			pDC.LineTo(itemRect.right-1, itemRect.bottom-1);
			pDC.LineTo(itemRect.right-1, itemRect.top-1);
			// Dark gray line
			pDC.SelectPen(penBtnShadow);
			pDC.MoveTo(itemRect.left+1, itemRect.bottom-2);
			pDC.LineTo(itemRect.right-2, itemRect.bottom-2);
			pDC.LineTo(itemRect.right-2, itemRect.top);
			//
			pDC.SelectPen(pOldPen);
			}
		}

	// Read the button's title
	CString sTitle;
	int nLen = GetWindowTextLength();
	int nRetLen = GetWindowText(sTitle.GetBufferSetLength(nLen), nLen + 1);

	CRect captionRect = lpDIS->rcItem;

	// Draw the icon
	if (m_csIcons[0].hIcon != 0)
		{
		DrawTheIcon(pDC, !sTitle.IsEmpty(), lpDIS->rcItem, captionRect, m_bIsPressed, m_bIsDisabled);
		}

	if (m_csBitmaps[0].hBitmap != 0)
		{
		pDC.SetBkColor(RGB(255,255,255));
		DrawTheBitmap(pDC, !sTitle.IsEmpty(), lpDIS->rcItem, captionRect, m_bIsPressed, m_bIsDisabled);
		}

	// Write the button title (if any)
	if (!sTitle.IsEmpty())
		{
		// Draw the button's title
		// If button is pressed then "press" title also
		if (m_bIsPressed && !m_bIsCheckBox)
			{
			captionRect.OffsetRect(1, 1);
			}
		// Center text
		CRect centerRect = captionRect;
		pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER | DT_CALCRECT);
		captionRect.OffsetRect((centerRect.Width() - captionRect.Width())/2, (centerRect.Height() - captionRect.Height())/2);
		pDC.SetBkMode(TRANSPARENT);
		if (m_bIsDisabled)
			{
			captionRect.OffsetRect(1, 1);
			pDC.SetTextColor(::GetSysColor(COLOR_3DHILIGHT));
			pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER);
			captionRect.OffsetRect(-1, -1);
			pDC.SetTextColor(::GetSysColor(COLOR_3DSHADOW));
			pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER);
			}
		else
			{
			if (m_bMouseOnButton || m_bIsPressed) 
				{
				pDC.SetTextColor(m_crColors[BTNST_COLOR_FG_IN]);
				pDC.SetBkColor(m_crColors[BTNST_COLOR_BK_IN]);
				} 
			else 
				{
				pDC.SetTextColor(m_crColors[BTNST_COLOR_FG_OUT]);
				pDC.SetBkColor(m_crColors[BTNST_COLOR_BK_OUT]);
				}
			pDC.DrawText(sTitle, -1, captionRect, DT_WORDBREAK | DT_CENTER);
			}
		}
	if (!m_bIsFlat || (m_bIsFlat && m_bDrawFlatFocus))
		{
		// Draw the focus rect
		if (m_bIsFocused)
			{
			CRect focusRect = itemRect;
			focusRect.DeflateRect(3, 3);
			pDC.DrawFocusRect(&focusRect);
			}
		}
}
예제 #6
0
LRESULT CLogListBox::OnDrawitem(UINT uMsg, WPARAM wParam, LPARAM lParam,BOOL& bHandled)
{
	LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
	if(!dis) return FALSE;
      
	LogListBoxItem * item = (LogListBoxItem *)dis->itemData;
	if(!item) return FALSE;
	
   CDCHandle dc = dis->hDC;

   if(dis->itemAction & (ODA_DRAWENTIRE|ODA_SELECT))
   {
		dc.SetBkColor(GetSysColor(COLOR_WINDOW));
		dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
      CRect r(dis->rcItem);
		if(!(dis->itemState & ODS_SELECTED ))
		{
			CBrush br;
			br.CreateSolidBrush(GetSysColor(COLOR_WINDOW));
			dc.FillRect(r,br);
		}
		CRect rct;
      GetClientRect(&rct);

		if(dis->itemState & ODS_SELECTED )
		{
			CRect rd(dis->rcItem);
			GuiTools::FillRectGradient(dis->hDC,rd,0xEAE2D9, 0xD3C1AF, false);
		}
		else if(dis->itemID != GetCount()-1) // If it isn't last item
		{
			CPen pen;
			pen.CreatePen(PS_SOLID, 1, RGB(190,190,190));
			SelectObject(dc.m_hDC, pen);
			dc.MoveTo(rct.left, r.bottom-1);
			dc.LineTo(rct.right, r.bottom-1);
		}
			  
		SetBkMode(dc.m_hDC,TRANSPARENT);

		SIZE TimeLabelDimensions;
		SelectObject(dc.m_hDC, NormalFont);
		GetTextExtentPoint32(dc, item->Time, item->Time.GetLength(), &TimeLabelDimensions);
		
		// Writing error time
		
		ExtTextOutW(dc.m_hDC, rct.right-5-TimeLabelDimensions.cx, r.top + LLB_VertMargin, ETO_CLIPPED, r, item->Time, item->Time.GetLength(), 0);
		// Writing error title
		SelectObject(dc.m_hDC, UnderlineFont);
		ExtTextOutW(dc.m_hDC, r.left+56, r.top + LLB_VertMargin, ETO_CLIPPED, r, item->strTitle, wcslen(item->strTitle), 0);
		
		// Writing some info
		SelectObject(dc.m_hDC, NormalFont);
		RECT ItemRect={r.left+56, r.top + LLB_VertMargin + LLB_VertDivider + item->TitleHeight, 
							r.right - 10, r.bottom-LLB_VertMargin};
		dc.DrawText(item->Info, item->Info.GetLength() , &ItemRect, DT_NOPREFIX);
			
		// Writing error text with bold (explication of error)
		SelectObject(dc.m_hDC, BoldFont);
		RECT TextRect = {r.left+56, LLB_VertMargin +r.top+ item->TitleHeight+LLB_VertDivider+((item->Info.GetLength())?(item->InfoHeight+LLB_VertDivider):0), r.right - 10, r.bottom-LLB_VertMargin};
		dc.DrawText(item->strText,  wcslen(item->strText), &TextRect, DT_NOPREFIX);

		if(item->Type == logError)
			dc.DrawIcon(12,r.top+8,ErrorIcon);
		else if(item->Type == logWarning)
			dc.DrawIcon(12,r.top+8,WarningIcon);
	}
  
	bHandled = true;
	return 0;
}
예제 #7
0
bool CPrintFolder::PrintHeaders(CDCHandle dc, UINT nPage)
{
	try
	{
		int nBkMode = dc.SetBkMode(TRANSPARENT);
		COLORREF clrTextColor = dc.SetTextColor(RGB(0,0,0));				

		// Draw header and footer!!
		if (m_bShowFooter || m_bShowPageNumbers)
		{
			HFONT hOldFont = dc.SelectFont(m_font);

			int cy = _rectExtents.bottom - (m_nFooterHeight - m_nPadding);
			
			dc.MoveTo(_rectExtents.left + m_nPadding, cy);
			dc.LineTo(_rectExtents.right - m_nPadding, cy);
			
			CRect r(_rectExtents.left, cy, _rectExtents.right, _rectExtents.bottom);
			
			if (m_bShowFooter)
			{
				
				DWORD dwStyle = DT_NOCLIP | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
				dwStyle |= (!m_bShowPageNumbers) ? DT_CENTER : DT_LEFT;
				dc.DrawText(_strFooter, -1, r, dwStyle);
			}

			if (m_bShowPageNumbers)
			{
				
				DWORD dwStyle = DT_NOCLIP | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
				dwStyle |= (!m_bShowFooter) ? DT_CENTER : DT_RIGHT;

				CString str;
				str.Format(IDS_PRINT_PAGE_FMT, nPage + 1, GetPageCount());
				dc.DrawText(str, -1, &r, dwStyle);
			}

			dc.SelectFont(hOldFont);
		}
		
		if (m_bShowHeader)
		{
			int cy = (_rectExtents.top + m_nHeaderHeight) - m_nPadding;
			
			dc.MoveTo(_rectExtents.left + m_nPadding, cy);
			dc.LineTo(_rectExtents.right - m_nPadding, cy);
			
			CRect r(_rectExtents.left, _rectExtents.top, _rectExtents.right, cy);
			
			HFONT hOldFont = dc.SelectFont(m_fontTitle);
			dc.DrawText(_strHeader, -1, &r, 
				DT_NOCLIP | DT_VCENTER | DT_CENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX);
			dc.SelectFont(hOldFont);
		}

		dc.SetBkMode(nBkMode);
		dc.SetTextColor(clrTextColor);
	}
	catch(_com_error &e) 
	{
		IW::CMessageBoxIndirect mb;
		mb.ShowException(IDS_LOW_LEVEL_ERROR_FMT, e);
	}

	return true;
}
예제 #8
0
void CListViewCtrlEx::_DrawNormalItem( LPDRAWITEMSTRUCT lpdis, const TListItem *pItem )
{
    if (!pItem)
        return;

    int nItem = lpdis->itemID;

    CDCHandle dc;
    dc.Attach(lpdis->hDC);

    HFONT	hOldFont = dc.SelectFont(m_fontDef);

    BOOL bSelect = FALSE ;
    if ((lpdis->itemAction | ODA_SELECT) &&
            (lpdis->itemState & ODS_SELECTED))
    {
        bSelect = TRUE ;
    }

    if ( bSelect )
        dc.FillSolidRect( &lpdis->rcItem, RGB(185,219,255));
    else
        dc.FillSolidRect( &lpdis->rcItem, pItem->clrBg);

    // draw check box
    if( pItem->dwFlags&(LISTITEM_CHECKBOX|LISTITEM_RADIOBOX) )
        _DrawCheckBox(dc, lpdis->rcItem, _super::GetCheckState(nItem), pItem->dwFlags);

    COLORREF oldClr = dc.GetTextColor();
    for(int i=0; i<pItem->subItems.size(); ++i)
    {
        CRect	rcSubItem;
        DWORD	nMarginWidth = 0;
        CRect	rcBounds;
        GetSubItemRect(nItem, i, LVIR_LABEL, &rcSubItem);

        nMarginWidth = LEFT_MARGIN_TEXT_COLUMN+3;

        if(i==0)
        {
            if( pItem->dwFlags&(LISTITEM_CHECKBOX|LISTITEM_RADIOBOX) )
            {
                nMarginWidth+=rcSubItem.left;
            }
            else
            {
                rcSubItem.left -= 19;
                nMarginWidth+=5;
            }
        }

#define DT_FLAGS_DRAW_TEXT		(DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_END_ELLIPSIS|DT_VCENTER)

        rcSubItem.left += LEFT_MARGIN_TEXT_COLUMN;
        rcSubItem.right -= 3;
        const TListSubItem &subItem = pItem->subItems[i];
        if(subItem.type == SUBITEM_LINK)
        {
            dc.SelectFont(m_fontLink);
            dc.SetTextColor(COLOR_LIST_LINK);

            CRect	rcProbeItem;
            dc.DrawText( subItem.str, -1, &rcProbeItem, DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_VCENTER|DT_CALCRECT);
            dc.DrawText( subItem.str, -1, &rcSubItem, DT_FLAGS_DRAW_TEXT);

            DWORD nMaxWidth = rcProbeItem.Width()+nMarginWidth;
            _SetColumnNeedWidth(i,nMaxWidth);
        }
        else
        {
            if (subItem.type == SUBITEM_ICON && subItem.nImg != NULL)
            {
                dc.DrawIconEx( rcSubItem.left, rcSubItem.top + 3, (HICON)subItem.nImg, 16 , 16, 0, 0, DI_NORMAL );
                rcSubItem.left = rcSubItem.left + 18;
            }
            else if (subItem.type == SUBITEM_PNG)
            {
                Gdiplus::Image* pImg = BkPngPool::Get(subItem.nImg);
                if (pImg)
                {
                    Gdiplus::Graphics graphics(dc);

                    SIZE size = {0, 0};
                    if (pImg)
                    {
                        size.cx = pImg->GetWidth();
                        size.cy = pImg->GetHeight();
                    }

                    graphics.DrawImage(pImg, Gdiplus::Rect(rcSubItem.left, rcSubItem.top + 5, size.cx, size.cy));
                }
                rcSubItem.left = rcSubItem.left + 18;
            } else if(subItem.type==SUBITEM_COMBO)
            {
                CDC	dcTmp;
                dcTmp.CreateCompatibleDC(dc);
                HBITMAP hBmpOld	= dcTmp.SelectBitmap(m_bitmapCombo);
                dc.BitBlt(rcSubItem.right-20, rcSubItem.top + 3, 20, 20, dcTmp, 0, 0, SRCCOPY);
                dcTmp.SelectBitmap(hBmpOld);
                dcTmp.DeleteDC();
            }

            UINT uFormat = DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_PATH_ELLIPSIS|DT_VCENTER;
            if (i == 3)
            {
                if (pItem->nLevel == enumLevelRisk)
                {
                    rcSubItem.DeflateRect(2, 3);

                    CPen penBorder;
                    penBorder.CreatePen( PS_SOLID, 1, RGB(224, 0, 0) );
                    CBrush bshInterior;
                    bshInterior.CreateSolidBrush( RGB(224, 0, 0)  );

                    HPEN hOldPen = dc.SelectPen( penBorder );
                    HBRUSH hOldBrush = dc.SelectBrush( bshInterior );

                    dc.RoundRect( rcSubItem, CPoint( 3, 3 ) );
                    dc.SelectPen(hOldPen);
                    dc.SelectBrush(hOldBrush);
                    dc.SetTextColor( RGB(255, 255, 255) );
                }
                else if (pItem->nLevel == enumLevelUnknown)
                {
                    rcSubItem.DeflateRect(2, 3);

                    CPen penBorder;
                    penBorder.CreatePen( PS_SOLID, 1, RGB(250, 115, 5) );
                    CBrush bshInterior;
                    bshInterior.CreateSolidBrush( RGB(250, 115, 5)  );

                    HPEN hOldPen = dc.SelectPen( penBorder );
                    HBRUSH hOldBrush = dc.SelectBrush( bshInterior );

                    dc.RoundRect( rcSubItem, CPoint( 3, 3 ) );
                    dc.SelectPen(hOldPen);
                    dc.SelectBrush(hOldBrush);
                    dc.SetTextColor( RGB(255, 255, 255) );
                }
                else
                    dc.SetTextColor( subItem.clr );

                uFormat = DT_SINGLELINE|DT_CENTER|DT_NOPREFIX|DT_PATH_ELLIPSIS|DT_VCENTER;
            }
            else
                dc.SetTextColor( subItem.clr );

            dc.DrawText( subItem.str, -1, &rcSubItem, uFormat);
            if (subItem.type == SUBITEM_ICON || subItem.type == SUBITEM_PNG)
                rcSubItem.left = rcSubItem.left - 18;

            CRect	rcProbeItem;
            dc.DrawText( subItem.str, -1, &rcProbeItem, DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_VCENTER|DT_CALCRECT);
            DWORD nMaxWidth = rcProbeItem.Width()+nMarginWidth;
            _SetColumnNeedWidth(i,nMaxWidth);
        }
    }

    CPen	penx;
    penx.CreatePen(PS_SOLID,1,pItem->clrBtmGapLine);
    HPEN	penOld = dc.SelectPen(penx);
    dc.MoveTo( lpdis->rcItem.left, lpdis->rcItem.bottom-1 );
    CRect rcClient;
    GetClientRect(rcClient);

    dc.LineTo( lpdis->rcItem.left + rcClient.Width(), lpdis->rcItem.bottom-1);
    dc.SelectPen(penOld);

    dc.SelectFont(hOldFont);
    dc.SetTextColor(oldClr);
    dc.Detach();
}
예제 #9
0
void CListViewCtrlEx::_DrawTitleItem( LPDRAWITEMSTRUCT lpdis, const TListItem *pItem )
{
    ATLASSERT(pItem);

    if(pItem->subItems.empty())
        return ;

    int	nWinWidth=lpdis->rcItem.right-lpdis->rcItem.left;
    CRect	rcWindows;
    GetWindowRect(rcWindows);
    if ( nWinWidth > rcWindows.Width())
        nWinWidth = rcWindows.Width()-20;

    int nItem = lpdis->itemID;

    CDCHandle dc;
    dc.Attach(lpdis->hDC);
    dc.FillSolidRect( &lpdis->rcItem, pItem->clrBg);
    HFONT	hOldFont = dc.SelectFont(m_fontDef);
    COLORREF clrOld = dc.GetTextColor();
    COLORREF clrDef = clrOld;

    //
    RECT rcItem = lpdis->rcItem;
    if( pItem->dwFlags&LISTITEM_EXPANDABLE )
    {
        //3 + 9 + 3
        if(rcItem.left>-12)
        {
            CDC	dcTmp;
            dcTmp.CreateCompatibleDC(dc);
            HBITMAP hBmpOld	= dcTmp.SelectBitmap(m_bitmapExpand);
            RECT rcMinus = _GetRectMinus(rcItem);
            dc.BitBlt( rcMinus.left, rcMinus.top, 9, 9, dcTmp, pItem->_isclapsed? 9:0, 0, SRCCOPY);
            dcTmp.SelectBitmap(hBmpOld);
        }
    }

    for ( int i = 0; i < pItem->subItems.size(); i++)
    {
        bool	bVCenter=TRUE;
        const TListSubItem& subItem = pItem->subItems[i];
        CRect rcItem = subItem.rcOffset;
        if ( i == 0 )
        {
            rcItem = lpdis->rcItem;

            if(pItem->nTopMargin>=0)
            {
                rcItem.top += pItem->nTopMargin;
                rcItem.bottom -= 0;
                bVCenter=FALSE;
            }
            else
            {
                rcItem.top += 2;
                rcItem.bottom -= 2;
            }
            rcItem.left+= pItem->nLeftmargin;
        }
        else
        {
            if ( rcItem.left < 0 )
            {
                rcItem.left = nWinWidth+rcItem.left;
            }
            if (rcItem.right < 0)
            {
                rcItem.right = nWinWidth+rcItem.right;
            }
            rcItem.OffsetRect( lpdis->rcItem.left, lpdis->rcItem.top);
        }

        if ( subItem.type == SUBITEM_TEXT )
        {
            dc.SetTextColor( subItem.clr);
            dc.SelectFont(m_fontDef);
        }
        else if ( subItem.type == SUBITEM_LINK )
        {
            dc.SelectFont(m_fontLink);
            dc.SetTextColor(COLOR_LIST_LINK);
        }
        else
        {
            dc.SetTextColor( subItem.clr);
            dc.SelectFont(m_fontDef);
        }

        CString strTitle = subItem.str;
        DWORD	nFlag=DT_SINGLELINE|DT_LEFT|DT_NOPREFIX|DT_END_ELLIPSIS;
        if(bVCenter)
            nFlag|=DT_VCENTER;

        if (i==0&&pItem->bBold||pItem->nHeightAdd!=0)
        {
            HFONT	fntOld=dc.SelectFont(BkFontPool::GetFont(pItem->bBold,FALSE,FALSE,pItem->nHeightAdd));
            dc.DrawText( strTitle, -1, &rcItem, nFlag);
            dc.SelectFont(fntOld);
        }
        else
            dc.DrawText( strTitle, -1, &rcItem, nFlag);
    }

    CPen	pex;
    pex.CreatePen(PS_SOLID,1,pItem->clrBtmGapLine);
    HPEN	penOld = dc.SelectPen(pex);
    dc.MoveTo( lpdis->rcItem.left, lpdis->rcItem.bottom-1 );
    dc.LineTo( lpdis->rcItem.right, lpdis->rcItem.bottom-1 );

    dc.SetTextColor(clrOld);
    dc.SelectPen(penOld);
    dc.SelectFont(hOldFont);
    dc.Detach();
}
예제 #10
0
BOOL CDxDatePickerDay::DrawDay(CDCHandle dc)
{
    // check this day item
    BOOL bThisMonthItem = FALSE;
    BOOL bNextMonthItem = FALSE;
    BOOL bPreviousMonthItem = FALSE;

    CDxMonthPicker* pControl = GetDatePicker();
    CDxDatePickerMonth* pMonth = GetMonth();

    COleDateTime dtDay = GetDate();
    CRect rcDay = GetRect();

    if (dtDay.GetYear() > pMonth->GetMonth().GetYear())
    {
        bNextMonthItem = TRUE;
    }
    else if (dtDay.GetYear() < pMonth->GetMonth().GetYear())
    {
        bPreviousMonthItem = TRUE;
    }
    else
    {
        // years the same
        if (dtDay.GetMonth() > pMonth->GetMonth().GetMonth())
            bNextMonthItem = TRUE;
        else if (dtDay.GetMonth() < pMonth->GetMonth().GetMonth())
            bPreviousMonthItem = TRUE;
        else // months the same
            bThisMonthItem = TRUE;
    }

    if (bPreviousMonthItem && !pMonth->GetShowDaysBefore())
        return FALSE;

    if (bNextMonthItem && !pMonth->GetShowDaysAfter())
        return FALSE;


    // apply settings to the DC
    dc.SetBkMode(TRANSPARENT);
    dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
    dc.FillSolidRect(rcDay, GetSysColor(COLOR_WINDOW));

    // change default drawing metrics if day is selected
    if (pControl->IsSelected(dtDay))
    {
        dc.SetTextColor(GetSysColor(COLOR_WINDOW));
        dc.FillSolidRect(rcDay, GetSysColor(COLOR_WINDOWTEXT));
    }

    // make a text for drawing
    CString strText;
    strText.Format(_T("%i"), dtDay.GetDay());

    // draw item content
    {
        // draw item text
        HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT));
        dc.DrawText(strText, strText.GetLength(), &rcDay, DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_NOCLIP);
    }

    CRect rcFocus = rcDay;
    BOOL bToday = FALSE;

    // highlight today item
    if (IsToday(dtDay))
    {
        dc.Draw3dRect(rcDay, GetSysColor(COLOR_HIGHLIGHT), GetSysColor(COLOR_HIGHLIGHT));
        bToday = TRUE;
    }

    if (pControl->IsSelected(dtDay))
    {
        if (!bToday)
        {
            dc.SetTextColor(0);
            dc.SetBkColor(RGB(255, 255, 255));
            dc.DrawFocusRect(&rcFocus);
        }
        else
        {
            COLORREF clrFocus = GetSysColor(COLOR_HIGHLIGHT);
            clrFocus = clrFocus ^ RGB(255, 128, 128);

            rcFocus.DeflateRect(0, 0, 1, 1);

            CPen pen1;
            pen1.CreatePen(PS_DOT, 1, clrFocus);

            HPEN hOldPen = dc.SelectPen(pen1);

            dc.MoveTo(rcFocus.TopLeft());
            dc.LineTo(rcFocus.right, rcFocus.top);
            dc.LineTo(rcFocus.right, rcFocus.bottom);
            dc.LineTo(rcFocus.left, rcFocus.bottom);
            dc.LineTo(rcFocus.left, rcFocus.top);

            dc.SelectPen(hOldPen);
        }
    }

    return TRUE;
}