Fixed bugs in, and added operators and copy constructors to, style
sheet classes. Now merges base, paragraph and content styles dynamically on display or layout so that we can distinguish between them. This means appling a paragraph style that has character formatting doesn't wipe out the original content formatting. The old-style static method can be enabled by setting wxRICHTEXT_USE_DYNAMIC_STYLES to 0 in richtextbuffer.h. The default style is initially empty, so that adding text reflects the base and paragraph styles. Setting the default style doesn't merge with the previous setting, but BeginStyle does. Adding new paragraphs is now sensitive to the previous paragraph's style and also whether its style has a next-paragraph style indication. Added wxRichTextCtrl::ApplyStyleSheet which reapplies styles to paragraphs with named styles. Added style application command to sample to demonstrate how styles can be changed and reapplied without affecting content character formatting. Fixed some range bugs in UI feedback and clipboard copying and pasting. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41501 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -47,10 +47,15 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
wxRichTextStyleDefinition(const wxRichTextStyleDefinition& def) { Copy(def); }
|
||||
wxRichTextStyleDefinition(const wxString& name = wxEmptyString) { Init(); m_name = name; }
|
||||
virtual ~wxRichTextStyleDefinition() {}
|
||||
|
||||
void Init() {}
|
||||
void Copy(const wxRichTextStyleDefinition& def);
|
||||
bool Eq(const wxRichTextStyleDefinition& def) const;
|
||||
void operator =(const wxRichTextStyleDefinition& def) { Copy(def); }
|
||||
bool operator ==(const wxRichTextStyleDefinition& def) const { return Eq(def); }
|
||||
|
||||
/// The name of the style.
|
||||
void SetName(const wxString& name) { m_name = name; }
|
||||
@@ -82,6 +87,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
wxRichTextCharacterStyleDefinition(const wxRichTextCharacterStyleDefinition& def): wxRichTextStyleDefinition(def) {}
|
||||
wxRichTextCharacterStyleDefinition(const wxString& name = wxEmptyString):
|
||||
wxRichTextStyleDefinition(name) {}
|
||||
virtual ~wxRichTextCharacterStyleDefinition() {}
|
||||
@@ -100,6 +106,7 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
wxRichTextParagraphStyleDefinition(const wxRichTextParagraphStyleDefinition& def): wxRichTextStyleDefinition(def) { m_nextStyle = def.m_nextStyle; }
|
||||
wxRichTextParagraphStyleDefinition(const wxString& name = wxEmptyString):
|
||||
wxRichTextStyleDefinition(name) {}
|
||||
virtual ~wxRichTextParagraphStyleDefinition() {}
|
||||
@@ -108,6 +115,10 @@ public:
|
||||
void SetNextStyle(const wxString& name) { m_nextStyle = name; }
|
||||
const wxString& GetNextStyle() const { return m_nextStyle; }
|
||||
|
||||
void Copy(const wxRichTextParagraphStyleDefinition& def);
|
||||
void operator =(const wxRichTextParagraphStyleDefinition& def) { Copy(def); }
|
||||
bool operator ==(const wxRichTextParagraphStyleDefinition& def) const;
|
||||
|
||||
protected:
|
||||
|
||||
/// The next style to use when adding a paragraph after this style.
|
||||
@@ -124,29 +135,39 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet: public wxObject
|
||||
|
||||
public:
|
||||
/// Constructors
|
||||
wxRichTextStyleSheet(const wxRichTextStyleSheet& sheet) { Copy(sheet); }
|
||||
wxRichTextStyleSheet() { Init(); }
|
||||
virtual ~wxRichTextStyleSheet() { DeleteStyles(); }
|
||||
|
||||
/// Initialisation
|
||||
void Init();
|
||||
|
||||
/// Copy
|
||||
void Copy(const wxRichTextStyleSheet& sheet);
|
||||
|
||||
/// Assignment
|
||||
void operator=(const wxRichTextStyleSheet& sheet) { Copy(sheet); }
|
||||
|
||||
/// Equality
|
||||
bool operator==(const wxRichTextStyleSheet& sheet) const;
|
||||
|
||||
/// Add a definition to the character style list
|
||||
bool AddCharacterStyle(wxRichTextCharacterStyleDefinition* def) { return AddStyle(m_characterStyleDefinitions, def); }
|
||||
bool AddCharacterStyle(wxRichTextCharacterStyleDefinition* def);
|
||||
|
||||
/// Add a definition to the paragraph style list
|
||||
bool AddParagraphStyle(wxRichTextParagraphStyleDefinition* def) { return AddStyle(m_paragraphStyleDefinitions, def); }
|
||||
bool AddParagraphStyle(wxRichTextParagraphStyleDefinition* def);
|
||||
|
||||
/// Remove a character style
|
||||
bool RemoveCharacterStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_characterStyleDefinitions, def, deleteStyle); }
|
||||
|
||||
/// Remove a paragraph style
|
||||
bool RemoveParagraphStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_characterStyleDefinitions, def, deleteStyle); }
|
||||
bool RemoveParagraphStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_paragraphStyleDefinitions, def, deleteStyle); }
|
||||
|
||||
/// Find a character definition by name
|
||||
wxRichTextCharacterStyleDefinition* FindCharacterStyle(const wxString& name) const { return (wxRichTextCharacterStyleDefinition*) FindStyle(m_characterStyleDefinitions, name); }
|
||||
|
||||
/// Find a paragraph definition by name
|
||||
wxRichTextParagraphStyleDefinition* FindParagraphStyle(const wxString& name) const { return (wxRichTextParagraphStyleDefinition*) FindStyle(m_characterStyleDefinitions, name); }
|
||||
wxRichTextParagraphStyleDefinition* FindParagraphStyle(const wxString& name) const { return (wxRichTextParagraphStyleDefinition*) FindStyle(m_paragraphStyleDefinitions, name); }
|
||||
|
||||
/// Return the number of character styes.
|
||||
size_t GetCharacterStyleCount() const { return m_characterStyleDefinitions.GetCount(); }
|
||||
|
Reference in New Issue
Block a user