int TooltipCustDraw(LPNMTTCUSTOMDRAW lpttcd) { if (lpttcd->nmcd.dwDrawStage == CDDS_PREPAINT) { if (gfstate & GFS_UIGRADIENT) { DrawGradientFill(lpttcd->nmcd.hdc, &lpttcd->nmcd.rc, gradclr1, gradclr2); } else { SetBkColor(lpttcd->nmcd.hdc, 0); FillRect(lpttcd->nmcd.hdc, &lpttcd->nmcd.rc, hBrushclr); } //ImageList_DrawEx(lvwIML, 16, lpttcd->nmcd.hdc, lpttcd->nmcd.rc.left + 6, lpttcd->nmcd.rc.top + 6, // 36, 18, CLR_DEFAULT, CLR_DEFAULT, ILD_NORMAL); DrawIconEx(lpttcd->nmcd.hdc, lpttcd->nmcd.rc.left + 6, lpttcd->nmcd.rc.top + 6, hTooltipTmp, 36, 18, 0, NULL, DI_NORMAL); SetBkMode(lpttcd->nmcd.hdc, TRANSPARENT); HGDIOBJ hOld = SelectObject(lpttcd->nmcd.hdc, hFontBold); ExtTextOut(lpttcd->nmcd.hdc, lpttcd->nmcd.rc.left + 50, lpttcd->nmcd.rc.top + 6, ETO_CLIPPED, &lpttcd->nmcd.rc, pszTooltipTitle, strlen(pszTooltipTitle), NULL); SelectObject(lpttcd->nmcd.hdc, hFont); lpttcd->nmcd.rc.left += 6; lpttcd->nmcd.rc.top += 26; DrawText(lpttcd->nmcd.hdc, pszTooltipText, strlen(pszTooltipText), &lpttcd->nmcd.rc, 0); SelectObject(lpttcd->nmcd.hdc, hOld); return CDRF_SKIPDEFAULT; } return CDRF_DODEFAULT; }
void CDisplayWindow::OnSize(int width, int height) { HDC hdc; RECT rc; hdc = GetDC(m_hDisplayWindow); SetRect(&rc,0,0,width,height); DrawGradientFill(hdc,&rc); ReleaseDC(m_hDisplayWindow,hdc); RedrawWindow(m_hDisplayWindow,NULL,NULL,RDW_INVALIDATE); }
//------------------------------------------------------------------------------------------- //! //------------------------------------------------------------------------------------------- void tContextPanelCommon::paint( QPainter* pPainter, const QStyleOptionGraphicsItem* pOption, QWidget* pWidget ) { Q_UNUSED( pOption ); Q_UNUSED( pWidget ); Q_UNUSED( pOption ); Q_UNUSED( pWidget ); if ( m_PanelType == ePanel_Standard ) { pPainter->setPen( QPen( MercuryPalette::GetColor( MercuryPalette::eColorRole_TankPinline ), 2 ) ); pPainter->drawRoundedRect(boundingRect().adjusted(1.5,1.5,-1.5,-1.5), 10, 10); } pPainter->setRenderHint( QPainter::Antialiasing ); DrawGradientFill( pPainter ); }
void CxStatic::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { ASSERT(lpDrawItemStruct != NULL); CBitmap bmp; CBitmap* pOldBitmap = NULL; CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rect = lpDrawItemStruct->rcItem; //Double Buffering - Modify MemDC for transparent background but doesn't work // because I have to invalidate parent when SetWindowText - Need to find a fix!!! pDC->SetBkColor(m_rgbBkgnd); CMemDC MemDC(pDC, &rect, m_bTransparentBk); // PAINT SOLID BACKGROUND IF NO BITMAP if ( !m_bBitmap){ if ( !m_bTransparentBk ){ if (m_fillmode == Normal) MemDC.FillRect(&rect, m_pBrush); else DrawGradientFill(&MemDC, &rect, m_fillmode); } } else{// DISPLAY BACKGROUND BITMAP DrawBitmap(&MemDC, &rect); } // TEXT RENDERING CFont* pOldFont = MemDC.SelectObject( &m_font ); COLORREF rgbText = MemDC.SetTextColor(m_rgbText); DrawText(&MemDC, &rect, m_strText); // Restore DC's State MemDC.SelectObject(pOldFont); MemDC.SetTextColor(rgbText); }
void CLabel::OnPaint() { CPaintDC dc(this); // device context for painting DWORD dwFlags = 0; CRect rc; GetClientRect(rc); CString strText; GetWindowText(strText); CBitmap bmp; /////////////////////////////////////////////////////// // // Set up for double buffering... // CDC* pDCMem; CBitmap* pOldBitmap = NULL; if (!m_bTransparent) { pDCMem = new CDC; pDCMem->CreateCompatibleDC(&dc); bmp.CreateCompatibleBitmap(&dc,rc.Width(),rc.Height()); pOldBitmap = pDCMem->SelectObject(&bmp); } else { pDCMem = &dc; } UINT nMode = pDCMem->SetBkMode(TRANSPARENT); COLORREF crText = pDCMem->SetTextColor(m_crText); CFont *pOldFont = pDCMem->SelectObject(&m_font); // Fill in backgound if not transparent if (!m_bTransparent) { if (m_fillmode == Normal) { CBrush br; if (m_hBackBrush != NULL) br.Attach(m_hBackBrush); else br.Attach(m_hwndBrush); pDCMem->FillRect(rc,&br); br.Detach(); } else // Gradient Fill { DrawGradientFill(pDCMem, &rc, m_crLoColor, m_crHiColor, 100); } } // If the text is flashing turn the text color on // then to the color of the window background. LOGBRUSH lb; ZeroMemory(&lb,sizeof(lb)); // Stop Checking complaining if (m_hBackBrush) ::GetObject(m_hBackBrush,sizeof(lb),&lb); // Something to do with flashing if (!m_bState && m_Type == Text) pDCMem->SetTextColor(lb.lbColor); DWORD style = GetStyle(); switch (style & SS_TYPEMASK) { case SS_RIGHT: dwFlags = DT_RIGHT | DT_WORDBREAK; break; case SS_CENTER: dwFlags = SS_CENTER | DT_WORDBREAK; break; case SS_LEFTNOWORDWRAP: dwFlags = DT_LEFT; break; default: // treat other types as left case SS_LEFT: dwFlags = DT_LEFT | DT_WORDBREAK; break; } // Added to expand tabs... if(strText.Find(_T('\t')) != -1) dwFlags |= DT_EXPANDTABS; // If the text centered make an assumtion that // the will want to center verticly as well if (style & SS_CENTERIMAGE) { dwFlags = DT_CENTER; // Apply if (strText.Find(_T("\r\n")) == -1) { dwFlags |= DT_VCENTER; // And because DT_VCENTER only works with single lines dwFlags |= DT_SINGLELINE; } } // // 3333 DDDDD // 3 D D // 33 D D E F X // 3 D D // 3333 DDDDD // // if (m_bRotation) { int nAlign = pDCMem->SetTextAlign (TA_BASELINE); CPoint pt; GetViewportOrgEx (pDCMem->m_hDC,&pt) ; SetViewportOrgEx (pDCMem->m_hDC,rc.Width() / 2, rc.Height() / 2, NULL) ; pDCMem->TextOut (0, 0, strText) ; SetViewportOrgEx (pDCMem->m_hDC,pt.x / 2, pt.y / 2, NULL) ; pDCMem->SetTextAlign (nAlign); } else { pDCMem->DrawText(strText,rc,dwFlags); if (m_bFont3d) { pDCMem->SetTextColor(m_cr3DHiliteColor); if (m_3dType == Raised) rc.OffsetRect(-1,-1); else rc.OffsetRect(1,1); pDCMem->DrawText(strText,rc,dwFlags); m_3dType; } } // Restore DC's State pDCMem->SetBkMode(nMode); pDCMem->SelectObject(pOldFont); pDCMem->SetTextColor(crText); if (!m_bTransparent) { dc.BitBlt(0,0,rc.Width(),rc.Height(),pDCMem,0,0,SRCCOPY); // continue DC restore pDCMem->SelectObject ( pOldBitmap ) ; delete pDCMem; } }