Added custom properties to style definitions and style sheets
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71276 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -101,11 +101,27 @@ public:
|
|||||||
/// Gets the style combined with the base style
|
/// Gets the style combined with the base style
|
||||||
virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
|
virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the definition's properties.
|
||||||
|
*/
|
||||||
|
wxRichTextProperties& GetProperties() { return m_properties; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the definition's properties.
|
||||||
|
*/
|
||||||
|
const wxRichTextProperties& GetProperties() const { return m_properties; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the definition's properties.
|
||||||
|
*/
|
||||||
|
void SetProperties(const wxRichTextProperties& props) { m_properties = props; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_name;
|
wxString m_name;
|
||||||
wxString m_baseStyle;
|
wxString m_baseStyle;
|
||||||
wxString m_description;
|
wxString m_description;
|
||||||
wxRichTextAttr m_style;
|
wxRichTextAttr m_style;
|
||||||
|
wxRichTextProperties m_properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -402,6 +418,21 @@ public:
|
|||||||
void SetDescription(const wxString& descr) { m_description = descr; }
|
void SetDescription(const wxString& descr) { m_description = descr; }
|
||||||
const wxString& GetDescription() const { return m_description; }
|
const wxString& GetDescription() const { return m_description; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the definition's properties.
|
||||||
|
*/
|
||||||
|
wxRichTextProperties& GetProperties() { return m_properties; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the definition's properties.
|
||||||
|
*/
|
||||||
|
const wxRichTextProperties& GetProperties() const { return m_properties; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the definition's properties.
|
||||||
|
*/
|
||||||
|
void SetProperties(const wxRichTextProperties& props) { m_properties = props; }
|
||||||
|
|
||||||
/// Implementation
|
/// Implementation
|
||||||
|
|
||||||
/// Add a definition to one of the style lists
|
/// Add a definition to one of the style lists
|
||||||
@@ -425,6 +456,7 @@ protected:
|
|||||||
|
|
||||||
wxRichTextStyleSheet* m_previousSheet;
|
wxRichTextStyleSheet* m_previousSheet;
|
||||||
wxRichTextStyleSheet* m_nextSheet;
|
wxRichTextStyleSheet* m_nextSheet;
|
||||||
|
wxRichTextProperties m_properties;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if wxUSE_HTML
|
#if wxUSE_HTML
|
||||||
|
@@ -69,6 +69,7 @@ public:
|
|||||||
bool ImportXML(wxRichTextBuffer* buffer, wxRichTextObject* obj, wxXmlNode* node);
|
bool ImportXML(wxRichTextBuffer* buffer, wxRichTextObject* obj, wxXmlNode* node);
|
||||||
bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node);
|
bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node);
|
||||||
bool ImportProperties(wxRichTextObject* obj, wxXmlNode* node);
|
bool ImportProperties(wxRichTextObject* obj, wxXmlNode* node);
|
||||||
|
bool ImportProperties(wxRichTextProperties& properties, wxXmlNode* node);
|
||||||
|
|
||||||
/// Import style parameters
|
/// Import style parameters
|
||||||
bool ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara = false);
|
bool ImportStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara = false);
|
||||||
|
@@ -2377,7 +2377,7 @@ public:
|
|||||||
wxRichTextAttr& GetAttributes() { return m_attributes; }
|
wxRichTextAttr& GetAttributes() { return m_attributes; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the object's properties.
|
Returns the object's properties.
|
||||||
*/
|
*/
|
||||||
wxRichTextProperties& GetProperties() { return m_properties; }
|
wxRichTextProperties& GetProperties() { return m_properties; }
|
||||||
|
|
||||||
@@ -2387,7 +2387,7 @@ public:
|
|||||||
const wxRichTextProperties& GetProperties() const { return m_properties; }
|
const wxRichTextProperties& GetProperties() const { return m_properties; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the object's properties.
|
Sets the object's properties.
|
||||||
*/
|
*/
|
||||||
void SetProperties(const wxRichTextProperties& props) { m_properties = props; }
|
void SetProperties(const wxRichTextProperties& props) { m_properties = props; }
|
||||||
|
|
||||||
|
@@ -179,6 +179,21 @@ public:
|
|||||||
Sets the attributes for this style.
|
Sets the attributes for this style.
|
||||||
*/
|
*/
|
||||||
void SetStyle(const wxTextAttr& style);
|
void SetStyle(const wxTextAttr& style);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the definition's properties.
|
||||||
|
*/
|
||||||
|
wxRichTextProperties& GetProperties();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the definition's properties.
|
||||||
|
*/
|
||||||
|
const wxRichTextProperties& GetProperties() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the definition's properties.
|
||||||
|
*/
|
||||||
|
void SetProperties(const wxRichTextProperties& props);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -662,5 +677,20 @@ public:
|
|||||||
Sets the style sheet's name.
|
Sets the style sheet's name.
|
||||||
*/
|
*/
|
||||||
void SetName(const wxString& name);
|
void SetName(const wxString& name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the sheet's properties.
|
||||||
|
*/
|
||||||
|
wxRichTextProperties& GetProperties();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the sheet's properties.
|
||||||
|
*/
|
||||||
|
const wxRichTextProperties& GetProperties() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets the sheet's properties.
|
||||||
|
*/
|
||||||
|
void SetProperties(const wxRichTextProperties& props);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -47,11 +47,12 @@ void wxRichTextStyleDefinition::Copy(const wxRichTextStyleDefinition& def)
|
|||||||
m_baseStyle = def.m_baseStyle;
|
m_baseStyle = def.m_baseStyle;
|
||||||
m_style = def.m_style;
|
m_style = def.m_style;
|
||||||
m_description = def.m_description;
|
m_description = def.m_description;
|
||||||
|
m_properties = def.m_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const
|
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 && m_properties == def.m_properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the style combined with the base style
|
/// Gets the style combined with the base style
|
||||||
@@ -523,6 +524,7 @@ void wxRichTextStyleSheet::Copy(const wxRichTextStyleSheet& sheet)
|
|||||||
|
|
||||||
SetName(sheet.GetName());
|
SetName(sheet.GetName());
|
||||||
SetDescription(sheet.GetDescription());
|
SetDescription(sheet.GetDescription());
|
||||||
|
m_properties = sheet.m_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Equality
|
/// Equality
|
||||||
|
@@ -207,6 +207,11 @@ bool wxRichTextXMLHandler::ImportXML(wxRichTextBuffer* buffer, wxRichTextObject*
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wxRichTextXMLHandler::ImportProperties(wxRichTextObject* obj, wxXmlNode* node)
|
bool wxRichTextXMLHandler::ImportProperties(wxRichTextObject* obj, wxXmlNode* node)
|
||||||
|
{
|
||||||
|
return ImportProperties(obj->GetProperties(), node);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxRichTextXMLHandler::ImportProperties(wxRichTextProperties& properties, wxXmlNode* node)
|
||||||
{
|
{
|
||||||
wxXmlNode* child = node->GetChildren();
|
wxXmlNode* child = node->GetChildren();
|
||||||
while (child)
|
while (child)
|
||||||
@@ -225,7 +230,7 @@ bool wxRichTextXMLHandler::ImportProperties(wxRichTextObject* obj, wxXmlNode* no
|
|||||||
wxVariant var = MakePropertyFromString(name, value, type);
|
wxVariant var = MakePropertyFromString(name, value, type);
|
||||||
if (!var.IsNull())
|
if (!var.IsNull())
|
||||||
{
|
{
|
||||||
obj->GetProperties().SetProperty(var);
|
properties.SetProperty(var);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
propertyChild = propertyChild->GetNext();
|
propertyChild = propertyChild->GetNext();
|
||||||
@@ -262,6 +267,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
|
|||||||
child = child->GetNext();
|
child = child->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImportProperties(def->GetProperties(), node);
|
||||||
|
|
||||||
sheet->AddCharacterStyle(def);
|
sheet->AddCharacterStyle(def);
|
||||||
}
|
}
|
||||||
else if (styleType == wxT("paragraphstyle"))
|
else if (styleType == wxT("paragraphstyle"))
|
||||||
@@ -284,6 +291,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
|
|||||||
child = child->GetNext();
|
child = child->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImportProperties(def->GetProperties(), node);
|
||||||
|
|
||||||
sheet->AddParagraphStyle(def);
|
sheet->AddParagraphStyle(def);
|
||||||
}
|
}
|
||||||
else if (styleType == wxT("boxstyle"))
|
else if (styleType == wxT("boxstyle"))
|
||||||
@@ -304,6 +313,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
|
|||||||
child = child->GetNext();
|
child = child->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImportProperties(def->GetProperties(), node);
|
||||||
|
|
||||||
sheet->AddBoxStyle(def);
|
sheet->AddBoxStyle(def);
|
||||||
}
|
}
|
||||||
else if (styleType == wxT("liststyle"))
|
else if (styleType == wxT("liststyle"))
|
||||||
@@ -339,6 +350,8 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
|
|||||||
child = child->GetNext();
|
child = child->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImportProperties(def->GetProperties(), node);
|
||||||
|
|
||||||
sheet->AddListStyle(def);
|
sheet->AddListStyle(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -835,6 +848,8 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
|
|||||||
wxRichTextBoxStyleDefinition* def = buffer->GetStyleSheet()->GetBoxStyle(i);
|
wxRichTextBoxStyleDefinition* def = buffer->GetStyleSheet()->GetBoxStyle(i);
|
||||||
ExportStyleDefinition(styleSheetNode, def);
|
ExportStyleDefinition(styleSheetNode, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteProperties(styleSheetNode, buffer->GetStyleSheet()->GetProperties());
|
||||||
}
|
}
|
||||||
bool success = ExportXML(rootNode, *buffer);
|
bool success = ExportXML(rootNode, *buffer);
|
||||||
#if wxRICHTEXT_USE_OUTPUT_TIMINGS
|
#if wxRICHTEXT_USE_OUTPUT_TIMINGS
|
||||||
@@ -910,6 +925,8 @@ bool wxRichTextXMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
|
|||||||
ExportStyleDefinition(stream, def, level + 1);
|
ExportStyleDefinition(stream, def, level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteProperties(stream, buffer->GetStyleSheet()->GetProperties(), level);
|
||||||
|
|
||||||
OutputIndentation(stream, level);
|
OutputIndentation(stream, level);
|
||||||
OutputString(stream, wxT("</stylesheet>"));
|
OutputString(stream, wxT("</stylesheet>"));
|
||||||
}
|
}
|
||||||
@@ -1373,6 +1390,8 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxXmlNode* parent, wxRichTextSt
|
|||||||
AddAttributes(styleNode, def->GetStyle(), true);
|
AddAttributes(styleNode, def->GetStyle(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WriteProperties(defNode, def->GetProperties());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2532,6 +2551,7 @@ bool wxRichTextParagraphLayoutBox::ImportFromXML(wxRichTextBuffer* buffer, wxXml
|
|||||||
|
|
||||||
child2 = child2->GetNext();
|
child2 = child2->GetNext();
|
||||||
}
|
}
|
||||||
|
handler->ImportProperties(sheet->GetProperties(), child);
|
||||||
|
|
||||||
// Notify that styles have changed. If this is vetoed by the app,
|
// Notify that styles have changed. If this is vetoed by the app,
|
||||||
// the new sheet will be deleted. If it is not vetoed, the
|
// the new sheet will be deleted. If it is not vetoed, the
|
||||||
|
Reference in New Issue
Block a user