void CDisplayWindow::DrawGradientFill(HDC hdc,RECT *rc) { if(m_hBitmapBackground) { DeleteObject(m_hBitmapBackground); } /* Create the (temporary) off-screen buffer used for drawing. */ m_hBitmapBackground = CreateCompatibleBitmap(hdc,rc->right - rc->left,rc->bottom - rc->top); SelectObject(m_hdcBackground,m_hBitmapBackground); Gdiplus::Graphics graphics(m_hdcBackground); Gdiplus::Rect DisplayRect(0,0,rc->right - rc->left,rc->bottom - rc->top); Gdiplus::GraphicsPath Path; Path.AddRectangle(DisplayRect); Gdiplus::PathGradientBrush pgb(&Path); pgb.SetCenterPoint(Gdiplus::Point(0,0)); pgb.SetCenterColor(m_CentreColor); INT count = 1; pgb.SetSurroundColors(&m_SurroundColor,&count); graphics.FillRectangle(&pgb,DisplayRect); /* This draws a separator line across the top edge of the window, so that it is visually separated from other windows. */ Gdiplus::Pen NewPen(BORDER_COLOUR,1); graphics.DrawLine(&NewPen,0,0,rc->right,0); }
void CSkinUnitODL::DrawImage(Gdiplus::Graphics& gcDrawer, Gdiplus::RectF rtDrawArea, Gdiplus::REAL fScale) { if (m_imgSkin) { Gdiplus::GraphicsPath gcPath; gcPath.AddRectangle(rtDrawArea); DrawImage(gcDrawer, gcPath, Gdiplus::PointF(rtDrawArea.X,rtDrawArea.Y), fScale); } }
void SelectionHandler::Draw(CDC& offscreenDC) { if (m_selectionState == selstateNoSelection) return; COORD coordStart; COORD coordEnd; SHORT maxX = (m_consoleParams->dwBufferColumns > 0) ? static_cast<SHORT>(m_consoleParams->dwBufferColumns - 1) : static_cast<SHORT>(m_consoleParams->dwColumns - 1); GetSelectionCoordinates(coordStart, coordEnd); SMALL_RECT& srWindow = m_consoleInfo->csbi.srWindow; if( coordEnd.Y < srWindow.Top || coordStart.Y > srWindow.Bottom ) return; INT nXStart = (static_cast<INT>(coordStart.X) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder; INT nYStart = (static_cast<INT>(coordStart.Y) - static_cast<INT>(srWindow.Top) ) * m_nCharHeight + m_nHInsideBorder; INT nXEnd = (static_cast<INT>( coordEnd.X) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder; INT nYEnd = (static_cast<INT>( coordEnd.Y) - static_cast<INT>(srWindow.Top) ) * m_nCharHeight + m_nHInsideBorder; INT nXmin = (static_cast<INT>(0) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder; INT nXmax = (static_cast<INT>(maxX) - static_cast<INT>(srWindow.Left)) * m_nCharWidth + m_nVInsideBorder; Gdiplus::Graphics gr(offscreenDC); Gdiplus::Color selectionColor; selectionColor.SetFromCOLORREF(g_settingsHandler->GetAppearanceSettings().stylesSettings.crSelectionColor); Gdiplus::Pen pen (selectionColor); Gdiplus::SolidBrush brush(Gdiplus::Color(64, selectionColor.GetR(), selectionColor.GetG(), selectionColor.GetB())); Gdiplus::GraphicsPath gp; if( nYStart == nYEnd ) { Gdiplus::Rect rect( nXStart, nYStart, (nXEnd - nXStart) + m_nCharWidth, m_nCharHeight); gp.AddRectangle(rect); } else { /* 2_________3 0______| | | 1 5___| |____________| 4 7 6 */ Gdiplus::Point points[8]; points[0].X = nXmin; points[0].Y = nYStart + m_nCharHeight; points[1].X = nXStart; points[1].Y = points[0].Y; points[2].X = points[1].X; points[2].Y = nYStart; points[3].X = nXmax + m_nCharWidth; points[3].Y = points[2].Y; points[4].X = points[3].X; points[4].Y = nYEnd; points[5].X = nXEnd + m_nCharWidth; points[5].Y = points[4].Y; points[6].X = points[5].X; points[6].Y = nYEnd + m_nCharHeight; points[7].X = points[0].X; points[7].Y = points[6].Y; gp.AddPolygon(points, 8); } gr.FillPath(&brush, &gp); gr.DrawPath(&pen, &gp); }
void GraphicsPath::AddRectangle(const RectF& rc) { Gdiplus::GraphicsPath* gp = reinterpret_cast<Gdiplus::GraphicsPath*>(_private); gp->AddRectangle(ToGDIRect<RectF, Gdiplus::RectF>(rc)); }