Correction to style code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43725 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-11-30 14:52:36 +00:00
parent 07b2748093
commit 3706bae03e

View File

@@ -401,7 +401,7 @@ bool wxRichTextStyleSheet::AddStyle(wxRichTextStyleDefinition* def)
wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition); wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
if (charDef) if (charDef)
return AddCharacterStyle(charDef); return AddCharacterStyle(charDef);
return false; return false;
} }
@@ -419,8 +419,8 @@ wxRichTextStyleDefinition* wxRichTextStyleSheet::FindStyle(const wxString& name,
wxRichTextCharacterStyleDefinition* charDef = FindCharacterStyle(name, recurse); wxRichTextCharacterStyleDefinition* charDef = FindCharacterStyle(name, recurse);
if (charDef) if (charDef)
return charDef; return charDef;
return NULL; return NULL;
} }
/// Copy /// Copy
@@ -447,7 +447,7 @@ void wxRichTextStyleSheet::Copy(const wxRichTextStyleSheet& sheet)
wxRichTextListStyleDefinition* def = (wxRichTextListStyleDefinition*) node->GetData(); wxRichTextListStyleDefinition* def = (wxRichTextListStyleDefinition*) node->GetData();
AddListStyle(new wxRichTextListStyleDefinition(*def)); AddListStyle(new wxRichTextListStyleDefinition(*def));
} }
SetName(sheet.GetName()); SetName(sheet.GetName());
SetDescription(sheet.GetDescription()); SetDescription(sheet.GetDescription());
} }
@@ -508,7 +508,7 @@ wxRichTextStyleDefinition* wxRichTextStyleListBox::GetStyle(size_t i) const
{ {
if (!GetStyleSheet()) if (!GetStyleSheet())
return NULL; return NULL;
if (i >= m_styleNames.GetCount() || i < 0) if (i >= m_styleNames.GetCount() || i < 0)
return NULL; return NULL;
@@ -521,9 +521,9 @@ void wxRichTextStyleListBox::UpdateStyles()
if (GetStyleSheet()) if (GetStyleSheet())
{ {
SetSelection(wxNOT_FOUND); SetSelection(wxNOT_FOUND);
m_styleNames.Clear(); m_styleNames.Clear();
size_t i; size_t i;
if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH) if (GetStyleType() == wxRICHTEXT_STYLE_ALL || GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH)
{ {
@@ -540,7 +540,7 @@ void wxRichTextStyleListBox::UpdateStyles()
for (i = 0; i < GetStyleSheet()->GetListStyleCount(); i++) for (i = 0; i < GetStyleSheet()->GetListStyleCount(); i++)
m_styleNames.Add(GetStyleSheet()->GetListStyle(i)->GetName()); m_styleNames.Add(GetStyleSheet()->GetListStyle(i)->GetName());
} }
m_styleNames.Sort(); m_styleNames.Sort();
SetItemCount(m_styleNames.GetCount()); SetItemCount(m_styleNames.GetCount());
@@ -589,7 +589,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
wxString str; wxString str;
bool isCentred = false; bool isCentred = false;
wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet())); wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE) if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
@@ -598,7 +598,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
if (isCentred) if (isCentred)
str << wxT("<center>"); str << wxT("<center>");
str << wxT("<table><tr>"); str << wxT("<table><tr>");
if (attr.GetLeftIndent() > 0) if (attr.GetLeftIndent() > 0)
@@ -722,15 +722,20 @@ wxString wxRichTextStyleListBox::GetStyleToShowInIdleTime(wxRichTextCtrl* ctrl,
// Take into account current default style just chosen by user // Take into account current default style just chosen by user
if (ctrl->IsDefaultStyleShowing()) if (ctrl->IsDefaultStyleShowing())
{ {
wxTextAttrEx attr;
ctrl->GetStyle(adjustedCaretPos, attr);
wxRichTextApplyStyle(attr, ctrl->GetDefaultStyleEx());
if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_CHARACTER) && if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_CHARACTER) &&
!ctrl->GetDefaultStyleEx().GetCharacterStyleName().IsEmpty()) !attr.GetCharacterStyleName().IsEmpty())
styleName = ctrl->GetDefaultStyleEx().GetCharacterStyleName(); styleName = attr.GetCharacterStyleName();
else if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_PARAGRAPH) && else if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_PARAGRAPH) &&
!ctrl->GetDefaultStyleEx().GetParagraphStyleName().IsEmpty()) !attr.GetParagraphStyleName().IsEmpty())
styleName = ctrl->GetDefaultStyleEx().GetParagraphStyleName(); styleName = attr.GetParagraphStyleName();
else if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_LIST) && else if ((styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_LIST) &&
!ctrl->GetDefaultStyleEx().GetListStyleName().IsEmpty()) !attr.GetListStyleName().IsEmpty())
styleName = ctrl->GetDefaultStyleEx().GetListStyleName(); styleName = attr.GetListStyleName();
} }
else if (obj && (styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_CHARACTER) && else if (obj && (styleType == wxRICHTEXT_STYLE_ALL || styleType == wxRICHTEXT_STYLE_CHARACTER) &&
!obj->GetAttributes().GetCharacterStyleName().IsEmpty()) !obj->GetAttributes().GetCharacterStyleName().IsEmpty())