- // Now set the text foreground and draw the text
- if (m_textForegroundColour.Ok ())
- {
- wxColour oldPenColour = m_currentColour;
- m_currentColour = m_textForegroundColour;
- bool sameColour = (oldPenColour.Ok () && m_currentColour.Ok () &&
- (oldPenColour.Red () == m_currentColour.Red ()) &&
- (oldPenColour.Blue () == m_currentColour.Blue ()) &&
- (oldPenColour.Green () == m_currentColour.Green ()) &&
- (oldPenColour.GetPixel() == m_currentColour.GetPixel()));
-
- if (!sameColour || !GetOptimization())
- {
- int pixel = -1;
- if (!m_colour) // Mono display
- {
- // Unless foreground is really white, draw it in black
- unsigned char red = m_textForegroundColour.Red ();
- unsigned char blue = m_textForegroundColour.Blue ();
- unsigned char green = m_textForegroundColour.Green ();
- if (red == (unsigned char) 255 && blue == (unsigned char) 255
- && green == (unsigned char) 255)
- {
- m_currentColour = *wxWHITE;
- pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour.SetPixel(pixel);
- m_textForegroundColour.SetPixel(pixel);
- }
- else
- {
- m_currentColour = *wxBLACK;
- pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour.SetPixel(pixel);
- m_textForegroundColour.SetPixel(pixel);
- }
- }
- else
- {
- pixel = m_textForegroundColour.AllocColour((Display*) m_display);
- m_currentColour.SetPixel(pixel);
- }
+ // Now set the text foreground and draw the text
+ if (m_textForegroundColour.Ok ())
+ {
+ wxColour oldPenColour = m_currentColour;
+ m_currentColour = m_textForegroundColour;
+ bool sameColour = (oldPenColour.Ok () && m_currentColour.Ok () &&
+ (oldPenColour.Red () == m_currentColour.Red ()) &&
+ (oldPenColour.Blue () == m_currentColour.Blue ()) &&
+ (oldPenColour.Green () == m_currentColour.Green ()) &&
+ (oldPenColour.GetPixel() == m_currentColour.GetPixel()));
+
+ if (!sameColour || !GET_OPTIMIZATION)
+ {
+ int pixel = CalculatePixel(m_textForegroundColour,
+ m_currentColour, false);
+
+ // Set the GC to the required colour
+ if (pixel > -1)
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ }
+ }
+ else
+ m_textForegroundColour = oldPenColour;
+ }
+
+ // We need to add the ascent, not the whole height, since X draws at the
+ // point above the descender.
+#if 0
+ if (use16)
+ XDrawString16((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
+ (XChar2b *)(char*) (const char*) text, slen);
+ else
+#endif // 0
+#if wxMOTIF_NEW_FONT_HANDLING
+ XFontSet fset = (XFontSet) m_font.GetFontSet (m_userScaleY * m_logicalScaleY, m_display);
+ XmbDrawString((Display*) m_display, (Pixmap) m_pixmap, fset, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent, text, slen);
+#else
+ XDrawString((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent, text, slen);
+#endif
+
+ if (m_window && m_window->GetBackingPixmap()) {
+#if 0
+ if (use16)
+ XDrawString16((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
+ (XChar2b *)(char*) (const char*) text, slen);
+ else
+#endif // 0
+#if wxMOTIF_NEW_FONT_HANDLING
+ XmbDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), fset, (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
+ wxConstCast(text.c_str(), char), slen);
+#else
+ XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
+ wxConstCast(text.c_str(), char), slen);
+#endif
+ }
+
+ // restore fill style
+ XSetFillStyle ((Display*) m_display, (GC) m_gc, gcV.fill_style);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFillStyle ((Display*) m_display, (GC) m_gcBacking,
+ gcBackingV.fill_style);
+
+ wxCoord w, h;
+ GetTextExtent (text, &w, &h);
+ CalcBoundingBox (x + w, y + h);
+ CalcBoundingBox (x, y);
+}
+
+void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
+ double angle )
+{
+ if (angle == 0.0)
+ {
+ DrawText(text, x, y);
+ return;
+ }
+
+ wxCHECK_RET( Ok(), "invalid dc" );
+
+ int oldBackgroundPixel = -1;
+ int oldForegroundPixel = -1;
+ int foregroundPixel = -1;
+ int backgroundPixel = -1;
+
+ if (m_textBackgroundColour.Ok())
+ {
+ oldBackgroundPixel = m_backgroundPixel;
+ backgroundPixel = m_textBackgroundColour.AllocColour(m_display);
+ }
+ if (m_textForegroundColour.Ok())
+ {
+ oldForegroundPixel = m_currentColour.GetPixel();
+
+ if( m_textForegroundColour.GetPixel() <= -1 )
+ CalculatePixel( m_textForegroundColour,
+ m_textForegroundColour, true);