void CToolBarPropertyPage::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { if (lpDrawItemStruct->CtlID == IDC_LIST_ICON) { CDCHandle dc = lpDrawItemStruct->hDC; // Save these value to restore them when done drawing. COLORREF crOldTextColor = dc.GetTextColor(); COLORREF crOldBkColor = dc.GetBkColor(); // If this item is selected, set the background color // and the text color to appropriate values. Also, erase // rect by filling it with the background color. if ((lpDrawItemStruct->itemAction | ODA_SELECT) && (lpDrawItemStruct->itemState & ODS_SELECTED)) { dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT)); dc.FillSolidRect(&lpDrawItemStruct->rcItem, ::GetSysColor(COLOR_HIGHLIGHT)); } else dc.FillSolidRect(&lpDrawItemStruct->rcItem, crOldBkColor); #if 0 // If this item has the focus, draw a red frame around the // item's rect. if ((lpDrawItemStruct->itemAction | ODA_FOCUS) && (lpDrawItemStruct->itemState & ODS_FOCUS)) { CBrush br; br.CreateSolidBrush(RGB(255, 0, 0)); dc.FrameRect(&lpDrawItemStruct->rcItem, br); } #endif IconListData* pData = (IconListData*)lpDrawItemStruct->itemData; if (pData) { CIconHandle icon = m_imgList.GetIcon(pData->nIndex); if (icon.m_hIcon) icon.DrawIconEx(dc, lpDrawItemStruct->rcItem.left + cxMargin, lpDrawItemStruct->rcItem.top + cyMargin, m_iconSize.cx, m_iconSize.cy); lpDrawItemStruct->rcItem.left += m_iconSize.cx + cxMargin + IconTextMargin; // Draw the text. dc.DrawText( pData->strText, pData->strText.GetLength(), &lpDrawItemStruct->rcItem, DT_SINGLELINE | DT_VCENTER); } // Reset the background color and the text color back to their // original values. dc.SetTextColor(crOldTextColor); dc.SetBkColor(crOldBkColor); } }
BOOL CBigFileListCtrl::OnEraseBkgnd(CDCHandle dc) { CRect rcClient; GetClientRect(rcClient); dc.FillSolidRect(rcClient, RGB(0xff, 0xff, 0xff)); return TRUE; }
LRESULT CPreviewWindow::OnEraseBackground(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { CDCHandle dc = (HDC) wParam; RECT rc; GetClientRect(&rc); rc.bottom = rc.top + 21; dc.FillSolidRect(&rc, RGB(174, 169, 167)); GetClientRect(&rc); rc.top += 21; dc.Draw3dRect(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, RGB(103, 99, 96), RGB(200, 199, 196)); CFontHandle oldFont = dc.SelectFont(AtlGetDefaultGuiFont()); dc.SetTextColor(RGB(0, 0, 0)); dc.SetBkMode(TRANSPARENT); const sChar *desc = "(no view item)"; frOpGraph::opMapIt it = g_graph->m_ops.find(m_client.m_curOp); if (it != g_graph->m_ops.end()) desc = it->second.plg->getDisplayName(); dc.TextOut(176, 3, desc); dc.SelectFont(oldFont); return 1; }
void CDxMonthPicker::DrawButtons(CDCHandle dc) { if (m_btnToday->m_bVisible) { dc.FillSolidRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNFACE)); CRect rcButtonX = m_btnToday->m_rcButton; rcButtonX.DeflateRect(1, 1, 1, 1); if (m_btnToday->m_bPressed) { dc.Draw3dRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNTEXT), GetSysColor(COLOR_BTNFACE)); dc.Draw3dRect(rcButtonX, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT)); } else { dc.Draw3dRect(m_btnToday->m_rcButton, GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_BTNTEXT)); dc.Draw3dRect(rcButtonX, GetSysColor(COLOR_3DHILIGHT), GetSysColor(COLOR_3DSHADOW)); } HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT)); CString strCaption = _T("Today"); dc.SetTextColor(RGB(0,0,0)); dc.DrawText(strCaption, strCaption.GetLength(), rcButtonX, DT_VCENTER | DT_CENTER | DT_SINGLELINE); } }
void CDxDatePickerMonth::DrawMonthHeader(CDCHandle dc) { if (m_rcHeader.IsRectEmpty()) return; COleDateTime dtMonth = GetMonth(); CRect rcHeader = m_rcHeader; CRect rcLeftScroll = m_rcLeftScroll; CRect rcRightScroll = m_rcRightScroll; CRect rcClient(m_pControl->m_rcControl); //dc.Draw3dRect(0, 0, rcClient.Width(), rcClient.Height(), m_clrStaticBorder, m_clrStaticBorder); CRect rcHeaderBk = m_rcMonth; rcHeaderBk.bottom = rcHeader.bottom; // fill background dc.FillSolidRect(rcHeaderBk, RGB(191, 219, 255)); // draw header text dc.SetBkColor(GetSysColor(COLOR_BTNFACE)); dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT)); CString strText; if (!m_pControl->m_strYearMonthFormat.IsEmpty()) { //strText = GetDateFormat(dtMonth, pControl->m_strYearMonthFormat); } else { strText.Format(_T("%s %d"), (LPCTSTR)m_pControl->GetMonthName( dtMonth.GetMonth()), dtMonth.GetYear()); } dc.DrawText(strText, strText.GetLength(), &rcHeader, DT_SINGLELINE | DT_VCENTER | DT_CENTER); // draw left scroll triangle if (!rcLeftScroll.IsRectEmpty()) { // draw left triangle itself if (GetShowLeftScroll()) DrawScrollTriangle(dc, rcLeftScroll, TRUE, m_clrMonthHeaderButton, m_pControl->m_bYearsTriangle); } // draw right scroll triangle if (!rcRightScroll.IsRectEmpty()) { // draw right triangle itself if (GetShowRightScroll()) DrawScrollTriangle(dc, rcRightScroll, FALSE, m_clrMonthHeaderButton, m_pControl->m_bYearsTriangle); } dc.SelectFont(hFontOld); }
void CDuiColorPicker::OnPaint( CDCHandle dc ) { CRect rcClient; GetClient(&rcClient); ALPHAINFO ai; CGdiAlpha::AlphaBackup(dc,rcClient,ai); dc.FillSolidRect(&rcClient,m_crCur); dc.DrawEdge(&rcClient, BDR_RAISEDINNER, BF_RECT); CGdiAlpha::AlphaRestore(dc,ai); }
LRESULT CNativeToolbar::OnEraseBkgnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled) { CRect rect; GetClientRect(rect); CDCHandle hdc = (HDC)wParam; hdc.FillSolidRect(rect, m_rgbBackColor ); bHandled = TRUE; return 1; }
void CDxMonthPicker::OnPaint(CDCHandle dc) { CRect rcClient; GetRect(rcClient); // draw background dc.FillSolidRect(rcClient, m_clrControlBack); // draw all month items in the collection m_monthPicker->Draw(dc); // draw today/none buttons DrawButtons(dc); // draw border //COLORREF m_clrStaticBorder = RGB(255,255,0); //dc.Draw3dRect(0, 0, rcClient.Width(), rcClient.Height(), m_clrStaticBorder, m_clrStaticBorder); }
void CColorCell::OnDraw(CDCHandle dc) { CBrush brush; brush.CreateSolidBrush(m_crCell); CBrushHandle brushOld = dc.SelectBrush(brush); CPenHandle penOld = dc.SelectStockPen(NULL_PEN); CRect rcPos; rcPos = m_rcPosition; dc.FillSolidRect(rcPos, GetSysColor(COLOR_BTNFACE)); rcPos.DeflateRect(m_nCellBorderSize, m_nCellBorderSize); if (!m_bAtFirstType) { dc.Rectangle(rcPos); } else { dc.Polygon (m_Points, 6); } dc.SelectBrush(brushOld); dc.SelectPen(penOld); }
void CNBTreeListView::DrawTreeItem(LPNMTVCUSTOMDRAW lptvcd, UINT iState, const RECT& rcItem) { CDCHandle dc = lptvcd->nmcd.hdc; HTREEITEM hItem = (HTREEITEM) lptvcd->nmcd.dwItemSpec; tMapItem* pVal = m_mapItems.Lookup(hItem); if( pVal == NULL ) return; // NOTE: Having an ImageList attached to the TreeView control seems // to produce some extra WM_ERASEBKGND msgs, which we can use to // optimize the painting... CImageList il = m_ctrlTree.GetImageList(TVSIL_NORMAL); // If the item had focus then draw it // NOTE: Only when images are used (see note above) // FIX-BY-PATRIA: DrawFocusRect should be done later //if( (iState & CDIS_FOCUS) != 0 && !il.IsNull() ) { // RECT rcFocus = rcItem; // rcFocus.left = 1; // dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT)); // dc.DrawFocusRect(&rcFocus); //} // If it's selected, paint the selection background if( iState & CDIS_SELECTED && iState & CDIS_FOCUS) { RECT rcHigh = rcItem; dc.FillSolidRect(&rcHigh, ::GetSysColor(COLOR_HIGHLIGHT)); } else if( il.IsNull() ) { RECT rcHigh = rcItem; dc.FillSolidRect(&rcHigh, lptvcd->clrTextBk); } // Always write text with background dc.SetBkMode(OPAQUE); dc.SetBkColor(::GetSysColor((iState & CDIS_SELECTED) != 0 ? COLOR_HIGHLIGHT : COLOR_WINDOW)); // Draw all columns of the item RECT rc = rcItem; int cnt = pVal->GetSize(); for( int i = 0; i < cnt; i++ ) { LPTLVITEM pItem = (*pVal)[i]; ATLASSERT(pItem); if( i != 0 ) rc.left = m_rcColumns[i].left; rc.right = m_rcColumns[i].right; if( pItem->mask & TLVIF_IMAGE ) { ATLASSERT(!il.IsNull()); int cx, cy; il.GetIconSize(cx, cy); il.DrawEx( pItem->iImage, dc, rc.left, rc.top, MIN(cx, rc.right - rc.left), cy, CLR_NONE, CLR_NONE, ILD_TRANSPARENT); rc.left += cx; } if( pItem->mask & TLVIF_TEXT ) { rc.left += 2; COLORREF clrText = lptvcd->clrText; if( pItem->mask & TLVIF_TEXTCOLOR ) clrText = pItem->clrText; if( iState & CDIS_SELECTED ) clrText = ::GetSysColor(COLOR_HIGHLIGHTTEXT); dc.SetTextColor(clrText); CFont font; HFONT hOldFont = NULL; if( pItem->mask & TLVIF_STATE ) { LOGFONT lf; ::GetObject(m_ctrlTree.GetFont(), sizeof(LOGFONT), &lf); if( pItem->state & TLVIS_BOLD ) lf.lfWeight += FW_BOLD - FW_NORMAL; if( pItem->state & TLVIS_ITALIC ) lf.lfItalic = TRUE; if( pItem->state & TLVIS_UNDERLINE ) lf.lfUnderline = TRUE; if( pItem->state & TLVIS_STRIKEOUT ) lf.lfStrikeOut = TRUE; font.CreateFontIndirect(&lf); ATLASSERT(!font.IsNull()); hOldFont = dc.SelectFont(font); } UINT format = pItem->mask & TLVIF_FORMAT ? pItem->format : 0; if (0 == i) { CNBDevice* pDevice = (CNBDevice*) m_ctrlTree.GetItemData(hItem); if (NULL != pDevice && pDevice->GetIDString(_T('*')).GetLength() > 0) { CString strBottom = pDevice->GetIDString(m_chHidden); CRect rcTop = rc; rcTop.DeflateRect(0, 0, 0, rcTop.Height() / 2); CRect rcBottom = rc; rcBottom.top = rcTop.bottom; dc.FillSolidRect(&rc, lptvcd->clrTextBk); LOGFONT lf; CFontHandle fontHandle = dc.GetCurrentFont(); fontHandle.GetLogFont(&lf); lf.lfWeight = FW_BOLD; CFont font; font.CreateFontIndirect(&lf); ATLASSERT(!font.IsNull()); HFONT hOldFont = dc.SelectFont(font); dc.DrawText(pItem->pszText, -1, &rcTop, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format); dc.SelectFont(hOldFont); COLORREF clrText = dc.GetTextColor(); clrText = RGB( (GetRValue(clrText) + 0x40) & 0xFF, (GetGValue(clrText) + 0x40) & 0xFF, (GetBValue(clrText) + 0x40) & 0xFF); clrText = dc.SetTextColor(clrText); dc.DrawText(strBottom, -1, &rcBottom, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format); dc.SetTextColor(clrText); } else { dc.FillSolidRect(&rc, lptvcd->clrTextBk); LOGFONT lf; CFontHandle fontHandle = dc.GetCurrentFont(); fontHandle.GetLogFont(&lf); lf.lfWeight = FW_BOLD; CFont font; font.CreateFontIndirect(&lf); ATLASSERT(!font.IsNull()); HFONT hOldFont = dc.SelectFont(font); dc.DrawText(pItem->pszText, -1, &rc, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format); dc.SelectFont(hOldFont); } } else { dc.DrawText(pItem->pszText, -1, &rc, DT_VCENTER | DT_SINGLELINE | DT_WORD_ELLIPSIS | format); } if( pItem->mask & TLVIF_STATE ) dc.SelectFont(hOldFont); } } // FIX-BY-PATRIA: DrawFocusRect should be done here if( (iState & CDIS_FOCUS) != 0 && !il.IsNull() ) { RECT rcFocus = rcItem; rcFocus.left = 1; dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT)); dc.DrawFocusRect(&rcFocus); } }
void CTreeView::DoPaint(CDCHandle hdc, const RECT& rcClip) { hdc.FillSolidRect(&rcClip, GetSysColor(COLOR_WINDOW)); DefWindowProc(WM_PAINT, reinterpret_cast<WPARAM>(hdc.m_hDC), 0); }
RectF CRender::DrawBitmap( CDCHandle& dc, const RectF& rText, IPicture* image, const HTMLElement* element, const PLACEMENT& placement) { if (image == NULL && (element == NULL || element->GetHtmlElement() == NULL)) return rText; LONG width, height; RectF rImg; if (image != NULL) { image->get_Width( &width ); image->get_Height( &height ); CSize szPic(width, height); // convert OLE size into pixels dc.HIMETRICtoDP( &szPic ); rImg.Width = static_cast<float>(szPic.cx); rImg.Height = static_cast<float>(szPic.cy); } else if (element != NULL) { rImg = element->GetSize(); } HRESULT hr = S_OK; //COLORREF transparent = RGB(253,0,200); COLORREF transparent = RGB(0,0,211); // C# transparent gif background color CMemBm bmp(dc, 0, 0, 0, (int)rImg.Width, (int)rImg.Height); CDCHandle hdcMem = bmp; hdcMem.FillSolidRect(0, 0, (int)rImg.Width, (int)rImg.Height, transparent); if (image != NULL) { hr = image->Render( hdcMem, 0, long(rImg.Height), long(rImg.Width), long(-rImg.Height), 0, 0, width, height, NULL ); } else if (element != NULL && element->GetHtmlElement() != NULL) { hr = element->GetHtmlElement()->DrawToDC(hdcMem); } //TODO over support if (/*m_overNode != v ||*/ GetScale() > 1.0f) { ScaleTransform(rImg); } AdjustOffsets(rImg, rText, placement); bmp.DrawTrans( dc, int(rImg.x), int(rImg.y), int(rImg.Width), int(rImg.Height), transparent); return rImg; }
void CDxDatePickerMonth::DrawDaysOfWeek(CDCHandle dc) { if (m_rcDaysOfWeek.IsRectEmpty()) return; // fill background dc.FillSolidRect(m_rcDaysOfWeek, m_clrDaysOfWeekBack); // draw days of week text dc.SetBkColor(m_clrDaysOfWeekBack); dc.SetTextColor(m_clrDaysOfWeekText); HFONT hFontOld = (HFONT)dc.SelectFont(CDxFontManager::GetSingleton().GetFont(DUIF_DEFAULTFONT)); int nMaxX = 0; SIZE szText; dc.GetTextExtent(_T("XX"), 2, &szText); int nTwoLetterWidth = szText.cx; int nWholeLetterWidth = 0; for (int i = 0; i < XTP_WEEK_DAYS; i++) { CString strText(m_pControl->GetDayOfWeekName(i)); dc.GetTextExtent(strText, strText.GetLength(), &szText); nWholeLetterWidth = max(nWholeLetterWidth, szText.cx); } for (int nDayDelta = 0; nDayDelta < XTP_WEEK_DAYS; nDayDelta++) { // calc item rect CDxDatePickerDay* pDay = GetDay(nDayDelta); CRect rcItem(pDay->GetRect()); rcItem.top = m_rcDaysOfWeek.top; rcItem.bottom = m_rcDaysOfWeek.bottom - 2; nMaxX = rcItem.right; // get item text CString strText(m_pControl->GetDayOfWeekName(pDay->GetDate().GetDayOfWeek())); // Check if we can draw whole text if (nWholeLetterWidth + 4 <= rcItem.Width()) { dc.DrawText(strText, strText.GetLength(), &rcItem, DT_SINGLELINE | DT_VCENTER | DT_CENTER); } else if (nTwoLetterWidth + 4 <= rcItem.Width()) // Draw 2 letters { int nChrLen = (int)_tcsnbcnt(strText, 2); dc.DrawText(strText, nChrLen, &rcItem, DT_SINGLELINE | DT_VCENTER | DT_CENTER); } else // Draw only first letter { int nChrLen = (int)_tcsnbcnt(strText, 1); dc.DrawText(strText, nChrLen, &rcItem, DT_SINGLELINE | DT_VCENTER | DT_CENTER); } } // draw bottom line on days of the week CRect rcBottomLine(m_rcDaysOfWeek); rcBottomLine.bottom--; rcBottomLine.top = rcBottomLine.bottom - 1; rcBottomLine.left = m_rcWeekNumbers.right - 1; rcBottomLine.right = nMaxX; dc.FillSolidRect(rcBottomLine, m_clrMonthBorder); dc.SelectFont(hFontOld); }
LRESULT CLayerOptionsDlg::OnDrawItem(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { UINT idCtl = (UINT) wParam; // control identifier LPDRAWITEMSTRUCT lpDrawItemStruct = (LPDRAWITEMSTRUCT) lParam; // item-drawing information CDCHandle pDC = lpDrawItemStruct->hDC; CRect rc = lpDrawItemStruct->rcItem; if (idCtl == IDC_LAYER_COLOR) { pDC.DrawEdge(&rc, (lpDrawItemStruct->itemState & ODS_SELECTED)? EDGE_SUNKEN : EDGE_RAISED, BF_RECT | BF_ADJUST); rc.InflateRect(-1,-1); pDC.FillSolidRect(&rc, m_color); } else { int w = 12; int h = 12; int id = lpDrawItemStruct->itemID; if (id >= 0) { COLORREF ref; if (lpDrawItemStruct->itemState & ODS_SELECTED) ref = ::GetSysColor(COLOR_HIGHLIGHT); else ref = ::GetSysColor(COLOR_WINDOW); // pDC->FillSolidRect(rc.left+1, rc.top+1, rc.Width()-1, rc.Height()-1, ref); pDC.FillSolidRect(&rc, ref); if (lpDrawItemStruct->itemState & ODS_FOCUS) pDC.DrawFocusRect(&rc); if (id < gNumLayerColors) { HBRUSH hOldBrush = pDC.SelectBrush((HBRUSH)GetStockObject(NULL_BRUSH)); pDC.Rectangle(rc.left+1, rc.top+1, rc.left+w+3, rc.top+h+3); pDC.SelectBrush(hOldBrush); CBrush brush; brush.CreateSolidBrush(gLayerColors[id].color); CRect r(rc.left+2, rc.top+2, rc.left+2+w, rc.top+2+h); pDC.FillRect(&r, brush); } if (lpDrawItemStruct->itemState & ODS_SELECTED) { pDC.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); pDC.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT)); } else { pDC.SetTextColor(::GetSysColor(COLOR_WINDOWTEXT)); pDC.SetBkColor(::GetSysColor(COLOR_WINDOW)); } pDC.TextOut(rc.left+((id < gNumLayerColors)? (w+6): 4), rc.top+2, (LPCTSTR)lpDrawItemStruct->itemData); } } return 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 CBigFileListCtrl::DoDrawItem(CDCHandle dc, LPDRAWITEMSTRUCT lpDrawItemStruct) { CRect rcItem = lpDrawItemStruct->rcItem; size_t idx = (size_t)lpDrawItemStruct->itemData; int nItem = lpDrawItemStruct->itemID; BOOL bSelect = lpDrawItemStruct->itemState & ODS_SELECTED; CRect rcDraw; CVirtualDirManager* pDir = (CVirtualDirManager*)m_pOwner; CString strFilePath, strFile, strDir; HICON hIcon = NULL, hIconCache = NULL; int nCurrentEnd = rcItem.left; double percent; CRect rcClient; CFontHandle underlineFont = KuiFontPool::GetFont(FALSE, TRUE, FALSE); CFontHandle normalFont = KuiFontPool::GetFont(FALSE, FALSE, FALSE); // 绘制背景 { rcDraw = rcItem; GetClientRect(rcClient); if (rcClient.right > rcDraw.right) rcDraw.right = rcClient.right; dc.FillSolidRect(rcDraw, RGB(0xff,0xff,0xff)); } if (idx == -1) { CString strMore; dc.SelectFont(underlineFont); dc.SetTextColor(RGB(0x4d, 0x70, 0x96)); strMore.Format( //_T("已经显示了%d个文件,还有%d个没有显示,点击此处查看全部"), _T("还有%d个没有显示,点击此处查看全部"), //GetItemCount() - 1, m_dwMoreItems); rcDraw = rcItem; dc.FillSolidRect(rcDraw, RGB(0xff, 0xff, 0xff)); int nLeft = rcItem.left + GetColumnWidth(0) + GetColumnWidth(1); int nRight = nLeft + GetColumnWidth(2); rcDraw.left = nLeft; rcDraw.right = nRight; dc.DrawText(strMore, strMore.GetLength(), rcDraw, DT_LEFT|DT_BOTTOM|DT_SINGLELINE|DT_CALCRECT); if (rcDraw.right > nRight) rcDraw.right = nRight; dc.DrawText(strMore, strMore.GetLength(), rcDraw, DT_LEFT|DT_BOTTOM|DT_SINGLELINE|DT_END_ELLIPSIS); m_rcMore.left = rcDraw.left; m_rcMore.right = rcDraw.right; m_rcMore.top = 0; m_rcMore.bottom = m_nItemHeight; return; } if (idx == -2) { CString strNone; dc.SelectFont(normalFont); dc.SetTextColor(RGB(0, 0, 0)); strNone = _T("没有发现文件,您可以重新扫描。"); rcDraw = rcItem; dc.FillSolidRect(rcDraw, RGB(0xff, 0xff, 0xff)); rcDraw.left = rcItem.left + GetColumnWidth(0) + GetColumnWidth(1); rcDraw.right = rcDraw.left + GetColumnWidth(2); dc.DrawText(strNone, strNone.GetLength(), rcDraw, DT_LEFT|DT_BOTTOM|DT_SINGLELINE|DT_END_ELLIPSIS); return; } percent = (double)pDir->m_vCacheFiles[idx].qwFileSize / pDir->m_vCacheFiles[0].qwFileSize; rcDraw = rcItem; dc.SetTextColor(RGB(0,0,0)); if (bSelect) { CPen penBorder; CBrush brushBk; CRect rcSelect = rcDraw; penBorder.CreatePen(PS_SOLID, 1, RGB(0x7d, 0xa2, 0xce)); brushBk.CreateSolidBrush(RGB(0xeb, 0xf4, 0xfd)); dc.SelectPen(penBorder); dc.SelectBrush(brushBk); dc.RoundRect(rcSelect, CPoint(3, 3)); rcSelect.left += 2; rcSelect.right -= 2; rcSelect.top += 2; rcSelect.bottom -= 2; DrawGradualColorRect(dc, rcSelect, RGB(0xdd, 0xec, 0xfd), RGB(0xc2, 0xdc, 0xfd)); } else { dc.FillSolidRect(rcDraw, RGB(0xff, 0xff, 0xff)); } { // 画背景进度条 CRect rcProgress = rcDraw; rcProgress.left += 2; rcProgress.right -= 2; rcProgress.top += 2; rcProgress.bottom -= 2; rcProgress.right = rcProgress.left + int(rcProgress.Width() * percent); COLORREF color1 = RGB(0xff, 0xf4, 0xcc); COLORREF color2 = RGB(0xff, 0xde, 0x5c); COLORREF color3 = RGB(0xff, 0xf4 + (0xde - 0xf4) * percent, 0xcc + (0x5c - 0xcc) * percent); DrawGradualColorRect(dc, rcProgress, color1, color3, FALSE); } //rcDraw.top = rcDraw.bottom; //rcDraw.bottom += 1; //dc.FillSolidRect(rcDraw, RGB(0xea, 0xe9, 0xe1)); dc.SetBkMode(TRANSPARENT); strFilePath = pDir->m_vCacheFiles[idx].strFilePath; strFile = strFilePath.Right(strFilePath.GetLength() - strFilePath.ReverseFind(_T('\\')) - 1); strDir = strFilePath.Left(strFilePath.GetLength()); // 绘制文件名 hIconCache = g_IconCache.GetIcon(strFilePath); if (hIconCache) { hIcon = hIconCache; } else { hIcon = bigfilehelper::GetIconFromFilePath(strFilePath); } rcDraw = rcItem; rcDraw.left = nCurrentEnd; nCurrentEnd += GetColumnWidth(0); rcDraw.right = nCurrentEnd; if (rcDraw.Width() > 8) { dc.DrawIconEx(rcDraw.left + 4, rcDraw.top + (rcDraw.Height() - 16) / 2, hIcon, 16, 16); } if (rcDraw.Width() > 24) { rcDraw.left += 24; BOOL bFilter = CBigfileFilter::Instance().IsFileInFilter(strFilePath); BOOL bfilterEnable = GetSysFilterEnable(); if(bFilter && bfilterEnable) dc.SetTextColor(RGB(0xcc, 0xcc, 0xcc)); dc.DrawText(strFile, strFile.GetLength(), rcDraw, DT_SINGLELINE|DT_VCENTER|DT_LEFT|DT_END_ELLIPSIS); } // 绘制进度条 rcDraw.left = nCurrentEnd; nCurrentEnd += GetColumnWidth(1); rcDraw.right = nCurrentEnd; if (rcDraw.Width() > 8) { CString strSize; bigfilehelper::GetFileSizeString(pDir->m_vCacheFiles[idx].qwFileSize, strSize); dc.DrawText(strSize, strSize.GetLength(), rcDraw, DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); } // if (rcDraw.Width() > 48) // { // CPen penBorder; // CBrush brushProgress; // CRect rcProgress = rcDraw; // int nLength; // rcProgress.left += 40; // rcProgress.right -= 4; // rcProgress.top += (rcDraw.Height() - 6) / 2; // rcProgress.bottom -= (rcDraw.Height() - 6) / 2; // penBorder.CreatePen(PS_SOLID, 1, RGB(0xb5, 0xb5, 0xb5)); // brushProgress.CreateSolidBrush(RGB(0xf3, 0xf6, 0xfd)); // dc.SelectPen(penBorder); // dc.SelectBrush(brushProgress); // dc.RoundRect(rcProgress, CPoint(3, 3)); // } // 绘制路径 rcDraw.left = nCurrentEnd; nCurrentEnd += GetColumnWidth(2); rcDraw.right = nCurrentEnd; if (rcDraw.Width() > 8) { dc.DrawText(strDir, strDir.GetLength(), rcDraw, DT_LEFT|DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS); } // 绘制控制 rcDraw.left = nCurrentEnd; nCurrentEnd += GetColumnWidth(3); rcDraw.right = nCurrentEnd; if (rcDraw.Width() > 4) { CRect rcLink; for (size_t i = 0; i < m_vLinks.size(); ++i) { CString strLink = m_vLinks[i].strLink; rcLink = rcDraw; rcLink.left = rcDraw.left + 4 + 40 * (long)i; rcLink.top += 4; rcLink.bottom += 4; dc.SelectFont(underlineFont); dc.SetTextColor(RGB(0x4d, 0x70, 0x96)); dc.DrawText(strLink, strLink.GetLength(), rcLink, DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_CALCRECT); if (rcLink.right > rcDraw.right) rcLink.right = rcDraw.right; dc.DrawText(strLink, strLink.GetLength(), rcLink, DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS); rcLink.top = (rcLink.top - m_nHeaderHeight) % m_nItemHeight; rcLink.bottom = (rcLink.bottom - m_nHeaderHeight) % m_nItemHeight; m_vLinks[i].rcLink = rcLink; } } // 绘制 //dc.DrawText(strFilePath, strFilePath.GetLength(), rcDraw, DT_SINGLELINE|DT_VCENTER|DT_LEFT); if (hIcon != hIconCache) { DestroyIcon(hIcon); } }
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; }
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(); }
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(); }