Styles now sorted alphabetically
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43652 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -482,6 +482,7 @@ private:
|
|||||||
bool m_applyOnSelection; // if true, applies style on selection
|
bool m_applyOnSelection; // if true, applies style on selection
|
||||||
wxRichTextStyleType m_styleType; // style type to display
|
wxRichTextStyleType m_styleType; // style type to display
|
||||||
bool m_autoSetSelection;
|
bool m_autoSetSelection;
|
||||||
|
wxArrayString m_styleNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -509,32 +509,10 @@ wxRichTextStyleDefinition* wxRichTextStyleListBox::GetStyle(size_t i) const
|
|||||||
if (!GetStyleSheet())
|
if (!GetStyleSheet())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (GetStyleType() == wxRICHTEXT_STYLE_ALL)
|
if (i >= m_styleNames.GetCount() || i < 0)
|
||||||
{
|
return NULL;
|
||||||
// First paragraph styles, then character, then list
|
|
||||||
if (i < GetStyleSheet()->GetParagraphStyleCount())
|
|
||||||
return GetStyleSheet()->GetParagraphStyle(i);
|
|
||||||
|
|
||||||
if ((i - GetStyleSheet()->GetParagraphStyleCount()) < GetStyleSheet()->GetCharacterStyleCount())
|
return GetStyleSheet()->FindStyle(m_styleNames[i]);
|
||||||
return GetStyleSheet()->GetCharacterStyle(i - GetStyleSheet()->GetParagraphStyleCount());
|
|
||||||
|
|
||||||
if ((i - GetStyleSheet()->GetParagraphStyleCount() - GetStyleSheet()->GetCharacterStyleCount()) < GetStyleSheet()->GetListStyleCount())
|
|
||||||
return GetStyleSheet()->GetListStyle(i - GetStyleSheet()->GetParagraphStyleCount() - GetStyleSheet()->GetCharacterStyleCount());
|
|
||||||
}
|
|
||||||
else if ((GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH) && (i < GetStyleSheet()->GetParagraphStyleCount()))
|
|
||||||
{
|
|
||||||
return GetStyleSheet()->GetParagraphStyle(i);
|
|
||||||
}
|
|
||||||
else if ((GetStyleType() == wxRICHTEXT_STYLE_CHARACTER) && (i < GetStyleSheet()->GetCharacterStyleCount()))
|
|
||||||
{
|
|
||||||
return GetStyleSheet()->GetCharacterStyle(i);
|
|
||||||
}
|
|
||||||
else if ((GetStyleType() == wxRICHTEXT_STYLE_LIST) && (i < GetStyleSheet()->GetListStyleCount()))
|
|
||||||
{
|
|
||||||
return GetStyleSheet()->GetListStyle(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the list
|
/// Updates the list
|
||||||
@@ -544,14 +522,27 @@ void wxRichTextStyleListBox::UpdateStyles()
|
|||||||
{
|
{
|
||||||
SetSelection(wxNOT_FOUND);
|
SetSelection(wxNOT_FOUND);
|
||||||
|
|
||||||
if (GetStyleType() == wxRICHTEXT_STYLE_ALL)
|
m_styleNames.Clear();
|
||||||
SetItemCount(GetStyleSheet()->GetParagraphStyleCount()+GetStyleSheet()->GetCharacterStyleCount()+GetStyleSheet()->GetListStyleCount());
|
|
||||||
else if (GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH)
|
size_t i;
|
||||||
SetItemCount(GetStyleSheet()->GetParagraphStyleCount());
|
if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH)
|
||||||
else if (GetStyleType() == wxRICHTEXT_STYLE_CHARACTER)
|
{
|
||||||
SetItemCount(GetStyleSheet()->GetCharacterStyleCount());
|
for (i = 0; i < GetStyleSheet()->GetParagraphStyleCount(); i++)
|
||||||
else if (GetStyleType() == wxRICHTEXT_STYLE_LIST)
|
m_styleNames.Add(GetStyleSheet()->GetParagraphStyle(i)->GetName());
|
||||||
SetItemCount(GetStyleSheet()->GetListStyleCount());
|
}
|
||||||
|
if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_CHARACTER)
|
||||||
|
{
|
||||||
|
for (i = 0; i < GetStyleSheet()->GetCharacterStyleCount(); i++)
|
||||||
|
m_styleNames.Add(GetStyleSheet()->GetCharacterStyle(i)->GetName());
|
||||||
|
}
|
||||||
|
if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_LIST)
|
||||||
|
{
|
||||||
|
for (i = 0; i < GetStyleSheet()->GetListStyleCount(); i++)
|
||||||
|
m_styleNames.Add(GetStyleSheet()->GetListStyle(i)->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_styleNames.Sort();
|
||||||
|
SetItemCount(m_styleNames.GetCount());
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
|
|
||||||
@@ -566,19 +557,7 @@ void wxRichTextStyleListBox::UpdateStyles()
|
|||||||
// Get index for style name
|
// Get index for style name
|
||||||
int wxRichTextStyleListBox::GetIndexForStyle(const wxString& name) const
|
int wxRichTextStyleListBox::GetIndexForStyle(const wxString& name) const
|
||||||
{
|
{
|
||||||
if (GetStyleSheet())
|
return m_styleNames.Index(name);
|
||||||
{
|
|
||||||
int count = GetItemCount();
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < (int) count; i++)
|
|
||||||
{
|
|
||||||
wxRichTextStyleDefinition* def = GetStyle(i);
|
|
||||||
if (def->GetName() == name)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set selection for string
|
/// Set selection for string
|
||||||
|
Reference in New Issue
Block a user