+ int x = LogicalToDeviceX(xLogical);
+ int y = LogicalToDeviceY(yLogical);
+ if (m_window && m_window->GetLayoutDirection() == wxLayout_RightToLeft)
+ x -= LogicalToDeviceXRel(w);
+
+ if (wxIsNullDouble(angle))
+ {
+ CalcBoundingBox(xLogical, yLogical);
+ CalcBoundingBox(xLogical + w, yLogical + h);
+ }
+ else
+ {
+ // To be compatible with MSW, the rotation axis must be in the old
+ // top-left corner.
+ // Calculate the vertices of the rotated rectangle containing the text,
+ // relative to the old top-left vertex.
+ // the rectangle vertices are counted clockwise with the first one
+ // being at (0, 0)
+ double x2 = w * matrix.xx;
+ double y2 = w * matrix.yx;
+ double x4 = h * matrix.xy;
+ double y4 = h * matrix.yy;
+ double x3 = x4 + x2;
+ double y3 = y4 + y2;
+ // Then we calculate max and min of the rotated rectangle.
+ wxCoord maxX = (wxCoord)(dmax(dmax(0, x2), dmax(x3, x4)) + 0.5),
+ maxY = (wxCoord)(dmax(dmax(0, y2), dmax(y3, y4)) + 0.5),
+ minX = (wxCoord)(dmin(dmin(0, x2), dmin(x3, x4)) - 0.5),
+ minY = (wxCoord)(dmin(dmin(0, y2), dmin(y3, y4)) - 0.5);
+ x += minX;
+ y += minY;
+ CalcBoundingBox(DeviceToLogicalX(x), DeviceToLogicalY(y));
+ CalcBoundingBox(DeviceToLogicalX(x + maxX - minX), DeviceToLogicalY(y + maxY - minY));
+ }
+
+ gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x, y, m_layout, NULL, bg_col);