📄 richtextbuffer.h
字号:
/// Maximum descent for this line (location of text baseline) int m_descent; // The parent object wxRichTextParagraph* m_parent;};WX_DECLARE_LIST_WITH_DECL( wxRichTextLine, wxRichTextLineList , class WXDLLIMPEXP_RICHTEXT );/*! * wxRichTextParagraph class declaration * This object represents a single paragraph (or in a straight text editor, a line). */class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextBox{ DECLARE_DYNAMIC_CLASS(wxRichTextParagraph)public:// Constructors wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL); wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* paraStyle = NULL, wxTextAttrEx* charStyle = NULL); virtual ~wxRichTextParagraph(); wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { 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; /// 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); /// Hit-testing: returns a flag indicating hit test details, plus /// information about position virtual int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition); /// Calculate range virtual void CalculateRange(long start, long& end);// Accessors /// Get the cached lines wxRichTextLineList& GetLines() { return m_cachedLines; }// Operations /// Copy void Copy(const wxRichTextParagraph& obj); /// Clone virtual wxRichTextObject* Clone() const { return new wxRichTextParagraph(*this); } /// Clear the cached lines void ClearLines();// Implementation /// Apply paragraph styles such as centering to the wrapped lines virtual void ApplyParagraphStyle(const wxTextAttrEx& attr, const wxRect& rect); /// Insert text at the given position virtual bool InsertText(long pos, const wxString& text); /// Split an object at this position if necessary, and return /// the previous object, or NULL if inserting at beginning. virtual wxRichTextObject* SplitAt(long pos, wxRichTextObject** previousObject = NULL); /// Move content to a list from this point virtual void MoveToList(wxRichTextObject* obj, wxList& list); /// Add content back from list virtual void MoveFromList(wxList& list); /// Get the plain text searching from the start or end of the range. /// The resulting string may be shorter than the range given. bool GetContiguousPlainText(wxString& text, const wxRichTextRange& range, bool fromStart = true); /// Find a suitable wrap position. wrapPosition is the last position in the line to the left /// of the split. bool FindWrapPosition(const wxRichTextRange& range, wxDC& dc, int availableSpace, long& wrapPosition); /// Find the object at the given position wxRichTextObject* FindObjectAtPosition(long position); /// Get the bullet text for this paragraph. wxString GetBulletText(); /// Allocate or reuse a line object wxRichTextLine* AllocateLine(int pos); /// Clear remaining unused line objects, if any bool ClearUnusedLines(int lineCount); /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically /// retrieve the actual style. wxTextAttrEx GetCombinedAttributes(const wxTextAttrEx& contentStyle) const; /// Get combined attributes of the base style and paragraph style. wxTextAttrEx GetCombinedAttributes() const; /// Get the first position from pos that has a line break character. long GetFirstLineBreakPosition(long pos); /// Create default tabstop array static void InitDefaultTabs(); /// Clear default tabstop array static void ClearDefaultTabs(); /// Get default tabstop array static const wxArrayInt& GetDefaultTabs() { return sm_defaultTabs; }protected: /// The lines that make up the wrapped paragraph wxRichTextLineList m_cachedLines; /// Default tabstops static wxArrayInt sm_defaultTabs;};/*! * wxRichTextPlainText class declaration * This object represents a single piece of text. */class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject{ DECLARE_DYNAMIC_CLASS(wxRichTextPlainText)public:// Constructors wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL); wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { 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; /// Get any text in this object for the given range virtual wxString GetTextForRange(const wxRichTextRange& range) const; /// Do a split, returning an object containing the second part, and setting /// the first part in 'this'. virtual wxRichTextObject* DoSplit(long pos); /// Calculate range virtual void CalculateRange(long start, long& end); /// Delete range virtual bool DeleteRange(const wxRichTextRange& range); /// Returns true if the object is empty virtual bool IsEmpty() const { return m_text.empty(); } /// Returns true if this object can merge itself with the given one. virtual bool CanMerge(wxRichTextObject* object) const; /// Returns true if this object merged itself with the given one. /// The calling code will then delete the given object. virtual bool Merge(wxRichTextObject* object); /// Dump to output stream for debugging virtual void Dump(wxTextOutputStream& stream); /// Get the first position from pos that has a line break character. long GetFirstLineBreakPosition(long pos);// Accessors /// Get the text const wxString& GetText() const { return m_text; } /// Set the text void SetText(const wxString& text) { m_text = text; }// Operations /// Copy void Copy(const wxRichTextPlainText& obj); /// Clone virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); }private: bool DrawTabbedString(wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected);protected: wxString m_text;};/*! * wxRichTextImageBlock stores information about an image, in binary in-memory form */class WXDLLIMPEXP_BASE wxDataInputStream;class WXDLLIMPEXP_BASE wxDataOutputStream;class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock: public wxObject{public: wxRichTextImageBlock(); wxRichTextImageBlock(const wxRichTextImageBlock& block); virtual ~wxRichTextImageBlock(); void Init(); void Clear(); // Load the original image into a memory block. // If the image is not a JPEG, we must convert it into a JPEG // to conserve space. // If it's not a JPEG we can make use of 'image', already scaled, so we don't have to // load the image a 2nd time. virtual bool MakeImageBlock(const wxString& filename, int imageType, wxImage& image, bool convertToJPEG = true); // Make an image block from the wxImage in the given // format. virtual bool MakeImageBlock(wxImage& image, int imageType, int quality = 80); // Write to a file bool Write(const wxString& filename); // Write data in hex to a stream bool WriteHex(wxOutputStream& stream); // Read data in hex from a stream bool ReadHex(wxInputStream& stream, int length, int imageType); // Copy from 'block' void Copy(const wxRichTextImageBlock& block); // Load a wxImage from the block bool Load(wxImage& image);//// Operators void operator=(const wxRichTextImageBlock& block);//// Accessors unsigned char* GetData() const { return m_data; } size_t GetDataSize() const { return m_dataSize; } int GetImageType() const { return m_imageType; } void SetData(unsigned char* image) { m_data = image; } void SetDataSize(size_t size) { m_dataSize = size; } void SetImageType(int imageType) { m_imageType = imageType; } bool Ok() const { return IsOk(); } bool IsOk() const { return GetData() != NULL; } // Gets the extension for the block's type wxString GetExtension() const;/// Implementation // Allocate and read from stream as a block of memory static unsigned char* ReadBlock(wxInputStream& stream, size_t size); static unsigned char* ReadBlock(const wxString& filename, size_t size); // Write memory block to stream static bool WriteBlock(wxOutputStream& stream, unsigned char* block, size_t size); // Write memory block to file static bool WriteBlock(const wxString& filename, unsigned char* block, size_t size);protected: // Size in bytes of the image stored. // This is in the raw, original form such as a JPEG file. unsigned char* m_data; size_t m_dataSize; int m_imageType; // wxWin type id};/*! * wxRichTextImage class declaration * This object represents an image. */class WXDLLIMPEXP_RICHTEXT wxRichTextImage: public wxRichTextObject{ DECLARE_DYNAMIC_CLASS(wxRichTextImage)public:// Constructors wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextObject(parent) { } wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxTextAttrEx* charStyle = NULL); wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttrEx* charStyle = NULL); wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject() { Copy(obj); }// Overrideables /// Draw the item virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& se
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -