X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c40766261bb2ee37b450a25346dac138f48088c7..2190f6aa153416d1c225532bb026df98b3e273ad:/src/common/textcmn.cpp diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index 46741123c2..53dd431459 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -297,8 +297,11 @@ bool wxTextAttr::EqPartial(const wxTextAttr& attr, int flags) const } // Create font from font attributes. -wxFont wxTextAttr::CreateFont() const +wxFont wxTextAttr::GetFont() const { + if ( !HasFont() ) + return wxNullFont; + int fontSize = 10; if (HasFontSize()) fontSize = GetFontSize(); @@ -359,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); @@ -521,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); @@ -542,10 +562,14 @@ wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr, const wxTextAttr& attrDef, const wxTextCtrlBase *text) { - wxFont font = attr.GetFont(); + wxFont font; + if (attr.HasFont()) + font = attr.GetFont(); + if ( !font.Ok() ) { - font = attrDef.GetFont(); + if (attrDef.HasFont()) + font = attrDef.GetFont(); if ( text && !font.Ok() ) font = text->GetFont(); @@ -765,41 +789,19 @@ wxTextCtrl& wxTextCtrlBase::operator<<(const wxString& s) return *TEXTCTRL(this); } -wxTextCtrl& wxTextCtrlBase::operator<<(float f) -{ - wxString str; - str.Printf(wxT("%.2f"), f); - AppendText(str); - return *TEXTCTRL(this); -} - wxTextCtrl& wxTextCtrlBase::operator<<(double d) { - wxString str; - str.Printf(wxT("%.2f"), d); - AppendText(str); - return *TEXTCTRL(this); + return *this << wxString::Format("%.2f", d); } wxTextCtrl& wxTextCtrlBase::operator<<(int i) { - wxString str; - str.Printf(wxT("%d"), i); - AppendText(str); - return *TEXTCTRL(this); -} - -wxTextCtrl& wxTextCtrlBase::operator<<(long i) -{ - wxString str; - str.Printf(wxT("%ld"), i); - AppendText(str); - return *TEXTCTRL(this); + return *this << wxString::Format("%d", i); } -wxTextCtrl& wxTextCtrlBase::operator<<(const wxChar c) +wxTextCtrl& wxTextCtrlBase::operator<<(long l) { - return operator<<(wxString(c)); + return *this << wxString::Format("%ld", l); } // ----------------------------------------------------------------------------