]> git.saurik.com Git - wxWidgets.git/blobdiff - src/richtext/richtextbuffer.cpp
Fix crash in wxMSW wxProgressDialog without wxPD_APP_MODAL style.
[wxWidgets.git] / src / richtext / richtextbuffer.cpp
index e96a98d07843f038cd2c4fd2620471ee1d602bf0..0a46f82d005298256d974c67cbdd2a32a472157e 100644 (file)
@@ -3338,11 +3338,10 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
     int lineSpacing = 0;
 
     // Let's assume line spacing of 10 is normal, 15 is 1.5, 20 is 2, etc.
-    if (attr.GetLineSpacing() != 10 && GetBuffer())
+    if (attr.HasLineSpacing() && attr.GetLineSpacing() > 0 && attr.GetFont().Ok())
     {
-        wxFont font(GetBuffer()->GetFontTable().FindFont(attr));
-        wxCheckSetFont(dc, font);
-        lineSpacing = (ConvertTenthsMMToPixels(dc, dc.GetCharHeight()) * attr.GetLineSpacing())/10;
+        wxCheckSetFont(dc, attr.GetFont());
+        lineSpacing = (int) (double(dc.GetCharHeight()) * (double(attr.GetLineSpacing())/10.0 - 1.0));
     }
 
     // Available space for text on each line differs.
@@ -3594,7 +3593,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
     // Apply styles to wrapped lines
     ApplyParagraphStyle(attr, rect, dc);
 
-    SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceBeforePara + spaceAfterPara));
+    SetCachedSize(wxSize(maxWidth, currentPosition.y + spaceAfterPara));
 
     m_dirty = false;
 
@@ -7621,24 +7620,6 @@ bool wxRichTextImageBlock::WriteHex(wxOutputStream& stream)
     return true;
 }
 
-inline int wxRichTextHexToDec(const char* buf)
-{
-    int firstDigit, secondDigit;
-
-    if (buf[0] >= 'A')
-        firstDigit = buf[0] - 'A' + 10;
-    else
-       firstDigit = buf[0] - '0';
-
-    if (buf[1] >= 'A')
-        secondDigit = buf[1] - 'A' + 10;
-    else
-        secondDigit = buf[1] - '0';
-
-    return (firstDigit & 0xF) * 16 + (secondDigit & 0xF );
-}
-
-
 // Read data in hex from a stream
 bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, wxBitmapType imageType)
 {
@@ -7658,7 +7639,7 @@ bool wxRichTextImageBlock::ReadHex(wxInputStream& stream, int length, wxBitmapTy
         str[0] = (char)stream.GetC();
         str[1] = (char)stream.GetC();
 
-        m_data[i] = (unsigned char)wxRichTextHexToDec(str);
+        m_data[i] = (unsigned char)wxHexToDec(str);
     }
 
     m_dataSize = dataSize;