wxBitmap use_bitmap = bitmap;
if ((w != ww) || (h != hh))
use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh );
+
+#if !GTK_CHECK_VERSION(2,2,0)
+ // NB: We can't render pixbufs with GTK+ < 2.2, we need to use pixmaps code.
+ // Pixbufs-based bitmaps with alpha channel don't have a mask, so we
+ // have to call GetPixmap() here -- it converts the pixbuf into pixmap
+ // and also creates the mask as a side-effect:
+ use_bitmap.GetPixmap();
+#endif
// apply mask if any
GdkBitmap *mask = (GdkBitmap *) NULL;
// Scale bitmap if required
wxBitmap use_bitmap;
- if ((bm_width != bm_ww) || (bm_height != bm_hh))
+ if ((memDC->m_selected.GetWidth()!= bm_ww) || ( memDC->m_selected.GetHeight()!= bm_hh))
{
// This indicates that the blitting code below will get
// a clipped bitmap and therefore needs to move the origin
}
int w,h;
-
- if (fabs(m_scaleY - 1.0) < 0.00001)
+
+ if (fabs(m_scaleY - 1.0) > 0.00001)
{
// If there is a user or actually any scale applied to
// the device context, scale the font.
wxMemoryDC dc;
dc.SelectObject(src);
dc.SetFont(GetFont());
- dc.SetBackground(*wxWHITE_BRUSH);
+ dc.SetBackground(*wxBLACK_BRUSH);
dc.SetBrush(*wxBLACK_BRUSH);
dc.Clear();
+ dc.SetTextForeground( *wxWHITE );
dc.DrawText(text, 0, 0);
dc.SelectObject(wxNullBitmap);
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.ConvertToImage();
-
- GdkColor *colText = m_textForegroundColour.GetColor(),
- *colBack = m_textBackgroundColour.GetColor();
- bool textColSet = TRUE;
+ wxImage image = src.ConvertToImage();
- unsigned char *data = image.GetData();
+ image.ConvertColourToAlpha( m_textForegroundColour.Red(),
+ m_textForegroundColour.Green(),
+ m_textForegroundColour.Blue() );
+ image = image.Rotate( rad, wxPoint(0,0) );
+
+ int i_angle = (int) angle;
+ i_angle = i_angle % 360;
+ int xoffset = 0;
+ if ((i_angle >= 90.0) && (i_angle < 270.0))
+ xoffset = image.GetWidth();
+ int yoffset = 0;
+ if ((i_angle >= 0.0) && (i_angle < 180.0))
+ yoffset = image.GetHeight();
+
+ if ((i_angle >= 0) && (i_angle < 90))
+ yoffset -= (int)( cos(rad)*h );
+ if ((i_angle >= 90) && (i_angle < 180))
+ xoffset -= (int)( sin(rad)*h );
+ if ((i_angle >= 180) && (i_angle < 270))
+ yoffset -= (int)( cos(rad)*h );
+ if ((i_angle >= 270) && (i_angle < 360))
+ xoffset -= (int)( sin(rad)*h );
+
+ int i_x = x - xoffset;
+ int i_y = y - yoffset;
+
+ src = image;
+ DoDrawBitmap( src, i_x, i_y, true );
- // paint pixel by pixel
- for ( wxCoord srcX = 0; srcX < w; srcX++ )
- {
- for ( wxCoord srcY = 0; srcY < h; srcY++ )
- {
- // transform source coords to dest coords
- double r = sqrt((double)srcX*srcX + srcY*srcY);
- double angleOrig = atan2((double)srcY, (double)srcX) - rad;
- wxCoord dstX = (wxCoord)(r*cos(angleOrig) + 0.5),
- dstY = (wxCoord)(r*sin(angleOrig) + 0.5);
-
- // non-white pixel?
- bool textPixel = data[(srcY*w + srcX)*3] != 0xff;
- if ( textPixel || (m_backgroundMode == wxSOLID) )
- {
- // change colour if needed
- if ( textPixel != textColSet )
- {
- gdk_gc_set_foreground( m_textGC, textPixel ? colText
- : colBack );
-
- textColSet = textPixel;
- }
-
- // don't use DrawPoint() because it uses the current pen
- // colour, and we don't need it here
- gdk_draw_point( m_window, m_textGC,
- XLOG2DEV(x) + dstX, YLOG2DEV(y) + dstY );
- }
- }
- }
// it would be better to draw with non underlined font and draw the line
// manually here (it would be more straight...)
}
#endif // 0
- // restore the font colour
- gdk_gc_set_foreground( m_textGC, colText );
-
// update the bounding box
CalcBoundingBox(x + minX, y + minY);
CalcBoundingBox(x + maxX, y + maxY);