- double dx = cos(angle / 180.0 * M_PI);
- double dy = sin(angle / 180.0 * M_PI);
- double x4 = -cy * dy;
- double y4 = cy * dx;
- double x3 = cx * dx;
- double y3 = cx * dy;
- double x2 = x3 + x4;
- double y2 = y3 + y4;
- double x1 = x;
- double y1 = y;
-
- // Create image from the source bitmap after writing the text into it.
- wxImage image(src);
-
- int minx = roundmin(0, roundmin(x4, roundmin(x2, x3)));
- int miny = roundmin(0, roundmin(y4, roundmin(y2, y3)));
- int maxx = roundmax(0, roundmax(x4, roundmax(x2, x3)));
- int maxy = roundmax(0, roundmax(y4, roundmax(y2, y3)));
-
- // This rotates counterclockwise around the top left corner.
- for (int rx = minx; rx < maxx; rx++)
+ double rad = DegToRad(angle);
+ double dx = cos(rad),
+ dy = sin(rad);
+
+ // the rectngle vertices are counted clockwise with the first one being at
+ // (0, 0) (or, rather, at (x, y))
+ double x2 = w*dx,
+ y2 = -w*dy; // y axis points to the bottom, hence minus
+ double x4 = h*dy,
+ y4 = h*dx;
+ double x3 = x4 + x2,
+ y3 = y4 + y2;
+
+ // calc max and min
+ wxCoord maxX = (wxCoord)(dmax(x2, dmax(x3, x4)) + 0.5),
+ maxY = (wxCoord)(dmax(y2, dmax(y3, y4)) + 0.5),
+ minX = (wxCoord)(dmin(x2, dmin(x3, x4)) - 0.5),
+ minY = (wxCoord)(dmin(y2, dmin(y3, y4)) - 0.5);
+
+ // prepare to blit-with-rotate the bitmap to the DC
+ wxImage image(src);
+
+ GdkColor *colText = m_textForegroundColour.GetColor(),
+ *colBack = m_textBackgroundColour.GetColor();
+
+ bool textColSet = TRUE;
+
+ unsigned char *data = image.GetData();
+
+ // paint pixel by pixel
+ for ( wxCoord srcX = 0; srcX < w; srcX++ )