#define wxRichTextAttr wxTextAttr
#define wxTextAttrEx wxTextAttr
+// Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a non-flashing
+// cursor reliably without using wxClientDC in case there
+// are platform-specific problems with the generic caret.
+#define wxRICHTEXT_USE_OWN_CARET 0
+
+// Switch off for binary compatibility, on for faster drawing
+// Note: this seems to be buggy (overzealous use of extents) so
+// don't use for now
+#define wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING 0
+
/*!
* Special characters
*/
extern WXDLLIMPEXP_RICHTEXT const wxChar wxRichTextLineBreakChar;
/*!
- * File types
+ * File types in wxRichText context.
*/
-
-#define wxRICHTEXT_TYPE_ANY 0
-#define wxRICHTEXT_TYPE_TEXT 1
-#define wxRICHTEXT_TYPE_XML 2
-#define wxRICHTEXT_TYPE_HTML 3
-#define wxRICHTEXT_TYPE_RTF 4
-#define wxRICHTEXT_TYPE_PDF 5
+enum wxRichTextFileType
+{
+ wxRICHTEXT_TYPE_ANY = 0,
+ wxRICHTEXT_TYPE_TEXT,
+ wxRICHTEXT_TYPE_XML,
+ wxRICHTEXT_TYPE_HTML,
+ wxRICHTEXT_TYPE_RTF,
+ wxRICHTEXT_TYPE_PDF
+};
/*!
* Forward declarations
/*!
* Flags returned from hit-testing
*/
+enum wxRichTextHitTestFlags
+{
+ // The point was not on this object
+ wxRICHTEXT_HITTEST_NONE = 0x01,
+
+ // The point was before the position returned from HitTest
+ wxRICHTEXT_HITTEST_BEFORE = 0x02,
-// The point was not on this object
-#define wxRICHTEXT_HITTEST_NONE 0x01
-// The point was before the position returned from HitTest
-#define wxRICHTEXT_HITTEST_BEFORE 0x02
-// The point was after the position returned from HitTest
-#define wxRICHTEXT_HITTEST_AFTER 0x04
-// The point was on the position returned from HitTest
-#define wxRICHTEXT_HITTEST_ON 0x08
-// The point was on space outside content
-#define wxRICHTEXT_HITTEST_OUTSIDE 0x10
+ // The point was after the position returned from HitTest
+ wxRICHTEXT_HITTEST_AFTER = 0x04,
+
+ // The point was on the position returned from HitTest
+ wxRICHTEXT_HITTEST_ON = 0x08,
+
+ // The point was on space outside content
+ wxRICHTEXT_HITTEST_OUTSIDE = 0x10
+};
/*!
* Flags for GetRangeSize
#define wxSCRIPT_MUL_FACTOR 1.5
-// Leave on for faster drawing, by storing the length of each object in a line
-#define wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING 1
-
/*!
* wxRichTextFontTable
* Manages quick access to a pool of fonts for rendering rich text
virtual int GetParagraphLength(long paragraphNumber) const;
/// Get the number of paragraphs
- virtual int GetParagraphCount() const { return GetChildCount(); }
+ virtual int GetParagraphCount() const { return static_cast<int>(GetChildCount()); }
/// Get the number of visible lines
virtual int GetLineCount() const;
/// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
/// content.
- bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes);
+ bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes);
/// Set list style
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
// Implementation
/// Apply paragraph styles such as centering to the wrapped lines
- virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect);
+ virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc);
/// Insert text at the given position
virtual bool InsertText(long pos, const wxString& text);
// 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);
+ virtual bool MakeImageBlock(const wxString& filename, wxBitmapType 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);
+ virtual bool MakeImageBlock(wxImage& image, wxBitmapType imageType, int quality = 80);
// Write to a file
bool Write(const wxString& filename);
bool WriteHex(wxOutputStream& stream);
// Read data in hex from a stream
- bool ReadHex(wxInputStream& stream, int length, int imageType);
+ bool ReadHex(wxInputStream& stream, int length, wxBitmapType imageType);
// Copy from 'block'
void Copy(const wxRichTextImageBlock& block);
unsigned char* GetData() const { return m_data; }
size_t GetDataSize() const { return m_dataSize; }
- int GetImageType() const { return m_imageType; }
+ wxBitmapType 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; }
+ void SetImageType(wxBitmapType imageType) { m_imageType = imageType; }
bool Ok() const { return IsOk(); }
bool IsOk() const { return GetData() != NULL; }
// 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
+ wxBitmapType m_imageType;
};
virtual void ResetAndClearCommands();
/// Load a file
- virtual bool LoadFile(const wxString& filename, int type = wxRICHTEXT_TYPE_ANY);
+ virtual bool LoadFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
/// Save a file
- virtual bool SaveFile(const wxString& filename, int type = wxRICHTEXT_TYPE_ANY);
+ virtual bool SaveFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
/// Load from a stream
- virtual bool LoadFile(wxInputStream& stream, int type = wxRICHTEXT_TYPE_ANY);
+ virtual bool LoadFile(wxInputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
/// Save to a stream
- virtual bool SaveFile(wxOutputStream& stream, int type = wxRICHTEXT_TYPE_ANY);
+ virtual bool SaveFile(wxOutputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY);
/// Set the handler flags, controlling loading and saving
void SetHandlerFlags(int flags) { m_handlerFlags = flags; }
static wxRichTextFileHandler *FindHandler(const wxString& name);
/// Finds a handler by extension and type
- static wxRichTextFileHandler *FindHandler(const wxString& extension, int imageType);
+ static wxRichTextFileHandler *FindHandler(const wxString& extension, wxRichTextFileType imageType);
/// Finds a handler by filename or, if supplied, type
- static wxRichTextFileHandler *FindHandlerFilenameOrType(const wxString& filename, int imageType);
+ static wxRichTextFileHandler *FindHandlerFilenameOrType(const wxString& filename,
+ wxRichTextFileType imageType);
/// Finds a handler by type
- static wxRichTextFileHandler *FindHandler(int imageType);
+ static wxRichTextFileHandler *FindHandler(wxRichTextFileType imageType);
/// Gets a wildcard incorporating all visible handlers. If 'types' is present,
/// will be filled with the file type corresponding to each filter. This can be
// in a larger document
#define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080
+// Convert the more common face names to names that will work on the current platform
+// in a larger document
+#define wxRICHTEXT_HANDLER_CONVERT_FACENAMES 0x0100
+
/*!
* wxRichTextFileHandler
* Base class for file handlers
{
DECLARE_CLASS(wxRichTextPlainTextHandler)
public:
- wxRichTextPlainTextHandler(const wxString& name = wxT("Text"), const wxString& ext = wxT("txt"), int type = wxRICHTEXT_TYPE_TEXT)
+ wxRichTextPlainTextHandler(const wxString& name = wxT("Text"),
+ const wxString& ext = wxT("txt"),
+ wxRichTextFileType type = wxRICHTEXT_TYPE_TEXT)
: wxRichTextFileHandler(name, ext, type)
{ }