]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/textctrl.cpp
make Set/GetLabel() set and return title in wxTLW, fixes #12371: Dialog::GetLabel...
[wxWidgets.git] / src / msw / textctrl.cpp
index 8ffbfce0c1799c2cdf93365d1e8942f6541b10fb..c2417d2cc4aedd24a83bfb228699968be94025ef 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;
 }
 
@@ -1206,9 +1193,7 @@ void wxTextCtrl::AppendText(const wxString& text)
     // don't do this if we're frozen, saves some time
     if ( !IsFrozen() && IsMultiLine() && GetRichVersion() > 1 )
     {
-        // setting the caret to the end and showing it simply doesn't work for
-        // RichEdit 2.0 -- force it to still do what we want
-        ::SendMessage(GetHwnd(), EM_LINESCROLL, 0, GetNumberOfLines());
+        ::SendMessage(GetHwnd(), WM_VSCROLL, SB_BOTTOM, NULL);
     }
 #endif // wxUSE_RICHEDIT
 }
@@ -2373,6 +2358,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
 // ----------------------------------------------------------------------------