Fixed common style collection and superscript/subscript selection

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53621 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2008-05-17 17:54:11 +00:00
parent 09b895cb4a
commit d1e5be0ec6
6 changed files with 82 additions and 39 deletions

View File

@@ -362,6 +362,18 @@ bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
return true;
}
// Resets bits in destination so new attributes aren't merged with mutually exclusive ones
static bool wxResetIncompatibleBits(const int mask, const int srcFlags, int& destFlags, int& destBits)
{
if ((srcFlags & mask) && (destFlags & mask))
{
destBits &= ~mask;
destFlags &= ~mask;
}
return true;
}
bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
{
wxTextAttr& destStyle = (*this);
@@ -524,6 +536,11 @@ bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
// Reset incompatible bits in the destination
wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_SUPERSCRIPT|wxTEXT_ATTR_EFFECT_SUBSCRIPT), srcFlags, destFlags, destBits);
wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_CAPITALS|wxTEXT_ATTR_EFFECT_SMALL_CAPITALS), srcFlags, destFlags, destBits);
wxResetIncompatibleBits((wxTEXT_ATTR_EFFECT_STRIKETHROUGH|wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH), srcFlags, destFlags, destBits);
CombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits);