}
else
{
- gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
+#if GTK_CHECK_VERSION(2,2,0)
+ if (use_bitmap.HasPixbuf())
+ {
+ gdk_draw_pixbuf(m_window, m_penGC,
+ use_bitmap.GetPixbuf(),
+ 0, 0, xx, yy, -1, -1,
+ GDK_RGB_DITHER_NORMAL, xx, yy);
+ }
+ else
+#endif
+ {
+ gdk_draw_pixmap(m_window, m_penGC,
+ use_bitmap.GetPixmap(),
+ 0, 0, xx, yy, -1, -1);
+ }
}
// remove mask again if any
// 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.
CalcBoundingBox (x, y);
}
+
+// TODO: There is an example of rotating text with GTK2 that would probably be
+// a better approach here:
+// http://www.daa.com.au/pipermail/pygtk/2003-April/005052.html
+
void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle )
{
if (angle == 0.0)
if (!m_window) return;
-#ifdef __WXGTK20__
+ wxCoord w;
+ wxCoord h;
+
+#ifdef __WXGTK20__
// implement later without GdkFont for GTK 2.0
- return;
+ GetTextExtent(text, &w, &h, NULL,NULL, &m_font);
+
#else
GdkFont *font = m_font.GetInternalFont( m_scaleY );
wxCHECK_RET( font, wxT("invalid font") );
// the size of the text
- wxCoord w = gdk_string_width( font, text.mbc_str() );
- wxCoord h = font->ascent + font->descent;
-
+ w = gdk_string_width( font, text.mbc_str() );
+ h = font->ascent + font->descent;
+#endif
// draw the string normally
wxBitmap src(w, h);
wxMemoryDC dc;
wxCoord dstX = (wxCoord)(r*cos(angleOrig) + 0.5),
dstY = (wxCoord)(r*sin(angleOrig) + 0.5);
- // black pixel?
- bool textPixel = data[(srcY*w + srcX)*3] == 0;
+ // non-white pixel?
+ bool textPixel = data[(srcY*w + srcX)*3] != 0xff;
if ( textPixel || (m_backgroundMode == wxSOLID) )
{
// change colour if needed
// update the bounding box
CalcBoundingBox(x + minX, y + minY);
CalcBoundingBox(x + maxX, y + maxY);
-#endif
}
void wxWindowDC::DoGetTextExtent(const wxString &string,
wxCoord *descent, wxCoord *externalLeading,
wxFont *theFont) const
{
+ if ( width )
+ *width = 0;
+ if ( height )
+ *height = 0;
+ if ( descent )
+ *descent = 0;
+ if ( externalLeading )
+ *externalLeading = 0;
+
if (string.IsEmpty())
{
- if (width) (*width) = 0;
- if (height) (*height) = 0;
return;
}
pango_layout_iter_free(iter);
*descent = h - PANGO_PIXELS(baseline);
}
- if (externalLeading)
- *externalLeading = 0; // ??
// Reset old font description
if (theFont)
pango_layout_set_font_description( m_layout, m_fontdesc );
#else // GTK+ 1.x
wxFont fontToUse = m_font;
- if (theFont) fontToUse = *theFont;
+ if (theFont)
+ fontToUse = *theFont;
GdkFont *font = fontToUse.GetInternalFont( m_scaleY );
- if (width) (*width) = wxCoord(gdk_string_width( font, string.mbc_str() ) / m_scaleX);
- if (height) (*height) = wxCoord((font->ascent + font->descent) / m_scaleY);
- if (descent) (*descent) = wxCoord(font->descent / m_scaleY);
- if (externalLeading) (*externalLeading) = 0; // ??
+ if ( !font )
+ return;
+
+ if (width)
+ *width = wxCoord(gdk_string_width( font, string.mbc_str() ) / m_scaleX);
+ if (height)
+ *height = wxCoord((font->ascent + font->descent) / m_scaleY);
+ if (descent)
+ *descent = wxCoord(font->descent / m_scaleY);
#endif // GTK+ 2/1
}