documentation for wxAppTraits (patch 1518295 from Francesco)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43576 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-07-24 18:20:18 +00:00
parent cb349f69fa
commit 336d8ae9a3
13 changed files with 408 additions and 232 deletions

View File

@@ -155,11 +155,22 @@ Of these, only wxTEXT\_ATTR\_EFFECT\_CAPITALS and wxTEXT\_ATTR\_EFFECT\_STRIKETH
Constructors. Constructors.
\membersection{wxRichTextAttr::CopyTo}\label{wxrichtextattrcopyto} \membersection{wxRichTextAttr::Apply}\label{wxrichtextattrapply}
\constfunc{void}{CopyTo}{\param{wxTextAttrEx\& }{attr}} \func{bool}{Combine}{\param{const wxRichTextAttrEx\& }{style}, \param{const wxRichTextAttrEx* }{compareWith = NULL}}
Copies the wxRichTextAttr attributes to a \helpref{wxTextAttrEx}{wxtextattrex} object. Applies the attributes in {\it style} to the original object, but not those attributes from {\it style} that are the same as those in {\it compareWith} (if passed).
See also \helpref{wxRichTextAttr::Combine}{wxrichtextattrcombine} for a function that does almost the same but returns a new object instead of modifying the original object.
\membersection{wxRichTextAttr::Combine}\label{wxrichtextattrcombine}
\constfunc{wxRichTextAttr}{Combine}{\param{const wxRichTextAttrEx\& }{style}, \param{const wxRichTextAttrEx* }{compareWith = NULL}}
Combines 'this' with {\it style}, but not applying attributes from {\it style} that are the same as those in {\it compareWith} (if passed).
A wxRichTextAttr object is returned and the original object is not changed.
See also \helpref{wxRichTextAttr::Apply}{wxrichtextattrapply} for a function that does almost the same but modifies the original object instead of returning a new one.
\membersection{wxRichTextAttr::CreateFont}\label{wxrichtextattrcreatefont} \membersection{wxRichTextAttr::CreateFont}\label{wxrichtextattrcreatefont}
@@ -404,9 +415,9 @@ Returns \true if the attribute object specifies bullet text (usually specifying
Returns \true if the attribute object specifies a character style name. Returns \true if the attribute object specifies a character style name.
\membersection{wxRichTextAttr::HasFaceName}\label{wxrichtextattrhasfacename} \membersection{wxRichTextAttr::HasFontFaceName}\label{wxrichtextattrhasfontfacename}
\constfunc{bool}{HasFaceName}{\void} \constfunc{bool}{HasFontFaceName}{\void}
Returns \true if the attribute object specifies a font face name. Returns \true if the attribute object specifies a font face name.
@@ -422,9 +433,9 @@ Returns \true if the {\it flag} is present in the attribute object's flag bitlis
Returns \true if the attribute object specifies any font attributes. Returns \true if the attribute object specifies any font attributes.
\membersection{wxRichTextAttr::HasItalic}\label{wxrichtextattrhasitalic} \membersection{wxRichTextAttr::HasFontItalic}\label{wxrichtextattrhasfontitalic}
\constfunc{bool}{HasItalic}{\void} \constfunc{bool}{HasFontItalic}{\void}
Returns \true if the attribute object specifies italic style. Returns \true if the attribute object specifies italic style.
@@ -482,9 +493,9 @@ Returns \true if the attribute object specifies a paragraph style name.
Returns \true if the attribute object specifies a right indent. Returns \true if the attribute object specifies a right indent.
\membersection{wxRichTextAttr::HasSize}\label{wxrichtextattrhassize} \membersection{wxRichTextAttr::HasFontSize}\label{wxrichtextattrhasfontsize}
\constfunc{bool}{HasSize}{\void} \constfunc{bool}{HasFontSize}{\void}
Returns \true if the attribute object specifies a font point size. Returns \true if the attribute object specifies a font point size.
@@ -506,9 +517,9 @@ Returns \true if the attribute object specifies a text foreground colour.
Returns \true if the attribute object specifies text effects. Returns \true if the attribute object specifies text effects.
\membersection{wxRichTextAttr::HasUnderlined}\label{wxrichtextattrhasunderlined} \membersection{wxRichTextAttr::HasFontUnderlined}\label{wxrichtextattrhasfontunderlined}
\constfunc{bool}{HasUnderlined}{\void} \constfunc{bool}{HasFontUnderlined}{\void}
Returns \true if the attribute object specifies either underlining or no underlining. Returns \true if the attribute object specifies either underlining or no underlining.
@@ -518,18 +529,12 @@ Returns \true if the attribute object specifies either underlining or no underli
Returns \true if the attribute object specifies a URL. Returns \true if the attribute object specifies a URL.
\membersection{wxRichTextAttr::HasWeight}\label{wxrichtextattrhasweight} \membersection{wxRichTextAttr::HasFontWeight}\label{wxrichtextattrhasfontweight}
\constfunc{bool}{HasWeight}{\void} \constfunc{bool}{HasFontWeight}{\void}
Returns \true if the attribute object specifies font weight (bold, light or normal). Returns \true if the attribute object specifies font weight (bold, light or normal).
\membersection{wxRichTextAttr::Init}\label{wxrichtextattrinit}
\func{void}{Init}{\void}
Initialise the object.
\membersection{wxRichTextAttr::IsCharacterStyle}\label{wxrichtextattrischaracterstyle} \membersection{wxRichTextAttr::IsCharacterStyle}\label{wxrichtextattrischaracterstyle}
\constfunc{bool}{IsCharacterStyle}{\void} \constfunc{bool}{IsCharacterStyle}{\void}

View File

@@ -37,9 +37,10 @@ Destructor.
\membersection{wxRichTextListStyleDefinition::CombineWithParagraphStyle}\label{wxrichtextliststyledefinitioncombinewithparagraphstyle} \membersection{wxRichTextListStyleDefinition::CombineWithParagraphStyle}\label{wxrichtextliststyledefinitioncombinewithparagraphstyle}
\func{wxRichTextAttr}{CombineWithParagraphStyle}{\param{int }{indent}, \param{const wxRichTextAttr\&}{ paraStyle}} \func{wxRichTextAttr}{CombineWithParagraphStyle}{\param{int }{indent}, \param{const wxRichTextAttr\&}{ paraStyle}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}}
This function combines the given paragraph style with the list style's base attributes and level style matching the given indent, returning the combined attributes. This function combines the given paragraph style with the list style's base attributes and level style matching the given indent, returning the combined attributes.
If {\it styleSheet} is specified, the base style for this definition will also be included in the result.
\membersection{wxRichTextListStyleDefinition::FindLevelForIndent}\label{wxrichtextliststyledefinitionfindlevelforindent} \membersection{wxRichTextListStyleDefinition::FindLevelForIndent}\label{wxrichtextliststyledefinitionfindlevelforindent}
@@ -49,9 +50,17 @@ This function finds the level (from 0 to 9) whose indentation attribute mostly c
\membersection{wxRichTextListStyleDefinition::GetCombinedStyle}\label{wxrichtextliststyledefinitioncombinewithparagraphstyle} \membersection{wxRichTextListStyleDefinition::GetCombinedStyle}\label{wxrichtextliststyledefinitioncombinewithparagraphstyle}
\constfunc{wxRichTextAttr}{GetCombinedStyle}{\param{int }{indent}} \constfunc{wxRichTextAttr}{GetCombinedStyle}{\param{int }{indent}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}}
This function combines the list style's base attributes and the level style matching the given indent, returning the combined attributes. This function combines the list style's base attributes and the level style matching the given indent, returning the combined attributes.
If {\it styleSheet} is specified, the base style for this definition will also be included in the result.
\membersection{wxRichTextListStyleDefinition::GetCombinedStyleForLevel}\label{wxrichtextliststyledefinitioncombinewithparagraphstyleforlevel}
\constfunc{wxRichTextAttr}{GetCombinedStyleLevel}{\param{int }{level}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}}
This function combines the list style's base attributes and the style for the specified level, returning the combined attributes.
If {\it styleSheet} is specified, the base style for this definition will also be included in the result.
\membersection{wxRichTextListStyleDefinition::GetLevelAttributes}\label{wxrichtextliststyledefinitiongetlevelattributes} \membersection{wxRichTextListStyleDefinition::GetLevelAttributes}\label{wxrichtextliststyledefinitiongetlevelattributes}

View File

@@ -52,11 +52,11 @@ Returns the style name.
Returns the attributes associated with this style. Returns the attributes associated with this style.
\membersection{wxRichTextStyleDefinition::Init}\label{wxrichtextstyledefinitioninit} \membersection{wxRichTextStyleDefinition::GetStyleMergedWithBase}\label{wxrichtextstyledefinitiongetstylemergedwithbase}
\func{void}{Init}{\void} \constfunc{wxRichTextAttr}{GetStyleMergedWithBase}{\param{wxRichTextStyleSheet*}{ sheet}}
Initialises the definition. Returns the style attributes combined with the attributes of the specified base style, if any. This function works recursively.
\membersection{wxRichTextStyleDefinition::SetBaseStyle}\label{wxrichtextstyledefinitionsetbasestyle} \membersection{wxRichTextStyleDefinition::SetBaseStyle}\label{wxrichtextstyledefinitionsetbasestyle}

View File

@@ -49,6 +49,12 @@ Adds a definition to the list style list.
Adds a definition to the paragraph style list. Adds a definition to the paragraph style list.
\membersection{wxRichTextStyleSheet::AddStyle}\label{wxrichtextstylesheetaddstyle}
\func{bool}{AddStyle}{\param{wxRichTextStyleDefinition* }{def}}
Adds a definition to the appropriate style list.
\membersection{wxRichTextStyleSheet::DeleteStyles}\label{wxrichtextstylesheetdeletestyles} \membersection{wxRichTextStyleSheet::DeleteStyles}\label{wxrichtextstylesheetdeletestyles}
\func{void}{DeleteStyles}{\void} \func{void}{DeleteStyles}{\void}
@@ -73,6 +79,12 @@ Finds a list definition by name.
Finds a paragraph definition by name. Finds a paragraph definition by name.
\membersection{wxRichTextStyleSheet::FindStyle}\label{wxrichtextstylesheetfindstyle}
\constfunc{wxRichTextStyleDefinition*}{FindStyle}{\param{const wxString\& }{name}}
Finds a style definition by name.
\membersection{wxRichTextStyleSheet::GetCharacterStyle}\label{wxrichtextstylesheetgetcharacterstyle} \membersection{wxRichTextStyleSheet::GetCharacterStyle}\label{wxrichtextstylesheetgetcharacterstyle}
\constfunc{wxRichTextCharacterStyleDefinition*}{GetCharacterStyle}{\param{size\_t }{n}} \constfunc{wxRichTextCharacterStyleDefinition*}{GetCharacterStyle}{\param{size\_t }{n}}
@@ -121,12 +133,6 @@ Returns the {\it n}th paragraph style.
Returns the number of paragraph styles. Returns the number of paragraph styles.
\membersection{wxRichTextStyleSheet::Init}\label{wxrichtextstylesheetinit}
\func{void}{Init}{\void}
Initialises the style sheet.
\membersection{wxRichTextStyleSheet::RemoveCharacterStyle}\label{wxrichtextstylesheetremovecharacterstyle} \membersection{wxRichTextStyleSheet::RemoveCharacterStyle}\label{wxrichtextstylesheetremovecharacterstyle}
\func{bool}{RemoveCharacterStyle}{\param{wxRichTextStyleDefinition* }{def}, \param{bool }{deleteStyle = false}} \func{bool}{RemoveCharacterStyle}{\param{wxRichTextStyleDefinition* }{def}, \param{bool }{deleteStyle = false}}
@@ -145,6 +151,12 @@ Removes a list style.
Removes a paragraph style. Removes a paragraph style.
\membersection{wxRichTextStyleSheet::RemoveStyle}\label{wxrichtextstylesheetremovestyle}
\func{bool}{RemoveStyle}{\param{wxRichTextStyleDefinition* }{def}, \param{bool }{deleteStyle = false}}
Removes a style.
\membersection{wxRichTextStyleSheet::SetDescription}\label{wxrichtextstylesheetsetdescription} \membersection{wxRichTextStyleSheet::SetDescription}\label{wxrichtextstylesheetsetdescription}
\func{void}{SetDescription}{\param{const wxString\& }{descr}} \func{void}{SetDescription}{\param{const wxString\& }{descr}}

View File

@@ -391,11 +391,11 @@ public:
int GetTextEffectFlags() const { return m_textEffectFlags; } int GetTextEffectFlags() const { return m_textEffectFlags; }
int GetOutlineLevel() const { return m_outlineLevel; } int GetOutlineLevel() const { return m_outlineLevel; }
bool HasWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; } bool HasFontWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
bool HasSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; } bool HasFontSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; }
bool HasItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; } bool HasFontItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; }
bool HasUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } bool HasFontUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; }
bool HasFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE) != 0; } bool HasFontFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE) != 0; }
bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); } bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); }
bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE); } bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE); }
@@ -566,11 +566,11 @@ public:
bool HasTabs() const { return (m_flags & wxTEXT_ATTR_TABS) != 0 ; } bool HasTabs() const { return (m_flags & wxTEXT_ATTR_TABS) != 0 ; }
bool HasLeftIndent() const { return (m_flags & wxTEXT_ATTR_LEFT_INDENT) != 0 ; } bool HasLeftIndent() const { return (m_flags & wxTEXT_ATTR_LEFT_INDENT) != 0 ; }
bool HasRightIndent() const { return (m_flags & wxTEXT_ATTR_RIGHT_INDENT) != 0 ; } bool HasRightIndent() const { return (m_flags & wxTEXT_ATTR_RIGHT_INDENT) != 0 ; }
bool HasWeight() const { return (m_flags & wxTEXT_ATTR_FONT_WEIGHT) != 0; } bool HasFontWeight() const { return (m_flags & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
bool HasSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; } bool HasFontSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; }
bool HasItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; } bool HasFontItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; }
bool HasUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } bool HasFontUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; }
bool HasFaceName() const { return (m_flags & wxTEXT_ATTR_FONT_FACE) != 0; } bool HasFontFaceName() const { return (m_flags & wxTEXT_ATTR_FONT_FACE) != 0; }
bool HasFont() const { return (m_flags & (wxTEXT_ATTR_FONT)) != 0; } bool HasFont() const { return (m_flags & (wxTEXT_ATTR_FONT)) != 0; }
bool HasParagraphSpacingAfter() const { return (m_flags & wxTEXT_ATTR_PARA_SPACING_AFTER) != 0; } bool HasParagraphSpacingAfter() const { return (m_flags & wxTEXT_ATTR_PARA_SPACING_AFTER) != 0; }
@@ -601,12 +601,16 @@ public:
return GetFlags() == 0; return GetFlags() == 0;
} }
// return the attribute having the valid font and colours: it uses the // Merges the given attributes. Does not affect 'this'. If compareWith
// attributes set in attr and falls back first to attrDefault and then to // is non-NULL, then it will be used to mask out those attributes that are the same in style
// the text control font/colours for those attributes which are not set // and compareWith, for situations where we don't want to explicitly set inherited attributes.
static wxRichTextAttr Combine(const wxRichTextAttr& attr, bool Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL);
const wxRichTextAttr& attrDef,
const wxTextCtrlBase *text); // Merges the given attributes and returns the result. Does not affect 'this'. If compareWith
// is non-NULL, then it will be used to mask out those attributes that are the same in style
// and compareWith, for situations where we don't want to explicitly set inherited attributes.
wxRichTextAttr Combine(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL) const;
private: private:
long m_flags; long m_flags;

View File

@@ -93,11 +93,14 @@ public:
void SetBaseStyle(const wxString& name) { m_baseStyle = name; } void SetBaseStyle(const wxString& name) { m_baseStyle = name; }
const wxString& GetBaseStyle() const { return m_baseStyle; } const wxString& GetBaseStyle() const { return m_baseStyle; }
/// Sets the style /// Sets and gets the style
void SetStyle(const wxRichTextAttr& style) { m_style = style; } void SetStyle(const wxRichTextAttr& style) { m_style = style; }
const wxRichTextAttr& GetStyle() const { return m_style; } const wxRichTextAttr& GetStyle() const { return m_style; }
wxRichTextAttr& GetStyle() { return m_style; } wxRichTextAttr& GetStyle() { return m_style; }
/// Gets the style combined with the base style
virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
protected: protected:
wxString m_name; wxString m_name;
wxString m_baseStyle; wxString m_baseStyle;
@@ -215,15 +218,15 @@ public:
/// Combine the base and list style with a paragraph style, using the given indent (from which /// Combine the base and list style with a paragraph style, using the given indent (from which
/// an appropriate level is found) /// an appropriate level is found)
wxRichTextAttr CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle); wxRichTextAttr CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet = NULL);
/// Combine the base and list style, using the given indent (from which /// Combine the base and list style, using the given indent (from which
/// an appropriate level is found) /// an appropriate level is found)
wxRichTextAttr GetCombinedStyle(int indent); wxRichTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL);
/// Combine the base and list style, using the given level from which /// Combine the base and list style, using the given level from which
/// an appropriate level is found) /// an appropriate level is found)
wxRichTextAttr GetCombinedStyleForLevel(int level); wxRichTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL);
/// Gets the number of available levels /// Gets the number of available levels
int GetLevelCount() const { return 10; } int GetLevelCount() const { return 10; }
@@ -276,6 +279,9 @@ public:
/// Add a definition to the list style list /// Add a definition to the list style list
bool AddListStyle(wxRichTextListStyleDefinition* def); bool AddListStyle(wxRichTextListStyleDefinition* def);
/// Add a definition to the appropriate style list
bool AddStyle(wxRichTextStyleDefinition* def);
/// Remove a character style /// Remove a character style
bool RemoveCharacterStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_characterStyleDefinitions, def, deleteStyle); } bool RemoveCharacterStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_characterStyleDefinitions, def, deleteStyle); }
@@ -285,6 +291,9 @@ public:
/// Remove a list style /// Remove a list style
bool RemoveListStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_listStyleDefinitions, def, deleteStyle); } bool RemoveListStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_listStyleDefinitions, def, deleteStyle); }
/// Remove a style
bool RemoveStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false);
/// Find a character definition by name /// Find a character definition by name
wxRichTextCharacterStyleDefinition* FindCharacterStyle(const wxString& name, bool recurse = true) const { return (wxRichTextCharacterStyleDefinition*) FindStyle(m_characterStyleDefinitions, name, recurse); } wxRichTextCharacterStyleDefinition* FindCharacterStyle(const wxString& name, bool recurse = true) const { return (wxRichTextCharacterStyleDefinition*) FindStyle(m_characterStyleDefinitions, name, recurse); }
@@ -294,6 +303,9 @@ public:
/// Find a list definition by name /// Find a list definition by name
wxRichTextListStyleDefinition* FindListStyle(const wxString& name, bool recurse = true) const { return (wxRichTextListStyleDefinition*) FindStyle(m_listStyleDefinitions, name, recurse); } wxRichTextListStyleDefinition* FindListStyle(const wxString& name, bool recurse = true) const { return (wxRichTextListStyleDefinition*) FindStyle(m_listStyleDefinitions, name, recurse); }
/// Find any definition by name
wxRichTextStyleDefinition* FindStyle(const wxString& name, bool recurse = true) const;
/// Return the number of character styles /// Return the number of character styles
size_t GetCharacterStyleCount() const { return m_characterStyleDefinitions.GetCount(); } size_t GetCharacterStyleCount() const { return m_characterStyleDefinitions.GetCount(); }

View File

@@ -1569,7 +1569,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const
{ {
wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(wholeStyle.GetParagraphStyleName()); wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(wholeStyle.GetParagraphStyleName());
if (def) if (def)
wxRichTextApplyStyle(wholeStyle, def->GetStyle()); wxRichTextApplyStyle(wholeStyle, def->GetStyleMergedWithBase(GetStyleSheet()));
} }
// Limit the attributes to be set to the content to only character attributes. // Limit the attributes to be set to the content to only character attributes.
@@ -1580,7 +1580,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const
{ {
wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterAttributes.GetCharacterStyleName()); wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterAttributes.GetCharacterStyleName());
if (def) if (def)
wxRichTextApplyStyle(characterAttributes, def->GetStyle()); wxRichTextApplyStyle(characterAttributes, def->GetStyleMergedWithBase(GetStyleSheet()));
} }
// If we are associated with a control, make undoable; otherwise, apply immediately // If we are associated with a control, make undoable; otherwise, apply immediately
@@ -1838,9 +1838,9 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons
{ {
if (style.HasFont()) if (style.HasFont())
{ {
if (style.HasSize() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_SIZE)) if (style.HasFontSize() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_SIZE))
{ {
if (currentStyle.GetFont().Ok() && currentStyle.HasSize()) if (currentStyle.GetFont().Ok() && currentStyle.HasFontSize())
{ {
if (currentStyle.GetFont().GetPointSize() != style.GetFont().GetPointSize()) if (currentStyle.GetFont().GetPointSize() != style.GetFont().GetPointSize())
{ {
@@ -1861,9 +1861,9 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons
} }
} }
if (style.HasItalic() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_ITALIC)) if (style.HasFontItalic() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_ITALIC))
{ {
if (currentStyle.GetFont().Ok() && currentStyle.HasItalic()) if (currentStyle.GetFont().Ok() && currentStyle.HasFontItalic())
{ {
if (currentStyle.GetFont().GetStyle() != style.GetFont().GetStyle()) if (currentStyle.GetFont().GetStyle() != style.GetFont().GetStyle())
{ {
@@ -1883,9 +1883,9 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons
} }
} }
if (style.HasWeight() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT)) if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT))
{ {
if (currentStyle.GetFont().Ok() && currentStyle.HasWeight()) if (currentStyle.GetFont().Ok() && currentStyle.HasFontWeight())
{ {
if (currentStyle.GetFont().GetWeight() != style.GetFont().GetWeight()) if (currentStyle.GetFont().GetWeight() != style.GetFont().GetWeight())
{ {
@@ -1905,9 +1905,9 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons
} }
} }
if (style.HasFaceName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_FACE)) if (style.HasFontFaceName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_FACE))
{ {
if (currentStyle.GetFont().Ok() && currentStyle.HasFaceName()) if (currentStyle.GetFont().Ok() && currentStyle.HasFontFaceName())
{ {
wxString faceName1(currentStyle.GetFont().GetFaceName()); wxString faceName1(currentStyle.GetFont().GetFaceName());
wxString faceName2(style.GetFont().GetFaceName()); wxString faceName2(style.GetFont().GetFaceName());
@@ -1930,9 +1930,9 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons
} }
} }
if (style.HasUnderlined() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE)) if (style.HasFontUnderlined() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE))
{ {
if (currentStyle.GetFont().Ok() && currentStyle.HasUnderlined()) if (currentStyle.GetFont().Ok() && currentStyle.HasFontUnderlined())
{ {
if (currentStyle.GetFont().GetUnderlined() != style.GetFont().GetUnderlined()) if (currentStyle.GetFont().GetUnderlined() != style.GetFont().GetUnderlined())
{ {
@@ -2512,13 +2512,13 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
wxRichTextListStyleDefinition* listDef = styleSheet->FindListStyle(para->GetAttributes().GetListStyleName()); wxRichTextListStyleDefinition* listDef = styleSheet->FindListStyle(para->GetAttributes().GetListStyleName());
if (paraDef && !listDef) if (paraDef && !listDef)
{ {
para->GetAttributes() = paraDef->GetStyle(); para->GetAttributes() = paraDef->GetStyleMergedWithBase(styleSheet);
foundCount ++; foundCount ++;
} }
else if (listDef && !paraDef) else if (listDef && !paraDef)
{ {
// Set overall style defined for the list style definition // Set overall style defined for the list style definition
para->GetAttributes() = listDef->GetStyle(); para->GetAttributes() = listDef->GetStyleMergedWithBase(styleSheet);
// Apply the style for this level // Apply the style for this level
wxRichTextApplyStyle(para->GetAttributes(), * listDef->GetLevelAttributes(listDef->FindLevelForIndent(currentIndent))); wxRichTextApplyStyle(para->GetAttributes(), * listDef->GetLevelAttributes(listDef->FindLevelForIndent(currentIndent)));
@@ -2527,7 +2527,7 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
else if (listDef && paraDef) else if (listDef && paraDef)
{ {
// Combines overall list style, style for level, and paragraph style // Combines overall list style, style for level, and paragraph style
para->GetAttributes() = listDef->CombineWithParagraphStyle(currentIndent, paraDef->GetStyle()); para->GetAttributes() = listDef->CombineWithParagraphStyle(currentIndent, paraDef->GetStyleMergedWithBase(styleSheet));
foundCount ++; foundCount ++;
} }
} }
@@ -2538,7 +2538,7 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
wxRichTextListStyleDefinition* listDef = styleSheet->FindListStyle(para->GetAttributes().GetListStyleName()); wxRichTextListStyleDefinition* listDef = styleSheet->FindListStyle(para->GetAttributes().GetListStyleName());
// Overall list definition style // Overall list definition style
para->GetAttributes() = listDef->GetStyle(); para->GetAttributes() = listDef->GetStyleMergedWithBase(styleSheet);
// Style for this level // Style for this level
wxRichTextApplyStyle(para->GetAttributes(), * listDef->GetLevelAttributes(listDef->FindLevelForIndent(currentIndent))); wxRichTextApplyStyle(para->GetAttributes(), * listDef->GetLevelAttributes(listDef->FindLevelForIndent(currentIndent)));
@@ -2550,7 +2550,7 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
wxRichTextParagraphStyleDefinition* def = styleSheet->FindParagraphStyle(para->GetAttributes().GetParagraphStyleName()); wxRichTextParagraphStyleDefinition* def = styleSheet->FindParagraphStyle(para->GetAttributes().GetParagraphStyleName());
if (def) if (def)
{ {
para->GetAttributes() = def->GetStyle(); para->GetAttributes() = def->GetStyleMergedWithBase(styleSheet);
foundCount ++; foundCount ++;
} }
} }
@@ -2564,6 +2564,8 @@ bool wxRichTextParagraphLayoutBox::ApplyStyleSheet(wxRichTextStyleSheet* styleSh
/// Set list style /// Set list style
bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel) bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel)
{ {
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0); bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0);
// bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0); // bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0);
bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0); bool specifyLevel = ((flags & wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL) != 0);
@@ -2631,7 +2633,7 @@ bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wx
// Renumbering will need to be done when we promote/demote a paragraph. // Renumbering will need to be done when we promote/demote a paragraph.
// Apply the overall list style, and item style for this level // Apply the overall list style, and item style for this level
wxTextAttrEx listStyle(def->GetCombinedStyleForLevel(thisLevel)); wxTextAttrEx listStyle(def->GetCombinedStyleForLevel(thisLevel, styleSheet));
wxRichTextApplyStyle(newPara->GetAttributes(), listStyle); wxRichTextApplyStyle(newPara->GetAttributes(), listStyle);
// Now we need to do numbering // Now we need to do numbering
@@ -2654,13 +2656,12 @@ bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wx
// Eliminate the main list-related attributes // Eliminate the main list-related attributes
newPara->GetAttributes().SetFlags(newPara->GetAttributes().GetFlags() & ~wxTEXT_ATTR_LEFT_INDENT & ~wxTEXT_ATTR_BULLET_STYLE & ~wxTEXT_ATTR_BULLET_NUMBER & ~wxTEXT_ATTR_BULLET_TEXT & wxTEXT_ATTR_LIST_STYLE_NAME); newPara->GetAttributes().SetFlags(newPara->GetAttributes().GetFlags() & ~wxTEXT_ATTR_LEFT_INDENT & ~wxTEXT_ATTR_BULLET_STYLE & ~wxTEXT_ATTR_BULLET_NUMBER & ~wxTEXT_ATTR_BULLET_TEXT & wxTEXT_ATTR_LIST_STYLE_NAME);
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
if (styleSheet && !newPara->GetAttributes().GetParagraphStyleName().IsEmpty()) if (styleSheet && !newPara->GetAttributes().GetParagraphStyleName().IsEmpty())
{ {
wxRichTextParagraphStyleDefinition* def = styleSheet->FindParagraphStyle(newPara->GetAttributes().GetParagraphStyleName()); wxRichTextParagraphStyleDefinition* def = styleSheet->FindParagraphStyle(newPara->GetAttributes().GetParagraphStyleName());
if (def) if (def)
{ {
newPara->GetAttributes() = def->GetStyle(); newPara->GetAttributes() = def->GetStyleMergedWithBase(styleSheet);
} }
} }
} }
@@ -2704,6 +2705,8 @@ bool wxRichTextParagraphLayoutBox::NumberList(const wxRichTextRange& range, wxRi
bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, const wxRichTextRange& promotionRange, int promoteBy, bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, const wxRichTextRange& promotionRange, int promoteBy,
wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel) wxRichTextListStyleDefinition* def, int flags, int startFrom, int specifiedLevel)
{ {
wxRichTextStyleSheet* styleSheet = GetStyleSheet();
bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0); bool withUndo = ((flags & wxRICHTEXT_SETSTYLE_WITH_UNDO) != 0);
// bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0); // bool applyMinimal = ((flags & wxRICHTEXT_SETSTYLE_OPTIMIZE) != 0);
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
@@ -2781,10 +2784,8 @@ bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, co
wxRichTextListStyleDefinition* defToUse = def; wxRichTextListStyleDefinition* defToUse = def;
if (!defToUse) if (!defToUse)
{ {
wxRichTextStyleSheet* sheet = GetStyleSheet(); if (styleSheet && !newPara->GetAttributes().GetListStyleName().IsEmpty())
defToUse = styleSheet->FindListStyle(newPara->GetAttributes().GetListStyleName());
if (sheet && !newPara->GetAttributes().GetListStyleName().IsEmpty())
defToUse = sheet->FindListStyle(newPara->GetAttributes().GetListStyleName());
} }
if (defToUse) if (defToUse)
@@ -2807,7 +2808,7 @@ bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, co
} }
// Apply the overall list style, and item style for this level // Apply the overall list style, and item style for this level
wxTextAttrEx listStyle(defToUse->GetCombinedStyleForLevel(thisLevel)); wxTextAttrEx listStyle(defToUse->GetCombinedStyleForLevel(thisLevel, styleSheet));
wxRichTextApplyStyle(newPara->GetAttributes(), listStyle); wxRichTextApplyStyle(newPara->GetAttributes(), listStyle);
// OK, we've (re)applied the style, now let's get the numbering right. // OK, we've (re)applied the style, now let's get the numbering right.
@@ -2923,10 +2924,10 @@ bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph*
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;
wxRichTextStyleSheet* sheet = GetStyleSheet(); wxRichTextStyleSheet* styleSheet = GetStyleSheet();
if (sheet && !previousParagraph->GetAttributes().GetListStyleName().IsEmpty()) if (styleSheet && !previousParagraph->GetAttributes().GetListStyleName().IsEmpty())
{ {
wxRichTextListStyleDefinition* def = sheet->FindListStyle(previousParagraph->GetAttributes().GetListStyleName()); wxRichTextListStyleDefinition* def = styleSheet->FindListStyle(previousParagraph->GetAttributes().GetListStyleName());
if (def) if (def)
{ {
// int thisIndent = previousParagraph->GetAttributes().GetLeftIndent(); // int thisIndent = previousParagraph->GetAttributes().GetLeftIndent();
@@ -4848,7 +4849,7 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
if (nextParaDef) if (nextParaDef)
{ {
foundAttributes = true; foundAttributes = true;
attr = nextParaDef->GetStyle(); attr = nextParaDef->GetStyleMergedWithBase(GetStyleSheet());
} }
} }
@@ -4856,7 +4857,7 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos
if (!foundAttributes) if (!foundAttributes)
{ {
foundAttributes = true; foundAttributes = true;
attr = paraDef->GetStyle(); attr = paraDef->GetStyleMergedWithBase(GetStyleSheet());
} }
} }
} }
@@ -5214,7 +5215,7 @@ bool wxRichTextBuffer::BeginCharacterStyle(const wxString& characterStyle)
wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterStyle); wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterStyle);
if (def) if (def)
{ {
wxTextAttrEx attr = def->GetStyle(); wxTextAttrEx attr = def->GetStyleMergedWithBase(GetStyleSheet());
return BeginStyle(attr); return BeginStyle(attr);
} }
} }
@@ -5229,7 +5230,7 @@ bool wxRichTextBuffer::BeginParagraphStyle(const wxString& paragraphStyle)
wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(paragraphStyle); wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(paragraphStyle);
if (def) if (def)
{ {
wxTextAttrEx attr = def->GetStyle(); wxTextAttrEx attr = def->GetStyleMergedWithBase(GetStyleSheet());
return BeginStyle(attr); return BeginStyle(attr);
} }
} }
@@ -5264,7 +5265,7 @@ bool wxRichTextBuffer::BeginURL(const wxString& url, const wxString& characterSt
wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterStyle); wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterStyle);
if (def) if (def)
{ {
attr = def->GetStyle(); attr = def->GetStyleMergedWithBase(GetStyleSheet());
} }
} }
attr.SetURL(url); attr.SetURL(url);
@@ -6848,9 +6849,7 @@ bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxTextAttrEx& style)
bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith) bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith)
{ {
wxTextAttrEx attr(destStyle); destStyle = destStyle.Combine(style, compareWith);
wxRichTextApplyStyle(attr, style, compareWith);
destStyle = attr;
return true; return true;
} }
@@ -6869,7 +6868,7 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style,
if (style.GetFlags() & wxTEXT_ATTR_FONT_FACE) if (style.GetFlags() & wxTEXT_ATTR_FONT_FACE)
{ {
if (compareWith && compareWith->HasFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName()) if (compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName())
{ {
// The same as currently displayed, so don't set // The same as currently displayed, so don't set
} }
@@ -6882,7 +6881,7 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style,
if (style.GetFlags() & wxTEXT_ATTR_FONT_SIZE) if (style.GetFlags() & wxTEXT_ATTR_FONT_SIZE)
{ {
if (compareWith && compareWith->HasSize() && compareWith->GetFontSize() == style.GetFontSize()) if (compareWith && compareWith->HasFontSize() && compareWith->GetFontSize() == style.GetFontSize())
{ {
// The same as currently displayed, so don't set // The same as currently displayed, so don't set
} }
@@ -6895,7 +6894,7 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style,
if (style.GetFlags() & wxTEXT_ATTR_FONT_ITALIC) if (style.GetFlags() & wxTEXT_ATTR_FONT_ITALIC)
{ {
if (compareWith && compareWith->HasItalic() && compareWith->GetFontStyle() == style.GetFontStyle()) if (compareWith && compareWith->HasFontItalic() && compareWith->GetFontStyle() == style.GetFontStyle())
{ {
// The same as currently displayed, so don't set // The same as currently displayed, so don't set
} }
@@ -6908,7 +6907,7 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style,
if (style.GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) if (style.GetFlags() & wxTEXT_ATTR_FONT_WEIGHT)
{ {
if (compareWith && compareWith->HasWeight() && compareWith->GetFontWeight() == style.GetFontWeight()) if (compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight())
{ {
// The same as currently displayed, so don't set // The same as currently displayed, so don't set
} }
@@ -6921,7 +6920,7 @@ bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style,
if (style.GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) if (style.GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE)
{ {
if (compareWith && compareWith->HasUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined()) if (compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined())
{ {
// The same as currently displayed, so don't set // The same as currently displayed, so don't set
} }
@@ -7411,116 +7410,184 @@ bool wxRichTextAttr::GetFontAttributes(const wxFont& font)
return true; return true;
} }
wxRichTextAttr wxRichTextAttr::Combine(const wxRichTextAttr& attr, wxRichTextAttr wxRichTextAttr::Combine(const wxRichTextAttr& style, const wxRichTextAttr* compareWith) const
const wxRichTextAttr& attrDef,
const wxTextCtrlBase *text)
{ {
wxColour colFg = attr.GetTextColour(); wxRichTextAttr destStyle = (*this);
if ( !colFg.Ok() ) destStyle.Apply(style, compareWith);
{
colFg = attrDef.GetTextColour();
if ( text && !colFg.Ok() ) return destStyle;
colFg = text->GetForegroundColour(); }
bool wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith)
{
wxRichTextAttr& destStyle = (*this);
if (style.HasFontWeight())
{
if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight()))
destStyle.SetFontWeight(style.GetFontWeight());
} }
wxColour colBg = attr.GetBackgroundColour(); if (style.HasFontSize())
if ( !colBg.Ok() )
{ {
colBg = attrDef.GetBackgroundColour(); if (!(compareWith && compareWith->HasFontSize() && compareWith->GetFontSize() == style.GetFontSize()))
destStyle.SetFontSize(style.GetFontSize());
if ( text && !colBg.Ok() )
colBg = text->GetBackgroundColour();
} }
wxRichTextAttr newAttr(colFg, colBg); if (style.HasFontItalic())
if (attr.HasWeight())
newAttr.SetFontWeight(attr.GetFontWeight());
if (attr.HasSize())
newAttr.SetFontSize(attr.GetFontSize());
if (attr.HasItalic())
newAttr.SetFontStyle(attr.GetFontStyle());
if (attr.HasUnderlined())
newAttr.SetFontUnderlined(attr.GetFontUnderlined());
if (attr.HasFaceName())
newAttr.SetFontFaceName(attr.GetFontFaceName());
if (attr.HasAlignment())
newAttr.SetAlignment(attr.GetAlignment());
else if (attrDef.HasAlignment())
newAttr.SetAlignment(attrDef.GetAlignment());
if (attr.HasTabs())
newAttr.SetTabs(attr.GetTabs());
else if (attrDef.HasTabs())
newAttr.SetTabs(attrDef.GetTabs());
if (attr.HasLeftIndent())
newAttr.SetLeftIndent(attr.GetLeftIndent(), attr.GetLeftSubIndent());
else if (attrDef.HasLeftIndent())
newAttr.SetLeftIndent(attrDef.GetLeftIndent(), attr.GetLeftSubIndent());
if (attr.HasRightIndent())
newAttr.SetRightIndent(attr.GetRightIndent());
else if (attrDef.HasRightIndent())
newAttr.SetRightIndent(attrDef.GetRightIndent());
// NEW ATTRIBUTES
if (attr.HasParagraphSpacingAfter())
newAttr.SetParagraphSpacingAfter(attr.GetParagraphSpacingAfter());
if (attr.HasParagraphSpacingBefore())
newAttr.SetParagraphSpacingBefore(attr.GetParagraphSpacingBefore());
if (attr.HasLineSpacing())
newAttr.SetLineSpacing(attr.GetLineSpacing());
if (attr.HasCharacterStyleName())
newAttr.SetCharacterStyleName(attr.GetCharacterStyleName());
if (attr.HasParagraphStyleName())
newAttr.SetParagraphStyleName(attr.GetParagraphStyleName());
if (attr.HasListStyleName())
newAttr.SetListStyleName(attr.GetListStyleName());
if (attr.HasBulletStyle())
newAttr.SetBulletStyle(attr.GetBulletStyle());
if (attr.HasBulletNumber())
newAttr.SetBulletNumber(attr.GetBulletNumber());
if (attr.HasBulletName())
newAttr.SetBulletName(attr.GetBulletName());
if (attr.HasBulletText())
{ {
newAttr.SetBulletText(attr.GetBulletText()); if (!(compareWith && compareWith->HasFontItalic() && compareWith->GetFontStyle() == style.GetFontStyle()))
newAttr.SetBulletFont(attr.GetBulletFont()); destStyle.SetFontStyle(style.GetFontStyle());
} }
if (attr.HasURL()) if (style.HasFontUnderlined())
newAttr.SetURL(attr.GetURL());
if (attr.HasPageBreak())
newAttr.SetPageBreak();
if (attr.HasTextEffects())
{ {
newAttr.SetTextEffects(attr.GetTextEffects()); if (!(compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined()))
newAttr.SetTextEffectFlags(attr.GetTextEffectFlags()); destStyle.SetFontUnderlined(style.GetFontUnderlined());
} }
if (attr.HasOutlineLevel()) if (style.HasFontFaceName())
newAttr.SetOutlineLevel(attr.GetOutlineLevel()); {
if (!(compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName()))
destStyle.SetFontFaceName(style.GetFontFaceName());
}
return newAttr; if (style.GetTextColour().Ok() && style.HasTextColour())
{
if (!(compareWith && compareWith->HasTextColour() && compareWith->GetTextColour() == style.GetTextColour()))
destStyle.SetTextColour(style.GetTextColour());
}
if (style.GetBackgroundColour().Ok() && style.HasBackgroundColour())
{
if (!(compareWith && compareWith->HasBackgroundColour() && compareWith->GetBackgroundColour() == style.GetBackgroundColour()))
destStyle.SetBackgroundColour(style.GetBackgroundColour());
}
if (style.HasAlignment())
{
if (!(compareWith && compareWith->HasAlignment() && compareWith->GetAlignment() == style.GetAlignment()))
destStyle.SetAlignment(style.GetAlignment());
}
if (style.HasTabs())
{
if (!(compareWith && compareWith->HasTabs() && wxRichTextTabsEq(compareWith->GetTabs(), style.GetTabs())))
destStyle.SetTabs(style.GetTabs());
}
if (style.HasLeftIndent())
{
if (!(compareWith && compareWith->HasLeftIndent() && compareWith->GetLeftIndent() == style.GetLeftIndent()
&& compareWith->GetLeftSubIndent() == style.GetLeftSubIndent()))
destStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent());
}
if (style.HasRightIndent())
{
if (!(compareWith && compareWith->HasRightIndent() && compareWith->GetRightIndent() == style.GetRightIndent()))
destStyle.SetRightIndent(style.GetRightIndent());
}
if (style.HasParagraphSpacingAfter())
{
if (!(compareWith && compareWith->HasParagraphSpacingAfter() && compareWith->GetParagraphSpacingAfter() == style.GetParagraphSpacingAfter()))
destStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter());
}
if (style.HasParagraphSpacingBefore())
{
if (!(compareWith && compareWith->HasParagraphSpacingBefore() && compareWith->GetParagraphSpacingBefore() == style.GetParagraphSpacingBefore()))
destStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore());
}
if (style.HasLineSpacing())
{
if (!(compareWith && compareWith->HasLineSpacing() && compareWith->GetLineSpacing() == style.GetLineSpacing()))
destStyle.SetLineSpacing(style.GetLineSpacing());
}
if (style.HasCharacterStyleName())
{
if (!(compareWith && compareWith->HasCharacterStyleName() && compareWith->GetCharacterStyleName() == style.GetCharacterStyleName()))
destStyle.SetCharacterStyleName(style.GetCharacterStyleName());
}
if (style.HasParagraphStyleName())
{
if (!(compareWith && compareWith->HasParagraphStyleName() && compareWith->GetParagraphStyleName() == style.GetParagraphStyleName()))
destStyle.SetParagraphStyleName(style.GetParagraphStyleName());
}
if (style.HasListStyleName())
{
if (!(compareWith && compareWith->HasListStyleName() && compareWith->GetListStyleName() == style.GetListStyleName()))
destStyle.SetListStyleName(style.GetListStyleName());
}
if (style.HasBulletStyle())
{
if (!(compareWith && compareWith->HasBulletStyle() && compareWith->GetBulletStyle() == style.GetBulletStyle()))
destStyle.SetBulletStyle(style.GetBulletStyle());
}
if (style.HasBulletText())
{
if (!(compareWith && compareWith->HasBulletText() && compareWith->GetBulletText() == style.GetBulletText()))
{
destStyle.SetBulletText(style.GetBulletText());
destStyle.SetBulletFont(style.GetBulletFont());
}
}
if (style.HasBulletNumber())
{
if (!(compareWith && compareWith->HasBulletNumber() && compareWith->GetBulletNumber() == style.GetBulletNumber()))
destStyle.SetBulletNumber(style.GetBulletNumber());
}
if (style.HasBulletName())
{
if (!(compareWith && compareWith->HasBulletName() && compareWith->GetBulletName() == style.GetBulletName()))
destStyle.SetBulletName(style.GetBulletName());
}
if (style.HasURL())
{
if (!(compareWith && compareWith->HasURL() && compareWith->GetURL() == style.GetURL()))
destStyle.SetURL(style.GetURL());
}
if (style.HasPageBreak())
{
if (!(compareWith && compareWith->HasPageBreak()))
destStyle.SetPageBreak();
}
if (style.HasTextEffects())
{
if (!(compareWith && compareWith->HasTextEffects() && compareWith->GetTextEffects() == style.GetTextEffects()))
{
int destBits = destStyle.GetTextEffects();
int destFlags = destStyle.GetTextEffectFlags();
int srcBits = style.GetTextEffects();
int srcFlags = style.GetTextEffectFlags();
wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags);
destStyle.SetTextEffects(destBits);
destStyle.SetTextEffectFlags(destFlags);
}
}
if (style.HasOutlineLevel())
{
if (!(compareWith && compareWith->HasOutlineLevel() && compareWith->GetOutlineLevel() == style.GetOutlineLevel()))
destStyle.SetOutlineLevel(style.GetOutlineLevel());
}
return true;
} }
/*! /*!
@@ -7643,27 +7710,27 @@ wxTextAttrEx wxTextAttrEx::CombineEx(const wxTextAttrEx& attr,
// Otherwise, if there are font attributes in attr, apply them // Otherwise, if there are font attributes in attr, apply them
if (attr.GetFlags() & wxTEXT_ATTR_FONT) if (attr.GetFlags() & wxTEXT_ATTR_FONT)
{ {
if (attr.HasSize()) if (attr.HasFontSize())
{ {
flags |= wxTEXT_ATTR_FONT_SIZE; flags |= wxTEXT_ATTR_FONT_SIZE;
font.SetPointSize(attr.GetFont().GetPointSize()); font.SetPointSize(attr.GetFont().GetPointSize());
} }
if (attr.HasItalic()) if (attr.HasFontItalic())
{ {
flags |= wxTEXT_ATTR_FONT_ITALIC;; flags |= wxTEXT_ATTR_FONT_ITALIC;;
font.SetStyle(attr.GetFont().GetStyle()); font.SetStyle(attr.GetFont().GetStyle());
} }
if (attr.HasWeight()) if (attr.HasFontWeight())
{ {
flags |= wxTEXT_ATTR_FONT_WEIGHT; flags |= wxTEXT_ATTR_FONT_WEIGHT;
font.SetWeight(attr.GetFont().GetWeight()); font.SetWeight(attr.GetFont().GetWeight());
} }
if (attr.HasFaceName()) if (attr.HasFontFaceName())
{ {
flags |= wxTEXT_ATTR_FONT_FACE; flags |= wxTEXT_ATTR_FONT_FACE;
font.SetFaceName(attr.GetFont().GetFaceName()); font.SetFaceName(attr.GetFont().GetFaceName());
} }
if (attr.HasUnderlined()) if (attr.HasFontUnderlined())
{ {
flags |= wxTEXT_ATTR_FONT_UNDERLINE; flags |= wxTEXT_ATTR_FONT_UNDERLINE;
font.SetUnderlined(attr.GetFont().GetUnderlined()); font.SetUnderlined(attr.GetFont().GetUnderlined());

View File

@@ -2929,7 +2929,7 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
{ {
// Flags are defined within each definition, so only certain // Flags are defined within each definition, so only certain
// attributes are applied. // attributes are applied.
wxRichTextAttr attr(def->GetStyle()); wxRichTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle());
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE; int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE;

View File

@@ -383,7 +383,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_dontUpdate = true; m_dontUpdate = true;
wxTextAttrEx* attr = GetAttributes(); wxTextAttrEx* attr = GetAttributes();
if (attr->HasFont() && attr->HasFaceName()) if (attr->HasFont() && attr->HasFontFaceName())
{ {
m_faceTextCtrl->SetValue(attr->GetFont().GetFaceName()); m_faceTextCtrl->SetValue(attr->GetFont().GetFaceName());
m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName()); m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName());
@@ -394,7 +394,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_faceListBox->SetFaceNameSelection(wxEmptyString); m_faceListBox->SetFaceNameSelection(wxEmptyString);
} }
if (attr->HasFont() && attr->HasSize()) if (attr->HasFont() && attr->HasFontSize())
{ {
wxString strSize = wxString::Format(wxT("%d"), attr->GetFont().GetPointSize()); wxString strSize = wxString::Format(wxT("%d"), attr->GetFont().GetPointSize());
m_sizeTextCtrl->SetValue(strSize); m_sizeTextCtrl->SetValue(strSize);
@@ -407,7 +407,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_sizeListBox->SetSelection(wxNOT_FOUND); m_sizeListBox->SetSelection(wxNOT_FOUND);
} }
if (attr->HasFont() && attr->HasWeight()) if (attr->HasFont() && attr->HasFontWeight())
{ {
if (attr->GetFont().GetWeight() == wxBOLD) if (attr->GetFont().GetWeight() == wxBOLD)
m_weightCtrl->SetSelection(1); m_weightCtrl->SetSelection(1);
@@ -419,7 +419,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_weightCtrl->SetSelection(wxNOT_FOUND); m_weightCtrl->SetSelection(wxNOT_FOUND);
} }
if (attr->HasFont() && attr->HasItalic()) if (attr->HasFont() && attr->HasFontItalic())
{ {
if (attr->GetFont().GetStyle() == wxITALIC) if (attr->GetFont().GetStyle() == wxITALIC)
m_styleCtrl->SetSelection(1); m_styleCtrl->SetSelection(1);
@@ -431,7 +431,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_styleCtrl->SetSelection(wxNOT_FOUND); m_styleCtrl->SetSelection(wxNOT_FOUND);
} }
if (attr->HasFont() && attr->HasUnderlined()) if (attr->HasFont() && attr->HasFontUnderlined())
{ {
if (attr->GetFont().GetUnderlined()) if (attr->GetFont().GetUnderlined())
m_underliningCtrl->SetSelection(1); m_underliningCtrl->SetSelection(1);

View File

@@ -528,7 +528,10 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
wxRichTextListStyleDefinition* def = wxDynamicCast(wxRichTextFormattingDialog::GetDialogStyleDefinition(this), wxRichTextListStyleDefinition* def = wxDynamicCast(wxRichTextFormattingDialog::GetDialogStyleDefinition(this),
wxRichTextListStyleDefinition); wxRichTextListStyleDefinition);
wxTextAttrEx attr(def->GetStyle()); wxRichTextStyleSheet* styleSheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
wxTextAttrEx attr(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet));
attr.SetFlags(attr.GetFlags() & attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER| (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
wxTEXT_ATTR_LINE_SPACING| wxTEXT_ATTR_LINE_SPACING|

View File

@@ -425,16 +425,8 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel); wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition);
//wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
//wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
wxTextAttrEx attr(def->GetStyle()); wxTextAttrEx attr(def->GetStyleMergedWithBase(GetStyleSheet()));
#if 0
attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
wxTEXT_ATTR_LINE_SPACING|
wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL));
#endif
wxFont font(m_previewCtrl->GetFont()); wxFont font(m_previewCtrl->GetFont());
font.SetPointSize(9); font.SetPointSize(9);

View File

@@ -53,6 +53,22 @@ bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const
return (m_name == def.m_name && m_baseStyle == def.m_baseStyle && m_style == def.m_style); return (m_name == def.m_name && m_baseStyle == def.m_baseStyle && m_style == def.m_style);
} }
/// Gets the style combined with the base style
wxRichTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
{
if (!m_baseStyle.IsEmpty())
{
wxRichTextStyleDefinition* baseStyle = sheet->FindStyle(m_baseStyle);
if (baseStyle)
{
wxRichTextAttr baseAttr = baseStyle->GetStyleMergedWithBase(sheet);
baseAttr.Apply(m_style, NULL);
return baseAttr;
}
}
return m_style;
}
/*! /*!
* Paragraph style definition * Paragraph style definition
*/ */
@@ -162,7 +178,7 @@ int wxRichTextListStyleDefinition::FindLevelForIndent(int indent) const
/// Combine the list style with a paragraph style, using the given indent (from which /// Combine the list style with a paragraph style, using the given indent (from which
/// an appropriate level is found) /// an appropriate level is found)
wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle) wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet)
{ {
int listLevel = FindLevelForIndent(indent); int listLevel = FindLevelForIndent(indent);
@@ -171,10 +187,13 @@ wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int inde
int oldLeftSubIndent = attr.GetLeftSubIndent(); int oldLeftSubIndent = attr.GetLeftSubIndent();
// First apply the overall paragraph style, if any // First apply the overall paragraph style, if any
wxRichTextApplyStyle(attr, GetStyle()); if (styleSheet)
attr.Apply(GetStyleMergedWithBase(styleSheet));
else
attr.Apply(GetStyle());
// Then apply paragraph style, e.g. from paragraph style definition // Then apply paragraph style, e.g. from paragraph style definition
wxRichTextApplyStyle(attr, paraStyle); attr.Apply(paraStyle);
// We override the indents according to the list definition // We override the indents according to the list definition
attr.SetLeftIndent(oldLeftIndent, oldLeftSubIndent); attr.SetLeftIndent(oldLeftIndent, oldLeftSubIndent);
@@ -184,22 +203,25 @@ wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int inde
/// Combine the base and list style, using the given indent (from which /// Combine the base and list style, using the given indent (from which
/// an appropriate level is found) /// an appropriate level is found)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent) wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet)
{ {
int listLevel = FindLevelForIndent(indent); int listLevel = FindLevelForIndent(indent);
return GetCombinedStyleForLevel(listLevel); return GetCombinedStyleForLevel(listLevel, styleSheet);
} }
/// Combine the base and list style, using the given indent (from which /// Combine the base and list style, using the given indent (from which
/// an appropriate level is found) /// an appropriate level is found)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel) wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet)
{ {
wxRichTextAttr attr(*GetLevelAttributes(listLevel)); wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent(); int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent(); int oldLeftSubIndent = attr.GetLeftSubIndent();
// Apply the overall paragraph style, if any // Apply the overall paragraph style, if any
wxRichTextApplyStyle(attr, GetStyle()); if (styleSheet)
attr.Apply(GetStyleMergedWithBase(styleSheet));
else
attr.Apply(GetStyle());
// We override the indents according to the list definition // We override the indents according to the list definition
attr.SetLeftIndent(oldLeftIndent, oldLeftSubIndent); attr.SetLeftIndent(oldLeftIndent, oldLeftSubIndent);
@@ -266,6 +288,18 @@ bool wxRichTextStyleSheet::RemoveStyle(wxList& list, wxRichTextStyleDefinition*
return false; return false;
} }
/// Remove a style
bool wxRichTextStyleSheet::RemoveStyle(wxRichTextStyleDefinition* def, bool deleteStyle)
{
if (RemoveParagraphStyle(def, deleteStyle))
return true;
if (RemoveCharacterStyle(def, deleteStyle))
return true;
if (RemoveListStyle(def, deleteStyle))
return true;
return false;
}
/// Find a definition by name /// Find a definition by name
wxRichTextStyleDefinition* wxRichTextStyleSheet::FindStyle(const wxList& list, const wxString& name, bool recurse) const wxRichTextStyleDefinition* wxRichTextStyleSheet::FindStyle(const wxList& list, const wxString& name, bool recurse) const
{ {
@@ -353,6 +387,42 @@ bool wxRichTextStyleSheet::AddListStyle(wxRichTextListStyleDefinition* def)
return AddStyle(m_listStyleDefinitions, def); return AddStyle(m_listStyleDefinitions, def);
} }
/// Add a definition to the appropriate style list
bool wxRichTextStyleSheet::AddStyle(wxRichTextStyleDefinition* def)
{
wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition);
if (listDef)
return AddListStyle(listDef);
wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
if (paraDef)
return AddParagraphStyle(paraDef);
wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
if (charDef)
return AddCharacterStyle(charDef);
return false;
}
/// Find any definition by name
wxRichTextStyleDefinition* wxRichTextStyleSheet::FindStyle(const wxString& name, bool recurse) const
{
wxRichTextListStyleDefinition* listDef = FindListStyle(name, recurse);
if (listDef)
return listDef;
wxRichTextParagraphStyleDefinition* paraDef = FindParagraphStyle(name, recurse);
if (paraDef)
return paraDef;
wxRichTextCharacterStyleDefinition* charDef = FindCharacterStyle(name, recurse);
if (charDef)
return charDef;
return NULL;
}
/// Copy /// Copy
void wxRichTextStyleSheet::Copy(const wxRichTextStyleSheet& sheet) void wxRichTextStyleSheet::Copy(const wxRichTextStyleSheet& sheet)
{ {
@@ -541,7 +611,9 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
bool isCentred = false; bool isCentred = false;
if (def->GetStyle().HasAlignment() && def->GetStyle().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE) wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
isCentred = true; isCentred = true;
if (isCentred) if (isCentred)
@@ -550,11 +622,11 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
str << wxT("<table><tr>"); str << wxT("<table><tr>");
if (def->GetStyle().GetLeftIndent() > 0) if (attr.GetLeftIndent() > 0)
{ {
wxClientDC dc((wxWindow*) this); wxClientDC dc((wxWindow*) this);
str << wxT("<td width=") << wxMin(50, (ConvertTenthsMMToPixels(dc, def->GetStyle().GetLeftIndent())/2)) << wxT("></td>"); str << wxT("<td width=") << wxMin(50, (ConvertTenthsMMToPixels(dc, attr.GetLeftIndent())/2)) << wxT("></td>");
} }
if (isCentred) if (isCentred)
@@ -569,7 +641,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
#endif #endif
int stdFontSize = 12; int stdFontSize = 12;
int thisFontSize = ((def->GetStyle().GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0) ? def->GetStyle().GetFontSize() : stdFontSize; int thisFontSize = ((attr.GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0) ? attr.GetFontSize() : stdFontSize;
if (thisFontSize < stdFontSize) if (thisFontSize < stdFontSize)
size ++; size ++;
@@ -580,11 +652,11 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
str << wxT(" size=") << size; str << wxT(" size=") << size;
if (!def->GetStyle().GetFontFaceName().IsEmpty()) if (!attr.GetFontFaceName().IsEmpty())
str << wxT(" face=\"") << def->GetStyle().GetFontFaceName() << wxT("\""); str << wxT(" face=\"") << attr.GetFontFaceName() << wxT("\"");
if (def->GetStyle().GetTextColour().Ok()) if (attr.GetTextColour().Ok())
str << wxT(" color=\"#") << ColourToHexString(def->GetStyle().GetTextColour()) << wxT("\""); str << wxT(" color=\"#") << ColourToHexString(attr.GetTextColour()) << wxT("\"");
str << wxT(">"); str << wxT(">");
@@ -592,11 +664,11 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
bool hasItalic = false; bool hasItalic = false;
bool hasUnderline = false; bool hasUnderline = false;
if (def->GetStyle().GetFontWeight() == wxBOLD) if (attr.GetFontWeight() == wxBOLD)
hasBold = true; hasBold = true;
if (def->GetStyle().GetFontStyle() == wxITALIC) if (attr.GetFontStyle() == wxITALIC)
hasItalic = true; hasItalic = true;
if (def->GetStyle().GetFontUnderlined()) if (attr.GetFontUnderlined())
hasUnderline = true; hasUnderline = true;
if (hasBold) if (hasBold)

View File

@@ -893,22 +893,22 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara
if (attr.GetFont().Ok()) if (attr.GetFont().Ok())
{ {
if (attr.HasSize()) if (attr.HasFontSize())
str << wxT(" fontsize=\"") << attr.GetFont().GetPointSize() << wxT("\""); str << wxT(" fontsize=\"") << attr.GetFont().GetPointSize() << wxT("\"");
//if (attr.HasFamily()) //if (attr.HasFontFamily())
// str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\""); // str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\"");
if (attr.HasItalic()) if (attr.HasFontItalic())
str << wxT(" fontstyle=\"") << attr.GetFont().GetStyle() << wxT("\""); str << wxT(" fontstyle=\"") << attr.GetFont().GetStyle() << wxT("\"");
if (attr.HasWeight()) if (attr.HasFontWeight())
str << wxT(" fontweight=\"") << attr.GetFont().GetWeight() << wxT("\""); str << wxT(" fontweight=\"") << attr.GetFont().GetWeight() << wxT("\"");
if (attr.HasUnderlined()) if (attr.HasFontUnderlined())
str << wxT(" fontunderlined=\"") << (int) attr.GetFont().GetUnderlined() << wxT("\""); str << wxT(" fontunderlined=\"") << (int) attr.GetFont().GetUnderlined() << wxT("\"");
if (attr.HasFaceName()) if (attr.HasFontFaceName())
str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\""); str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\"");
} }