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
+24 -19
View File
@@ -155,11 +155,22 @@ Of these, only wxTEXT\_ATTR\_EFFECT\_CAPITALS and wxTEXT\_ATTR\_EFFECT\_STRIKETH
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}
@@ -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.
\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.
@@ -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.
\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.
@@ -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.
\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.
@@ -506,9 +517,9 @@ Returns \true if the attribute object specifies a text foreground colour.
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.
@@ -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.
\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).
\membersection{wxRichTextAttr::Init}\label{wxrichtextattrinit}
\func{void}{Init}{\void}
Initialise the object.
\membersection{wxRichTextAttr::IsCharacterStyle}\label{wxrichtextattrischaracterstyle}
\constfunc{bool}{IsCharacterStyle}{\void}
+11 -2
View File
@@ -37,9 +37,10 @@ Destructor.
\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.
If {\it styleSheet} is specified, the base style for this definition will also be included in the result.
\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}
\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.
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}
+3 -3
View File
@@ -52,11 +52,11 @@ Returns the style name.
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}
+18 -6
View File
@@ -49,6 +49,12 @@ Adds a definition to the list 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}
\func{void}{DeleteStyles}{\void}
@@ -73,6 +79,12 @@ Finds a list 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}
\constfunc{wxRichTextCharacterStyleDefinition*}{GetCharacterStyle}{\param{size\_t }{n}}
@@ -121,12 +133,6 @@ Returns the {\it n}th paragraph style.
Returns the number of paragraph styles.
\membersection{wxRichTextStyleSheet::Init}\label{wxrichtextstylesheetinit}
\func{void}{Init}{\void}
Initialises the style sheet.
\membersection{wxRichTextStyleSheet::RemoveCharacterStyle}\label{wxrichtextstylesheetremovecharacterstyle}
\func{bool}{RemoveCharacterStyle}{\param{wxRichTextStyleDefinition* }{def}, \param{bool }{deleteStyle = false}}
@@ -145,6 +151,12 @@ Removes a list 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}
\func{void}{SetDescription}{\param{const wxString\& }{descr}}
+20 -16
View File
@@ -391,11 +391,11 @@ public:
int GetTextEffectFlags() const { return m_textEffectFlags; }
int GetOutlineLevel() const { return m_outlineLevel; }
bool HasWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
bool HasSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; }
bool HasItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; }
bool HasUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; }
bool HasFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE) != 0; }
bool HasFontWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
bool HasFontSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; }
bool HasFontItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; }
bool HasFontUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; }
bool HasFontFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE) != 0; }
bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); }
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 HasLeftIndent() const { return (m_flags & wxTEXT_ATTR_LEFT_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 HasSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; }
bool HasItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; }
bool HasUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; }
bool HasFaceName() const { return (m_flags & wxTEXT_ATTR_FONT_FACE) != 0; }
bool HasFontWeight() const { return (m_flags & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
bool HasFontSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; }
bool HasFontItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; }
bool HasFontUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; }
bool HasFontFaceName() const { return (m_flags & wxTEXT_ATTR_FONT_FACE) != 0; }
bool HasFont() const { return (m_flags & (wxTEXT_ATTR_FONT)) != 0; }
bool HasParagraphSpacingAfter() const { return (m_flags & wxTEXT_ATTR_PARA_SPACING_AFTER) != 0; }
@@ -601,12 +601,16 @@ public:
return GetFlags() == 0;
}
// return the attribute having the valid font and colours: it uses the
// attributes set in attr and falls back first to attrDefault and then to
// the text control font/colours for those attributes which are not set
static wxRichTextAttr Combine(const wxRichTextAttr& attr,
const wxRichTextAttr& attrDef,
const wxTextCtrlBase *text);
// Merges the given attributes. 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.
bool Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL);
// 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:
long m_flags;
+16 -4
View File
@@ -93,11 +93,14 @@ public:
void SetBaseStyle(const wxString& name) { m_baseStyle = name; }
const wxString& GetBaseStyle() const { return m_baseStyle; }
/// Sets the style
/// Sets and gets the style
void SetStyle(const wxRichTextAttr& style) { m_style = style; }
const wxRichTextAttr& GetStyle() const { return m_style; }
wxRichTextAttr& GetStyle() { return m_style; }
/// Gets the style combined with the base style
virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
protected:
wxString m_name;
wxString m_baseStyle;
@@ -215,15 +218,15 @@ public:
/// Combine the base and list style with a paragraph style, using the given indent (from which
/// 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
/// 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
/// an appropriate level is found)
wxRichTextAttr GetCombinedStyleForLevel(int level);
wxRichTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL);
/// Gets the number of available levels
int GetLevelCount() const { return 10; }
@@ -276,6 +279,9 @@ public:
/// Add a definition to the list style list
bool AddListStyle(wxRichTextListStyleDefinition* def);
/// Add a definition to the appropriate style list
bool AddStyle(wxRichTextStyleDefinition* def);
/// Remove a character style
bool RemoveCharacterStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_characterStyleDefinitions, def, deleteStyle); }
@@ -285,6 +291,9 @@ public:
/// Remove a list style
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
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
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
size_t GetCharacterStyleCount() const { return m_characterStyleDefinitions.GetCount(); }
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -2929,7 +2929,7 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
{
// Flags are defined within each definition, so only certain
// attributes are applied.
wxRichTextAttr attr(def->GetStyle());
wxRichTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle());
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE;
+5 -5
View File
@@ -383,7 +383,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_dontUpdate = true;
wxTextAttrEx* attr = GetAttributes();
if (attr->HasFont() && attr->HasFaceName())
if (attr->HasFont() && attr->HasFontFaceName())
{
m_faceTextCtrl->SetValue(attr->GetFont().GetFaceName());
m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName());
@@ -394,7 +394,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_faceListBox->SetFaceNameSelection(wxEmptyString);
}
if (attr->HasFont() && attr->HasSize())
if (attr->HasFont() && attr->HasFontSize())
{
wxString strSize = wxString::Format(wxT("%d"), attr->GetFont().GetPointSize());
m_sizeTextCtrl->SetValue(strSize);
@@ -407,7 +407,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_sizeListBox->SetSelection(wxNOT_FOUND);
}
if (attr->HasFont() && attr->HasWeight())
if (attr->HasFont() && attr->HasFontWeight())
{
if (attr->GetFont().GetWeight() == wxBOLD)
m_weightCtrl->SetSelection(1);
@@ -419,7 +419,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_weightCtrl->SetSelection(wxNOT_FOUND);
}
if (attr->HasFont() && attr->HasItalic())
if (attr->HasFont() && attr->HasFontItalic())
{
if (attr->GetFont().GetStyle() == wxITALIC)
m_styleCtrl->SetSelection(1);
@@ -431,7 +431,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
m_styleCtrl->SetSelection(wxNOT_FOUND);
}
if (attr->HasFont() && attr->HasUnderlined())
if (attr->HasFont() && attr->HasFontUnderlined())
{
if (attr->GetFont().GetUnderlined())
m_underliningCtrl->SetSelection(1);
+4 -1
View File
@@ -527,8 +527,11 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
wxRichTextListStyleDefinition* def = wxDynamicCast(wxRichTextFormattingDialog::GetDialogStyleDefinition(this),
wxRichTextListStyleDefinition);
wxRichTextStyleSheet* styleSheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
wxTextAttrEx attr(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet));
wxTextAttrEx attr(def->GetStyle());
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|
+1 -9
View File
@@ -425,16 +425,8 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
wxRichTextStyleDefinition* def = m_stylesListBox->GetStyleListBox()->GetStyle(sel);
wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition);
//wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
//wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
wxTextAttrEx attr(def->GetStyle());
#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
wxTextAttrEx attr(def->GetStyleMergedWithBase(GetStyleSheet()));
wxFont font(m_previewCtrl->GetFont());
font.SetPointSize(9);
+90 -18
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);
}
/// 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
*/
@@ -162,7 +178,7 @@ int wxRichTextListStyleDefinition::FindLevelForIndent(int indent) const
/// Combine the list style with a paragraph style, using the given indent (from which
/// 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);
@@ -171,10 +187,13 @@ wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int inde
int oldLeftSubIndent = attr.GetLeftSubIndent();
// 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
wxRichTextApplyStyle(attr, paraStyle);
attr.Apply(paraStyle);
// We override the indents according to the list definition
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
/// an appropriate level is found)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet)
{
int listLevel = FindLevelForIndent(indent);
return GetCombinedStyleForLevel(listLevel);
return GetCombinedStyleForLevel(listLevel, styleSheet);
}
/// Combine the base and list style, using the given indent (from which
/// an appropriate level is found)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel)
wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet)
{
wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent();
// 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
attr.SetLeftIndent(oldLeftIndent, oldLeftSubIndent);
@@ -266,6 +288,18 @@ bool wxRichTextStyleSheet::RemoveStyle(wxList& list, wxRichTextStyleDefinition*
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
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);
}
/// 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
void wxRichTextStyleSheet::Copy(const wxRichTextStyleSheet& sheet)
{
@@ -540,8 +610,10 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
wxString str;
bool isCentred = false;
wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
if (def->GetStyle().HasAlignment() && def->GetStyle().GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
isCentred = true;
if (isCentred)
@@ -550,11 +622,11 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
str << wxT("<table><tr>");
if (def->GetStyle().GetLeftIndent() > 0)
if (attr.GetLeftIndent() > 0)
{
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)
@@ -569,7 +641,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
#endif
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)
size ++;
@@ -580,11 +652,11 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
str << wxT(" size=") << size;
if (!def->GetStyle().GetFontFaceName().IsEmpty())
str << wxT(" face=\"") << def->GetStyle().GetFontFaceName() << wxT("\"");
if (!attr.GetFontFaceName().IsEmpty())
str << wxT(" face=\"") << attr.GetFontFaceName() << wxT("\"");
if (def->GetStyle().GetTextColour().Ok())
str << wxT(" color=\"#") << ColourToHexString(def->GetStyle().GetTextColour()) << wxT("\"");
if (attr.GetTextColour().Ok())
str << wxT(" color=\"#") << ColourToHexString(attr.GetTextColour()) << wxT("\"");
str << wxT(">");
@@ -592,11 +664,11 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
bool hasItalic = false;
bool hasUnderline = false;
if (def->GetStyle().GetFontWeight() == wxBOLD)
if (attr.GetFontWeight() == wxBOLD)
hasBold = true;
if (def->GetStyle().GetFontStyle() == wxITALIC)
if (attr.GetFontStyle() == wxITALIC)
hasItalic = true;
if (def->GetStyle().GetFontUnderlined())
if (attr.GetFontUnderlined())
hasUnderline = true;
if (hasBold)
+6 -6
View File
@@ -893,22 +893,22 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara
if (attr.GetFont().Ok())
{
if (attr.HasSize())
if (attr.HasFontSize())
str << wxT(" fontsize=\"") << attr.GetFont().GetPointSize() << wxT("\"");
//if (attr.HasFamily())
//if (attr.HasFontFamily())
// str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\"");
if (attr.HasItalic())
if (attr.HasFontItalic())
str << wxT(" fontstyle=\"") << attr.GetFont().GetStyle() << wxT("\"");
if (attr.HasWeight())
if (attr.HasFontWeight())
str << wxT(" fontweight=\"") << attr.GetFont().GetWeight() << wxT("\"");
if (attr.HasUnderlined())
if (attr.HasFontUnderlined())
str << wxT(" fontunderlined=\"") << (int) attr.GetFont().GetUnderlined() << wxT("\"");
if (attr.HasFaceName())
if (attr.HasFontFaceName())
str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\"");
}