]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/graphics.cpp
simpler implementation that also works over remote connections by Kevin O.
[wxWidgets.git] / src / msw / graphics.cpp
index cad53a46d03398008e35cbb3884fa68da992dfa6..78f1e4aa0cbe0c6921d8399408f2bb34b9b804d8 100644 (file)
@@ -272,7 +272,7 @@ private:
     GraphicsPath* m_brushPath;
 };
 
-class WXDLLIMPEXP_CORE wxGDIPlusBitmapData : public wxGraphicsObjectRefData
+class WXDLLIMPEXP_CORE wxGDIPlusBitmapData : public wxGraphicsBitmapData
 {
 public:
     wxGDIPlusBitmapData( wxGraphicsRenderer* renderer, Bitmap* bitmap );
@@ -280,6 +280,7 @@ public:
     ~wxGDIPlusBitmapData ();
 
     virtual Bitmap* GetGDIPlusBitmap() { return m_bitmap; }
+    virtual void* GetNativeBitmap() const { return m_bitmap; }
 
 #if wxUSE_IMAGE
     wxImage ConvertToImage() const;
@@ -943,13 +944,13 @@ wxGDIPlusFontData::~wxGDIPlusFontData()
 //-----------------------------------------------------------------------------
 
 wxGDIPlusBitmapData::wxGDIPlusBitmapData( wxGraphicsRenderer* renderer, Bitmap* bitmap ) :
-    wxGraphicsObjectRefData( renderer ), m_bitmap( bitmap )
+    wxGraphicsBitmapData( renderer ), m_bitmap( bitmap )
 {
     m_helper = NULL;
 }
 
 wxGDIPlusBitmapData::wxGDIPlusBitmapData( wxGraphicsRenderer* renderer,
-                        const wxBitmap &bmp) : wxGraphicsObjectRefData( renderer )
+                        const wxBitmap &bmp) : wxGraphicsBitmapData( renderer )
 {
     m_bitmap = NULL;
     m_helper = NULL;
@@ -1769,12 +1770,14 @@ void wxGDIPlusContext::GetTextExtent( const wxString &str, wxDouble *width, wxDo
 
     REAL factorY = m_fontScaleRatio;
 
-    REAL rDescent = ffamily.GetCellDescent(FontStyleRegular) *
-        f->GetSize() / ffamily.GetEmHeight(FontStyleRegular);
-    REAL rAscent = ffamily.GetCellAscent(FontStyleRegular) *
-        f->GetSize() / ffamily.GetEmHeight(FontStyleRegular);
-    REAL rHeight = ffamily.GetLineSpacing(FontStyleRegular) *
-        f->GetSize() / ffamily.GetEmHeight(FontStyleRegular);
+    // Notice that we must use the real font style or the results would be
+    // incorrect for italic/bold fonts.
+    const INT style = f->GetStyle();
+    const REAL size = f->GetSize();
+    const REAL emHeight = ffamily.GetEmHeight(style);
+    REAL rDescent = ffamily.GetCellDescent(style) * size / emHeight;
+    REAL rAscent = ffamily.GetCellAscent(style) * size / emHeight;
+    REAL rHeight = ffamily.GetLineSpacing(style) * size / emHeight;
 
     if ( height )
         *height = rHeight * factorY;