+/*!
+ * List style definition
+ */
+
+void wxRichTextListStyleDefinition::Copy(const wxRichTextListStyleDefinition& def)
+{
+ wxRichTextParagraphStyleDefinition::Copy(def);
+
+ int i;
+ for (i = 0; i < 10; i++)
+ m_levelStyles[i] = def.m_levelStyles[i];
+}
+
+bool wxRichTextListStyleDefinition::operator ==(const wxRichTextListStyleDefinition& def) const
+{
+ if (!Eq(def))
+ return false;
+ int i;
+ for (i = 0; i < 10; i++)
+ if (!(m_levelStyles[i] == def.m_levelStyles[i]))
+ return false;
+
+ return true;
+}
+
+/// Sets/gets the attributes for the given level
+void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxRichTextAttr& attr)
+{
+ wxASSERT( (i >= 0 && i < 10) );
+ if (i >= 0 && i < 10)
+ m_levelStyles[i] = attr;
+}
+
+const wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
+{
+ wxASSERT( (i >= 0 && i < 10) );
+ if (i >= 0 && i < 10)
+ return & m_levelStyles[i];
+ else
+ return NULL;
+}
+
+wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
+{
+ wxASSERT( (i >= 0 && i < 10) );
+ if (i >= 0 && i < 10)
+ return & m_levelStyles[i];
+ else
+ return NULL;
+}
+
+/// Convenience function for setting the major attributes for a list level specification
+void wxRichTextListStyleDefinition::SetAttributes(int i, int leftIndent, int leftSubIndent, int bulletStyle, const wxString& bulletSymbol)
+{
+ wxASSERT( (i >= 0 && i < 10) );
+ if (i >= 0 && i < 10)
+ {
+ wxRichTextAttr attr;
+
+ attr.SetBulletStyle(bulletStyle);
+ attr.SetLeftIndent(leftIndent, leftSubIndent);
+
+ if (!bulletSymbol.IsEmpty())
+ {
+ if (bulletStyle & wxTEXT_ATTR_BULLET_STYLE_SYMBOL)
+ attr.SetBulletText(bulletSymbol);
+ else
+ attr.SetBulletName(bulletSymbol);
+ }
+
+ m_levelStyles[i] = attr;
+ }
+}
+
+/// Finds the level corresponding to the given indentation
+int wxRichTextListStyleDefinition::FindLevelForIndent(int indent) const
+{
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ if (indent < m_levelStyles[i].GetLeftIndent())
+ {
+ if (i > 0)
+ return i - 1;
+ else
+ return 0;
+ }
+ }
+ return 9;
+}
+
+/// Combine the list style with a paragraph style, using the given indent (from which
+/// an appropriate level is found)
+wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle)
+{
+ int listLevel = FindLevelForIndent(indent);
+
+ wxRichTextAttr attr(*GetLevelAttributes(listLevel));
+ int oldLeftIndent = attr.GetLeftIndent();
+ int oldLeftSubIndent = attr.GetLeftSubIndent();
+
+ // First apply the overall paragraph style, if any
+ wxRichTextApplyStyle(attr, GetStyle());
+
+ // Then apply paragraph style, e.g. from paragraph style definition
+ wxRichTextApplyStyle(attr, paraStyle);
+
+ // We override the indents according to the list definition
+ attr.SetLeftIndent(oldLeftIndent, oldLeftSubIndent);
+
+ return attr;
+}
+
+/// Combine the base and list style, using the given indent (from which
+/// an appropriate level is found)
+wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent)
+{
+ int listLevel = FindLevelForIndent(indent);
+ return GetCombinedStyleForLevel(listLevel);
+}
+
+/// Combine the base and list style, using the given indent (from which
+/// an appropriate level is found)
+wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel)
+{
+ wxRichTextAttr attr(*GetLevelAttributes(listLevel));
+ int oldLeftIndent = attr.GetLeftIndent();
+ int oldLeftSubIndent = attr.GetLeftSubIndent();
+
+ // Apply the overall paragraph style, if any
+ wxRichTextApplyStyle(attr, GetStyle());
+
+ // We override the indents according to the list definition
+ attr.SetLeftIndent(oldLeftIndent, oldLeftSubIndent);
+
+ return attr;
+}
+
+/// Is this a numbered list?
+bool wxRichTextListStyleDefinition::IsNumbered(int i) const
+{
+ return (0 != (GetLevelAttributes(i)->GetFlags() &
+ (wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER|wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER|
+ wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER|wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER)));
+}
+