int GetRichVersion() const { return m_verRichEdit; }
bool IsRich() const { return m_verRichEdit != 0; }
- // rich edit controls are not compatible with normal ones and wem ust set
- // the colours for them otherwise
+ // rich edit controls are not compatible with normal ones and we must set
+ // the colours and font for them otherwise
virtual bool SetBackgroundColour(const wxColour& colour);
virtual bool SetForegroundColour(const wxColour& colour);
+ virtual bool SetFont(const wxFont& font);
#else
bool IsRich() const { return false; }
#endif // wxUSE_RICHEDIT
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
// ----------------------------------------------------------------------------