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

@@ -730,7 +730,7 @@ public:
/// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
/// content. /// content.
bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes); bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes);
/// Set list style /// Set list style
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);

View File

@@ -32,6 +32,7 @@ class wxRichTextCtrl;
////@begin control identifiers ////@begin control identifiers
#define SYMBOL_WXRICHTEXTBULLETSPAGE_STYLE wxRESIZE_BORDER|wxTAB_TRAVERSAL #define SYMBOL_WXRICHTEXTBULLETSPAGE_STYLE wxRESIZE_BORDER|wxTAB_TRAVERSAL
#define SYMBOL_WXRICHTEXTBULLETSPAGE_TITLE _("wxRichTextBulletsPage")
#define SYMBOL_WXRICHTEXTBULLETSPAGE_IDNAME ID_RICHTEXTBULLETSPAGE #define SYMBOL_WXRICHTEXTBULLETSPAGE_IDNAME ID_RICHTEXTBULLETSPAGE
#define SYMBOL_WXRICHTEXTBULLETSPAGE_SIZE wxSize(400, 300) #define SYMBOL_WXRICHTEXTBULLETSPAGE_SIZE wxSize(400, 300)
#define SYMBOL_WXRICHTEXTBULLETSPAGE_POSITION wxDefaultPosition #define SYMBOL_WXRICHTEXTBULLETSPAGE_POSITION wxDefaultPosition

View File

@@ -362,6 +362,18 @@ bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
return true; 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) bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
{ {
wxTextAttr& destStyle = (*this); wxTextAttr& destStyle = (*this);
@@ -524,6 +536,11 @@ bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith)
int srcBits = style.GetTextEffects(); int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags(); 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); CombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits); destStyle.SetTextEffects(destBits);

View File

@@ -1946,11 +1946,14 @@ static bool wxHasStyle(long flags, long style)
/// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
/// content. /// content.
bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes) bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes)
{ {
absentStyleAttributes |= (~style.GetFlags() & wxTEXT_ATTR_ALL);
absentTextEffectAttributes |= (~style.GetTextEffectFlags() & 0xFFFF);
if (style.HasFont()) if (style.HasFont())
{ {
if (style.HasFontSize() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_SIZE)) if (style.HasFontSize() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_SIZE))
{ {
if (currentStyle.HasFontSize()) if (currentStyle.HasFontSize())
{ {
@@ -1967,7 +1970,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasFontItalic() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_ITALIC)) if (style.HasFontItalic() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_ITALIC))
{ {
if (currentStyle.HasFontItalic()) if (currentStyle.HasFontItalic())
{ {
@@ -1984,7 +1987,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT)) if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT))
{ {
if (currentStyle.HasFontWeight()) if (currentStyle.HasFontWeight())
{ {
@@ -2001,7 +2004,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasFontFaceName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_FACE)) if (style.HasFontFaceName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_FACE))
{ {
if (currentStyle.HasFontFaceName()) if (currentStyle.HasFontFaceName())
{ {
@@ -2021,7 +2024,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasFontUnderlined() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE)) if (style.HasFontUnderlined() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE))
{ {
if (currentStyle.HasFontUnderlined()) if (currentStyle.HasFontUnderlined())
{ {
@@ -2039,7 +2042,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasTextColour() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_TEXT_COLOUR)) if (style.HasTextColour() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_TEXT_COLOUR))
{ {
if (currentStyle.HasTextColour()) if (currentStyle.HasTextColour())
{ {
@@ -2054,7 +2057,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetTextColour(style.GetTextColour()); currentStyle.SetTextColour(style.GetTextColour());
} }
if (style.HasBackgroundColour() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BACKGROUND_COLOUR)) if (style.HasBackgroundColour() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BACKGROUND_COLOUR))
{ {
if (currentStyle.HasBackgroundColour()) if (currentStyle.HasBackgroundColour())
{ {
@@ -2069,7 +2072,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetBackgroundColour(style.GetBackgroundColour()); currentStyle.SetBackgroundColour(style.GetBackgroundColour());
} }
if (style.HasAlignment() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_ALIGNMENT)) if (style.HasAlignment() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_ALIGNMENT))
{ {
if (currentStyle.HasAlignment()) if (currentStyle.HasAlignment())
{ {
@@ -2084,7 +2087,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetAlignment(style.GetAlignment()); currentStyle.SetAlignment(style.GetAlignment());
} }
if (style.HasTabs() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_TABS)) if (style.HasTabs() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_TABS))
{ {
if (currentStyle.HasTabs()) if (currentStyle.HasTabs())
{ {
@@ -2099,7 +2102,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetTabs(style.GetTabs()); currentStyle.SetTabs(style.GetTabs());
} }
if (style.HasLeftIndent() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_LEFT_INDENT)) if (style.HasLeftIndent() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LEFT_INDENT))
{ {
if (currentStyle.HasLeftIndent()) if (currentStyle.HasLeftIndent())
{ {
@@ -2114,7 +2117,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent()); currentStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent());
} }
if (style.HasRightIndent() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_RIGHT_INDENT)) if (style.HasRightIndent() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_RIGHT_INDENT))
{ {
if (currentStyle.HasRightIndent()) if (currentStyle.HasRightIndent())
{ {
@@ -2129,7 +2132,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetRightIndent(style.GetRightIndent()); currentStyle.SetRightIndent(style.GetRightIndent());
} }
if (style.HasParagraphSpacingAfter() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_PARA_SPACING_AFTER)) if (style.HasParagraphSpacingAfter() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARA_SPACING_AFTER))
{ {
if (currentStyle.HasParagraphSpacingAfter()) if (currentStyle.HasParagraphSpacingAfter())
{ {
@@ -2144,7 +2147,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter()); currentStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter());
} }
if (style.HasParagraphSpacingBefore() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_PARA_SPACING_BEFORE)) if (style.HasParagraphSpacingBefore() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARA_SPACING_BEFORE))
{ {
if (currentStyle.HasParagraphSpacingBefore()) if (currentStyle.HasParagraphSpacingBefore())
{ {
@@ -2159,7 +2162,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore()); currentStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore());
} }
if (style.HasLineSpacing() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_LINE_SPACING)) if (style.HasLineSpacing() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LINE_SPACING))
{ {
if (currentStyle.HasLineSpacing()) if (currentStyle.HasLineSpacing())
{ {
@@ -2174,7 +2177,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetLineSpacing(style.GetLineSpacing()); currentStyle.SetLineSpacing(style.GetLineSpacing());
} }
if (style.HasCharacterStyleName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_CHARACTER_STYLE_NAME)) if (style.HasCharacterStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_CHARACTER_STYLE_NAME))
{ {
if (currentStyle.HasCharacterStyleName()) if (currentStyle.HasCharacterStyleName())
{ {
@@ -2189,7 +2192,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetCharacterStyleName(style.GetCharacterStyleName()); currentStyle.SetCharacterStyleName(style.GetCharacterStyleName());
} }
if (style.HasParagraphStyleName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_PARAGRAPH_STYLE_NAME)) if (style.HasParagraphStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARAGRAPH_STYLE_NAME))
{ {
if (currentStyle.HasParagraphStyleName()) if (currentStyle.HasParagraphStyleName())
{ {
@@ -2204,7 +2207,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetParagraphStyleName(style.GetParagraphStyleName()); currentStyle.SetParagraphStyleName(style.GetParagraphStyleName());
} }
if (style.HasListStyleName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_LIST_STYLE_NAME)) if (style.HasListStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LIST_STYLE_NAME))
{ {
if (currentStyle.HasListStyleName()) if (currentStyle.HasListStyleName())
{ {
@@ -2219,7 +2222,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetListStyleName(style.GetListStyleName()); currentStyle.SetListStyleName(style.GetListStyleName());
} }
if (style.HasBulletStyle() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_STYLE)) if (style.HasBulletStyle() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_STYLE))
{ {
if (currentStyle.HasBulletStyle()) if (currentStyle.HasBulletStyle())
{ {
@@ -2234,7 +2237,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetBulletStyle(style.GetBulletStyle()); currentStyle.SetBulletStyle(style.GetBulletStyle());
} }
if (style.HasBulletNumber() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_NUMBER)) if (style.HasBulletNumber() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_NUMBER))
{ {
if (currentStyle.HasBulletNumber()) if (currentStyle.HasBulletNumber())
{ {
@@ -2249,7 +2252,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetBulletNumber(style.GetBulletNumber()); currentStyle.SetBulletNumber(style.GetBulletNumber());
} }
if (style.HasBulletText() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_TEXT)) if (style.HasBulletText() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_TEXT))
{ {
if (currentStyle.HasBulletText()) if (currentStyle.HasBulletText())
{ {
@@ -2267,7 +2270,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasBulletName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_BULLET_NAME)) if (style.HasBulletName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_NAME))
{ {
if (currentStyle.HasBulletName()) if (currentStyle.HasBulletName())
{ {
@@ -2284,7 +2287,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasURL() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_URL)) if (style.HasURL() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_URL))
{ {
if (currentStyle.HasURL()) if (currentStyle.HasURL())
{ {
@@ -2301,13 +2304,17 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
} }
} }
if (style.HasTextEffects() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_EFFECTS)) if (style.HasTextEffects() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_EFFECTS))
{ {
if (currentStyle.HasTextEffects()) if (currentStyle.HasTextEffects())
{ {
// We need to find the bits in the new style that are different: // We need to find the bits in the new style that are different:
// just look at those bits that are specified by the new style. // just look at those bits that are specified by the new style.
// We need to remove the bits and flags that are not common between current style
// and new style. In so doing we need to take account of the styles absent from one or more of the
// previous styles.
int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags(); int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags();
int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags(); int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags();
@@ -2326,9 +2333,17 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const
currentStyle.SetTextEffects(style.GetTextEffects()); currentStyle.SetTextEffects(style.GetTextEffects());
currentStyle.SetTextEffectFlags(style.GetTextEffectFlags()); currentStyle.SetTextEffectFlags(style.GetTextEffectFlags());
} }
// Mask out the flags and values that cannot be common because they were absent in one or more objecrs
// that we've looked at so far
currentStyle.SetTextEffects(currentStyle.GetTextEffects() & ~absentTextEffectAttributes);
currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~absentTextEffectAttributes);
if (currentStyle.GetTextEffectFlags() == 0)
currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_EFFECTS);
} }
if (style.HasOutlineLevel() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_OUTLINE_LEVEL)) if (style.HasOutlineLevel() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_OUTLINE_LEVEL))
{ {
if (currentStyle.HasOutlineLevel()) if (currentStyle.HasOutlineLevel())
{ {
@@ -2358,6 +2373,11 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range
long multipleStyleAttributes = 0; long multipleStyleAttributes = 0;
int multipleTextEffectAttributes = 0; int multipleTextEffectAttributes = 0;
int absentStyleAttributesPara = 0;
int absentStyleAttributesChar = 0;
int absentTextEffectAttributesPara = 0;
int absentTextEffectAttributesChar = 0;
wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst(); wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst();
while (node) while (node)
{ {
@@ -2368,7 +2388,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range
{ {
wxTextAttr paraStyle = para->GetCombinedAttributes(); wxTextAttr paraStyle = para->GetCombinedAttributes();
CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes); CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesPara, absentTextEffectAttributesPara);
} }
else else
{ {
@@ -2378,7 +2398,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range
// First collect paragraph attributes only // First collect paragraph attributes only
wxTextAttr paraStyle = para->GetCombinedAttributes(); wxTextAttr paraStyle = para->GetCombinedAttributes();
paraStyle.SetFlags(paraStyle.GetFlags() & wxTEXT_ATTR_PARAGRAPH); paraStyle.SetFlags(paraStyle.GetFlags() & wxTEXT_ATTR_PARAGRAPH);
CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes); CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesPara, absentTextEffectAttributesPara);
wxRichTextObjectList::compatibility_iterator childNode = para->GetChildren().GetFirst(); wxRichTextObjectList::compatibility_iterator childNode = para->GetChildren().GetFirst();
@@ -2392,7 +2412,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range
// Now collect character attributes only // Now collect character attributes only
childStyle.SetFlags(childStyle.GetFlags() & wxTEXT_ATTR_CHARACTER); childStyle.SetFlags(childStyle.GetFlags() & wxTEXT_ATTR_CHARACTER);
CollectStyle(style, childStyle, multipleStyleAttributes, multipleTextEffectAttributes); CollectStyle(style, childStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesChar, absentTextEffectAttributesChar);
} }
childNode = childNode->GetNext(); childNode = childNode->GetNext();

View File

@@ -216,8 +216,6 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
attributes.SetLineSpacing(10); attributes.SetLineSpacing(10);
attributes.SetParagraphSpacingAfter(10); attributes.SetParagraphSpacingAfter(10);
attributes.SetParagraphSpacingBefore(0); attributes.SetParagraphSpacingBefore(0);
attributes.SetTextEffects(0);
attributes.SetTextEffectFlags(wxTEXT_ATTR_EFFECT_STRIKETHROUGH|wxTEXT_ATTR_EFFECT_CAPITALS);
SetBasicStyle(attributes); SetBasicStyle(attributes);

View File

@@ -392,8 +392,9 @@ bool wxRichTextFontPage::TransferDataFromWindow()
} }
else else
{ {
attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_SUBSCRIPT | wxTEXT_ATTR_EFFECT_SUPERSCRIPT ); // If they are undetermined, we don't want to include these flags in the text effects - the objects
attr->SetTextEffects(attr->GetTextEffects() & ~( wxTEXT_ATTR_EFFECT_SUPERSCRIPT | wxTEXT_ATTR_EFFECT_SUBSCRIPT)); // should retain their original style.
attr->SetTextEffectFlags(attr->GetTextEffectFlags() & ~(wxTEXT_ATTR_EFFECT_SUBSCRIPT|wxTEXT_ATTR_EFFECT_SUPERSCRIPT) );
} }
return true; return true;
@@ -514,16 +515,16 @@ bool wxRichTextFontPage::TransferDataToWindow()
} }
else else
{ {
m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
} }
} }
else else
{ {
m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED); m_strikethroughCtrl->Set3StateValue(wxCHK_UNDETERMINED);
m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED); m_capitalsCtrl->Set3StateValue(wxCHK_UNDETERMINED);
m_superscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); m_superscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
m_subscriptCtrl->Set3StateValue(wxCHK_UNCHECKED); m_subscriptCtrl->Set3StateValue(wxCHK_UNDETERMINED);
} }
UpdatePreview(); UpdatePreview();
@@ -790,8 +791,11 @@ void wxRichTextFontPage::OnCapsctrlClick( wxCommandEvent& WXUNUSED(event) )
void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) ) void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXUNUSED(event) )
{ {
if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED && m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); m_subscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );
else
m_subscriptCtrl->Set3StateValue( wxCHK_CHECKED );
UpdatePreview(); UpdatePreview();
} }
@@ -801,7 +805,10 @@ void wxRichTextFontPage::OnRichtextfontpageSuperscriptClick( wxCommandEvent& WXU
void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) ) void wxRichTextFontPage::OnRichtextfontpageSubscriptClick( wxCommandEvent& WXUNUSED(event) )
{ {
if ( m_superscriptCtrl->Get3StateValue() == wxCHK_CHECKED && m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED ) if ( m_subscriptCtrl->Get3StateValue() == wxCHK_CHECKED)
m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED ); m_superscriptCtrl->Set3StateValue( wxCHK_UNCHECKED );
else
m_superscriptCtrl->Set3StateValue( wxCHK_CHECKED );
UpdatePreview(); UpdatePreview();
} }