+void wxDC::DoDrawText(const wxString& text, long x, long y)
+{
+ if (m_textForegroundColour.Ok())
+ SetTextColor(GetHdc(), m_textForegroundColour.GetPixel() );
+
+ DWORD old_background = 0;
+ if (m_textBackgroundColour.Ok())
+ {
+ old_background = SetBkColor(GetHdc(), m_textBackgroundColour.GetPixel() );
+ }
+
+ if (m_backgroundMode == wxTRANSPARENT)
+ SetBkMode(GetHdc(), TRANSPARENT);
+ else
+ SetBkMode(GetHdc(), OPAQUE);
+
+ (void)TextOut(GetHdc(), XLOG2DEV(x), YLOG2DEV(y), WXSTRINGCAST text, wxStrlen(WXSTRINGCAST text));
+
+ if (m_textBackgroundColour.Ok())
+ (void)SetBkColor(GetHdc(), old_background);
+
+ CalcBoundingBox(x, y);
+
+ long w, h;
+ GetTextExtent(text, &w, &h);
+ CalcBoundingBox((x + w), (y + h));
+}
+
+// ---------------------------------------------------------------------------
+// set GDI objects
+// ---------------------------------------------------------------------------
+
+void wxDC::SetPalette(const wxPalette& palette)
+{
+ // Set the old object temporarily, in case the assignment deletes an object
+ // that's not yet selected out.
+ if (m_oldPalette)
+ {
+ ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, TRUE);
+ m_oldPalette = 0;
+ }
+
+ m_palette = palette;
+
+ if (!m_palette.Ok())
+ {
+ // Setting a NULL colourmap is a way of restoring
+ // the original colourmap
+ if (m_oldPalette)
+ {
+ ::SelectPalette(GetHdc(), (HPALETTE) m_oldPalette, TRUE);
+ m_oldPalette = 0;
+ }
+
+ return;
+ }
+
+ if (m_palette.Ok() && m_palette.GetHPALETTE())
+ {
+ HPALETTE oldPal = ::SelectPalette(GetHdc(), (HPALETTE) m_palette.GetHPALETTE(), TRUE);
+ if (!m_oldPalette)
+ m_oldPalette = (WXHPALETTE) oldPal;
+
+ ::RealizePalette(GetHdc());
+ }
+}
+