void CVideoPane::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CDialog::OnPaint() for painting messages // 绘制标题栏 if (NULL != m_pImgCaption) { // 设置坐标 CRect rect; GetClientRect(rect); Gdiplus::Rect gRect(rect.left, rect.top, rect.right, CAPTION_HEIGHT); Gdiplus::ImageAttributes ImgAtt; ImgAtt.SetWrapMode(Gdiplus::WrapModeTileFlipXY); Gdiplus::Graphics graphics(dc); graphics.DrawImage(m_pImgCaption, gRect, 0, 0, (INT)m_pImgCaption->GetWidth(), (INT)m_pImgCaption->GetHeight(), Gdiplus::UnitPixel, &ImgAtt); } // 标题栏文本 CRect rect; GetClientRect(rect); rect.left += BTN_CLOSE_SPACE; rect.bottom = CAPTION_HEIGHT; dc.SetBkMode(CAPTION_FONT_BKCLR); dc.SetTextColor(CAPTION_FONT_COLOR); CFont font; font.CreateFont(CAPTION_FONT_SIZE, 0, 0, 0, FW_NORMAL, FALSE,FALSE,FALSE,0,0,0,0,0,CAPTION_FONT_NAME); dc.SelectObject(font); dc.DrawText(m_strCaptionText, -1, &rect, DT_SINGLELINE | DT_VCENTER); }
void CVideoStatic::SetBackGroudImage(const CPaintDC& dc) { // ¼ÓÔر³¾°logoͼƬ if (NULL == m_pImage) { m_pImage = Gdiplus::Image::FromFile(m_strLogoPath); if (NULL == m_pImage) { LOG_RUN_ERROR("m_pImage is null."); return; } else { if (Gdiplus::Ok != m_pImage->GetLastStatus()) { std::string strPath = eLTE_Tool::UnicodeToANSI(m_strLogoPath.GetString()).c_str(); LOG_RUN_ERROR("Gdiplus::Image::FromFile failed. (%s)", strPath.c_str()); m_pImage = NULL; return; } } } // ¾ÓÖÐλÖüÆËã CRect rect; GetClientRect(&rect); int iWidth = (int)m_pImage->GetWidth(); int iHeight = (int)m_pImage->GetHeight(); if ((double)rect.right/rect.bottom > (double)iWidth/iHeight) { iHeight = rect.bottom / 3; iWidth = iHeight * (int)m_pImage->GetWidth() / (int)m_pImage->GetHeight(); } else { iWidth = rect.right / 3; iHeight = iWidth * (int)m_pImage->GetHeight() / (int)m_pImage->GetWidth(); } int iLeft = (rect.right - iWidth) / 2; int iTop = (rect.bottom - iHeight) / 2; // »æÖÆͼƬ Gdiplus::Graphics graphics(dc); Gdiplus::Rect gRect(iLeft, iTop, iWidth, iHeight); Gdiplus::ImageAttributes ImgAtt; ImgAtt.SetWrapMode(Gdiplus::WrapModeTileFlipXY); graphics.DrawImage(m_pImage, gRect, 0, 0, (INT)m_pImage->GetWidth(), (INT)m_pImage->GetHeight(), Gdiplus::UnitPixel, &ImgAtt); }
void FreeSpaceWidget::paintEvent(QPaintEvent*) { QPainter p(this); p.setPen(palette().mid().color()); p.drawRect(0, 0, width() - 1, height() - 1); p.drawPixmap(2, height() / 2 - d->iconPix.height() / 2, d->iconPix, 0, 0, d->iconPix.width(), d->iconPix.height()); if (isValid()) { // We will compute the estimated % of space size used to download and process. unsigned long eUsedKb = d->dSizeKb + d->kBUsed; int peUsed = (int)(100.0 * ((double)eUsedKb / (double)d->kBSize)); int pClamp = (peUsed > 100) ? 100 : peUsed; QColor barcol = QColor(62, 255, 62); // Smooth Green. if (peUsed > 80) { barcol = QColor(240, 255, 62); // Smooth Yellow. } if (peUsed > 95) { barcol = QColor(255, 62, 62); // Smooth Red. } p.setBrush(barcol); p.setPen(palette().light().color()); QRect gRect(d->iconPix.height() + 3, 2, (int)(((double)width() - 3.0 - d->iconPix.width() - 2.0) * (pClamp / 100.0)), height() - 5); p.drawRect(gRect); QRect tRect(d->iconPix.height() + 3, 2, width() - 3 - d->iconPix.width() - 2, height() - 5); QString text = QString::fromUtf8("%1%").arg(peUsed); QFontMetrics fontMt = p.fontMetrics(); // QRect fontRect = fontMt.boundingRect(tRect.x(), tRect.y(), // tRect.width(), tRect.height(), 0, text); p.setPen(Qt::black); p.drawText(tRect, Qt::AlignCenter, text); } }
static int drawGraphic2(PARAM *p, int id, DATA *d) { int x,y,w,h,fontsize; x = 80; y = 50; w = 350; h = 180; fontsize = 10; gBeginDraw (p,id); //gSetFloatFormat(p,"%5.2f"); gComment (p,"This is a comment in the metafile"); gSetColor (p,BLACK); gSetFont (p,TIMES,fontsize,Normal,0); gBoxWithText (p,x,y,w,h,fontsize,"phi/rad","sin(phi)",NULL); gXAxis (p,0,1.0f,2.0f*PI,1); gYAxis (p,-1.5f,0.5f,1.5f,1); //gSetStyle (p,1); gSetStyle (p,DotLine); gXGrid (p); gYGrid (p); //gSetStyle (p,0); gSetColor (p,RED); gSetStyle (p,DashDotLine); /* gSetLinestyle (p,LINESTYLE_RECT); */ gLine (p,d->x,d->y,d->n); gSetColor (p,BLUE); gText (p,x+w/2,y-fontsize*2,"Date: 19-NOV-2000",ALIGN_CENTER); fontsize = 24; gSetFont (p,TIMES,fontsize,Bold,1); gText (p,x+w/2,y-fontsize*2,"This is a Diagram",ALIGN_CENTER); gDrawPie (p,10,10,30,30,0,130); gRect (p,10,50,30,30); gEndDraw (p); return 0; }