Style application fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42944 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1227,7 +1227,7 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
|
wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
|
||||||
wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
|
wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* paraStyle = NULL, wxTextAttrEx* charStyle = NULL);
|
||||||
virtual ~wxRichTextParagraph();
|
virtual ~wxRichTextParagraph();
|
||||||
wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); }
|
wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); }
|
||||||
|
|
||||||
@@ -1500,8 +1500,8 @@ public:
|
|||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextObject(parent) { }
|
wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextObject(parent) { }
|
||||||
wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL);
|
wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxTextAttrEx* charStyle = NULL);
|
||||||
wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL);
|
wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttrEx* charStyle = NULL);
|
||||||
wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject() { Copy(obj); }
|
wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject() { Copy(obj); }
|
||||||
|
|
||||||
// Overrideables
|
// Overrideables
|
||||||
@@ -2267,6 +2267,9 @@ WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const
|
|||||||
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
|
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
|
||||||
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
|
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
|
||||||
|
|
||||||
|
/// Split into paragraph and character styles
|
||||||
|
WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxTextAttrEx& style, wxTextAttrEx& parStyle, wxTextAttrEx& charStyle);
|
||||||
|
|
||||||
/// Compare tabs
|
/// Compare tabs
|
||||||
WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);
|
WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);
|
||||||
|
|
||||||
|
@@ -909,8 +909,12 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text,
|
|||||||
{
|
{
|
||||||
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
||||||
// Don't use the base style, just the default style, and the base style will
|
// Don't use the base style, just the default style, and the base style will
|
||||||
// be combined at display time
|
// be combined at display time.
|
||||||
wxTextAttrEx style(GetDefaultStyle());
|
// Divide into paragraph and character styles.
|
||||||
|
|
||||||
|
wxTextAttrEx defaultCharStyle;
|
||||||
|
wxTextAttrEx defaultParaStyle;
|
||||||
|
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
|
||||||
#else
|
#else
|
||||||
wxTextAttrEx style(GetAttributes());
|
wxTextAttrEx style(GetAttributes());
|
||||||
|
|
||||||
@@ -918,10 +922,14 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text,
|
|||||||
// then the attributes will remain the 'basic style' (i.e. the
|
// then the attributes will remain the 'basic style' (i.e. the
|
||||||
// layout box's style).
|
// layout box's style).
|
||||||
wxRichTextApplyStyle(style, GetDefaultStyle());
|
wxRichTextApplyStyle(style, GetDefaultStyle());
|
||||||
|
|
||||||
|
wxTextAttrEx defaultCharStyle = style;
|
||||||
|
wxTextAttrEx defaultParaStyle = style;
|
||||||
#endif
|
#endif
|
||||||
wxRichTextParagraph* para = new wxRichTextParagraph(text, this, & style);
|
wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle;
|
||||||
if (paraStyle)
|
wxTextAttrEx* cStyle = & defaultCharStyle;
|
||||||
para->SetAttributes(*paraStyle);
|
|
||||||
|
wxRichTextParagraph* para = new wxRichTextParagraph(text, this, pStyle, cStyle);
|
||||||
|
|
||||||
AppendChild(para);
|
AppendChild(para);
|
||||||
|
|
||||||
@@ -936,23 +944,27 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
|
|||||||
{
|
{
|
||||||
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
||||||
// Don't use the base style, just the default style, and the base style will
|
// Don't use the base style, just the default style, and the base style will
|
||||||
// be combined at display time
|
// be combined at display time.
|
||||||
wxTextAttrEx style(GetDefaultStyle());
|
// Divide into paragraph and character styles.
|
||||||
|
|
||||||
|
wxTextAttrEx defaultCharStyle;
|
||||||
|
wxTextAttrEx defaultParaStyle;
|
||||||
|
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
|
||||||
#else
|
#else
|
||||||
wxTextAttrEx style(GetAttributes());
|
wxTextAttrEx style(GetAttributes());
|
||||||
|
|
||||||
//wxLogDebug("Initial style = %s", style.GetFont().GetFaceName());
|
|
||||||
//wxLogDebug("Initial size = %d", style.GetFont().GetPointSize());
|
|
||||||
|
|
||||||
// Apply default style. If the style has no attributes set,
|
// Apply default style. If the style has no attributes set,
|
||||||
// then the attributes will remain the 'basic style' (i.e. the
|
// then the attributes will remain the 'basic style' (i.e. the
|
||||||
// layout box's style).
|
// layout box's style).
|
||||||
wxRichTextApplyStyle(style, GetDefaultStyle());
|
wxRichTextApplyStyle(style, GetDefaultStyle());
|
||||||
|
|
||||||
//wxLogDebug("Style after applying default style = %s", style.GetFont().GetFaceName());
|
wxTextAttrEx defaultCharStyle = style;
|
||||||
//wxLogDebug("Size after applying default style = %d", style.GetFont().GetPointSize());
|
wxTextAttrEx defaultParaStyle = style;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle;
|
||||||
|
wxTextAttrEx* cStyle = & defaultCharStyle;
|
||||||
|
|
||||||
wxRichTextParagraph* firstPara = NULL;
|
wxRichTextParagraph* firstPara = NULL;
|
||||||
wxRichTextParagraph* lastPara = NULL;
|
wxRichTextParagraph* lastPara = NULL;
|
||||||
|
|
||||||
@@ -961,9 +973,7 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
|
|||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
size_t len = text.length();
|
size_t len = text.length();
|
||||||
wxString line;
|
wxString line;
|
||||||
wxRichTextParagraph* para = new wxRichTextParagraph(wxEmptyString, this, & style);
|
wxRichTextParagraph* para = new wxRichTextParagraph(wxEmptyString, this, pStyle, cStyle);
|
||||||
if (paraStyle)
|
|
||||||
para->SetAttributes(*paraStyle);
|
|
||||||
|
|
||||||
AppendChild(para);
|
AppendChild(para);
|
||||||
|
|
||||||
@@ -978,15 +988,10 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
|
|||||||
wxRichTextPlainText* plainText = (wxRichTextPlainText*) para->GetChildren().GetFirst()->GetData();
|
wxRichTextPlainText* plainText = (wxRichTextPlainText*) para->GetChildren().GetFirst()->GetData();
|
||||||
plainText->SetText(line);
|
plainText->SetText(line);
|
||||||
|
|
||||||
para = new wxRichTextParagraph(wxEmptyString, this, & style);
|
para = new wxRichTextParagraph(wxEmptyString, this, pStyle, cStyle);
|
||||||
if (paraStyle)
|
|
||||||
para->SetAttributes(*paraStyle);
|
|
||||||
|
|
||||||
AppendChild(para);
|
AppendChild(para);
|
||||||
|
|
||||||
//if (!firstPara)
|
|
||||||
// firstPara = para;
|
|
||||||
|
|
||||||
lastPara = para;
|
lastPara = para;
|
||||||
line = wxEmptyString;
|
line = wxEmptyString;
|
||||||
}
|
}
|
||||||
@@ -1002,18 +1007,6 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
|
|||||||
plainText->SetText(line);
|
plainText->SetText(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (firstPara)
|
|
||||||
range.SetStart(firstPara->GetRange().GetStart());
|
|
||||||
else if (lastPara)
|
|
||||||
range.SetStart(lastPara->GetRange().GetStart());
|
|
||||||
|
|
||||||
if (lastPara)
|
|
||||||
range.SetEnd(lastPara->GetRange().GetEnd());
|
|
||||||
else if (firstPara)
|
|
||||||
range.SetEnd(firstPara->GetRange().GetEnd());
|
|
||||||
*/
|
|
||||||
|
|
||||||
UpdateRanges();
|
UpdateRanges();
|
||||||
|
|
||||||
SetDirty(false);
|
SetDirty(false);
|
||||||
@@ -1026,8 +1019,12 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxT
|
|||||||
{
|
{
|
||||||
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
||||||
// Don't use the base style, just the default style, and the base style will
|
// Don't use the base style, just the default style, and the base style will
|
||||||
// be combined at display time
|
// be combined at display time.
|
||||||
wxTextAttrEx style(GetDefaultStyle());
|
// Divide into paragraph and character styles.
|
||||||
|
|
||||||
|
wxTextAttrEx defaultCharStyle;
|
||||||
|
wxTextAttrEx defaultParaStyle;
|
||||||
|
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
|
||||||
#else
|
#else
|
||||||
wxTextAttrEx style(GetAttributes());
|
wxTextAttrEx style(GetAttributes());
|
||||||
|
|
||||||
@@ -1035,14 +1032,17 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxT
|
|||||||
// then the attributes will remain the 'basic style' (i.e. the
|
// then the attributes will remain the 'basic style' (i.e. the
|
||||||
// layout box's style).
|
// layout box's style).
|
||||||
wxRichTextApplyStyle(style, GetDefaultStyle());
|
wxRichTextApplyStyle(style, GetDefaultStyle());
|
||||||
|
|
||||||
|
wxTextAttrEx defaultCharStyle = style;
|
||||||
|
wxTextAttrEx defaultParaStyle = style;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxRichTextParagraph* para = new wxRichTextParagraph(this, & style);
|
wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle;
|
||||||
AppendChild(para);
|
wxTextAttrEx* cStyle = & defaultCharStyle;
|
||||||
para->AppendChild(new wxRichTextImage(image, this));
|
|
||||||
|
|
||||||
if (paraStyle)
|
wxRichTextParagraph* para = new wxRichTextParagraph(this, pStyle);
|
||||||
para->SetAttributes(*paraStyle);
|
AppendChild(para);
|
||||||
|
para->AppendChild(new wxRichTextImage(image, this, cStyle));
|
||||||
|
|
||||||
UpdateRanges();
|
UpdateRanges();
|
||||||
SetDirty(true);
|
SetDirty(true);
|
||||||
@@ -1054,8 +1054,6 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxT
|
|||||||
/// Insert fragment into this box at the given position. If partialParagraph is true,
|
/// Insert fragment into this box at the given position. If partialParagraph is true,
|
||||||
/// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
|
/// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
|
||||||
/// marker.
|
/// marker.
|
||||||
/// TODO: if fragment is inserted inside styled fragment, must apply that style to
|
|
||||||
/// to the data (if it has a default style, anyway).
|
|
||||||
|
|
||||||
bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParagraphLayoutBox& fragment)
|
bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParagraphLayoutBox& fragment)
|
||||||
{
|
{
|
||||||
@@ -1085,6 +1083,11 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
|
|||||||
wxRichTextParagraph* firstPara = wxDynamicCast(firstParaNode->GetData(), wxRichTextParagraph);
|
wxRichTextParagraph* firstPara = wxDynamicCast(firstParaNode->GetData(), wxRichTextParagraph);
|
||||||
wxASSERT (firstPara != NULL);
|
wxASSERT (firstPara != NULL);
|
||||||
|
|
||||||
|
// Apply the new paragraph attributes to the existing paragraph
|
||||||
|
wxTextAttrEx attr(para->GetAttributes());
|
||||||
|
wxRichTextApplyStyle(attr, firstPara->GetAttributes());
|
||||||
|
para->SetAttributes(attr);
|
||||||
|
|
||||||
wxRichTextObjectList::compatibility_iterator objectNode = firstPara->GetChildren().GetFirst();
|
wxRichTextObjectList::compatibility_iterator objectNode = firstPara->GetChildren().GetFirst();
|
||||||
while (objectNode)
|
while (objectNode)
|
||||||
{
|
{
|
||||||
@@ -1191,9 +1194,6 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
|
|||||||
if (finalPara->GetChildCount() == 0)
|
if (finalPara->GetChildCount() == 0)
|
||||||
{
|
{
|
||||||
wxRichTextPlainText* text = new wxRichTextPlainText(wxEmptyString);
|
wxRichTextPlainText* text = new wxRichTextPlainText(wxEmptyString);
|
||||||
#if !wxRICHTEXT_USE_DYNAMIC_STYLES
|
|
||||||
text->SetAttributes(finalPara->GetAttributes());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
finalPara->AppendChild(text);
|
finalPara->AppendChild(text);
|
||||||
}
|
}
|
||||||
@@ -2297,19 +2297,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range
|
|||||||
/// Set default style
|
/// Set default style
|
||||||
bool wxRichTextParagraphLayoutBox::SetDefaultStyle(const wxTextAttrEx& style)
|
bool wxRichTextParagraphLayoutBox::SetDefaultStyle(const wxTextAttrEx& style)
|
||||||
{
|
{
|
||||||
// I don't think the default style should be combined with the previous
|
|
||||||
// default style.
|
|
||||||
m_defaultAttributes = style;
|
m_defaultAttributes = style;
|
||||||
|
|
||||||
#if 0
|
|
||||||
// keep the old attributes if the new style doesn't specify them unless the
|
|
||||||
// new style is empty - then reset m_defaultStyle (as there is no other way
|
|
||||||
// to do it)
|
|
||||||
if ( style.IsDefault() )
|
|
||||||
m_defaultAttributes = style;
|
|
||||||
else
|
|
||||||
m_defaultAttributes = wxTextAttrEx::CombineEx(style, m_defaultAttributes, NULL);
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2915,13 +2903,6 @@ bool wxRichTextParagraphLayoutBox::PromoteList(int promoteBy, const wxRichTextRa
|
|||||||
/// position of the paragraph that it had to start looking from.
|
/// position of the paragraph that it had to start looking from.
|
||||||
bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const
|
bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
wxRichTextObjectList::compatibility_iterator node = m_children.Find(previousParagraph);
|
|
||||||
|
|
||||||
if (!node)
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE)
|
if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -2985,21 +2966,17 @@ wxArrayInt wxRichTextParagraph::sm_defaultTabs;
|
|||||||
wxRichTextParagraph::wxRichTextParagraph(wxRichTextObject* parent, wxTextAttrEx* style):
|
wxRichTextParagraph::wxRichTextParagraph(wxRichTextObject* parent, wxTextAttrEx* style):
|
||||||
wxRichTextBox(parent)
|
wxRichTextBox(parent)
|
||||||
{
|
{
|
||||||
if (parent && !style)
|
|
||||||
SetAttributes(parent->GetAttributes());
|
|
||||||
if (style)
|
if (style)
|
||||||
SetAttributes(*style);
|
SetAttributes(*style);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRichTextParagraph::wxRichTextParagraph(const wxString& text, wxRichTextObject* parent, wxTextAttrEx* style):
|
wxRichTextParagraph::wxRichTextParagraph(const wxString& text, wxRichTextObject* parent, wxTextAttrEx* paraStyle, wxTextAttrEx* charStyle):
|
||||||
wxRichTextBox(parent)
|
wxRichTextBox(parent)
|
||||||
{
|
{
|
||||||
if (parent && !style)
|
if (paraStyle)
|
||||||
SetAttributes(parent->GetAttributes());
|
SetAttributes(*paraStyle);
|
||||||
if (style)
|
|
||||||
SetAttributes(*style);
|
|
||||||
|
|
||||||
AppendChild(new wxRichTextPlainText(text, this));
|
AppendChild(new wxRichTextPlainText(text, this, charStyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRichTextParagraph::~wxRichTextParagraph()
|
wxRichTextParagraph::~wxRichTextParagraph()
|
||||||
@@ -4105,8 +4082,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextPlainText, wxRichTextObject)
|
|||||||
wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject* parent, wxTextAttrEx* style):
|
wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject* parent, wxTextAttrEx* style):
|
||||||
wxRichTextObject(parent)
|
wxRichTextObject(parent)
|
||||||
{
|
{
|
||||||
if (parent && !style)
|
|
||||||
SetAttributes(parent->GetAttributes());
|
|
||||||
if (style)
|
if (style)
|
||||||
SetAttributes(*style);
|
SetAttributes(*style);
|
||||||
|
|
||||||
@@ -4609,6 +4584,13 @@ bool wxRichTextBuffer::InsertParagraphsWithUndo(long pos, const wxRichTextParagr
|
|||||||
{
|
{
|
||||||
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false);
|
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false);
|
||||||
|
|
||||||
|
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
||||||
|
wxTextAttrEx attr(GetDefaultStyle());
|
||||||
|
#else
|
||||||
|
wxTextAttrEx attr(GetBasicStyle());
|
||||||
|
wxRichTextApplyStyle(attr, GetDefaultStyle());
|
||||||
|
#endif
|
||||||
|
|
||||||
wxTextAttrEx* p = NULL;
|
wxTextAttrEx* p = NULL;
|
||||||
wxTextAttrEx paraAttr;
|
wxTextAttrEx paraAttr;
|
||||||
if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
|
if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
|
||||||
@@ -4617,13 +4599,8 @@ bool wxRichTextBuffer::InsertParagraphsWithUndo(long pos, const wxRichTextParagr
|
|||||||
if (!paraAttr.IsDefault())
|
if (!paraAttr.IsDefault())
|
||||||
p = & paraAttr;
|
p = & paraAttr;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
p = & attr;
|
||||||
wxTextAttrEx attr(GetDefaultStyle());
|
|
||||||
#else
|
|
||||||
wxTextAttrEx attr(GetBasicStyle());
|
|
||||||
wxRichTextApplyStyle(attr, GetDefaultStyle());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
action->GetNewParagraphs() = paragraphs;
|
action->GetNewParagraphs() = paragraphs;
|
||||||
|
|
||||||
@@ -4662,13 +4639,6 @@ bool wxRichTextBuffer::InsertTextWithUndo(long pos, const wxString& text, wxRich
|
|||||||
p = & paraAttr;
|
p = & paraAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxRICHTEXT_USE_DYNAMIC_STYLES
|
|
||||||
wxTextAttrEx attr(GetDefaultStyle());
|
|
||||||
#else
|
|
||||||
wxTextAttrEx attr(GetBasicStyle());
|
|
||||||
wxRichTextApplyStyle(attr, GetDefaultStyle());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
action->GetNewParagraphs().AddParagraphs(text, p);
|
action->GetNewParagraphs().AddParagraphs(text, p);
|
||||||
|
|
||||||
int length = action->GetNewParagraphs().GetRange().GetLength();
|
int length = action->GetNewParagraphs().GetRange().GetLength();
|
||||||
@@ -6234,17 +6204,21 @@ bool wxRichTextRange::LimitTo(const wxRichTextRange& range)
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxRichTextImage, wxRichTextObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxRichTextImage, wxRichTextObject)
|
||||||
|
|
||||||
wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent):
|
wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent, wxTextAttrEx* charStyle):
|
||||||
wxRichTextObject(parent)
|
wxRichTextObject(parent)
|
||||||
{
|
{
|
||||||
m_image = image;
|
m_image = image;
|
||||||
|
if (charStyle)
|
||||||
|
SetAttributes(*charStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRichTextImage::wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent):
|
wxRichTextImage::wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent, wxTextAttrEx* charStyle):
|
||||||
wxRichTextObject(parent)
|
wxRichTextObject(parent)
|
||||||
{
|
{
|
||||||
m_imageBlock = imageBlock;
|
m_imageBlock = imageBlock;
|
||||||
m_imageBlock.Load(m_image);
|
m_imageBlock.Load(m_image);
|
||||||
|
if (charStyle)
|
||||||
|
SetAttributes(*charStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load wxImage from the block
|
/// Load wxImage from the block
|
||||||
@@ -6907,6 +6881,20 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Split into paragraph and character styles
|
||||||
|
bool wxRichTextSplitParaCharStyles(const wxTextAttrEx& style, wxTextAttrEx& parStyle, wxTextAttrEx& charStyle)
|
||||||
|
{
|
||||||
|
wxTextAttrEx defaultCharStyle1(style);
|
||||||
|
wxTextAttrEx defaultParaStyle1(style);
|
||||||
|
defaultCharStyle1.SetFlags(defaultCharStyle1.GetFlags()&wxTEXT_ATTR_CHARACTER);
|
||||||
|
defaultParaStyle1.SetFlags(defaultParaStyle1.GetFlags()&wxTEXT_ATTR_PARAGRAPH);
|
||||||
|
|
||||||
|
wxRichTextApplyStyle(charStyle, defaultCharStyle1);
|
||||||
|
wxRichTextApplyStyle(parStyle, defaultParaStyle1);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void wxSetFontPreservingStyles(wxTextAttr& attr, const wxFont& font)
|
void wxSetFontPreservingStyles(wxTextAttr& attr, const wxFont& font)
|
||||||
{
|
{
|
||||||
long flags = attr.GetFlags();
|
long flags = attr.GetFlags();
|
||||||
|
Reference in New Issue
Block a user