⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 richtextstyles.h

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 H
📖 第 1 页 / 共 2 页
字号:
/////////////////////////////////////////////////////////////////////////////// Name:        wx/richtext/richtextstyles.h// Purpose:     Style management for wxRichTextCtrl// Author:      Julian Smart// Modified by:// Created:     2005-09-30// RCS-ID:      $Id: richtextstyles.h,v 1.17 2006/11/26 12:47:49 JS Exp $// Copyright:   (c) Julian Smart// Licence:     wxWindows licence/////////////////////////////////////////////////////////////////////////////#ifndef _WX_RICHTEXTSTYLES_H_#define _WX_RICHTEXTSTYLES_H_/*! * Includes */#include "wx/defs.h"#if wxUSE_RICHTEXT#include "wx/richtext/richtextbuffer.h"#if wxUSE_HTML#include "wx/htmllbox.h"#endif#if wxUSE_COMBOCTRL#include "wx/combo.h"#endif#include "wx/choice.h"/*! * Forward declarations */class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl;class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer;/*! * wxRichTextStyleDefinition class declaration * A base class for paragraph and character styles. */class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition: public wxObject{    DECLARE_CLASS(wxRichTextStyleDefinition)public:    /// Copy constructors    wxRichTextStyleDefinition(const wxRichTextStyleDefinition& def)    : wxObject()    {        Init();        Copy(def);    }    /// Default constructor    wxRichTextStyleDefinition(const wxString& name = wxEmptyString) { Init(); m_name = name; }    /// Destructor    virtual ~wxRichTextStyleDefinition() {}    /// Initialises members    void Init() {}    /// Copies from def    void Copy(const wxRichTextStyleDefinition& def);    /// Equality test    bool Eq(const wxRichTextStyleDefinition& def) const;    /// Assignment operator    void operator =(const wxRichTextStyleDefinition& def) { Copy(def); }    /// Equality operator    bool operator ==(const wxRichTextStyleDefinition& def) const { return Eq(def); }    /// Override to clone the object    virtual wxRichTextStyleDefinition* Clone() const = 0;    /// Sets and gets the name of the style    void SetName(const wxString& name) { m_name = name; }    const wxString& GetName() const { return m_name; }    /// Sets and gets the style description    void SetDescription(const wxString& descr) { m_description = descr; }    const wxString& GetDescription() const { return m_description; }    /// Sets and gets the name of the style that this style is based on    void SetBaseStyle(const wxString& name) { m_baseStyle = name; }    const wxString& GetBaseStyle() const { return m_baseStyle; }    /// 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;    wxString        m_description;    wxRichTextAttr  m_style;};/*! * wxRichTextCharacterStyleDefinition class declaration */class WXDLLIMPEXP_RICHTEXT wxRichTextCharacterStyleDefinition: public wxRichTextStyleDefinition{    DECLARE_DYNAMIC_CLASS(wxRichTextCharacterStyleDefinition)public:    /// Copy constructor    wxRichTextCharacterStyleDefinition(const wxRichTextCharacterStyleDefinition& def): wxRichTextStyleDefinition(def) {}    /// Default constructor    wxRichTextCharacterStyleDefinition(const wxString& name = wxEmptyString):        wxRichTextStyleDefinition(name) {}    /// Destructor    virtual ~wxRichTextCharacterStyleDefinition() {}    /// Clones the object    virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextCharacterStyleDefinition(*this); }protected:};/*! * wxRichTextParagraphStyleDefinition class declaration */class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphStyleDefinition: public wxRichTextStyleDefinition{    DECLARE_DYNAMIC_CLASS(wxRichTextParagraphStyleDefinition)public:    /// Copy constructor    wxRichTextParagraphStyleDefinition(const wxRichTextParagraphStyleDefinition& def): wxRichTextStyleDefinition(def) { m_nextStyle = def.m_nextStyle; }    /// Default constructor    wxRichTextParagraphStyleDefinition(const wxString& name = wxEmptyString):        wxRichTextStyleDefinition(name) {}    // Destructor    virtual ~wxRichTextParagraphStyleDefinition() {}    /// Sets and gets the next style    void SetNextStyle(const wxString& name) { m_nextStyle = name; }    const wxString& GetNextStyle() const { return m_nextStyle; }    /// Copies from def    void Copy(const wxRichTextParagraphStyleDefinition& def);    /// Assignment operator    void operator =(const wxRichTextParagraphStyleDefinition& def) { Copy(def); }    /// Equality operator    bool operator ==(const wxRichTextParagraphStyleDefinition& def) const;    /// Clones the object    virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextParagraphStyleDefinition(*this); }protected:    /// The next style to use when adding a paragraph after this style.    wxString    m_nextStyle;};/*! * wxRichTextListStyleDefinition class declaration */class WXDLLIMPEXP_RICHTEXT wxRichTextListStyleDefinition: public wxRichTextParagraphStyleDefinition{    DECLARE_DYNAMIC_CLASS(wxRichTextListStyleDefinition)public:    /// Copy constructor    wxRichTextListStyleDefinition(const wxRichTextListStyleDefinition& def): wxRichTextParagraphStyleDefinition(def) { Init(); Copy(def); }    /// Default constructor    wxRichTextListStyleDefinition(const wxString& name = wxEmptyString):        wxRichTextParagraphStyleDefinition(name) { Init(); }    /// Destructor    virtual ~wxRichTextListStyleDefinition() {}    /// Copies from def    void Copy(const wxRichTextListStyleDefinition& def);    /// Assignment operator    void operator =(const wxRichTextListStyleDefinition& def) { Copy(def); }    /// Equality operator    bool operator ==(const wxRichTextListStyleDefinition& def) const;    /// Clones the object    virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextListStyleDefinition(*this); }    /// Sets/gets the attributes for the given level    void SetLevelAttributes(int i, const wxRichTextAttr& attr);    wxRichTextAttr* GetLevelAttributes(int i);    const wxRichTextAttr* GetLevelAttributes(int i) const;    /// Convenience function for setting the major attributes for a list level specification    void SetAttributes(int i, int leftIndent, int leftSubIndent, int bulletStyle, const wxString& bulletSymbol = wxEmptyString);    /// Finds the level corresponding to the given indentation    int FindLevelForIndent(int indent) const;    /// 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, wxRichTextStyleSheet* styleSheet = NULL);    /// Combine the base and list style, using the given indent (from which    /// an appropriate level is found)    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, wxRichTextStyleSheet* styleSheet = NULL);    /// Gets the number of available levels    int GetLevelCount() const { return 10; }    /// Is this a numbered list?    bool IsNumbered(int i) const;protected:    /// The styles for each level (up to 10)    wxRichTextAttr m_levelStyles[10];};/*! * The style sheet */class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet: public wxObject{    DECLARE_CLASS( wxRichTextStyleSheet )public:    /// Constructors    wxRichTextStyleSheet(const wxRichTextStyleSheet& sheet)    : wxObject()    {        Copy(sheet);    }    wxRichTextStyleSheet() { Init(); }    virtual ~wxRichTextStyleSheet();    /// 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);    /// Add a definition to the paragraph style list    bool AddParagraphStyle(wxRichTextParagraphStyleDefinition* def);    /// 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); }    /// Remove a paragraph style    bool RemoveParagraphStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_paragraphStyleDefinitions, def, deleteStyle); }    /// 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); }    /// Find a paragraph definition by name    wxRichTextParagraphStyleDefinition* FindParagraphStyle(const wxString& name, bool recurse = true) const { return (wxRichTextParagraphStyleDefinition*) FindStyle(m_paragraphStyleDefinitions, name, recurse); }    /// 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(); }    /// Return the number of paragraph styles    size_t GetParagraphStyleCount() const { return m_paragraphStyleDefinitions.GetCount(); }    /// Return the number of list styles    size_t GetListStyleCount() const { return m_listStyleDefinitions.GetCount(); }    /// Return the nth character style    wxRichTextCharacterStyleDefinition* GetCharacterStyle(size_t n) const { return (wxRichTextCharacterStyleDefinition*) m_characterStyleDefinitions.Item(n)->GetData(); }    /// Return the nth paragraph style    wxRichTextParagraphStyleDefinition* GetParagraphStyle(size_t n) const { return (wxRichTextParagraphStyleDefinition*) m_paragraphStyleDefinitions.Item(n)->GetData(); }    /// Return the nth list style    wxRichTextListStyleDefinition* GetListStyle(size_t n) const { return (wxRichTextListStyleDefinition*) m_listStyleDefinitions.Item(n)->GetData(); }    /// Delete all styles    void DeleteStyles();    /// Insert into list of style sheets    bool InsertSheet(wxRichTextStyleSheet* before);    /// Append to list of style sheets    bool AppendSheet(wxRichTextStyleSheet* after);    /// Unlink from the list of style sheets    void Unlink();    /// Get/set next sheet    wxRichTextStyleSheet* GetNextSheet() const { return m_nextSheet; }    void SetNextSheet(wxRichTextStyleSheet* sheet) { m_nextSheet = sheet; }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -