void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) {
PenColour(fore);
BrushColour(back);
- hdc->DrawPolygon(npts, (wxPoint*)pts);
+ wxPoint *p = new wxPoint[npts];
+
+ for (int i=0; i<npts; i++) {
+ p[i].x = pts[i].x;
+ p[i].y = pts[i].y;
+ }
+ hdc->DrawPolygon(npts, p);
+ delete [] p;
}
void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
int x, y;
wxRect r = wxRectFromPRectangle(rc);
wxBitmap bmp(r.width, r.height, 32);
- wxAlphaPixelData pixData(bmp);
- // Set the fill pixels
- ColourDesired cdf(fill.AsLong());
- int red = cdf.GetRed();
- int green = cdf.GetGreen();
- int blue = cdf.GetBlue();
+ // This block is needed to ensure that the changes done to the bitmap via
+ // pixel data object are committed before the bitmap is drawn.
+ {
+ wxAlphaPixelData pixData(bmp);
+
+ // 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;
+ }
+ }
- wxAlphaPixelData::Iterator p(pixData);
- for (y=0; y<r.height; y++) {
- p.MoveTo(pixData, 0, y);
+ // 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.Red() = wxPy_premultiply(red, alphaFill);
- p.Green() = wxPy_premultiply(green, alphaFill);
- p.Blue() = wxPy_premultiply(blue, alphaFill);
- p.Alpha() = alphaFill;
- ++p;
+ 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;
}
- }
-
- // 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;
+ 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
#ifdef __WXMSW__
lv->Show();
#endif
-#ifdef __WXOSX_COCOA__
+#if defined(__WXOSX_COCOA__) || defined(__WXGTK__)
+ // This color will end up being our border
SetBackgroundColour(wxColour(0xC0, 0xC0, 0xC0));
#endif
}
x = y = 0;
w = sz.x;
h = sz.y;
-#ifdef __WXOSX_COCOA__
+#if defined(__WXOSX_COCOA__) || defined(__WXGTK__)
// make room for the parent's bg color to show, to act as a border
x = y = 1;
w -= 2;
void ListBoxImpl::RegisterRGBAImage(int type, int width, int height,
const unsigned char *pixelsImage)
{
+#ifdef wxHAS_RAW_BITMAP
wxBitmap bmp = BitmapFromRGBAImage(width, height, pixelsImage);
RegisterImageHelper(type, bmp);
+#endif
}