// to change its style independently.
flags |= wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY;
}
- else
+ else if (def->IsKindOf(CLASSINFO(wxRichTextCharacterStyleDefinition)))
attr.SetCharacterStyleName(def->GetName());
+ else if (def->IsKindOf(CLASSINFO(wxRichTextBoxStyleDefinition)))
+ attr.GetTextBoxAttr().SetBoxStyleName(def->GetName());
- if (HasSelection())
+ if (def->IsKindOf(CLASSINFO(wxRichTextBoxStyleDefinition)))
+ {
+ if (GetFocusObject() && (GetFocusObject() != & GetBuffer()))
+ {
+ SetStyle(GetFocusObject(), attr);
+ return true;
+ }
+ else
+ return false;
+ }
+ else if (HasSelection())
return SetStyleEx(GetSelectionRange(), attr, flags);
else
{
}
// Apply attributes to the object being edited, if any
-bool wxRichTextFormattingDialog::ApplyStyle(wxRichTextCtrl* WXUNUSED(ctrl), int flags)
+bool wxRichTextFormattingDialog::ApplyStyle(wxRichTextCtrl* ctrl, int WXUNUSED(flags))
{
if (GetObject())
{
- wxRichTextParagraphLayoutBox* parentContainer = GetObject()->GetParentContainer();
- if (parentContainer)
- parentContainer->SetStyle(GetObject(), m_attributes, flags);
+ ctrl->SetStyle(GetObject(), m_attributes);
return true;
}
else
ctrl = GetRichTextCtrl();
if (!ctrl)
return false;
- if (!ctrl->HasSelection())
- return false;
-
wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition);
- wxRichTextBoxStyleDefinition* boxDef = wxDynamicCast(def, wxRichTextBoxStyleDefinition);
- if (listDef && m_restartNumberingCtrl->GetValue())
+ if (listDef && m_restartNumberingCtrl->GetValue() && ctrl->HasSelection())
{
wxRichTextRange range = ctrl->GetSelectionRange();
return ctrl->SetListStyle(range, listDef, wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_RENUMBER);
}
- else if (boxDef)
- {
- if (!ctrl->GetFocusObject() || (ctrl->GetFocusObject() && (ctrl->GetFocusObject() == & ctrl->GetBuffer())))
- return false;
- ctrl->SetStyle(ctrl->GetFocusObject(), def->GetStyleMergedWithBase(m_stylesListBox->GetStyleSheet()));
- return true;
- }
else
{
return ctrl->ApplyStyle(def);