- wxCHECK_RET( IsOk(), wxT("invalid window dc") );
-
- if (!m_gdkwindow) return;
-
- if (text.empty()) return;
-
- wxCoord x = XLOG2DEV(xLogical),
- y = YLOG2DEV(yLogical);
-
- wxCHECK_RET( m_context, wxT("no Pango context") );
- wxCHECK_RET( m_layout, wxT("no Pango layout") );
- wxCHECK_RET( m_fontdesc, wxT("no Pango font description") );
-
- gdk_pango_context_set_colormap( m_context, m_cmap ); // not needed in gtk+ >= 2.6
-
- wxCharBuffer data = wxGTK_CONV(text);
- if ( !data )
- return;
-
- pango_layout_set_text(m_layout, data, data.length());
- const bool setAttrs = m_font.GTKSetPangoAttrs(m_layout);
-
- int oldSize = 0;
- const bool isScaled = fabs(m_scaleY - 1.0) > 0.00001;
- if (isScaled)
- {
- // If there is a user or actually any scale applied to
- // the device context, scale the font.
-
- // scale font description
- oldSize = pango_font_description_get_size(m_fontdesc);
- pango_font_description_set_size(m_fontdesc, int(oldSize * m_scaleY));
-
- // actually apply scaled font
- pango_layout_set_font_description( m_layout, m_fontdesc );
- }
-
- int w, h;
- pango_layout_get_pixel_size(m_layout, &w, &h);
-
- // Draw layout.
- int x_rtl = x;
- if (m_window && m_window->GetLayoutDirection() == wxLayout_RightToLeft)
- x_rtl -= w;
-
- const GdkColor* bg_col = NULL;
- if (m_backgroundMode == wxBRUSHSTYLE_SOLID)
- bg_col = m_textBackgroundColour.GetColor();
-
- gdk_draw_layout_with_colors(m_gdkwindow, m_textGC, x_rtl, y, m_layout, NULL, bg_col);
-
- if (isScaled)
- {
- // reset unscaled size
- pango_font_description_set_size( m_fontdesc, oldSize );
-
- // actually apply unscaled font
- pango_layout_set_font_description( m_layout, m_fontdesc );
- }
- if (setAttrs)
- {
- // undo underline attributes setting:
- pango_layout_set_attributes(m_layout, NULL);
- }
-
- CalcBoundingBox(xLogical + int(w / m_scaleX), yLogical + int(h / m_scaleY));
- CalcBoundingBox(xLogical, yLogical);