X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4e8d95587c7fbd84af1238a818062704a53b4151..a516284f67e1910fc6dc5364b289340332d0d35f:/include/wx/richtext/richtextctrl.h diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index 2c6d93de7a..6456ef94af 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -27,7 +27,7 @@ #define wxRICHTEXT_BUFFERED_PAINTING 0 #endif -class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition; +class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleDefinition; /*! * Styles and flags @@ -38,6 +38,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition; #define wxRE_READONLY 0x0010 #define wxRE_MULTILINE 0x0020 +#define wxRE_CENTRE_CARET 0x8000 +#define wxRE_CENTER_CARET wxRE_CENTRE_CARET /* Flags */ @@ -46,6 +48,13 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition; #define wxRICHTEXT_CTRL_DOWN 0x02 #define wxRICHTEXT_ALT_DOWN 0x04 +/* Extra flags + */ + +// Don't draw guide lines around boxes and tables +#define wxRICHTEXT_EX_NO_GUIDELINES 0x00000100 + + /* Defaults */ @@ -64,14 +73,17 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition; // Milliseconds before layout occurs after resize #define wxRICHTEXT_DEFAULT_LAYOUT_INTERVAL 50 -/*! - * Forward declarations +/* Identifiers */ +#define wxID_RICHTEXT_PROPERTIES1 (wxID_HIGHEST + 1) +#define wxID_RICHTEXT_PROPERTIES2 (wxID_HIGHEST + 2) +#define wxID_RICHTEXT_PROPERTIES3 (wxID_HIGHEST + 3) /*! - * wxRichTextItem class declaration + * Forward declarations */ +#if 0 // Drawing styles/states #define wxRICHTEXT_SELECTED 0x01 #define wxRICHTEXT_TAGGED 0x02 @@ -79,12 +91,74 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextStyleDefinition; #define wxRICHTEXT_FOCUSSED 0x04 // The item itself has the focus #define wxRICHTEXT_IS_FOCUS 0x08 +#endif + +// Normal selection occurs initially and as user drags within one container. +// Common ancestor selection occurs when the user starts dragging across containers +// that have a common ancestor, for example the cells in a table. +enum wxRichTextCtrlSelectionState +{ + wxRichTextCtrlSelectionState_Normal, + wxRichTextCtrlSelectionState_CommonAncestor +}; + +/*! + * wxRichTextContextMenuPropertiesInfo keeps track of objects that appear in the context menu, + * whose properties are available to be edited. + */ + +class WXDLLIMPEXP_RICHTEXT wxRichTextContextMenuPropertiesInfo +{ +public: + wxRichTextContextMenuPropertiesInfo() { Init(); } + +// Operations + + /// Initialisation + void Init() {} + + /// Add an item + bool AddItem(const wxString& label, wxRichTextObject* obj); + + /// Returns number of menu items were added. + int AddMenuItems(wxMenu* menu, int startCmd = wxID_RICHTEXT_PROPERTIES1) const; + + /// Add appropriate menu items for the current container and clicked on object + /// (and container's parent, if appropriate). + int AddItems(wxRichTextObject* container, wxRichTextObject* obj); + + /// Clear the items + void Clear() { m_objects.Clear(); m_labels.Clear(); } + +// Accessors + /// Gets the nth label + wxString GetLabel(int n) const { return m_labels[n]; } + + /// Gets the nth object + wxRichTextObject* GetObject(int n) const { return m_objects[n]; } + + /// Get objects + wxRichTextObjectPtrArray& GetObjects() { return m_objects; } + const wxRichTextObjectPtrArray& GetObjects() const { return m_objects; } + + /// Get labels + wxArrayString& GetLabels() { return m_labels; } + const wxArrayString& GetLabels() const { return m_labels; } + + /// Get number of items + int GetCount() const { return m_objects.GetCount(); } + + //wxArrayInt m_ids; + wxRichTextObjectPtrArray m_objects; + wxArrayString m_labels; +}; /*! * wxRichTextCtrl class declaration */ -class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxTextCtrlBase, +class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxControl, + public wxTextCtrlIface, public wxScrollHelper { DECLARE_CLASS( wxRichTextCtrl ) @@ -112,8 +186,6 @@ public: // Accessors - virtual wxString GetValue() const; - virtual wxString GetRange(long from, long to) const; virtual int GetLineLength(long lineNo) const ; @@ -131,6 +203,11 @@ public: virtual void GetSelection(long* from, long* to) const; virtual wxString GetStringSelection() const; + + const wxRichTextSelection& GetSelection() const { return m_selection; } + wxRichTextSelection& GetSelection() { return m_selection; } + void SetSelection(const wxRichTextSelection& sel) { m_selection = sel; } + /// Get filename wxString GetFilename() const { return m_filename; } @@ -144,8 +221,61 @@ public: /// Get the threshold in character positions for doing layout optimization during sizing long GetDelayedLayoutThreshold() const { return m_delayedLayoutThreshold; } + /// Set text cursor + void SetTextCursor(const wxCursor& cursor ) { m_textCursor = cursor; } + + /// Get text cursor + wxCursor GetTextCursor() const { return m_textCursor; } + + /// Set URL cursor + void SetURLCursor(const wxCursor& cursor ) { m_urlCursor = cursor; } + + /// Get URL cursor + wxCursor GetURLCursor() const { return m_urlCursor; } + + /// Are we showing the caret position at the start of a line + /// instead of at the end of the previous one? + bool GetCaretAtLineStart() const { return m_caretAtLineStart; } + void SetCaretAtLineStart(bool atStart) { m_caretAtLineStart = atStart; } + + /// Are we dragging a selection? + bool GetDragging() const { return m_dragging; } + void SetDragging(bool dragging) { m_dragging = dragging; } + + /// Get/set drag start position + const wxPoint& GetDragStart() const { return m_dragStart; } + void SetDragStart(const wxPoint& pt) { m_dragStart = pt; } + +#if wxRICHTEXT_BUFFERED_PAINTING + /// Get the buffer bitmap + const wxBitmap& GetBufferBitmap() const { return m_bufferBitmap; } + wxBitmap& GetBufferBitmap() { return m_bufferBitmap; } +#endif + + /// Get/set context menu + wxMenu* GetContextMenu() const { return m_contextMenu; } + void SetContextMenu(wxMenu* menu); + + /// Anchor so we know how to extend the selection + /// It's a caret position since it's between two characters. + long GetSelectionAnchor() const { return m_selectionAnchor; } + void SetSelectionAnchor(long anchor) { m_selectionAnchor = anchor; } + + /// Anchor object if selecting multiple containers. + wxRichTextObject* GetSelectionAnchorObject() const { return m_selectionAnchorObject; } + void SetSelectionAnchorObject(wxRichTextObject* anchor) { m_selectionAnchorObject = anchor; } + + wxRichTextContextMenuPropertiesInfo& GetContextMenuPropertiesInfo() { return m_contextMenuPropertiesInfo; } + const wxRichTextContextMenuPropertiesInfo& GetContextMenuPropertiesInfo() const { return m_contextMenuPropertiesInfo; } + + /// The wxRichTextObject object that currently has the editing focus + wxRichTextParagraphLayoutBox* GetFocusObject() const { return m_focusObject; } + bool SetFocusObject(wxRichTextParagraphLayoutBox* obj, bool setCaretPosition = true); + // Operations + void Invalidate() { GetBuffer().Invalidate(wxRICHTEXT_ALL); } + // editing virtual void Clear(); virtual void Replace(long from, long to, const wxString& value); @@ -153,7 +283,8 @@ public: // load/save the controls contents from/to the file virtual bool DoLoadFile(const wxString& file, int fileType); - virtual bool DoSaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY); + virtual bool DoSaveFile(const wxString& file = wxEmptyString, + int fileType = wxRICHTEXT_TYPE_ANY); /// Set the handler flags, controlling loading and saving void SetHandlerFlags(int flags) { GetBuffer().SetHandlerFlags(flags); } @@ -178,30 +309,35 @@ public: // methods allow to apply the given text style to the given selection or to // set/get the style which will be used for all appended text virtual bool SetStyle(long start, long end, const wxTextAttr& style); - virtual bool SetStyle(long start, long end, const wxTextAttrEx& style); + virtual bool SetStyle(long start, long end, const wxRichTextAttr& style); + virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style); virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style); virtual bool GetStyle(long position, wxTextAttr& style); - virtual bool GetStyle(long position, wxTextAttrEx& style); virtual bool GetStyle(long position, wxRichTextAttr& style); + virtual bool GetStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container); + // Set the style for a single object + virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr); + + // get the common set of styles for the range + virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style); + virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style); + virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container); // 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 GetUncombinedStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container); - virtual bool SetDefaultStyle(const wxTextAttrEx& style); virtual bool SetDefaultStyle(const wxTextAttr& style); + virtual bool SetDefaultStyle(const wxRichTextAttr& style); + + virtual const wxRichTextAttr& GetDefaultStyleEx() const; - // TODO: change to GetDefaultStyle if we merge wxTextAttr and wxTextAttrEx - virtual const wxTextAttrEx& GetDefaultStyleEx() const; - virtual const wxTextAttr& GetDefaultStyle() const; + //virtual const wxTextAttr& GetDefaultStyle() const; /// Set list style virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); @@ -220,6 +356,9 @@ public: virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); + /// Deletes the content in the given range + virtual bool Delete(const wxRichTextRange& range); + // translate between the position (which is just an index in the text ctrl // considering all its contents as a single strings) and (x, y) coordinates // which represent column and line. @@ -265,45 +404,55 @@ public: virtual void SelectAll(); virtual void SetEditable(bool editable); - /// Call Freeze to prevent refresh - virtual void Freeze(); - - /// Call Thaw to refresh - virtual void Thaw(); - - /// Call Thaw to refresh - virtual bool IsFrozen() const { return m_freezeCount > 0; } - + /// Returns true if there was a selection and the object containing the selection + /// was the same as the current focus object. virtual bool HasSelection() const; + /// Returns true if there was a selection, whether or not the current focus object + /// is the same as the selection's container object. + virtual bool HasUnfocusedSelection() const; + ///// Functionality specific to wxRichTextCtrl /// Write an image at the current insertion point. Supply optional type to use /// for internal and file storage of the raw data. - virtual bool WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG); + virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, + const wxRichTextAttr& textAttr = wxRichTextAttr()); /// Write a bitmap at the current insertion point. Supply optional type to use /// for internal and file storage of the raw data. - virtual bool WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG); + virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, + const wxRichTextAttr& textAttr = wxRichTextAttr()); /// Load an image from file and write at the current insertion point. - virtual bool WriteImage(const wxString& filename, int bitmapType); + virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType, + const wxRichTextAttr& textAttr = wxRichTextAttr()); /// Write an image block at the current insertion point. - virtual bool WriteImage(const wxRichTextImageBlock& imageBlock); + virtual bool WriteImage(const wxRichTextImageBlock& imageBlock, + const wxRichTextAttr& textAttr = wxRichTextAttr()); + + /// Write a text box at the current insertion point, returning the text box. + /// You can then call SetFocusObject() to set the focus to the new object. + virtual wxRichTextBox* WriteTextBox(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. + virtual wxRichTextTable* WriteTable(int rows, int cols, const wxRichTextAttr& tableAttr = wxRichTextAttr(), const wxRichTextAttr& cellAttr = wxRichTextAttr()); /// Insert a newline (actually paragraph) at the current insertion point. virtual bool Newline(); + /// Insert a line break at the current insertion point. + virtual bool LineBreak(); + /// Set basic (overall) style - virtual void SetBasicStyle(const wxTextAttrEx& style) { GetBuffer().SetBasicStyle(style); } virtual void SetBasicStyle(const wxRichTextAttr& style) { GetBuffer().SetBasicStyle(style); } /// Get basic (overall) style - virtual const wxTextAttrEx& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); } + virtual const wxRichTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); } - /// Begin using a style - virtual bool BeginStyle(const wxTextAttrEx& style) { return GetBuffer().BeginStyle(style); } + virtual bool BeginStyle(const wxRichTextAttr& style) { return GetBuffer().BeginStyle(style); } /// End the style virtual bool EndStyle() { return GetBuffer().EndStyle(); } @@ -437,11 +586,12 @@ public: wxRichTextRange GetSelectionRange() const; void SetSelectionRange(const wxRichTextRange& range); - /// Get/set the selection range in character positions. -1, -1 means no selection. + /// Get/set the selection range in character positions. -2, -2 means no selection + /// -1, -1 means select everything. /// The range is in internal format, i.e. a single character selection is denoted /// by (n, n) - const wxRichTextRange& GetInternalSelectionRange() const { return m_selectionRange; } - void SetInternalSelectionRange(const wxRichTextRange& range) { m_selectionRange = range; } + wxRichTextRange GetInternalSelectionRange() const { return m_selection.GetRange(); } + void SetInternalSelectionRange(const wxRichTextRange& range) { m_selection.Set(range, GetFocusObject()); } /// Add a new paragraph of text to the end of the buffer virtual wxRichTextRange AddParagraph(const wxString& text); @@ -454,7 +604,7 @@ public: virtual bool LayoutContent(bool onlyVisibleRect = false); /// Move the caret to the given character position - virtual bool MoveCaret(long pos, bool showAtLineStart = false); + virtual bool MoveCaret(long pos, bool showAtLineStart = false, wxRichTextParagraphLayoutBox* container = NULL); /// Move right virtual bool MoveRight(int noPositions = 1, int flags = 0); @@ -524,26 +674,18 @@ public: /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, bold button updating. style must have /// flags indicating which attributes are of interest. - virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const - { - return GetBuffer().HasCharacterAttributes(range, style); - } virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const { - return GetBuffer().HasCharacterAttributes(range, style); + return GetBuffer().HasCharacterAttributes(range.ToInternal(), style); } /// Test if this whole range has paragraph attributes of the specified kind. If any /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, centering button updating. style must have /// flags indicating which attributes are of interest. - virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const - { - return GetBuffer().HasParagraphAttributes(range, style); - } virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const { - return GetBuffer().HasParagraphAttributes(range, style); + return GetBuffer().HasParagraphAttributes(range.ToInternal(), style); } /// Is all of the selection bold? @@ -590,6 +732,8 @@ public: void Command(wxCommandEvent& event); void OnDropFiles(wxDropFilesEvent& event); + void OnCaptureLost(wxMouseCaptureLostEvent& event); + void OnSysColourChanged(wxSysColourChangedEvent& event); void OnCut(wxCommandEvent& event); void OnCopy(wxCommandEvent& event); @@ -597,6 +741,7 @@ public: void OnUndo(wxCommandEvent& event); void OnRedo(wxCommandEvent& event); void OnSelectAll(wxCommandEvent& event); + void OnProperties(wxCommandEvent& event); void OnClear(wxCommandEvent& event); void OnUpdateCut(wxUpdateUIEvent& event); @@ -605,6 +750,7 @@ public: void OnUpdateUndo(wxUpdateUIEvent& event); void OnUpdateRedo(wxUpdateUIEvent& event); void OnUpdateSelectAll(wxUpdateUIEvent& event); + void OnUpdateProperties(wxUpdateUIEvent& event); void OnUpdateClear(wxUpdateUIEvent& event); // Show a context menu for Rich Edit controls (the standard @@ -663,14 +809,14 @@ public: /// Paint the background virtual void PaintBackground(wxDC& dc); + /// Other user defined painting after everything else (i.e. all text) is painted + virtual void PaintAboveContent(wxDC& WXUNUSED(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); - /// Write text virtual void DoWriteText(const wxString& value, int flags = 0); @@ -678,7 +824,7 @@ public: virtual bool ShouldInheritColours() const { return false; } /// Position the caret - virtual void PositionCaret(); + virtual void PositionCaret(wxRichTextParagraphLayoutBox* container = NULL); /// Extend the selection, returning true if the selection was /// changed. Selections are in caret positions. @@ -687,6 +833,9 @@ public: /// Scroll into view. This takes a _caret_ position. virtual bool ScrollIntoView(long position, int keyCode); + /// Refresh the area affected by a selection change + bool RefreshForSelectionChange(const wxRichTextSelection& oldSelection, const wxRichTextSelection& newSelection); + /// The caret position is the character position just before the caret. /// A value of -1 means the caret is at the start of the buffer. void SetCaretPosition(long position, bool showAtLineStart = false) ; @@ -707,8 +856,9 @@ public: /// to the start of the next, which may be the exact same caret position. void MoveCaretBack(long oldPosition) ; - /// Get the caret height and position for the given character position - bool GetCaretPositionForIndex(long position, wxRect& rect); + /// Get the caret height and position for the given character position. If container is null, + /// the current focus object will be used. + bool GetCaretPositionForIndex(long position, wxRect& rect, wxRichTextParagraphLayoutBox* container = NULL); /// Gets the line for the visible caret position. If the caret is /// shown at the very end of the line, it means the next character is actually @@ -766,11 +916,46 @@ public: // Implementation - /// Font names take a long time to retrieve, so cache them (on demand) - static const wxArrayString& GetAvailableFontNames(); - static void ClearAvailableFontNames(); + /// Set up the caret for the given position and container, after a mouse click + bool SetCaretPositionAfterClick(wxRichTextParagraphLayoutBox* container, long position, int hitTestFlags, bool extendSelection = false); + + /// Find the caret position for the combination of hit-test flags and character position. + /// Returns the caret position and also an indication of where to place the caret (caretLineStart) + /// since this is ambiguous (same position used for end of line and start of next). + long FindCaretPositionForCharacterPosition(long position, int hitTestFlags, wxRichTextParagraphLayoutBox* container, + bool& caretLineStart); + + /// Font names take a long time to retrieve, so cache them (on demand) + static const wxArrayString& GetAvailableFontNames(); + static void ClearAvailableFontNames(); - WX_FORWARD_TO_SCROLL_HELPER() + WX_FORWARD_TO_SCROLL_HELPER() + + // implement wxTextEntry methods + virtual wxString DoGetValue() const; + +protected: + // implement the wxTextEntry pure virtual method + virtual wxWindow *GetEditableWindow() { return this; } + + // margins functions + virtual bool DoSetMargins(const wxPoint& pt); + virtual wxPoint DoGetMargins() const; + + // FIXME: this does not work, it allows this code to compile but will fail + // during run-time +#ifndef __WXUNIVERSAL__ +#ifdef __WXMSW__ + virtual WXHWND GetEditHWND() const { return GetHWND(); } +#endif +#ifdef __WXMOTIF__ + virtual WXWidget GetTextWidget() const { return NULL; } +#endif +#ifdef __WXGTK20__ + virtual GtkEditable *GetEditable() const { return NULL; } + virtual GtkEntry *GetEntry() const { return NULL; } +#endif +#endif // !__WXUNIVERSAL__ // Overrides protected: @@ -779,13 +964,11 @@ protected: virtual void DoSetValue(const wxString& value, int flags = 0); + virtual void DoThaw(); + // Data members private: - - /// Allows nested Freeze/Thaw - int m_freezeCount; - #if wxRICHTEXT_BUFFERED_PAINTING /// Buffer bitmap wxBitmap m_bufferBitmap; @@ -806,12 +989,17 @@ private: long m_caretPositionForDefaultStyle; /// Selection range in character positions. -2, -2 means no selection. - wxRichTextRange m_selectionRange; + wxRichTextSelection m_selection; + + wxRichTextCtrlSelectionState m_selectionState; /// Anchor so we know how to extend the selection /// It's a caret position since it's between two characters. long m_selectionAnchor; + /// Anchor object if selecting multiple container objects, such as grid cells. + wxRichTextObject* m_selectionAnchorObject; + /// Are we editable? bool m_editable; @@ -838,6 +1026,11 @@ private: wxCursor m_urlCursor; static wxArrayString sm_availableFontNames; + + wxRichTextContextMenuPropertiesInfo m_contextMenuPropertiesInfo; + + /// The object that currently has the editing focus + wxRichTextParagraphLayoutBox* m_focusObject; }; /*! @@ -849,17 +1042,19 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextEvent : public wxNotifyEvent public: wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0) : wxNotifyEvent(commandType, winid), - m_itemIndex(-1), m_flags(0), m_oldStyleSheet(NULL), m_newStyleSheet(NULL) + m_flags(0), m_position(-1), m_oldStyleSheet(NULL), m_newStyleSheet(NULL), + m_char((wxChar) 0), m_container(NULL), m_oldContainer(NULL) { } wxRichTextEvent(const wxRichTextEvent& event) : wxNotifyEvent(event), - m_itemIndex(event.m_itemIndex), m_flags(event.m_flags), - m_oldStyleSheet(event.m_oldStyleSheet), m_newStyleSheet(event.m_newStyleSheet) + m_flags(event.m_flags), m_position(-1), + m_oldStyleSheet(event.m_oldStyleSheet), m_newStyleSheet(event.m_newStyleSheet), + m_char((wxChar) 0), m_container(event.m_container), m_oldContainer(event.m_oldContainer) { } - int GetIndex() const { return m_itemIndex; } - void SetIndex(int n) { m_itemIndex = n; } + long GetPosition() const { return m_position; } + void SetPosition(long pos) { m_position = pos; } int GetFlags() const { return m_flags; } void SetFlags(int flags) { m_flags = flags; } @@ -870,51 +1065,80 @@ public: wxRichTextStyleSheet* GetNewStyleSheet() const { return m_newStyleSheet; } void SetNewStyleSheet(wxRichTextStyleSheet* sheet) { m_newStyleSheet = sheet; } + const wxRichTextRange& GetRange() const { return m_range; } + void SetRange(const wxRichTextRange& range) { m_range = range; } + + wxChar GetCharacter() const { return m_char; } + void SetCharacter(wxChar ch) { m_char = ch; } + + wxRichTextParagraphLayoutBox* GetContainer() const { return m_container; } + void SetContainer(wxRichTextParagraphLayoutBox* container) { m_container = container; } + + wxRichTextParagraphLayoutBox* GetOldContainer() const { return m_oldContainer; } + void SetOldContainer(wxRichTextParagraphLayoutBox* container) { m_oldContainer = container; } + virtual wxEvent *Clone() const { return new wxRichTextEvent(*this); } protected: - int m_itemIndex; - int m_flags; - wxRichTextStyleSheet* m_oldStyleSheet; - wxRichTextStyleSheet* m_newStyleSheet; + int m_flags; + long m_position; + wxRichTextStyleSheet* m_oldStyleSheet; + wxRichTextStyleSheet* m_newStyleSheet; + wxRichTextRange m_range; + wxChar m_char; + wxRichTextParagraphLayoutBox* m_container; + wxRichTextParagraphLayoutBox* m_oldContainer; private: DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRichTextEvent) }; /*! - * wxRichTextCtrl event macros + * wxRichTextCtrl events */ - -BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 2600) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 2601) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 2602) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 2603) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 2604) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 2605) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RETURN, 2606) - - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, 2607) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, 2608) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, 2609) - DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, 2610) -END_DECLARE_EVENT_TYPES() +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_RETURN, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_CHARACTER, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_DELETE, wxRichTextEvent ); + +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, wxRichTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_RICHTEXT, wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, wxRichTextEvent ); + +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_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 ); typedef void (wxEvtHandler::*wxRichTextEventFunction)(wxRichTextEvent&); -#define EVT_RICHTEXT_ITEM_SELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_ITEM_DESELECTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_LEFT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_MIDDLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_LEFT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_RETURN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RETURN, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), - -#define EVT_RICHTEXT_STYLESHEET_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_STYLESHEET_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_STYLESHEET_REPLACING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), -#define EVT_RICHTEXT_STYLESHEET_REPLACED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, id, -1, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxRichTextEventFunction, & fn ), NULL ), +#define wxRichTextEventHandler(func) \ + wxEVENT_HANDLER_CAST(wxRichTextEventFunction, func) + +#define EVT_RICHTEXT_LEFT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_RIGHT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_MIDDLE_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_LEFT_DCLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_RETURN(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RETURN, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_CHARACTER(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CHARACTER, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_DELETE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_DELETE, id, -1, wxRichTextEventHandler( fn ), NULL ), + +#define EVT_RICHTEXT_STYLESHEET_CHANGING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_STYLESHEET_CHANGED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_STYLESHEET_REPLACING(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id, -1, wxRichTextEventHandler( fn ), NULL ), +#define EVT_RICHTEXT_STYLESHEET_REPLACED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, id, -1, wxRichTextEventHandler( fn ), NULL ), + +#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_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 ), #endif // wxUSE_RICHTEXT