- int w, h;
- pango_layout_get_pixel_size(m_layout, &w, &h);
-
- const GdkColor* bg_col = NULL;
- if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
- bg_col = m_textBackgroundColour.GetColor();
-
- // rotate the text
- PangoMatrix matrix = PANGO_MATRIX_INIT;
- pango_matrix_rotate (&matrix, angle);
- pango_context_set_matrix (m_context, &matrix);
- pango_layout_context_changed (m_layout);
-
- // 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.
- // We could use the matrix for this, but it's simpler with trignonometry.
- double rad = DegToRad(angle);
- // the rectangle vertices are counted clockwise with the first one
- // being at (0, 0)
- double x2 = w * cos(rad);
- double y2 = -w * sin(rad); // y axis points to the bottom, hence minus
- double x4 = h * sin(rad);
- double y4 = h * cos(rad);
- 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);
-
- gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x+minX, y+minY,
- m_layout, NULL, bg_col);
-
- if (setAttrs)
- pango_layout_set_attributes(m_layout, NULL);
-
- // clean up the transformation matrix
- pango_context_set_matrix(m_context, NULL);