📄 richtextbuffer.h
字号:
int m_paragraphSpacingAfter; int m_paragraphSpacingBefore; int m_lineSpacing; int m_bulletStyle; int m_bulletNumber; int m_textEffects; int m_textEffectFlags; int m_outlineLevel; wxString m_bulletText; wxString m_bulletFont; wxString m_bulletName; wxString m_urlTarget; // Character styles wxColour m_colText, m_colBack; int m_fontSize; int m_fontStyle; int m_fontWeight; bool m_fontUnderlined; wxString m_fontFaceName; // Character style wxString m_characterStyleName; // Paragraph style wxString m_paragraphStyleName; // List style wxString m_listStyleName;};/*! * wxRichTextObject class declaration * This is the base for drawable objects. */class WXDLLIMPEXP_RICHTEXT wxRichTextObject: public wxObject{ DECLARE_CLASS(wxRichTextObject)public:// Constructors wxRichTextObject(wxRichTextObject* parent = NULL); virtual ~wxRichTextObject();// Overrideables /// Draw the item, within the given range. Some objects may ignore the range (for /// example paragraphs) while others must obey it (lines, to implement wrapping) virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style) = 0; /// Lay the item out at the specified position with the given size constraint. /// Layout must set the cached size. virtual bool Layout(wxDC& dc, const wxRect& rect, int style) = 0; /// Hit-testing: returns a flag indicating hit test details, plus /// information about position virtual int HitTest(wxDC& WXUNUSED(dc), const wxPoint& WXUNUSED(pt), long& WXUNUSED(textPosition)) { return false; } /// Finds the absolute position and row height for the given character position virtual bool FindPosition(wxDC& WXUNUSED(dc), long WXUNUSED(index), wxPoint& WXUNUSED(pt), int* WXUNUSED(height), bool WXUNUSED(forceLineStart)) { return false; } /// Get the best size, i.e. the ideal starting size for this object irrespective /// of available space. For a short text string, it will be the size that exactly encloses /// the text. For a longer string, it might use the parent width for example. virtual wxSize GetBestSize() const { return m_size; } /// Get the object size for the given range. Returns false if the range /// is invalid for this object. virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0)) const = 0; /// Do a split, returning an object containing the second part, and setting /// the first part in 'this'. virtual wxRichTextObject* DoSplit(long WXUNUSED(pos)) { return NULL; } /// Calculate range. By default, guess that the object is 1 unit long. virtual void CalculateRange(long start, long& end) { end = start ; m_range.SetRange(start, end); } /// Delete range virtual bool DeleteRange(const wxRichTextRange& WXUNUSED(range)) { return false; } /// Returns true if the object is empty virtual bool IsEmpty() const { return false; } /// Get any text in this object for the given range virtual wxString GetTextForRange(const wxRichTextRange& WXUNUSED(range)) const { return wxEmptyString; } /// Returns true if this object can merge itself with the given one. virtual bool CanMerge(wxRichTextObject* WXUNUSED(object)) const { return false; } /// Returns true if this object merged itself with the given one. /// The calling code will then delete the given object. virtual bool Merge(wxRichTextObject* WXUNUSED(object)) { return false; } /// Dump to output stream for debugging virtual void Dump(wxTextOutputStream& stream);// Accessors /// Get/set the cached object size as calculated by Layout. virtual wxSize GetCachedSize() const { return m_size; } virtual void SetCachedSize(const wxSize& sz) { m_size = sz; } /// Get/set the object position virtual wxPoint GetPosition() const { return m_pos; } virtual void SetPosition(const wxPoint& pos) { m_pos = pos; } /// Get the rectangle enclosing the object virtual wxRect GetRect() const { return wxRect(GetPosition(), GetCachedSize()); } /// Set the range void SetRange(const wxRichTextRange& range) { m_range = range; } /// Get the range const wxRichTextRange& GetRange() const { return m_range; } wxRichTextRange& GetRange() { return m_range; } /// Get/set dirty flag (whether the object needs Layout to be called) virtual bool GetDirty() const { return m_dirty; } virtual void SetDirty(bool dirty) { m_dirty = dirty; } /// Is this composite? virtual bool IsComposite() const { return false; } /// Get/set the parent. virtual wxRichTextObject* GetParent() const { return m_parent; } virtual void SetParent(wxRichTextObject* parent) { m_parent = parent; } /// Set the margin around the object virtual void SetMargins(int margin); virtual void SetMargins(int leftMargin, int rightMargin, int topMargin, int bottomMargin); virtual int GetLeftMargin() const { return m_leftMargin; } virtual int GetRightMargin() const { return m_rightMargin; } virtual int GetTopMargin() const { return m_topMargin; } virtual int GetBottomMargin() const { return m_bottomMargin; } /// Set attributes object void SetAttributes(const wxTextAttrEx& attr) { m_attributes = attr; } const wxTextAttrEx& GetAttributes() const { return m_attributes; } wxTextAttrEx& GetAttributes() { return m_attributes; } /// Set/get stored descent void SetDescent(int descent) { m_descent = descent; } int GetDescent() const { return m_descent; } /// Gets the containing buffer wxRichTextBuffer* GetBuffer() const;// Operations /// Clone the object virtual wxRichTextObject* Clone() const { return NULL; } /// Copy void Copy(const wxRichTextObject& obj); /// Reference-counting allows us to use the same object in multiple /// lists (not yet used) void Reference() { m_refCount ++; } void Dereference(); /// Convert units in tenths of a millimetre to device units int ConvertTenthsMMToPixels(wxDC& dc, int units); static int ConvertTenthsMMToPixels(int ppi, int units);protected: wxSize m_size; wxPoint m_pos; int m_descent; // Descent for this object (if any) bool m_dirty; int m_refCount; wxRichTextObject* m_parent; /// The range of this object (start position to end position) wxRichTextRange m_range; /// Margins int m_leftMargin; int m_rightMargin; int m_topMargin; int m_bottomMargin; /// Attributes wxTextAttrEx m_attributes;};WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT );/*! * wxRichTextCompositeObject class declaration * Objects of this class can contain other objects. */class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject: public wxRichTextObject{ DECLARE_CLASS(wxRichTextCompositeObject)public:// Constructors wxRichTextCompositeObject(wxRichTextObject* parent = NULL); virtual ~wxRichTextCompositeObject();// Overrideables /// Hit-testing: returns a flag indicating hit test details, plus /// information about position virtual int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition); /// Finds the absolute position and row height for the given character position virtual bool FindPosition(wxDC& dc, long index, wxPoint& pt, int* height, bool forceLineStart); /// Calculate range virtual void CalculateRange(long start, long& end); /// Delete range virtual bool DeleteRange(const wxRichTextRange& range); /// Get any text in this object for the given range virtual wxString GetTextForRange(const wxRichTextRange& range) const; /// Dump to output stream for debugging virtual void Dump(wxTextOutputStream& stream);// Accessors /// Get the children wxRichTextObjectList& GetChildren() { return m_children; } const wxRichTextObjectList& GetChildren() const { return m_children; } /// Get the child count size_t GetChildCount() const ; /// Get the nth child wxRichTextObject* GetChild(size_t n) const ; /// Get/set dirty flag virtual bool GetDirty() const { return m_dirty; } virtual void SetDirty(bool dirty) { m_dirty = dirty; } /// Is this composite? virtual bool IsComposite() const { return true; } /// Returns true if the buffer is empty virtual bool IsEmpty() const { return GetChildCount() == 0; }// Operations /// Copy void Copy(const wxRichTextCompositeObject& obj); /// Assignment void operator= (const wxRichTextCompositeObject& obj) { Copy(obj); } /// Append a child, returning the position size_t AppendChild(wxRichTextObject* child) ; /// Insert the child in front of the given object, or at the beginning bool InsertChild(wxRichTextObject* child, wxRichTextObject* inFrontOf) ; /// Delete the child bool RemoveChild(wxRichTextObject* child, bool deleteChild = false) ; /// Delete all children bool DeleteChildren() ; /// Recursively merge all pieces that can be merged. bool Defragment();protected: wxRichTextObjectList m_children;};/*! * wxRichTextBox class declaration * This defines a 2D space to lay out objects */class WXDLLIMPEXP_RICHTEXT wxRichTextBox: public wxRichTextCompositeObject{ DECLARE_DYNAMIC_CLASS(wxRichTextBox)public:// Constructors wxRichTextBox(wxRichTextObject* parent = NULL); wxRichTextBox(const wxRichTextBox& obj): wxRichTextCompositeObject() { Copy(obj); }// Overrideables /// Draw the item virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); /// Lay the item out virtual bool Layout(wxDC& dc, const wxRect& rect, int style); /// Get/set the object size for the given range. Returns false if the range /// is invalid for this object. virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0)) const;// Accessors// Operations /// Clone virtual wxRichTextObject* Clone() const { return new wxRichTextBox(*this); } /// Copy void Copy(const wxRichTextBox& obj);protected:};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -