void CXTFlatComboBoxThemeOffice2003::DrawArrowBack(CDC* pDC, CRect& rcArrow, int eState, CXTFlatComboBox* pCombo) { rcArrow.left = rcArrow.right - (m_cxArrow - 2); if (eState == xtMouseHover) { XTPDrawHelpers()->GradientFill(pDC, &rcArrow, XTPColorManager()->grcLunaSelected, FALSE); CXTPPenDC pen(*pDC, GetMSO2003Color(XPCOLOR_HIGHLIGHT_BORDER)); pDC->MoveTo(rcArrow.left-1, rcArrow.top); pDC->LineTo(rcArrow.left-1, rcArrow.bottom); } else if (eState == xtMouseSelect) { XTPDrawHelpers()->GradientFill(pDC, &rcArrow, XTPColorManager()->grcLunaPushed, FALSE); CXTPPenDC pen(*pDC, GetMSO2003Color(XPCOLOR_HIGHLIGHT_BORDER)); pDC->MoveTo(rcArrow.left-1, rcArrow.top); pDC->LineTo(rcArrow.left-1, rcArrow.bottom); } else if (pCombo->IsWindowEnabled()) { rcArrow.DeflateRect(1, 1); XTPDrawHelpers()->GradientFill(pDC, &rcArrow, XTPColorManager()->grcMenuItemPopup, FALSE); } }
void CXTPPopupThemeOffice2003::DrawBackground(CDC* pDC, CXTPPopupControl* pControl, CRect rcClient) { if (pControl->GetBackgroundBitmap() > 0) { CXTPPopupPaintManager::DrawBackground(pDC, pControl, rcClient); return; } XTPDrawHelpers()->GradientFill(pDC, rcClient, m_clrBackground, FALSE); pDC->Draw3dRect(rcClient, m_clrFrame.clrLight, m_clrFrame.clrDark); rcClient.DeflateRect(1, 1); CRect rcGripper(rcClient); rcGripper.bottom = rcGripper.top + 7; XTPDrawHelpers()->GradientFill(pDC, rcGripper, m_clrGripper, FALSE); int nRight = max (2, (rcGripper.Width() - 4 * 9) / 2); for (int i = 0; i < 9; i++) { pDC->FillSolidRect(nRight, rcGripper.top + 1, 2, 2, RGB(40, 50, 71)); pDC->FillSolidRect(nRight + 1, rcGripper.top + 2, 2, 2, RGB(249, 249, 251)); pDC->FillSolidRect(nRight + 1, rcGripper.top + 2, 1, 1, RGB(97, 116, 152)); nRight += 4; } }
void CXTPPopupThemeMSN::DrawBackground(CDC* pDC, CXTPPopupControl* pControl, CRect rcClient) { if (pControl->GetBackgroundBitmap() > 0) { CXTPPopupPaintManager::DrawBackground(pDC, pControl, rcClient); return; } pDC->Draw3dRect(rcClient, RGB(166, 180, 207), RGB(69, 86, 144)); rcClient.DeflateRect(1, 1); pDC->Draw3dRect(rcClient, RGB(255, 255, 255), RGB(207, 222, 244)); rcClient.DeflateRect(1, 1); CRect rcBackground(rcClient.left, rcClient.top, rcClient.right, rcClient.top + 12); XTPDrawHelpers()->GradientFill(pDC, rcBackground, RGB(207, 215, 236), RGB(255, 255, 255) , FALSE); rcBackground = CRect(rcClient.left, rcBackground.bottom, rcClient.right, rcClient.top + 23); XTPDrawHelpers()->GradientFill(pDC, rcBackground, RGB(255, 255, 255), RGB(207, 221, 244), FALSE); rcBackground = CRect(rcClient.left, rcBackground.bottom, rcClient.right, rcClient.top + 40); XTPDrawHelpers()->GradientFill(pDC, rcBackground, RGB(207, 221, 244), RGB(255, 255, 255), FALSE); rcBackground = CRect(rcClient.left, rcBackground.bottom, rcClient.right, rcClient.bottom); XTPDrawHelpers()->GradientFill(pDC, rcBackground, RGB(255, 255, 255), RGB(207, 221, 244), FALSE); CRect rcFrame(rcClient.left, rcClient.top + 22, rcClient.right, rcClient.bottom); pDC->Draw3dRect(rcFrame, RGB(114, 142, 184), RGB(185, 201, 239)); }
void CXTPPopupThemeOffice2000::DrawBackground(CDC* pDC, CXTPPopupControl* pControl, CRect rcClient) { if (pControl->GetBackgroundBitmap() > 0) { CXTPPopupPaintManager::DrawBackground(pDC, pControl, rcClient); return; } XTPDrawHelpers()->GradientFill(pDC, rcClient, m_clrBackground, FALSE); pDC->Draw3dRect(rcClient, m_clrFrame.clrLight, m_clrFrame.clrDark); rcClient.DeflateRect(1, 1); //rcClient.DeflateRect(2, 2); CRect rcBackground(rcClient.left, rcClient.top, rcClient.right, rcClient.top + 22); XTPDrawHelpers()->GradientFill(pDC, rcBackground, RGB(0, 0, 128), RGB(24, 180, 192), TRUE); rcClient.DeflateRect(1, 1); rcBackground = CRect(rcClient.left, rcBackground.top + 23 , rcClient.right, rcClient.bottom); pDC->Draw3dRect(rcBackground, m_clrFrame.clrDark, m_clrFrame.clrLight); rcBackground.DeflateRect(1, 1); pDC->Draw3dRect(rcBackground, m_clrFrame.clrLight, m_clrFrame.clrDark); rcBackground.DeflateRect(1, 1); rcBackground.right = rcBackground.left + 30; XTPDrawHelpers()->GradientFill(pDC, rcBackground, RGB(0, 0, 128), RGB(0, 0, 128), FALSE); }
LRESULT CXTPSkinObjectFrame::OnPrint(WPARAM wParam, LPARAM lParam) { LRESULT lResult = TRUE; if (lParam != PRF_NONCLIENT) { m_bLockFrameDraw++; lResult = DefWindowProc(WM_PRINT, wParam, lParam); m_bLockFrameDraw--; } if (lParam & PRF_NONCLIENT) { if (m_spi[SB_VERT].fVisible) m_spi[SB_VERT].fVisible = GetStyle() & WS_VSCROLL; if (m_spi[SB_HORZ].fVisible) m_spi[SB_HORZ].fVisible = GetStyle() & WS_HSCROLL; CDC* pDC = CDC::FromHandle((HDC)wParam); if ((GetExStyle() & WS_EX_LAYOUTRTL) && !XTPDrawHelpers()->IsContextRTL(pDC)) XTPDrawHelpers()->SetContextRTL(pDC, 1); DrawFrame(pDC); } return lResult; }
void CXTPExcelTabCtrlThemeOffice2003::DrawButtonBack(CDC* pDC, CRect& rect, CXTPExcelTabCtrlButtonState& state) { if (state.m_bEnabled && state.m_bHilight) { if (state.m_bPressed) { XTPDrawHelpers()->GradientFill(pDC, &rect, XTPColorManager()->grcLunaPushed, FALSE); } else { XTPDrawHelpers()->GradientFill(pDC, &rect, XTPColorManager()->grcLunaSelected, FALSE); } pDC->Draw3dRect(&rect, m_clrBorder3DHilite, m_clrBorder3DHilite); } else { pDC->FillSolidRect(rect, m_clr3DFace); pDC->Draw3dRect(rect, m_clr3DFace, m_clr3DFace); } rect.DeflateRect(1, 1); }
void CXTPPopupPaintManager::DrawBackground(CDC* pDC, CXTPPopupControl* pControl, CRect rcClient) { if (pControl->GetBackgroundBitmap() > 0) { CXTPImageManagerIcon* pImage = pControl->GetImageManager()->GetImage(pControl->GetBackgroundBitmap(), 0); if (pImage) { pImage->Draw(pDC, CPoint(0, 0)); } } else { XTPDrawHelpers()->GradientFill(pDC, rcClient, m_clrBackground, TRUE); if (m_clrFrame.clrLight != (COLORREF)-1) pDC->Draw3dRect(rcClient, m_clrFrame.clrLight, m_clrFrame.clrDark); } }
void CXTPHeaderCtrlThemeResource::OnDrawItemBackground(LPDRAWITEMSTRUCT lpDIS) { CXTPResourceImages* pImages = XTPResourceImages(); if (pImages) { CDC* pDC = CDC::FromHandle(lpDIS->hDC); CRect rcItem = lpDIS->rcItem; rcItem.left++; if (lpDIS->itemState == ODS_SELECTED) { XTPDrawHelpers()->GradientFill(pDC, &rcItem, m_crgBackPressed, FALSE); // draw border. { CXTPPenDC dcPen(pDC->m_hDC, m_cr3DDkShadow); pDC->MoveTo(rcItem.left, rcItem.bottom-1); pDC->LineTo(rcItem.right, rcItem.bottom-1); } // draw separator. { CXTPPenDC dcPen(pDC->m_hDC, m_cr3DShadow); pDC->MoveTo(rcItem.right, 2); pDC->LineTo(rcItem.right, rcItem.bottom-3); } } else { // draw separator. CXTPPenDC dcPen(pDC->m_hDC, m_cr3DShadow); pDC->MoveTo(rcItem.right, 2); pDC->LineTo(rcItem.right, rcItem.bottom-3); } } else { CXTPHeaderCtrlThemeOfficeXP::OnDrawItemBackground(lpDIS); } }
CXTMemDC::CXTMemDC(CDC* pDC, const CRect& rect, CXTPPaintManagerColorGradient crBack/*=GetXtremeColor(COLOR_3DFACE)*/, BOOL bHorz/*=FALSE*/) { ASSERT(pDC != NULL); m_pDC = pDC; if (!m_pDC) return; // If rect is NULL, use the device context's clip box. if (rect.IsRectEmpty()) m_pDC->GetClipBox(&m_rc); else m_rc.CopyRect(&rect); // Create the memory DC, set Map Mode if (CreateCompatibleDC(m_pDC)) { SetMapMode(m_pDC->GetMapMode()); // Create a bitmap big enough to hold the window's image m_bitmap.CreateCompatibleBitmap(m_pDC, m_rc.Width(), m_rc.Height()); // Select the bitmap into the memory DC m_hOldBitmap = (HBITMAP)SelectObject(&m_bitmap)->GetSafeHandle(); if (crBack != COLORREF_NULL) { // fill background XTPDrawHelpers()->GradientFill(this, CRect(0, 0, m_rc.Width(), m_rc.Height()), crBack, bHorz); } m_bValid = TRUE; } // Something bad happened, could be GDI leak, didn't create device context. else { m_bValid = FALSE; m_hOldBitmap = NULL; } }
void CXTPHeaderCtrlThemeResource::OnDrawBackground(LPDRAWITEMSTRUCT lpDIS) { CXTPResourceImages* pImages = XTPResourceImages(); if (pImages) { CDC* pDC = CDC::FromHandle(lpDIS->hDC); CRect rcItem = lpDIS->rcItem; // fill background XTPDrawHelpers()->GradientFill(pDC, rcItem, m_crgBack, FALSE); rcItem.right += 2; // draw border. CXTPPenDC penDC(pDC->m_hDC, m_cr3DDkShadow); pDC->MoveTo(lpDIS->rcItem.left, lpDIS->rcItem.bottom-1); pDC->LineTo(lpDIS->rcItem.right, lpDIS->rcItem.bottom-1); } else { CXTPHeaderCtrlThemeOfficeXP::OnDrawBackground(lpDIS); } }
void CXTPMarqueeCtrl::OnDrawMarquee(CDC* pDC, CRect rcClient) { int nEdge = (m_bWinThemed? 3: 1); rcClient.DeflateRect(nEdge, nEdge); pDC->IntersectClipRect(rcClient); // calculate marquee size. int x = IsVertical()? rcClient.left: m_nPos; int y = IsVertical()? m_nPos : rcClient.top; // determine the dimensions for the bitmap. int cx = IsVertical()? rcClient.Width(): m_cxChunk; int cy = IsVertical()? m_cxChunk: rcClient.Height(); // create a memory device context, and select the bitmap into it. CBitmap bmpChunk; bmpChunk.CreateCompatibleBitmap(pDC, cx, cy); CXTPCompatibleDC dcChunk(pDC, &bmpChunk); for (int i = 0; i < _countof(m_chAlpha); ++ i) { dcChunk.BitBlt(0, 0, cx, cy, pDC, x, y, SRCCOPY); // draw the chunk using the memory dc. CXTPEmptyRect rcChunk; if (IsVertical()) { rcChunk.right = cx; rcChunk.bottom = m_cxChunk - (IsSmooth() ? 0 : m_nGap); } else { rcChunk.right = m_cxChunk - (IsSmooth() ? 0 : m_nGap); rcChunk.bottom = cy; } if (m_bWinThemed) { m_themeWrapper.DrawThemeBackground(dcChunk, IsVertical()? PP_CHUNKVERT: PP_CHUNK, PBS_NORMAL, &rcChunk, NULL); } else { dcChunk.FillSolidRect(rcChunk, m_crChunk); } if (XTPDrawHelpers()->m_pfnAlphaBlend) { BLENDFUNCTION bf; bf.BlendOp = AC_SRC_OVER; bf.BlendFlags = 0; bf.SourceConstantAlpha = m_chAlpha[i]; bf.AlphaFormat = 0; XTPDrawHelpers()->m_pfnAlphaBlend(pDC->GetSafeHdc(), x, y, cx, cy, dcChunk, 0, 0, cx, cy, bf); } else { ::BitBlt(pDC->GetSafeHdc(), x, y, cx, cy, dcChunk, 0, 0, SRCCOPY); } if (IsVertical()) { y += cy; } else { x += cx; } } }
BOOL CXTPCoreTreeControl::RegisterWindowClass(HINSTANCE hInstance /*= NULL*/) { return XTPDrawHelpers()->RegisterWndClass(hInstance, _T("XTPCoreTree"), CS_DBLCLKS); }
void CXTPShortcutListBoxTheme::DrawItem(CXTPShortcutListBox* pMenuListBox, LPDRAWITEMSTRUCT lpDIS) { // Define temporary variables. CDC* pDC = CDC::FromHandle (lpDIS->hDC); CRect rcIcon = lpDIS->rcItem; CRect rcText = lpDIS->rcItem; int iItemID = lpDIS->itemID; // if empty, draw focus rect. if (iItemID < 0) { rcIcon.bottom = rcIcon.top + 15; pDC->DrawFocusRect(rcIcon); return; } // Get the menu item. CXTPShortcutListBox::CONTENT_ITEM* pCI = pMenuListBox->GetMenuItem(iItemID); ASSERT(pCI); if (!pCI) return; // set the text foreground and background colors. pDC->SetTextColor(GetTextColor()); // repaint the background. pDC->SetBkMode(TRANSPARENT); long iMargin = (rcIcon.Width()-m_cxIcon)/2; rcIcon.top += m_cyEdge; rcIcon.left += iMargin; rcIcon.right = rcIcon.left + m_cxIcon; rcIcon.bottom = rcIcon.top + m_cyIcon; int iOffset = 0; BOOL bSelected = FALSE; BOOL bPressed = FALSE; if ((lpDIS->itemState & ODS_SELECTED) && pCI->m_bEnabled) { bSelected = TRUE; CRect rcBorder(rcIcon); rcBorder.InflateRect(2, 2); if (::GetKeyState(VK_LBUTTON) < 0) { if (!m_crgItemBackPressed.IsNull()) XTPDrawHelpers()->GradientFill(pDC, rcBorder, m_crgItemBackPressed, FALSE); pDC->Draw3dRect(&rcBorder, m_crgItemBorder.clrLight, m_crgItemBorder.clrDark); iOffset = 1; bPressed = TRUE; } else { if (!m_crgItemBackHot.IsNull()) XTPDrawHelpers()->GradientFill(pDC, rcBorder, m_crgItemBackHot, FALSE); pDC->Draw3dRect(&rcBorder, m_crgItemBorder.clrDark, m_crgItemBorder.clrLight); iOffset = -1; } } LOGFONT lf; pMenuListBox->GetFont()->GetLogFont(&lf); if (bSelected && !pMenuListBox->m_bNoUnderline) lf.lfUnderline = 1; // select the font used by the button text. CFont font; font.CreateFontIndirect(&lf); CXTPFontDC fnt(pDC, &font); // get the text height. int iTextHeight = pMenuListBox->GetTextHeight(pCI->m_strText); // define the text rect. rcText.top = rcText.bottom - (iTextHeight + m_cyEdge); rcText.left += m_cyEdge; rcText.right -= m_cyEdge; if ((pMenuListBox->m_bNoBorder) && (iOffset != 0)) { rcIcon.OffsetRect(iOffset, iOffset); rcText.OffsetRect(iOffset, iOffset); } if (pCI->m_pIcon) { DrawImage(pDC, rcIcon, pCI->m_pIcon, pCI->m_bEnabled, bSelected, bPressed); } DrawText(pDC, rcText, pCI); }
CXTPTrayIcon::CXTPTrayIcon() { SetDefaultValues(); XTPDrawHelpers()->RegisterWndClass(NULL, XTPTRAYICON_CLASSNAME, 0); }
void CXTPSkinObjectHeader::DrawItemEntry(CDC* pDC, int nIndex, CRect rcItem, int nState) { CXTPSkinManagerClass* pClass = GetSkinClass(); CHeaderCtrl* pHeaderCtrl = (CHeaderCtrl*)this; CImageList* pImageList = CImageList::FromHandle((HIMAGELIST) ::SendMessage(pHeaderCtrl->m_hWnd, HDM_GETIMAGELIST, 0, 0L)); // Set up the header item order array. HD_ITEM hdi; ::ZeroMemory(&hdi, sizeof(HD_ITEM)); hdi.fmt = HDF_STRING | HDF_IMAGE; hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_IMAGE | HDI_LPARAM; // Get the header item text and format CString strCaption; LPTSTR pszText = strCaption.GetBuffer(256); pszText[0] = 0; hdi.pszText = pszText; hdi.cchTextMax = 255; BOOL bResult = pHeaderCtrl->GetItem(nIndex, &hdi); strCaption.ReleaseBuffer(); #ifdef _UNICODE if (!bResult) { char tText[256]; tText[0] = 0; HD_ITEMA hdia; ::ZeroMemory(&hdia, sizeof(HD_ITEMA)); hdia.fmt = HDF_STRING | HDF_IMAGE; hdia.mask = HDI_TEXT | HDI_FORMAT | HDI_IMAGE | HDI_LPARAM; // Get the header item text and format hdia.pszText = tText; hdia.cchTextMax = 255; ::SendMessage(pHeaderCtrl->m_hWnd, HDM_GETITEMA, nIndex, (LPARAM)&hdia); strCaption = tText; hdi.fmt = hdia.fmt; hdi.iImage = hdia.iImage; hdi.lParam = hdia.lParam; } #else bResult; #endif if (hdi.fmt & HDF_OWNERDRAW) { DRAWITEMSTRUCT dis; dis.CtlType = ODT_HEADER; dis.CtlID = (UINT)GetDlgCtrlID(); dis.itemID = nIndex; dis.itemAction = ODA_DRAWENTIRE; dis.itemState = (nState == HIS_PRESSED) ? ODS_SELECTED : 0; dis.hwndItem = m_hWnd; dis.hDC = pDC->GetSafeHdc(); dis.rcItem = rcItem; dis.itemData = hdi.lParam; // Now send it off to my parent... if (GetParent()->SendMessage(WM_DRAWITEM, dis.CtlID, (LPARAM)(DRAWITEMSTRUCT*)&dis)) { return; } } CRect rcText(rcItem); if (pImageList && (hdi.fmt & HDF_IMAGE) && hdi.iImage >= 0 && hdi.iImage < pImageList->GetImageCount()) { int iBitmapMargin = (int)SendMessage(HDM_GETBITMAPMARGIN); if (iBitmapMargin == 0) iBitmapMargin = GetMetrics()->m_cxEdge * 3; int cxBitmap = 16, cyBitmap = 16; ImageList_GetIconSize(pImageList->GetSafeHandle(), &cxBitmap, &cyBitmap); CPoint pt(rcItem.left + iBitmapMargin, (rcItem.bottom + rcItem.top - cyBitmap) / 2); if (hdi.fmt & HDF_BITMAP_ON_RIGHT) { CSize sz = pDC->GetTextExtent(strCaption); pt.x += sz.cx + iBitmapMargin + 9; if (pt.x + cxBitmap > rcItem.right - 3) pt.x = max(rcItem.left + 6, rcItem.right - 3 - cxBitmap); if (nState == HIS_PRESSED) pt.x ++; pImageList->Draw(pDC, hdi.iImage, pt, ILD_TRANSPARENT); rcText.right = pt.x + 6; } else { if (nState == HIS_PRESSED) pt.x ++; pImageList->Draw(pDC, hdi.iImage, pt, ILD_TRANSPARENT); rcText.left += cxBitmap + iBitmapMargin; } } if (((hdi.fmt & HDF_IMAGE) == 0) && ((hdi.fmt & HDF_SORTUP) || (hdi.fmt & HDF_SORTDOWN))) { int iBitmapMargin = GetMetrics()->m_cxEdge * 3; CSize sz = pDC->GetTextExtent(strCaption); CPoint pt(rcItem.left + iBitmapMargin, (rcItem.bottom + rcItem.top - 2) / 2); pt.x += sz.cx + iBitmapMargin + 9; if (pt.x + 9 > rcItem.right - 3) pt.x = max(rcItem.left + 6, rcItem.right - 3 - 9); if (hdi.fmt & HDF_SORTUP) { XTPDrawHelpers()->Triangle(pDC, CPoint(pt.x - 4, pt.y + 2), CPoint(pt.x, pt.y - 2), CPoint(pt.x + 4, pt.y + 2), GetColor(COLOR_3DSHADOW)); } else { XTPDrawHelpers()->Triangle(pDC, CPoint(pt.x - 4, pt.y - 2), CPoint(pt.x, pt.y + 2), CPoint(pt.x + 4, pt.y - 2), GetColor(COLOR_3DSHADOW)); } rcText.right = pt.x; } UINT nFormat = DT_SINGLELINE | DT_VCENTER | DT_END_ELLIPSIS | DT_NOPREFIX; // determine justification for text. switch (hdi.fmt & HDF_JUSTIFYMASK) { case HDF_LEFT: nFormat |= DT_LEFT; rcText.DeflateRect(9, 0, 6, 0); break; case HDF_CENTER: nFormat |= DT_CENTER; rcText.DeflateRect(6, 0, 6, 0); break; case HDF_RIGHT: nFormat |= DT_RIGHT; rcText.DeflateRect(6, 0, 9, 0); break; } if (rcText.Width() > 0) { if (nState == HIS_PRESSED) rcText.OffsetRect(1, 1); // draw text. pDC->SetTextColor(GetColor(COLOR_BTNTEXT)); pClass->DrawThemeText(pDC, HP_HEADERITEM, nState, strCaption, nFormat, &rcText); } }