void TC2DrawBlt(HDC dhdc, int dx, int dy, int dw, int dh, HDC shdc, int sx, int sy, int sw, int sh, BOOL useTrans) { if(useTrans) TransBlt(dhdc, dx, dy, dw, dh, shdc, sx, sy, sw, sh); else StretchBlt(dhdc, dx, dy, dw, dh, shdc, sx, sy, sw, sh, SRCCOPY); }
/*************************************************** OnDraw The Ultimate Grid calls this visual function every time it is drawing a cell. It is up to the individual cell type to properly draw itself. Params: dc - device context to draw the cell with rect - rectangle to draw the cell in col - column that is being drawn row - row that is being drawn cell - cell that is being drawn selected- TRUE if the cell is selected, otherwise FALSE current - TRUE if the cell is the current cell, otherwise FALSE Return <none> ****************************************************/ void CUGCTMail::OnDraw(CDC *dc,RECT *rect,int col,long row,CUGCell *cell,int selected,int current) { if (!m_drawThemesSet) m_useThemes = cell->UseThemes(); CBrush * pOldBrush = dc->SelectObject( (selected || current) ? &m_blueBrush : &m_whiteBrush); int backgroundMode = dc->GetBkMode(); dc->SetBkMode(TRANSPARENT); dc->FillRect(rect, (selected || current) ? &m_blueBrush : &m_whiteBrush); mailItem item = ParseString(cell); // Draw left icon POINT ptLeftIcon; ptLeftIcon.x = rect->left + leftIconLeftMargin; ptLeftIcon.y = rect->top + leftIconTopMargin; m_leftImages.SetBkColor( (selected || current) ? RGB(46,106,197) : RGB(255,255,255)); m_leftImages.Draw(dc, item.leftIcon, ptLeftIcon, ILD_NORMAL); // Need to fill the background for the left images, because we can't transparently draw 24 bit images from an image list. IMAGEINFO iiLeft; if (m_leftImages.m_hImageList) { m_leftImages.GetImageInfo(item.leftIcon, &iiLeft); } else { iiLeft.rcImage.left = iiLeft.rcImage.right = iiLeft.rcImage.top = iiLeft.rcImage.bottom = 0; } IMAGEINFO iiRight; iiRight.rcImage.left = iiRight.rcImage.right = iiRight.rcImage.top = iiRight.rcImage.bottom = 0; if (m_rightImages.m_hImageList) { // Draw right image m_rightImages.GetImageInfo(item.rightIcon, &iiRight); POINT ptRightIcon; ptRightIcon.x = rect->right - iiRight.rcImage.right + iiRight.rcImage.left; ptRightIcon.y = rect->top; m_rightImages.Draw(dc, item.rightIcon, ptRightIcon, ILD_TRANSPARENT); } // Draw text CFont * pOldFont = dc->SelectObject((item.isRead) ? &m_fontNormal : &m_fontBold); COLORREF oldTextCol = dc->SetTextColor((selected || current) ? RGB(255, 255, 255) : RGB(0,0,0)); RECT rcText = *rect; rcText.top += 4; rcText.right -= iiRight.rcImage.right - iiRight.rcImage.left; rcText.left += iiLeft.rcImage.right - iiLeft.rcImage.left + leftIconLeftMargin + leftIconRightMargin; dc->DrawText(item.sender, &rcText, DT_END_ELLIPSIS); CSize szDate = dc->GetTextExtent(item.dateString); CSize szSender = dc->GetTextExtent(item.sender); RECT rc = rcText; rc.left = rc.right - szDate.cx - 4; if (rc.left < rcText.left + szSender.cx + 4) { rc.left = rcText.left + szSender.cx + 4; } dc->DrawText(item.dateString, &rc, DT_END_ELLIPSIS); /* if (item.attachmentPath.GetLength() && m_attachmentImage.m_hObject) { BITMAP bm; m_attachmentImage.GetBitmap(&bm); rc.right -= bm.bmWidth; } */ rc.left = rcText.left; rc.top = rc.bottom - (szDate.cy + 4); if (item.attachmentPath.GetLength()) { if (m_attachmentImage.m_hObject) { BITMAP bm; m_attachmentImage.GetBitmap(&bm); rc.right -= bm.bmWidth; CDC dcImg; dcImg.CreateCompatibleDC(dc); CBitmap * pOldBitmap = dcImg.SelectObject(&m_attachmentImage); if (!TransBlt(*dc, rc.right, rect->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, dcImg, 0, 0, bm.bmWidth, bm.bmHeight, RGB(255, 255, 255))) { // This probably means we're running on W95 dc->BitBlt(rc.right, rect->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, &dcImg, 0, 0, SRCCOPY); } dcImg.SelectObject(pOldBitmap); } } dc->SelectObject(&m_fontNormal); dc->DrawText(item.subject, &rc, DT_END_ELLIPSIS); // Line across the bottom dc->MoveTo(rect->left, rect->bottom-1); dc->SelectObject(&m_bluePen); dc->LineTo(rect->right-1, rect->bottom-1); dc->LineTo(rect->right-1, rect->top); dc->SelectObject(pOldBrush); dc->SetTextColor(oldTextCol); dc->SetBkMode(backgroundMode); }