void OnDraw(HDC hdc)
{
	Gdiplus::Graphics graphics(hdc);

	RECT rect;
	GetClientRect(g_hWnd, &rect);

	Gdiplus::Color backgroundColor(OriginalBackgroundColor);
	if (!g_useOriginalColor)
	{
		backgroundColor = OtherBackgroundColor;
	}

	Gdiplus::SolidBrush backgroundBrush(backgroundColor);
	graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

	const TCHAR* message = _T("Click the buttons with your eyes! Look at a button and press the space bar to click. ")
		_T("(Make sure the window has input focus.)");
	Gdiplus::Font font(_T("Arial"), 10);
	Gdiplus::SolidBrush textBrush(Gdiplus::Color::Black);
	Gdiplus::RectF textRect((Gdiplus::REAL)10, 
							(Gdiplus::REAL)(ButtonTop + ButtonHeight + 20), 
							(Gdiplus::REAL)(rect.right - 20), 
							(Gdiplus::REAL)(rect.bottom - rect.top));
	Gdiplus::StringFormat textFormat;
	graphics.DrawString(message, (INT)_tcslen(message), &font, textRect, &textFormat, &textBrush);
}
Exemplo n.º 2
0
void OnDraw(HDC hdc)
{
	Gdiplus::Graphics graphics(hdc);

	RECT rect;
	GetClientRect(g_hWnd, &rect);

	Gdiplus::Color backgroundColor(OriginalBackgroundColor);
	if (!g_useOriginalColor)
	{
		backgroundColor = OtherBackgroundColor;
	}

	Gdiplus::SolidBrush backgroundBrush(backgroundColor);
	graphics.FillRectangle(&backgroundBrush, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

	const TCHAR* message = _T("Click the buttons with your eyes! Look at a button and use the Direct Click key -- ")
		_T("typically the Applications key, the one next to the right Ctrl key, with a picture of a menu on it.");
	Gdiplus::Font font(_T("Arial"), 10);
	Gdiplus::SolidBrush textBrush(Gdiplus::Color::Black);
	Gdiplus::RectF textRect((Gdiplus::REAL)10, 
							(Gdiplus::REAL)(ButtonTop + ButtonHeight + 20), 
							(Gdiplus::REAL)(rect.right - 20), 
							(Gdiplus::REAL)(rect.bottom - rect.top));
	Gdiplus::StringFormat textFormat;
	graphics.DrawString(message, _tcslen(message), &font, textRect, &textFormat, &textBrush);
}
Exemplo n.º 3
0
void CMonitorWidget::DrawInformations(Gdiplus::Graphics & graphics)
{
   CRect rcDuration, rcPages, rcDiskSpace;
   pStaticDuration.GetWindowRect(rcDuration);
   pStaticPages.GetWindowRect(rcPages);
   pStaticDiskSpace.GetWindowRect(rcDiskSpace);
   
   ScreenToClient(rcDuration);
   ScreenToClient(rcPages);
   ScreenToClient(rcDiskSpace);

   Gdiplus::SolidBrush textBrush(Gdiplus::Color(150, 0,0,0));
   Gdiplus::SolidBrush shadowBrush(Gdiplus::Color(150, 255, 255, 255));
   Gdiplus::Font font(_T("Arial"), m_nFontSize, Gdiplus::FontStyleBold, Gdiplus::UnitPixel);

   if(m_bShowDuration)
   {
      Gdiplus::PointF textOrigin(rcDuration.left, rcDuration.top);
      Gdiplus::PointF textOriginShadow(rcDuration.left, rcDuration.top+1);

      graphics.DrawString(m_csDuration, m_csDuration.GetLength(), &font, textOriginShadow, &shadowBrush);
      graphics.DrawString(m_csDuration, m_csDuration.GetLength(), &font, textOrigin, &textBrush);
   }

   if(m_bShowPages)
   {
      Gdiplus::PointF textOrigin(rcPages.left, rcPages.top);
      Gdiplus::PointF textOriginShadow(rcPages.left, rcPages.top+1);

      graphics.DrawString(m_csPages, m_csPages.GetLength(), &font, textOriginShadow, &shadowBrush);
      graphics.DrawString(m_csPages, m_csPages.GetLength(), &font, textOrigin, &textBrush);
   }

   if(m_bShowDiskSpace)
   {
      Gdiplus::PointF textOrigin(rcDiskSpace.left, rcDiskSpace.top);
      Gdiplus::PointF textOriginShadow(rcDiskSpace.left, rcDiskSpace.top+1);

      graphics.DrawString(m_csDiskSpace, m_csDiskSpace.GetLength(), &font, textOriginShadow, &shadowBrush);
      graphics.DrawString(m_csDiskSpace, m_csDiskSpace.GetLength(), &font, textOrigin, &textBrush);
   }
}
Exemplo n.º 4
0
void CScreenShotView::updatePreviewItem(const QPoint &pos)
{
    C_SCREENSHOT_LOG_FUNCTION;
    QPixmap pixmap(m_previewItemWidth,m_previewItemPixmapHeight+m_previewItemTextHeight);
    pixmap.fill(QColor(Qt::white));
    QPainter painter(&pixmap);
    painter.setRenderHints(QPainter::TextAntialiasing
                           | QPainter::SmoothPixmapTransform
                           | QPainter::HighQualityAntialiasing
                           | QPainter::NonCosmeticDefaultPen
                           | QPainter::Qt4CompatiblePainting);
    QPointF toItemPos = getPointToSelectedItem(pos);

    qreal scaleSize = 3;
    {//draw preview
        qreal width = m_previewItemWidth / scaleSize;
        qreal height = m_previewItemPixmapHeight / scaleSize;
        qreal x = (toItemPos.x() - 0.5 * width);
        QPointF pos(0,0);
        if(x < 0)
        {
            width = width + x;
            pos.setX(-x * scaleSize);
            x = 0;
        }
        else
        {
            width = qMin(width,m_desktopPixmap.width() - x);
        }
        qreal y = (toItemPos.y() - 0.5 * height);
        if(y < 0)
        {
            height += y;
            pos.setY(-y * scaleSize);
            y = 0;
        }
        else
        {
            height = qMin(height,m_desktopPixmap.height() - y);
        }
        QPixmap pixmap = m_desktopPixmap.copy(x,y,width,height).scaled(width * scaleSize,height * scaleSize);
        painter.drawImage(pos,pixmap.toImage());
        QColor lineColor("#89D4EB");
        lineColor.setAlpha(128);
        QPen pen(lineColor);
        pen.setWidth(m_previewLineWidth);
        painter.setPen(pen);
        QLineF hLine(0,0.5 * m_previewItemPixmapHeight,m_previewItemWidth,0.5 * m_previewItemPixmapHeight);
        painter.drawLine(hLine);
        QLineF vLine(0.5 * m_previewItemWidth,0,0.5 * m_previewItemWidth,m_previewItemPixmapHeight);
        painter.drawLine(vLine);
    }
    QRectF textRect(0,m_previewItemPixmapHeight,m_previewItemWidth,m_previewItemTextHeight);
    {//draw text background
        QBrush textBrush(QColor("#4F4F4F"));
        QPen pen(Qt::NoPen);
        painter.setPen(pen);
        painter.setBrush(textBrush);
        painter.drawRect(textRect);
    }
    {//draw text
        QRgb pointRgb = getPixmapPosRgb(m_desktopPixmap,toItemPos.toPoint());
        QFont font;
        font.setPixelSize(m_previewPointSize);
        painter.setFont(font);
        QColor textColor("#B8B8B8");
        QPen pen(textColor);
        painter.setPen(pen);
        QString text = QString("(%1,%2)\nRGB:(%3,%4,%5)")
                .arg(pos.x())
                .arg(pos.y())
                .arg(qRed(pointRgb))
                .arg(qGreen(pointRgb))
                .arg(qBlue(pointRgb));
        painter.drawText(textRect,Qt::AlignCenter,text);
    }
    m_previewItem->setPixmap(pixmap);
    qreal x = pos.x() - m_previewItemDx - pixmap.width();
    if(x < 0)
    {
        x = pos.x() + m_previewItemDy;
    }
    qreal y = pos.y() + m_previewItemDy;
    if(y + pixmap.height() > this->height())
    {
        y = pos.y() - m_previewItemDy - pixmap.height();
    }
    m_previewItem->setPos(x,y);
    if(!m_previewItem->isVisible())
    {
        emit sigPreviewItemShow();
        m_previewItem->setVisible(true && !m_onlySelect);
    }
}
Exemplo n.º 5
0
BOOL GDIPluseExt::DrawBoardsText(Graphics&  gp,PointF startpf,CString strText,CString strFont,INT nfontsize,Color textcolor,Color boardscolor)
{

	gp.SetSmoothingMode(SmoothingModeAntiAlias);
	gp.SetInterpolationMode(InterpolationModeHighQualityBicubic);

#ifdef _UNICODE

	StringFormat strformat;
	FontFamily  fontFamily(strFont);
	GraphicsPath path;
	path.AddString(strText,strText.GetLength(), &fontFamily, 
		FontStyleRegular, 
		(REAL)nfontsize,
		startpf, 
		&strformat );
	for(int i=1; i < 4; ++i)
	{
		Pen pen(boardscolor, (REAL)i);
		pen.SetLineJoin(LineJoinRound);
		gp.DrawPath(&pen, &path);
	}
	SolidBrush  textBrush(textcolor); 
	gp.FillPath(&textBrush, &path);
#else

	//字符转换
	int font_len = strFont.GetLength();
	WCHAR* pfont_w = new WCHAR[font_len];
	MultiByteToWideChar(CP_ACP,0,strFont.GetBuffer(),-1,pfont_w,font_len);
	strFont.ReleaseBuffer();
	//字符转换
	int text_len = strText.GetLength();
	WCHAR* ptext_w = new WCHAR[text_len];
	MultiByteToWideChar(CP_ACP,0,strText.GetBuffer(),-1,ptext_w,text_len);
	strText.ReleaseBuffer();


	FontFamily  fontFamily(pfont_w);

	Font font(&fontFamily, (REAL)nfontsize, FontStyleRegular, UnitPixel);

	GraphicsPath path;
	StringFormat strformat;

	path.AddString(ptext_w,wcsnlen_s(ptext_w,text_len), &fontFamily, 
		font.GetStyle(),
		font.GetSize(),
		startpf, 
		&strformat );

	for(int i=1; i < 4; ++i)
	{
		Pen pen(boardscolor,(REAL)i);
		pen.SetLineJoin(LineJoinRound);
		gp.DrawPath(&pen, &path);
	}

	SolidBrush  textBrush(textcolor); 
	gp.FillPath(&textBrush, &path);
	
	DEL_P(ptext_w);
	DEL_P(pfont_w);
#endif
	return TRUE;
}