superposition of text styles in wxTextCtrl now works as expected (and as documented)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12709 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2001-11-26 14:50:50 +00:00
parent 33b7a5491f
commit eda40bfc08
6 changed files with 282 additions and 65 deletions

View File

@@ -69,6 +69,41 @@ wxTextCtrlBase::~wxTextCtrlBase()
// style functions - not implemented here
// ----------------------------------------------------------------------------
/* static */
wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr,
const wxTextAttr& attrDef,
const wxTextCtrlBase *text)
{
wxFont font = attr.GetFont();
if ( !font.Ok() )
{
font = attrDef.GetFont();
if ( text && !font.Ok() )
font = text->GetFont();
}
wxColour colFg = attr.GetTextColour();
if ( !colFg.Ok() )
{
colFg = attrDef.GetTextColour();
if ( text && !colFg.Ok() )
colFg = text->GetForegroundColour();
}
wxColour colBg = attr.GetBackgroundColour();
if ( !colBg.Ok() )
{
colBg = attrDef.GetBackgroundColour();
if ( text && !colBg.Ok() )
colBg = text->GetBackgroundColour();
}
return wxTextAttr(colFg, colBg, font);
}
// apply styling to text range
bool wxTextCtrlBase::SetStyle(long WXUNUSED(start), long WXUNUSED(end),
const wxTextAttr& WXUNUSED(style))
@@ -78,9 +113,11 @@ bool wxTextCtrlBase::SetStyle(long WXUNUSED(start), long WXUNUSED(end),
}
// change default text attributes
bool wxTextCtrlBase::SetDefaultStyle(const wxTextAttr &style)
bool wxTextCtrlBase::SetDefaultStyle(const wxTextAttr& style)
{
m_defaultStyle = style;
// keep the old attributes if the new style doesn't specify them
m_defaultStyle = wxTextAttr::Combine(style, m_defaultStyle, this);
return TRUE;
}