]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
implement * and / operators for wxPoint, not only wxSize.
[wxWidgets.git] / src / msw / textctrl.cpp
index 8ffbfce0c1799c2cdf93365d1e8942f6541b10fb..d9376ed7564521ae0317cf433f6ad177b8b88ab9 100644 (file)
@@ -1038,10 +1038,6 @@ wxTextCtrl::StreamIn(const wxString& value,
         wxLogLastError(wxT("EM_STREAMIN"));
     }
 
-#if !wxUSE_WCHAR_T
-    free(wchBuf);
-#endif // !wxUSE_WCHAR_T
-
     return true;
 }
 
@@ -1054,13 +1050,8 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
 
     const int len = GetWindowTextLength(GetHwnd());
 
-#if wxUSE_WCHAR_T
     wxWCharBuffer wchBuf(len);
     wchar_t *wpc = wchBuf.data();
-#else
-    wchar_t *wchBuf = (wchar_t *)malloc((len + 1)*sizeof(wchar_t));
-    wchar_t *wpc = wchBuf;
-#endif
 
     wxStreamOutData data;
     data.wpc = wpc;
@@ -1100,10 +1091,6 @@ wxTextCtrl::StreamOut(wxFontEncoding encoding, bool selectionOnly) const
         }
     }
 
-#if !wxUSE_WCHAR_T
-    free(wchBuf);
-#endif // !wxUSE_WCHAR_T
-
     return out;
 }
 
@@ -2373,6 +2360,26 @@ bool wxTextCtrl::SetForegroundColour(const wxColour& colour)
     return true;
 }
 
+bool wxTextCtrl::SetFont(const wxFont& font)
+{
+    if ( !wxTextCtrlBase::SetFont(font) )
+        return false;
+
+    if ( IsRich() )
+    {
+        // Using WM_SETFONT doesn't work reliably with rich edit controls: as
+        // an example, if we set a fixed width font for a richedit 4.1 control,
+        // it's used for the ASCII characters but inserting any non-ASCII ones
+        // switches the font to a proportional one, whether it's done
+        // programmatically or not. So just use EM_SETCHARFORMAT for this too.
+        wxTextAttr attr;
+        attr.SetFont(font);
+        SetDefaultStyle(attr);
+    }
+
+    return true;
+}
+
 // ----------------------------------------------------------------------------
 // styling support for rich edit controls
 // ----------------------------------------------------------------------------