]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/richtext/richtextctrl.h
Use system colours for ownerdrawn highlighting (patch #1555426).
[wxWidgets.git] / include / wx / richtext / richtextctrl.h
index beef94f24d628ae451791e828347b63027d5e0e2..1e7d5c3d77acaa92aa6d23f7b480bc704e790147 100644 (file)
 #include "wx/textctrl.h"
 #endif
 
+#if !defined(__WXGTK__) && !defined(__WXMAC__)
+#define wxRICHTEXT_BUFFERED_PAINTING 1
+#else
+#define wxRICHTEXT_BUFFERED_PAINTING 0
+#endif
+
 class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition;
 
 /*!
@@ -157,9 +163,14 @@ public:
     virtual void Replace(long from, long to, const wxString& value);
     virtual void Remove(long from, long to);
 
+#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
+    bool LoadFile(const wxString& file, int fileType = wxRICHTEXT_TYPE_ANY);
+    bool SaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY);
+#endif
+
     // load/save the controls contents from/to the file
-    virtual bool LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY);
-    virtual bool SaveFile(const wxString& file = wxEmptyString, int type = wxRICHTEXT_TYPE_ANY);
+    virtual bool DoLoadFile(const wxString& file, int fileType);
+    virtual bool DoSaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY);
 
     // sets/clears the dirty flag
     virtual void MarkDirty();
@@ -180,9 +191,22 @@ public:
     virtual bool SetStyle(long start, long end, const wxTextAttr& style);
     virtual bool SetStyle(long start, long end, const wxTextAttrEx& style);
     virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style);
-    virtual bool GetStyle(long position, wxTextAttr& style) const;
-    virtual bool GetStyle(long position, wxTextAttrEx& style) const;
-    virtual bool GetStyle(long position, wxRichTextAttr& style) const;
+    virtual bool GetStyle(long position, wxTextAttr& style);
+    virtual bool GetStyle(long position, wxTextAttrEx& style);
+    virtual bool GetStyle(long position, wxRichTextAttr& style);
+
+    // extended style setting operation with flags including:
+    // wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY
+    // see richtextbuffer.h for more details.
+    virtual bool SetStyleEx(long start, long end, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+    virtual bool SetStyleEx(const wxRichTextRange& range, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+    virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+    /// Get the content (uncombined) attributes for this position.
+    virtual bool GetUncombinedStyle(long position, wxTextAttr& style);
+    virtual bool GetUncombinedStyle(long position, wxTextAttrEx& style);
+    virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style);
+
     virtual bool SetDefaultStyle(const wxTextAttrEx& style);
     virtual bool SetDefaultStyle(const wxTextAttr& style);
 
@@ -379,6 +403,9 @@ public:
     /// Clear the selection
     virtual void SelectNone();
 
+    /// Select the word at the given character position
+    virtual bool SelectWord(long position);
+
     /// Get/set the selection range in character positions. -1, -1 means no selection.
     /// The range is in API convention, i.e. a single character selection is denoted
     /// by (n, n+1)
@@ -495,16 +522,16 @@ public:
     }
 
     /// Is all of the selection bold?
-    virtual bool IsSelectionBold() const;
+    virtual bool IsSelectionBold();
 
     /// Is all of the selection italics?
-    virtual bool IsSelectionItalics() const;
+    virtual bool IsSelectionItalics();
 
     /// Is all of the selection underlined?
-    virtual bool IsSelectionUnderlined() const;
+    virtual bool IsSelectionUnderlined();
 
     /// Is all of the selection aligned according to the specified flag?
-    virtual bool IsSelectionAligned(wxTextAttrAlignment alignment) const;
+    virtual bool IsSelectionAligned(wxTextAttrAlignment alignment);
 
     /// Apply bold to the selection
     virtual bool ApplyBoldToSelection();
@@ -525,6 +552,9 @@ public:
     void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { GetBuffer().SetStyleSheet(styleSheet); }
     wxRichTextStyleSheet* GetStyleSheet() const { return GetBuffer().GetStyleSheet(); }
 
+    /// Apply the style sheet to the buffer, for example if the styles have changed.
+    bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL);
+
 // Command handlers
 
     void Command(wxCommandEvent& event);
@@ -590,8 +620,6 @@ public:
     /// Scrolling
     void OnScroll(wxScrollWinEvent& event);
 
-// Implementation
-
     /// Set font, and also default attributes
     virtual bool SetFont(const wxFont& font);
 
@@ -604,8 +632,10 @@ public:
     /// Paint the background
     virtual void PaintBackground(wxDC& dc);
 
+#if wxRICHTEXT_BUFFERED_PAINTING
     /// Recreate buffer bitmap if necessary
     virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
+#endif
 
     /// Set the selection
     virtual void DoSetSelection(long from, long to, bool scrollCaret = true);
@@ -712,6 +742,8 @@ public:
         SetCaretPositionForDefaultStyle(GetCaretPosition());
     }
 
+// Implementation
+
 #if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
      WX_FORWARD_TO_SCROLL_HELPER()
 #endif
@@ -727,14 +759,18 @@ private:
     /// Allows nested Freeze/Thaw
     int                     m_freezeCount;
 
+#if wxRICHTEXT_BUFFERED_PAINTING
     /// Buffer bitmap
     wxBitmap                m_bufferBitmap;
+#endif
 
     /// Text buffer
     wxRichTextBuffer        m_buffer;
 
+#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
     /// Filename
     wxString                m_filename;
+#endif
 
     wxMenu*                 m_contextMenu;