]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/graphics.cpp
Fix wxString unit test when not using UTF-8.
[wxWidgets.git] / src / msw / graphics.cpp
index e2065c05e9c7fb8bfc7938cc1bed3b75ba707a60..cad53a46d03398008e35cbb3884fa68da992dfa6 100644 (file)
@@ -396,10 +396,7 @@ protected:
     void Init(Graphics* graphics, int width, int height);
 
 private:
-    virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y)
-        { DoDrawFilledText(str, x, y, wxNullGraphicsBrush); }
-    virtual void DoDrawFilledText(const wxString& str, wxDouble x, wxDouble y,
-                                  const wxGraphicsBrush& backgroundBrush);
+    virtual void DoDrawText(const wxString& str, wxDouble x, wxDouble y);
 
     Graphics* m_context;
     wxStack<GraphicsState> m_stateStack;
@@ -541,6 +538,7 @@ public :
     virtual wxGraphicsBitmap CreateBitmap( const wxBitmap &bitmap );
 #if wxUSE_IMAGE
     virtual wxGraphicsBitmap CreateBitmapFromImage(const wxImage& image);
+    virtual wxImage CreateImageFromBitmap(const wxGraphicsBitmap& bmp);
 #endif // wxUSE_IMAGE
 
     virtual wxGraphicsFont CreateFont( const wxFont& font,
@@ -898,7 +896,7 @@ wxGDIPlusFontData::Init(const wxString& name,
                         const wxColour& col,
                         Unit fontUnit)
 {
-    m_font = new Font(name, size, style, fontUnit);
+    m_font = new Font(name.wc_str(), size, style, fontUnit);
 
     m_textBrush = new SolidBrush(wxColourToColor(col));
 }
@@ -1078,22 +1076,6 @@ wxGDIPlusBitmapData::~wxGDIPlusBitmapData()
     delete m_helper;
 }
 
-// ----------------------------------------------------------------------------
-// wxGraphicsBitmap implementation
-// ----------------------------------------------------------------------------
-
-#if wxUSE_IMAGE
-
-wxImage wxGraphicsBitmap::ConvertToImage() const
-{
-    const wxGDIPlusBitmapData* const
-        data = static_cast<wxGDIPlusBitmapData*>(GetGraphicsData());
-
-    return data ? data->ConvertToImage() : wxNullImage;
-}
-
-#endif // wxUSE_IMAGE
-
 //-----------------------------------------------------------------------------
 // wxGDIPlusPath implementation
 //-----------------------------------------------------------------------------
@@ -1405,6 +1387,7 @@ void wxGDIPlusContext::Init(Graphics* graphics, int width, int height)
     m_context->SetTextRenderingHint(TextRenderingHintSystemDefault);
     m_context->SetPixelOffsetMode(PixelOffsetModeHalf);
     m_context->SetSmoothingMode(SmoothingModeHighQuality);
+    m_context->SetInterpolationMode(InterpolationModeHighQuality);
     m_state1 = m_context->Save();
     m_state2 = m_context->Save();
 }
@@ -1550,10 +1533,44 @@ bool wxGDIPlusContext::SetAntialiasMode(wxAntialiasMode antialias)
     return true;
 }
 
-bool wxGDIPlusContext::SetInterpolationQuality(wxInterpolationQuality WXUNUSED(interpolation))
+bool wxGDIPlusContext::SetInterpolationQuality(wxInterpolationQuality interpolation)
 {
-    // placeholder
-    return false;
+    if (m_interpolation == interpolation)
+        return true;
+
+    InterpolationMode interpolationMode = InterpolationModeDefault;
+    switch (interpolation)
+    {
+        case wxINTERPOLATION_DEFAULT:
+            interpolationMode = InterpolationModeDefault;
+            break;
+
+        case wxINTERPOLATION_NONE:
+            interpolationMode = InterpolationModeNearestNeighbor;
+            break;
+
+        case wxINTERPOLATION_FAST:
+            interpolationMode = InterpolationModeLowQuality;
+            break;
+
+        case wxINTERPOLATION_GOOD:
+            interpolationMode = InterpolationModeHighQuality;
+            break;
+
+        case wxINTERPOLATION_BEST:
+            interpolationMode = InterpolationModeHighQualityBicubic;
+            break;
+
+        default:
+            return false;
+    }
+
+    if ( m_context->SetInterpolationMode(interpolationMode) != Gdiplus::Ok )
+        return false;
+
+    m_interpolation = interpolation;
+
+    return true;
 }
 
 bool wxGDIPlusContext::SetCompositionMode(wxCompositionMode op)
@@ -1713,9 +1730,8 @@ void wxGDIPlusContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxD
     DeleteObject(iconInfo.hbmMask);
 }
 
-void wxGDIPlusContext::DoDrawFilledText(const wxString& str,
-                                        wxDouble x, wxDouble y,
-                                        const wxGraphicsBrush& brush)
+void wxGDIPlusContext::DoDrawText(const wxString& str,
+                                        wxDouble x, wxDouble y )
 {
    if (m_composition == wxCOMPOSITION_DEST)
         return;
@@ -1728,9 +1744,7 @@ void wxGDIPlusContext::DoDrawFilledText(const wxString& str,
 
     wxGDIPlusFontData * const
         fontData = (wxGDIPlusFontData *)m_font.GetRefData();
-    wxGDIPlusBrushData * const
-        brushData = (wxGDIPlusBrushData *)brush.GetRefData();
-
     m_context->DrawString
                (
                     str.wc_str(*wxConvUI),  // string to draw, always Unicode
@@ -1738,8 +1752,7 @@ void wxGDIPlusContext::DoDrawFilledText(const wxString& str,
                     fontData->GetGDIPlusFont(),
                     PointF(x, y),
                     StringFormat::GenericTypographic(),
-                    brushData ? brushData->GetGDIPlusBrush()
-                              : fontData->GetGDIPlusBrush()
+                    fontData->GetGDIPlusBrush()
                );
 }
 
@@ -2194,8 +2207,19 @@ wxGraphicsBitmap wxGDIPlusRenderer::CreateBitmapFromImage(const wxImage& image)
         return wxNullGraphicsBitmap;
 }
 
+
+wxImage wxGDIPlusRenderer::CreateImageFromBitmap(const wxGraphicsBitmap& bmp)
+{
+    ENSURE_LOADED_OR_RETURN(wxNullImage);
+    const wxGDIPlusBitmapData* const
+        data = static_cast<wxGDIPlusBitmapData*>(bmp.GetGraphicsData());
+
+    return data ? data->ConvertToImage() : wxNullImage;
+}
+
 #endif // wxUSE_IMAGE
 
+
 wxGraphicsBitmap wxGDIPlusRenderer::CreateBitmapFromNativeBitmap( void *bitmap )
 {
     ENSURE_LOADED_OR_RETURN(wxNullGraphicsBitmap);