void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { #ifdef wxHAS_RAW_BITMAP wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp = BitmapFromRGBAImage(width, height, pixelsImage); hdc->DrawBitmap(bmp, r.x, r.y, true); #endif }
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { wxBrush br; if (((SurfaceImpl&)surfacePattern).bitmap) br = wxBrush(*((SurfaceImpl&)surfacePattern).bitmap); else // Something is wrong so display in red br = wxBrush(*wxRED, wxSOLID); hdc->SetPen(*wxTRANSPARENT_PEN); hdc->SetBrush(br); hdc->DrawRectangle(wxRectFromPRectangle(rc)); }
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back) { SetFont(font); hdc->SetTextForeground(wxColourFromCA(fore)); hdc->SetTextBackground(wxColourFromCA(back)); FillRectangle(rc, back); hdc->SetClippingRegion(wxRectFromPRectangle(rc)); // see comments above hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent); hdc->DestroyClippingRegion(); }
void Window::InvalidateRectangle(PRectangle rc) { wxRect r = wxRectFromPRectangle(rc); GETWIN(id)->Refresh(false, &r); }
void Window::SetPosition(PRectangle rc) { wxRect r = wxRectFromPRectangle(rc); GETWIN(id)->SetSize(r); }
void SurfaceImpl::SetClip(PRectangle rc) { hdc->SetClippingRegion(wxRectFromPRectangle(rc)); }
void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { wxRect r = wxRectFromPRectangle(rc); hdc->Blit(r.x, r.y, r.width, r.height, ((SurfaceImpl&)surfaceSource).hdc, from.x, from.y, wxCOPY); }
void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { PenColour(fore); BrushColour(back); hdc->DrawEllipse(wxRectFromPRectangle(rc)); }
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int /*flags*/) { #if wxUSE_GRAPHICS_CONTEXT wxGCDC dc(*(wxMemoryDC*)hdc); wxColour penColour(wxColourFromCAandAlpha(outline, alphaOutline)); wxColour brushColour(wxColourFromCAandAlpha(fill, alphaFill)); dc.SetPen(wxPen(penColour)); dc.SetBrush(wxBrush(brushColour)); dc.DrawRoundedRectangle(wxRectFromPRectangle(rc), cornerSize); return; #else #ifdef wxHAVE_RAW_BITMAP // TODO: do something with cornerSize wxUnusedVar(cornerSize); int x, y; wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp(r.width, r.height, 32); wxAlphaPixelData pixData(bmp); pixData.UseAlpha(); // Set the fill pixels ColourDesired cdf(fill.AsLong()); int red = cdf.GetRed(); int green = cdf.GetGreen(); int blue = cdf.GetBlue(); wxAlphaPixelData::Iterator p(pixData); for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); for (x=0; x<r.width; x++) { p.Red() = wxPy_premultiply(red, alphaFill); p.Green() = wxPy_premultiply(green, alphaFill); p.Blue() = wxPy_premultiply(blue, alphaFill); p.Alpha() = alphaFill; ++p; } } // Set the outline pixels ColourDesired cdo(outline.AsLong()); red = cdo.GetRed(); green = cdo.GetGreen(); blue = cdo.GetBlue(); for (x=0; x<r.width; x++) { p.MoveTo(pixData, x, 0); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; p.MoveTo(pixData, x, r.height-1); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; } for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; p.MoveTo(pixData, r.width-1, y); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; } // Draw the bitmap hdc->DrawBitmap(bmp, r.x, r.y, true); #else wxUnusedVar(cornerSize); wxUnusedVar(alphaFill); wxUnusedVar(alphaOutline); RectangleDraw(rc, outline, fill); #endif #endif }
void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) { PenColour(fore); BrushColour(back); hdc->DrawRoundedRectangle(wxRectFromPRectangle(rc), 4); }
void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) { BrushColour(back); hdc->SetPen(*wxTRANSPARENT_PEN); hdc->DrawRectangle(wxRectFromPRectangle(rc)); }
void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(fore); BrushColour(back); hdc->DrawRectangle(wxRectFromPRectangle(rc)); }
void SurfaceImpl::AlphaRectangle (PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int WXUNUSED(flags)) { #ifdef wxHAVE_RAW_BITMAP wxUnusedVar(cornerSize); int x, y; wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp(r.width, r.height, 32); wxAlphaPixelData pixData(bmp); pixData.UseAlpha(); wxAlphaPixelData::Iterator p(pixData); // Set the fill pixels ColourDesired cdf(fill.AsLong()); int red = cdf.GetRed(); int green = cdf.GetGreen(); int blue = cdf.GetBlue(); #ifdef __WXMSW__ int aFill = alphaFill; #else int aFill = 0xff; #endif for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); for (x=0; x<r.width; x++) { p.Red() = red * aFill / 0xff; p.Green() = green * aFill / 0xff; p.Blue() = blue * aFill / 0xff; p.Alpha() = alphaFill; ++p; } } // Set the outline pixels ColourDesired cdo(outline.AsLong()); red = cdo.GetRed(); green = cdo.GetGreen(); blue = cdo.GetBlue(); #ifdef __WXMSW__ int aOutline = alphaOutline; #else int aOutline = 0xff; #endif for (x=0; x<r.width; x++) { p.MoveTo(pixData, x, 0); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; p.MoveTo(pixData, x, r.height-1); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; } for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; p.MoveTo(pixData, r.width-1, y); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; } // Draw the bitmap hdc->DrawBitmap(bmp, r.x, r.y, true); #else wxUnusedVar(cornerSize); wxUnusedVar(alphaFill); wxUnusedVar(alphaOutline); RectangleDraw(rc, outline, fill); #endif }