void wxRichTextListStyleDefinition::Copy(const wxRichTextListStyleDefinition& def)
{
wxRichTextParagraphStyleDefinition::Copy(def);
-
+
int i;
for (i = 0; i < 10; i++)
m_levelStyles[i] = def.m_levelStyles[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 wxTextAttrEx& attr)
+void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxRichTextAttr& attr)
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
m_levelStyles[i] = attr;
}
-const wxTextAttrEx* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
+const wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
return NULL;
}
-wxTextAttrEx* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
+wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
{
- wxTextAttrEx attr;
-
+ wxRichTextAttr attr;
+
attr.SetBulletStyle(bulletStyle);
attr.SetLeftIndent(leftIndent, leftSubIndent);
if (!bulletSymbol.IsEmpty())
- attr.SetBulletSymbol(bulletSymbol[0]);
-
- m_levelStyles[i] = attr;
- }
+ {
+ 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
/// Combine the list style with a paragraph style, using the given indent (from which
/// an appropriate level is found)
-wxTextAttrEx wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxTextAttrEx& paraStyle)
+wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle)
{
int listLevel = FindLevelForIndent(indent);
-
- wxTextAttrEx attr(*GetLevelAttributes(listLevel));
+
+ wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent();
- // First apply the overall paragraph style, if any
+ // 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)
-wxTextAttrEx wxRichTextListStyleDefinition::GetCombinedStyle(int indent)
+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)
-wxTextAttrEx wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel)
+wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel)
{
- wxTextAttrEx attr(*GetLevelAttributes(listLevel));
+ wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent();
- // Apply the overall paragraph style, if any
+ // 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;
}
if (m_nextSheet)
m_nextSheet->m_previousSheet = m_previousSheet;
-
+
if (m_previousSheet)
m_previousSheet->m_nextSheet = m_nextSheet;
-
+
m_previousSheet = NULL;
m_nextSheet = NULL;
}
if (def->GetName().Lower() == name.Lower())
return def;
}
-
+
if (m_nextSheet && recurse)
return m_nextSheet->FindStyle(list, name, recurse);
{
m_previousSheet = before->m_previousSheet;
m_nextSheet = before;
-
+
before->m_previousSheet = this;
return true;
}
{
last = last->m_nextSheet;
}
-
+
if (last)
{
m_previousSheet = last;
last->m_nextSheet = this;
-
+
return true;
}
else
m_previousSheet->m_nextSheet = m_nextSheet;
if (m_nextSheet)
m_nextSheet->m_previousSheet = m_previousSheet;
-
+
m_previousSheet = NULL;
m_nextSheet = NULL;
}
IMPLEMENT_CLASS(wxRichTextStyleListBox, wxHtmlListBox)
BEGIN_EVENT_TABLE(wxRichTextStyleListBox, wxHtmlListBox)
- EVT_LISTBOX(wxID_ANY, wxRichTextStyleListBox::OnSelect)
EVT_LEFT_DOWN(wxRichTextStyleListBox::OnLeftDown)
EVT_LEFT_DCLICK(wxRichTextStyleListBox::OnLeftDoubleClick)
EVT_IDLE(wxRichTextStyleListBox::OnIdle)
{
if (!GetStyleSheet())
return wxEmptyString;
-
+
wxRichTextStyleDefinition* def = GetStyle(n);
if (def)
return CreateHTML(def);
else if ((GetStyleType() == wxRICHTEXT_STYLE_LIST) && (i < GetStyleSheet()->GetListStyleCount()))
{
return GetStyleSheet()->GetListStyle(i);
- }
+ }
return NULL;
}
{
if (GetStyleSheet())
{
+ SetSelection(wxNOT_FOUND);
+
if (GetStyleType() == wxRICHTEXT_STYLE_ALL)
SetItemCount(GetStyleSheet()->GetParagraphStyleCount()+GetStyleSheet()->GetCharacterStyleCount()+GetStyleSheet()->GetListStyleCount());
else if (GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH)
SetItemCount(GetStyleSheet()->GetCharacterStyleCount());
else if (GetStyleType() == wxRICHTEXT_STYLE_LIST)
SetItemCount(GetStyleSheet()->GetListStyleCount());
+
Refresh();
+
+ if (GetItemCount() > 0)
+ {
+ SetSelection(0);
+ SendSelectedEvent();
+ }
}
}
str << wxT("<td nowrap>");
+#ifdef __WXMSW__
+ int size = 3;
+#else
int size = 4;
+#endif
- // Standard size is 12, say
- size += (def->GetStyle().HasFont() ? def->GetStyle().GetFontSize() : 12) - 12;
+ int stdFontSize = 12;
+ int thisFontSize = ((def->GetStyle().GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0) ? def->GetStyle().GetFontSize() : stdFontSize;
+
+ if (thisFontSize < stdFontSize)
+ size ++;
+ else if (thisFontSize > stdFontSize)
+ size --;
str += wxT("<font");
return (int) pixels;
}
-/// React to selection
-void wxRichTextStyleListBox::OnSelect(wxCommandEvent& WXUNUSED(event))
-{
-#if 0
- wxRichTextStyleDefinition* def = GetStyle(event.GetSelection());
- if (def)
- {
- wxMessageBox(def->GetName());
- }
-#endif
-}
-
void wxRichTextStyleListBox::OnLeftDown(wxMouseEvent& event)
{
wxVListBox::OnLeftDown(event);
{
styleName = para->GetAttributes().GetListStyleName();
}
-
+
return styleName;
}
const wxSize& size, long style)
{
wxControl::Create(parent, id, pos, size, style);
-
+
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
-
- m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
-
- wxArrayString choices;
- choices.Add(_("All styles"));
- choices.Add(_("Paragraph styles"));
- choices.Add(_("Character styles"));
- choices.Add(_("List styles"));
-
- m_styleChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
-
+ if (size != wxDefaultSize)
+ SetInitialSize(size);
+
+ bool showSelector = ((style & wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR) == 0);
+
+ m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, showSelector ? wxSIMPLE_BORDER : wxNO_BORDER);
+
wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL);
- boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 5);
- boxSizer->Add(m_styleChoice, 0, wxALL|wxEXPAND, 5);
-
- SetSizer(boxSizer);
+
+ if (showSelector)
+ {
+ wxArrayString choices;
+ choices.Add(_("All styles"));
+ choices.Add(_("Paragraph styles"));
+ choices.Add(_("Character styles"));
+ choices.Add(_("List styles"));
+
+ m_styleChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
+
+ boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 5);
+ boxSizer->Add(m_styleChoice, 0, wxALL|wxEXPAND, 5);
+ }
+ else
+ {
+ boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 0);
+ }
+
+ SetSizer(boxSizer);
+ Layout();
m_dontUpdate = true;
-
- int i = StyleTypeToIndex(m_styleListBox->GetStyleType());
- m_styleChoice->SetSelection(i);
-
+
+ if (m_styleChoice)
+ {
+ int i = StyleTypeToIndex(m_styleListBox->GetStyleType());
+ m_styleChoice->SetSelection(i);
+ }
+
m_dontUpdate = false;
-
+
return true;
}
wxRichTextStyleListCtrl::~wxRichTextStyleListCtrl()
{
+
}
/// React to style type choice
{
if (m_dontUpdate)
return;
-
+
wxRichTextStyleListBox::wxRichTextStyleType styleType = StyleIndexToType(event.GetSelection());
m_styleListBox->SetStyleType(styleType);
}
m_dontUpdate = true;
if (m_styleChoice)
- {
+ {
int i = StyleTypeToIndex(m_styleListBox->GetStyleType());
m_styleChoice->SetSelection(i);
}
-
+
m_dontUpdate = false;
}
void wxRichTextStyleListCtrl::UpdateStyles()
{
if (m_styleListBox)
- m_styleListBox->UpdateStyles();
+ m_styleListBox->UpdateStyles();
}
#if wxUSE_COMBOCTRL
if (GetRichTextCtrl() && !IsPopupShown() && m_stylePopup && wxWindow::FindFocus() != this)
{
wxString styleName = wxRichTextStyleListBox::GetStyleToShowInIdleTime(GetRichTextCtrl(), m_stylePopup->GetStyleType());
-
+
wxString currentValue = GetValue();
if (!styleName.IsEmpty())
{
#endif
// wxUSE_RICHTEXT
-