Improved auto list numbering

Fixed selection bugs


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@55175 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2008-08-22 15:21:13 +00:00
parent 2e1ff9a2df
commit f493fe3249
2 changed files with 31 additions and 9 deletions

View File

@@ -5894,8 +5894,14 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
{ {
if (para && para->GetRange().GetEnd() == pos) if (para && para->GetRange().GetEnd() == pos)
pos1 ++; pos1 ++;
// Now see if we need to number the paragraph.
if (newPara->GetAttributes().HasBulletNumber()) if (newPara->GetAttributes().HasBulletNumber())
newPara->GetAttributes().SetBulletNumber(newPara->GetAttributes().GetBulletNumber()+1); {
wxRichTextAttr numberingAttr;
if (FindNextParagraphNumber(para, numberingAttr))
wxRichTextApplyStyle(newPara->GetAttributes(), (const wxRichTextAttr&) numberingAttr);
}
} }
action->SetPosition(pos); action->SetPosition(pos);
@@ -6003,6 +6009,25 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
} }
} }
} }
// Also apply list style if present
if (lookUpNewParaStyle && !para->GetAttributes().GetListStyleName().IsEmpty() && GetStyleSheet())
{
wxRichTextListStyleDefinition* listDef = GetStyleSheet()->FindListStyle(para->GetAttributes().GetListStyleName());
if (listDef)
{
int thisIndent = para->GetAttributes().GetLeftIndent();
int thisLevel = para->GetAttributes().HasOutlineLevel() ? para->GetAttributes().GetOutlineLevel() : listDef->FindLevelForIndent(thisIndent);
// Apply the overall list style, and item style for this level
wxTextAttrEx listStyle(listDef->GetCombinedStyleForLevel(thisLevel, GetStyleSheet()));
wxRichTextApplyStyle(attr, listStyle);
attr.SetOutlineLevel(thisLevel);
if (para->GetAttributes().HasBulletNumber())
attr.SetBulletNumber(para->GetAttributes().GetBulletNumber());
}
}
if (!foundAttributes) if (!foundAttributes)
{ {
attr = para->GetAttributes(); attr = para->GetAttributes();
@@ -6015,14 +6040,6 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
attr.SetFlags(flags); attr.SetFlags(flags);
} }
// Now see if we need to number the paragraph.
if (attr.HasBulletStyle())
{
wxRichTextAttr numberingAttr;
if (FindNextParagraphNumber(para, numberingAttr))
wxRichTextApplyStyle(attr, (const wxRichTextAttr&) numberingAttr);
}
return attr; return attr;
} }
else else

View File

@@ -1091,6 +1091,9 @@ bool wxRichTextCtrl::ExtendSelection(long oldPos, long newPos, int flags)
{ {
if (flags & wxRICHTEXT_SHIFT_DOWN) if (flags & wxRICHTEXT_SHIFT_DOWN)
{ {
if (oldPos == newPos)
return false;
wxRichTextRange oldSelection = m_selectionRange; wxRichTextRange oldSelection = m_selectionRange;
// If not currently selecting, start selecting // If not currently selecting, start selecting
@@ -1109,6 +1112,8 @@ bool wxRichTextCtrl::ExtendSelection(long oldPos, long newPos, int flags)
// the end. // the end.
if (newPos > m_selectionAnchor) if (newPos > m_selectionAnchor)
m_selectionRange.SetRange(m_selectionAnchor+1, newPos); m_selectionRange.SetRange(m_selectionAnchor+1, newPos);
else if (newPos == m_selectionAnchor)
m_selectionRange = wxRichTextRange(-2, -2);
else else
m_selectionRange.SetRange(newPos+1, m_selectionAnchor); m_selectionRange.SetRange(newPos+1, m_selectionAnchor);
} }