diff --git a/include/wx/msw/textctrl.h b/include/wx/msw/textctrl.h index c5e03295f3..b852df9a84 100644 --- a/include/wx/msw/textctrl.h +++ b/include/wx/msw/textctrl.h @@ -90,6 +90,7 @@ public: // apply text attribute to the range of text (only works with richedit // controls) virtual bool SetStyle(long start, long end, const wxTextAttr& style); + virtual bool SetDefaultStyle(const wxTextAttr& style); #endif // wxUSE_RICHEDIT // translate between the position (which is just an index in the text ctrl diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 3824a797f4..14801b5eac 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -1788,6 +1788,19 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) return ok; } +bool wxTextCtrl::SetDefaultStyle(const wxTextAttr& style) +{ + if ( !wxTextCtrlBase::SetDefaultStyle(style) ) + return FALSE; + + // we have to do this or the style wouldn't apply for the text typed by the + // user + long posLast = GetLastPosition(); + SetStyle(posLast, posLast, m_defaultStyle); + + return TRUE; +} + // ---------------------------------------------------------------------------- // wxRichEditModule // ----------------------------------------------------------------------------