X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/303f0be79e904523d3b2e912ab1a5c7ab812d2b6..ab67e8874db324fab5223cc8d5dff8a8de3e2b77:/include/wx/richtext/richtextctrl.h diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index 3eeedef9cc..efd4959840 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -686,7 +686,7 @@ public: /** Sets the attributes for a single object */ - virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr); + virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); //@{ /** @@ -844,6 +844,28 @@ public: virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); //@} + /** + Sets the properties for the given range, passing flags to determine how the + attributes are set. You can merge properties or replace them. + + The end point of range is specified as the last character position of the span + of text, plus one. So, for example, to set the properties for a character at + position 5, use the range (5,6). + + @a flags may contain a bit list of the following values: + - wxRICHTEXT_SETSPROPERTIES_NONE: no flag. + - wxRICHTEXT_SETPROPERTIES_WITH_UNDO: specifies that this operation should be + undoable. + - wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY: specifies that the properties should only be + applied to paragraphs, and not the content. + - wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY: specifies that the properties should only be + applied to characters, and not the paragraph. + - wxRICHTEXT_SETPROPERTIES_RESET: resets (clears) the existing properties before applying + the new properties. + - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties. + */ + virtual bool SetProperties(const wxRichTextRange& range, const wxRichTextProperties& properties, int flags = wxRICHTEXT_SETPROPERTIES_WITH_UNDO); + /** Deletes the content within the given range. */ @@ -985,12 +1007,6 @@ public: void SetSelection(const wxRichTextSelection& sel) { m_selection = sel; } //@} - - /** - Selects all the text in the buffer. - */ - virtual void SelectAll(); - /** Makes the control editable, or not. */ @@ -1038,6 +1054,21 @@ public: */ virtual wxRichTextBox* WriteTextBox(const wxRichTextAttr& textAttr = wxRichTextAttr()); + /** + Writes a field at the current insertion point. + + @param fieldType + The field type, matching an existing field type definition. + @param properties + Extra data for the field. + @param textAttr + Optional attributes. + + @see wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard + */ + virtual wxRichTextField* WriteField(const wxString& fieldType, const wxRichTextProperties& properties, + const wxRichTextAttr& textAttr = wxRichTextAttr()); + /** Write a table at the current insertion point, returning the table. You can then call SetFocusObject() to set the focus to the new object. @@ -1631,6 +1662,104 @@ public: */ virtual bool EditProperties(wxRichTextObject* obj, wxWindow* parent) { return obj->EditProperties(parent, & GetBuffer()); } + /** + Gets the object's properties menu label. + */ + virtual wxString GetPropertiesMenuLabel(wxRichTextObject* obj) { return obj->GetPropertiesMenuLabel(); } + + /** + Prepares the content just before insertion (or after buffer reset). Called by the same function in wxRichTextBuffer. + Currently is only called if undo mode is on. + */ + virtual void PrepareContent(wxRichTextParagraphLayoutBox& WXUNUSED(container)) {} + + /** + Can we delete this range? + Sends an event to the control. + */ + virtual bool CanDeleteRange(wxRichTextParagraphLayoutBox& container, const wxRichTextRange& range) const; + + /** + Can we insert content at this position? + Sends an event to the control. + */ + virtual bool CanInsertContent(wxRichTextParagraphLayoutBox& container, long pos) const; + + /** + Enable or disable the vertical scrollbar. + */ + virtual void EnableVerticalScrollbar(bool enable); + + /** + Returns @true if the vertical scrollbar is enabled. + */ + virtual bool GetVerticalScrollbarEnabled() const { return m_verticalScrollbarEnabled; } + + /** + Sets the scale factor for displaying fonts, for example for more comfortable + editing. + */ + void SetFontScale(double fontScale, bool refresh = false); + + /** + Returns the scale factor for displaying fonts, for example for more comfortable + editing. + */ + double GetFontScale() const { return GetBuffer().GetFontScale(); } + + /** + Sets the scale factor for displaying certain dimensions such as indentation and + inter-paragraph spacing. This can be useful when editing in a small control + where you still want legible text, but a minimum of wasted white space. + */ + void SetDimensionScale(double dimScale, bool refresh = false); + + /** + Returns the scale factor for displaying certain dimensions such as indentation + and inter-paragraph spacing. + */ + double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); } + + /** + Sets an overall scale factor for displaying and editing the content. + */ + void SetScale(double scale, bool refresh = false); + + /** + Returns an overall scale factor for displaying and editing the content. + */ + double GetScale() const { return m_scale; } + + /** + Returns an unscaled point. + */ + wxPoint GetUnscaledPoint(const wxPoint& pt) const; + + /** + Returns a scaled point. + */ + wxPoint GetScaledPoint(const wxPoint& pt) const; + + /** + Returns an unscaled size. + */ + wxSize GetUnscaledSize(const wxSize& sz) const; + + /** + Returns a scaled size. + */ + wxSize GetScaledSize(const wxSize& sz) const; + + /** + Returns an unscaled rectangle. + */ + wxRect GetUnscaledRect(const wxRect& rect) const; + + /** + Returns a scaled rectangle. + */ + wxRect GetScaledRect(const wxRect& rect) const; + // Command handlers /** @@ -2009,6 +2138,17 @@ public: // Implementation + /** + Processes the back key. + */ + virtual bool ProcessBackKey(wxKeyEvent& event, int flags); + + /** + Given a character position at which there is a list style, find the range + encompassing the same list style by looking backwards and forwards. + */ + virtual wxRichTextRange FindRangeForList(long pos, bool& isNumberedList); + /** Sets up the caret for the given position and container, after a mouse click. */ @@ -2022,6 +2162,11 @@ public: long FindCaretPositionForCharacterPosition(long position, int hitTestFlags, wxRichTextParagraphLayoutBox* container, bool& caretLineStart); + /** + Processes mouse movement in order to change the cursor + */ + virtual bool ProcessMouseMovement(wxRichTextParagraphLayoutBox* container, wxRichTextObject* obj, long position, const wxPoint& pos); + /** Font names take a long time to retrieve, so cache them (on demand). */ @@ -2109,6 +2254,9 @@ protected: /// Are we editable? bool m_editable; + /// Is the vertical scrollbar enabled? + bool m_verticalScrollbarEnabled; + /// Are we showing the caret position at the start of a line /// instead of at the end of the previous one? bool m_caretAtLineStart; @@ -2147,6 +2295,9 @@ protected: /// The object that currently has the editing focus wxRichTextParagraphLayoutBox* m_focusObject; + + /// An overall scale factor + double m_scale; }; #if wxUSE_DRAG_AND_DROP @@ -2228,6 +2379,9 @@ protected: when the control's stylesheet has been replaced, for example when a file is loaded into the control. Valid event functions: GetOldStyleSheet, GetNewStyleSheet. + @event{EVT_RICHTEXT_PROPERTIES_CHANGED(id, func)} + Process a @c wxEVT_COMMAND_RICHTEXT_PROPERTIES_CHANGED event, generated when + properties have been applied to the control. Valid event functions: GetPosition, GetRange. @event{EVT_RICHTEXT_CONTENT_INSERTED(id, func)} Process a @c wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED event, generated when content has been inserted into the control. @@ -2404,6 +2558,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEE wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, wxRichTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, wxRichTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_PROPERTIES_CHANGED, wxRichTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, wxRichTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_BUFFER_RESET, wxRichTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_FOCUS_OBJECT_CHANGED, wxRichTextEvent ); @@ -2429,6 +2584,7 @@ typedef void (wxEvtHandler::*wxRichTextEventFunction)(wxRichTextEvent&); #define EVT_RICHTEXT_CONTENT_INSERTED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, id, -1, wxRichTextEventHandler( fn ), NULL ), #define EVT_RICHTEXT_CONTENT_DELETED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, id, -1, wxRichTextEventHandler( fn ), NULL ), #define EVT_RICHTEXT_STYLE_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_PROPERTIES_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_PROPERTIES_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ), #define EVT_RICHTEXT_SELECTION_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ), #define EVT_RICHTEXT_BUFFER_RESET(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_BUFFER_RESET, id, -1, wxRichTextEventHandler( fn ), NULL ), #define EVT_RICHTEXT_FOCUS_OBJECT_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_FOCUS_OBJECT_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ),