2005-10-19 08:52:47 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-19 13:00:58 -04:00
|
|
|
// Name: wx/richtext/richtextctrl.h
|
2005-10-19 08:52:47 -04:00
|
|
|
// Purpose: A rich edit control
|
|
|
|
// Author: Julian Smart
|
2005-10-19 13:00:58 -04:00
|
|
|
// Modified by:
|
2005-10-19 08:52:47 -04:00
|
|
|
// Created: 2005-09-30
|
2005-10-19 13:00:58 -04:00
|
|
|
// RCS-ID: $Id$
|
2005-10-19 08:52:47 -04:00
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_RICHTEXTCTRL_H_
|
|
|
|
#define _WX_RICHTEXTCTRL_H_
|
|
|
|
|
2005-10-28 10:24:04 -04:00
|
|
|
#include "wx/richtext/richtextbuffer.h"
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
#if wxUSE_RICHTEXT
|
|
|
|
|
|
|
|
#include "wx/scrolwin.h"
|
|
|
|
#include "wx/caret.h"
|
|
|
|
|
2005-10-28 10:24:04 -04:00
|
|
|
#include "wx/textctrl.h"
|
|
|
|
|
2006-10-08 10:00:04 -04:00
|
|
|
#if !defined(__WXGTK__) && !defined(__WXMAC__)
|
|
|
|
#define wxRICHTEXT_BUFFERED_PAINTING 1
|
|
|
|
#else
|
|
|
|
#define wxRICHTEXT_BUFFERED_PAINTING 0
|
|
|
|
#endif
|
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleDefinition;
|
2006-09-12 04:42:40 -04:00
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/*!
|
|
|
|
* Styles and flags
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Styles
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define wxRE_READONLY 0x0010
|
|
|
|
#define wxRE_MULTILINE 0x0020
|
2009-01-21 07:06:21 -05:00
|
|
|
#define wxRE_CENTRE_CARET 0x8000
|
|
|
|
#define wxRE_CENTER_CARET wxRE_CENTRE_CARET
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/* Flags
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define wxRICHTEXT_SHIFT_DOWN 0x01
|
|
|
|
#define wxRICHTEXT_CTRL_DOWN 0x02
|
|
|
|
#define wxRICHTEXT_ALT_DOWN 0x04
|
|
|
|
|
|
|
|
/* Defaults
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define wxRICHTEXT_DEFAULT_OVERALL_SIZE wxSize(-1, -1)
|
|
|
|
#define wxRICHTEXT_DEFAULT_IMAGE_SIZE wxSize(80, 80)
|
|
|
|
#define wxRICHTEXT_DEFAULT_SPACING 3
|
|
|
|
#define wxRICHTEXT_DEFAULT_MARGIN 3
|
|
|
|
#define wxRICHTEXT_DEFAULT_UNFOCUSSED_BACKGROUND wxColour(175, 175, 175)
|
|
|
|
#define wxRICHTEXT_DEFAULT_FOCUSSED_BACKGROUND wxColour(140, 140, 140)
|
|
|
|
#define wxRICHTEXT_DEFAULT_UNSELECTED_BACKGROUND wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)
|
|
|
|
#define wxRICHTEXT_DEFAULT_TYPE_COLOUR wxColour(0, 0, 200)
|
|
|
|
#define wxRICHTEXT_DEFAULT_FOCUS_RECT_COLOUR wxColour(100, 80, 80)
|
|
|
|
#define wxRICHTEXT_DEFAULT_CARET_WIDTH 2
|
2005-10-21 09:02:15 -04:00
|
|
|
// Minimum buffer size before delayed layout kicks in
|
|
|
|
#define wxRICHTEXT_DEFAULT_DELAYED_LAYOUT_THRESHOLD 20000
|
|
|
|
// Milliseconds before layout occurs after resize
|
|
|
|
#define wxRICHTEXT_DEFAULT_LAYOUT_INTERVAL 50
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Forward declarations
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxRichTextItem class declaration
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Drawing styles/states
|
|
|
|
#define wxRICHTEXT_SELECTED 0x01
|
|
|
|
#define wxRICHTEXT_TAGGED 0x02
|
|
|
|
// The control is focussed
|
|
|
|
#define wxRICHTEXT_FOCUSSED 0x04
|
|
|
|
// The item itself has the focus
|
|
|
|
#define wxRICHTEXT_IS_FOCUS 0x08
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxRichTextCtrl class declaration
|
|
|
|
*/
|
|
|
|
|
2009-02-27 05:54:12 -05:00
|
|
|
class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxTextCtrlBase,
|
2006-10-08 18:42:20 -04:00
|
|
|
public wxScrollHelper
|
2005-10-19 13:00:58 -04:00
|
|
|
{
|
2005-10-19 08:52:47 -04:00
|
|
|
DECLARE_CLASS( wxRichTextCtrl )
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Constructors
|
|
|
|
|
|
|
|
wxRichTextCtrl( );
|
2006-07-03 17:13:18 -04:00
|
|
|
wxRichTextCtrl( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
2006-11-08 13:51:03 -05:00
|
|
|
long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr);
|
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxRichTextCtrl( );
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
// Operations
|
|
|
|
|
|
|
|
/// Creation
|
2006-07-03 17:13:18 -04:00
|
|
|
bool Create( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
2006-11-08 13:51:03 -05:00
|
|
|
long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr );
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Member initialisation
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
///// wxTextCtrl compatibility
|
|
|
|
|
|
|
|
// Accessors
|
|
|
|
|
|
|
|
virtual wxString GetRange(long from, long to) const;
|
|
|
|
|
|
|
|
virtual int GetLineLength(long lineNo) const ;
|
|
|
|
virtual wxString GetLineText(long lineNo) const ;
|
|
|
|
virtual int GetNumberOfLines() const ;
|
|
|
|
|
|
|
|
virtual bool IsModified() const ;
|
|
|
|
virtual bool IsEditable() const ;
|
|
|
|
|
|
|
|
// more readable flag testing methods
|
|
|
|
bool IsSingleLine() const { return !HasFlag(wxRE_MULTILINE); }
|
|
|
|
bool IsMultiLine() const { return !IsSingleLine(); }
|
|
|
|
|
|
|
|
// If the return values from and to are the same, there is no selection.
|
|
|
|
virtual void GetSelection(long* from, long* to) const;
|
|
|
|
|
|
|
|
virtual wxString GetStringSelection() const;
|
|
|
|
|
|
|
|
/// Get filename
|
|
|
|
wxString GetFilename() const { return m_filename; }
|
|
|
|
|
|
|
|
/// Set filename
|
|
|
|
void SetFilename(const wxString& filename) { m_filename = filename; }
|
|
|
|
|
2005-10-21 09:02:15 -04:00
|
|
|
/// Set the threshold in character positions for doing layout optimization during sizing
|
|
|
|
void SetDelayedLayoutThreshold(long threshold) { m_delayedLayoutThreshold = threshold; }
|
|
|
|
|
|
|
|
/// Get the threshold in character positions for doing layout optimization during sizing
|
|
|
|
long GetDelayedLayoutThreshold() const { return m_delayedLayoutThreshold; }
|
|
|
|
|
2008-02-27 03:54:55 -05:00
|
|
|
/// 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; }
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
// Operations
|
|
|
|
|
|
|
|
// editing
|
|
|
|
virtual void Clear();
|
|
|
|
virtual void Replace(long from, long to, const wxString& value);
|
|
|
|
virtual void Remove(long from, long to);
|
|
|
|
|
|
|
|
// load/save the controls contents from/to the file
|
2006-09-24 07:40:33 -04:00
|
|
|
virtual bool DoLoadFile(const wxString& file, int fileType);
|
2008-05-10 05:40:33 -04:00
|
|
|
virtual bool DoSaveFile(const wxString& file = wxEmptyString,
|
|
|
|
int fileType = wxRICHTEXT_TYPE_ANY);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
2006-10-26 02:32:47 -04:00
|
|
|
/// Set the handler flags, controlling loading and saving
|
|
|
|
void SetHandlerFlags(int flags) { GetBuffer().SetHandlerFlags(flags); }
|
|
|
|
|
|
|
|
/// Get the handler flags, controlling loading and saving
|
|
|
|
int GetHandlerFlags() const { return GetBuffer().GetHandlerFlags(); }
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
// sets/clears the dirty flag
|
|
|
|
virtual void MarkDirty();
|
|
|
|
virtual void DiscardEdits();
|
|
|
|
|
|
|
|
// set the max number of characters which may be entered in a single line
|
|
|
|
// text control
|
|
|
|
virtual void SetMaxLength(unsigned long WXUNUSED(len)) { }
|
|
|
|
|
|
|
|
// writing text inserts it at the current position, appending always
|
|
|
|
// inserts it at the end
|
|
|
|
virtual void WriteText(const wxString& text);
|
|
|
|
virtual void AppendText(const wxString& text);
|
|
|
|
|
|
|
|
// text control under some platforms supports the text styles: these
|
|
|
|
// 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
|
2006-07-03 17:13:18 -04:00
|
|
|
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style);
|
2006-09-19 13:06:54 -04:00
|
|
|
virtual bool GetStyle(long position, wxTextAttr& style);
|
2006-09-29 04:53:23 -04:00
|
|
|
|
2006-11-15 10:59:06 -05:00
|
|
|
// get the common set of styles for the range
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style);
|
2006-10-08 10:00:04 -04:00
|
|
|
// 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.
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual bool SetStyleEx(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
|
2006-10-08 10:00:04 -04:00
|
|
|
|
2006-09-29 04:53:23 -04:00
|
|
|
/// Get the content (uncombined) attributes for this position.
|
|
|
|
virtual bool GetUncombinedStyle(long position, wxTextAttr& style);
|
|
|
|
|
2006-07-03 17:13:18 -04:00
|
|
|
virtual bool SetDefaultStyle(const wxTextAttr& style);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual const wxTextAttr& GetDefaultStyleEx() const { return GetDefaultStyle(); }
|
|
|
|
|
2006-07-03 17:13:18 -04:00
|
|
|
virtual const wxTextAttr& GetDefaultStyle() const;
|
2005-10-19 08:52:47 -04:00
|
|
|
|
2006-10-17 10:09:14 -04:00
|
|
|
/// Set list style
|
|
|
|
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
|
|
|
|
virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
|
|
|
|
|
|
|
|
/// Clear list for given range
|
|
|
|
virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
|
|
|
|
|
|
|
|
/// Number/renumber any list elements in the given range
|
|
|
|
/// def/defName can be NULL/empty to indicate that the existing list style should be used.
|
2006-10-19 10:04:13 -04:00
|
|
|
virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
|
2006-10-17 10:09:14 -04:00
|
|
|
virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
|
|
|
|
|
|
|
|
/// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1
|
|
|
|
/// def/defName can be NULL/empty to indicate that the existing list style should be used.
|
2006-10-19 10:04:13 -04:00
|
|
|
virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
|
2006-10-17 10:09:14 -04:00
|
|
|
virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
|
|
|
|
|
2006-11-18 17:27:48 -05:00
|
|
|
/// Deletes the content in the given range
|
|
|
|
virtual bool Delete(const wxRichTextRange& range);
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
// 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.
|
|
|
|
virtual long XYToPosition(long x, long y) const;
|
|
|
|
virtual bool PositionToXY(long pos, long *x, long *y) const;
|
|
|
|
|
|
|
|
virtual void ShowPosition(long pos);
|
|
|
|
|
|
|
|
// find the character at position given in pixels
|
|
|
|
//
|
|
|
|
// NB: pt is in device coords (not adjusted for the client area origin nor
|
|
|
|
// scrolling)
|
|
|
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
|
|
|
|
virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
|
|
|
|
wxTextCoord *col,
|
|
|
|
wxTextCoord *row) const;
|
|
|
|
|
|
|
|
// Clipboard operations
|
|
|
|
virtual void Copy();
|
|
|
|
virtual void Cut();
|
|
|
|
virtual void Paste();
|
|
|
|
virtual void DeleteSelection();
|
|
|
|
|
|
|
|
virtual bool CanCopy() const;
|
|
|
|
virtual bool CanCut() const;
|
|
|
|
virtual bool CanPaste() const;
|
|
|
|
virtual bool CanDeleteSelection() const;
|
|
|
|
|
|
|
|
// Undo/redo
|
|
|
|
virtual void Undo();
|
|
|
|
virtual void Redo();
|
|
|
|
|
|
|
|
virtual bool CanUndo() const;
|
|
|
|
virtual bool CanRedo() const;
|
|
|
|
|
|
|
|
// Insertion point
|
|
|
|
virtual void SetInsertionPoint(long pos);
|
|
|
|
virtual void SetInsertionPointEnd();
|
|
|
|
virtual long GetInsertionPoint() const;
|
|
|
|
virtual wxTextPos GetLastPosition() const;
|
|
|
|
|
|
|
|
virtual void SetSelection(long from, long to);
|
|
|
|
virtual void SelectAll();
|
|
|
|
virtual void SetEditable(bool editable);
|
|
|
|
|
|
|
|
virtual bool HasSelection() 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.
|
2008-05-10 05:40:33 -04:00
|
|
|
virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Write a bitmap at the current insertion point. Supply optional type to use
|
|
|
|
/// for internal and file storage of the raw data.
|
2008-05-10 05:40:33 -04:00
|
|
|
virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Load an image from file and write at the current insertion point.
|
2008-05-10 05:40:33 -04:00
|
|
|
virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Write an image block at the current insertion point.
|
|
|
|
virtual bool WriteImage(const wxRichTextImageBlock& imageBlock);
|
|
|
|
|
|
|
|
/// Insert a newline (actually paragraph) at the current insertion point.
|
|
|
|
virtual bool Newline();
|
|
|
|
|
2006-11-20 06:33:44 -05:00
|
|
|
/// Insert a line break at the current insertion point.
|
|
|
|
virtual bool LineBreak();
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Set basic (overall) style
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual void SetBasicStyle(const wxTextAttr& style) { GetBuffer().SetBasicStyle(style); }
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Get basic (overall) style
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual const wxTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
|
2005-10-19 08:52:47 -04:00
|
|
|
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual bool BeginStyle(const wxTextAttr& style) { return GetBuffer().BeginStyle(style); }
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// End the style
|
|
|
|
virtual bool EndStyle() { return GetBuffer().EndStyle(); }
|
|
|
|
|
|
|
|
/// End all styles
|
|
|
|
virtual bool EndAllStyles() { return GetBuffer().EndAllStyles(); }
|
|
|
|
|
|
|
|
/// Begin using bold
|
|
|
|
bool BeginBold() { return GetBuffer().BeginBold(); }
|
|
|
|
|
|
|
|
/// End using bold
|
|
|
|
bool EndBold() { return GetBuffer().EndBold(); }
|
|
|
|
|
|
|
|
/// Begin using italic
|
|
|
|
bool BeginItalic() { return GetBuffer().BeginItalic(); }
|
|
|
|
|
|
|
|
/// End using italic
|
|
|
|
bool EndItalic() { return GetBuffer().EndItalic(); }
|
|
|
|
|
|
|
|
/// Begin using underline
|
|
|
|
bool BeginUnderline() { return GetBuffer().BeginUnderline(); }
|
|
|
|
|
|
|
|
/// End using underline
|
|
|
|
bool EndUnderline() { return GetBuffer().EndUnderline(); }
|
|
|
|
|
|
|
|
/// Begin using point size
|
|
|
|
bool BeginFontSize(int pointSize) { return GetBuffer().BeginFontSize(pointSize); }
|
|
|
|
|
|
|
|
/// End using point size
|
|
|
|
bool EndFontSize() { return GetBuffer().EndFontSize(); }
|
|
|
|
|
|
|
|
/// Begin using this font
|
|
|
|
bool BeginFont(const wxFont& font) { return GetBuffer().BeginFont(font); }
|
|
|
|
|
|
|
|
/// End using a font
|
|
|
|
bool EndFont() { return GetBuffer().EndFont(); }
|
|
|
|
|
|
|
|
/// Begin using this colour
|
|
|
|
bool BeginTextColour(const wxColour& colour) { return GetBuffer().BeginTextColour(colour); }
|
|
|
|
|
|
|
|
/// End using a colour
|
|
|
|
bool EndTextColour() { return GetBuffer().EndTextColour(); }
|
|
|
|
|
|
|
|
/// Begin using alignment
|
|
|
|
bool BeginAlignment(wxTextAttrAlignment alignment) { return GetBuffer().BeginAlignment(alignment); }
|
|
|
|
|
|
|
|
/// End alignment
|
|
|
|
bool EndAlignment() { return GetBuffer().EndAlignment(); }
|
|
|
|
|
|
|
|
/// Begin left indent
|
|
|
|
bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0) { return GetBuffer().BeginLeftIndent(leftIndent, leftSubIndent); }
|
|
|
|
|
|
|
|
/// End left indent
|
|
|
|
bool EndLeftIndent() { return GetBuffer().EndLeftIndent(); }
|
|
|
|
|
|
|
|
/// Begin right indent
|
|
|
|
bool BeginRightIndent(int rightIndent) { return GetBuffer().BeginRightIndent(rightIndent); }
|
|
|
|
|
|
|
|
/// End right indent
|
|
|
|
bool EndRightIndent() { return GetBuffer().EndRightIndent(); }
|
|
|
|
|
|
|
|
/// Begin paragraph spacing
|
|
|
|
bool BeginParagraphSpacing(int before, int after) { return GetBuffer().BeginParagraphSpacing(before, after); }
|
|
|
|
|
|
|
|
/// End paragraph spacing
|
|
|
|
bool EndParagraphSpacing() { return GetBuffer().EndParagraphSpacing(); }
|
|
|
|
|
|
|
|
/// Begin line spacing
|
|
|
|
bool BeginLineSpacing(int lineSpacing) { return GetBuffer().BeginLineSpacing(lineSpacing); }
|
|
|
|
|
|
|
|
/// End line spacing
|
|
|
|
bool EndLineSpacing() { return GetBuffer().EndLineSpacing(); }
|
|
|
|
|
|
|
|
/// Begin numbered bullet
|
|
|
|
bool BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD)
|
|
|
|
{ return GetBuffer().BeginNumberedBullet(bulletNumber, leftIndent, leftSubIndent, bulletStyle); }
|
|
|
|
|
|
|
|
/// End numbered bullet
|
|
|
|
bool EndNumberedBullet() { return GetBuffer().EndNumberedBullet(); }
|
|
|
|
|
|
|
|
/// Begin symbol bullet
|
2006-10-26 02:32:47 -04:00
|
|
|
bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL)
|
2005-10-19 08:52:47 -04:00
|
|
|
{ return GetBuffer().BeginSymbolBullet(symbol, leftIndent, leftSubIndent, bulletStyle); }
|
|
|
|
|
|
|
|
/// End symbol bullet
|
|
|
|
bool EndSymbolBullet() { return GetBuffer().EndSymbolBullet(); }
|
|
|
|
|
2006-10-20 09:04:12 -04:00
|
|
|
/// Begin standard bullet
|
|
|
|
bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD)
|
|
|
|
{ return GetBuffer().BeginStandardBullet(bulletName, leftIndent, leftSubIndent, bulletStyle); }
|
|
|
|
|
|
|
|
/// End standard bullet
|
|
|
|
bool EndStandardBullet() { return GetBuffer().EndStandardBullet(); }
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Begin named character style
|
|
|
|
bool BeginCharacterStyle(const wxString& characterStyle) { return GetBuffer().BeginCharacterStyle(characterStyle); }
|
|
|
|
|
|
|
|
/// End named character style
|
|
|
|
bool EndCharacterStyle() { return GetBuffer().EndCharacterStyle(); }
|
|
|
|
|
|
|
|
/// Begin named paragraph style
|
|
|
|
bool BeginParagraphStyle(const wxString& paragraphStyle) { return GetBuffer().BeginParagraphStyle(paragraphStyle); }
|
|
|
|
|
|
|
|
/// End named character style
|
|
|
|
bool EndParagraphStyle() { return GetBuffer().EndParagraphStyle(); }
|
|
|
|
|
2006-10-20 09:04:12 -04:00
|
|
|
/// Begin named list style
|
|
|
|
bool BeginListStyle(const wxString& listStyle, int level = 1, int number = 1) { return GetBuffer().BeginListStyle(listStyle, level, number); }
|
|
|
|
|
|
|
|
/// End named character style
|
|
|
|
bool EndListStyle() { return GetBuffer().EndListStyle(); }
|
|
|
|
|
2006-10-26 02:32:47 -04:00
|
|
|
/// Begin URL
|
|
|
|
bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString) { return GetBuffer().BeginURL(url, characterStyle); }
|
|
|
|
|
|
|
|
/// End URL
|
|
|
|
bool EndURL() { return GetBuffer().EndURL(); }
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Sets the default style to the style under the cursor
|
|
|
|
bool SetDefaultStyleToCursorStyle();
|
|
|
|
|
|
|
|
/// Clear the selection
|
|
|
|
virtual void SelectNone();
|
|
|
|
|
2006-10-01 10:46:03 -04:00
|
|
|
/// Select the word at the given character position
|
|
|
|
virtual bool SelectWord(long position);
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Get/set the selection range in character positions. -1, -1 means no selection.
|
2006-09-19 09:47:32 -04:00
|
|
|
/// The range is in API convention, i.e. a single character selection is denoted
|
|
|
|
/// by (n, n+1)
|
|
|
|
wxRichTextRange GetSelectionRange() const;
|
|
|
|
void SetSelectionRange(const wxRichTextRange& range);
|
|
|
|
|
|
|
|
/// Get/set the selection range in character positions. -1, -1 means no selection.
|
|
|
|
/// 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; }
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Add a new paragraph of text to the end of the buffer
|
|
|
|
virtual wxRichTextRange AddParagraph(const wxString& text);
|
|
|
|
|
|
|
|
/// Add an image
|
|
|
|
virtual wxRichTextRange AddImage(const wxImage& image);
|
|
|
|
|
|
|
|
/// Layout the buffer: which we must do before certain operations, such as
|
|
|
|
/// setting the caret position.
|
2005-10-22 09:44:30 -04:00
|
|
|
virtual bool LayoutContent(bool onlyVisibleRect = false);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Move the caret to the given character position
|
|
|
|
virtual bool MoveCaret(long pos, bool showAtLineStart = false);
|
|
|
|
|
|
|
|
/// Move right
|
|
|
|
virtual bool MoveRight(int noPositions = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Move left
|
|
|
|
virtual bool MoveLeft(int noPositions = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Move up
|
|
|
|
virtual bool MoveUp(int noLines = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Move up
|
|
|
|
virtual bool MoveDown(int noLines = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Move to the end of the line
|
|
|
|
virtual bool MoveToLineEnd(int flags = 0);
|
|
|
|
|
|
|
|
/// Move to the start of the line
|
|
|
|
virtual bool MoveToLineStart(int flags = 0);
|
|
|
|
|
|
|
|
/// Move to the end of the paragraph
|
|
|
|
virtual bool MoveToParagraphEnd(int flags = 0);
|
|
|
|
|
|
|
|
/// Move to the start of the paragraph
|
|
|
|
virtual bool MoveToParagraphStart(int flags = 0);
|
|
|
|
|
|
|
|
/// Move to the start of the buffer
|
|
|
|
virtual bool MoveHome(int flags = 0);
|
|
|
|
|
|
|
|
/// Move to the end of the buffer
|
|
|
|
virtual bool MoveEnd(int flags = 0);
|
|
|
|
|
|
|
|
/// Move n pages up
|
|
|
|
virtual bool PageUp(int noPages = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Move n pages down
|
|
|
|
virtual bool PageDown(int noPages = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Move n words left
|
|
|
|
virtual bool WordLeft(int noPages = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Move n words right
|
|
|
|
virtual bool WordRight(int noPages = 1, int flags = 0);
|
|
|
|
|
|
|
|
/// Returns the buffer associated with the control.
|
|
|
|
wxRichTextBuffer& GetBuffer() { return m_buffer; }
|
|
|
|
const wxRichTextBuffer& GetBuffer() const { return m_buffer; }
|
|
|
|
|
|
|
|
/// Start batching undo history for commands.
|
|
|
|
virtual bool BeginBatchUndo(const wxString& cmdName) { return m_buffer.BeginBatchUndo(cmdName); }
|
|
|
|
|
|
|
|
/// End batching undo history for commands.
|
|
|
|
virtual bool EndBatchUndo() { return m_buffer.EndBatchUndo(); }
|
|
|
|
|
|
|
|
/// Are we batching undo history for commands?
|
|
|
|
virtual bool BatchingUndo() const { return m_buffer.BatchingUndo(); }
|
|
|
|
|
|
|
|
/// Start suppressing undo history for commands.
|
|
|
|
virtual bool BeginSuppressUndo() { return m_buffer.BeginSuppressUndo(); }
|
|
|
|
|
|
|
|
/// End suppressing undo history for commands.
|
|
|
|
virtual bool EndSuppressUndo() { return m_buffer.EndSuppressUndo(); }
|
|
|
|
|
|
|
|
/// Are we suppressing undo history for commands?
|
|
|
|
virtual bool SuppressingUndo() const { return m_buffer.SuppressingUndo(); }
|
|
|
|
|
|
|
|
/// Test if this whole range has character 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, bold button updating. style must have
|
|
|
|
/// flags indicating which attributes are of interest.
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const
|
2005-10-19 08:52:47 -04:00
|
|
|
{
|
2006-11-15 10:59:06 -05:00
|
|
|
return GetBuffer().HasCharacterAttributes(range.ToInternal(), style);
|
2005-10-19 08:52:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// 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.
|
2007-10-09 07:20:36 -04:00
|
|
|
virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const
|
2005-10-19 08:52:47 -04:00
|
|
|
{
|
2006-11-15 10:59:06 -05:00
|
|
|
return GetBuffer().HasParagraphAttributes(range.ToInternal(), style);
|
2005-10-19 08:52:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Is all of the selection bold?
|
2006-09-19 13:06:54 -04:00
|
|
|
virtual bool IsSelectionBold();
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Is all of the selection italics?
|
2006-09-19 13:06:54 -04:00
|
|
|
virtual bool IsSelectionItalics();
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Is all of the selection underlined?
|
2006-09-19 13:06:54 -04:00
|
|
|
virtual bool IsSelectionUnderlined();
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Is all of the selection aligned according to the specified flag?
|
2006-09-19 13:06:54 -04:00
|
|
|
virtual bool IsSelectionAligned(wxTextAttrAlignment alignment);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Apply bold to the selection
|
|
|
|
virtual bool ApplyBoldToSelection();
|
|
|
|
|
|
|
|
/// Apply italic to the selection
|
|
|
|
virtual bool ApplyItalicToSelection();
|
|
|
|
|
|
|
|
/// Apply underline to the selection
|
|
|
|
virtual bool ApplyUnderlineToSelection();
|
|
|
|
|
|
|
|
/// Apply alignment to the selection
|
|
|
|
virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment);
|
|
|
|
|
2006-09-12 04:42:40 -04:00
|
|
|
/// Apply a named style to the selection
|
2006-10-10 13:01:36 -04:00
|
|
|
virtual bool ApplyStyle(wxRichTextStyleDefinition* def);
|
2006-09-12 04:42:40 -04:00
|
|
|
|
2006-10-17 10:09:14 -04:00
|
|
|
/// Set style sheet, if any
|
2005-10-19 08:52:47 -04:00
|
|
|
void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { GetBuffer().SetStyleSheet(styleSheet); }
|
|
|
|
wxRichTextStyleSheet* GetStyleSheet() const { return GetBuffer().GetStyleSheet(); }
|
|
|
|
|
2006-10-17 10:09:14 -04:00
|
|
|
/// Push style sheet to top of stack
|
|
|
|
bool PushStyleSheet(wxRichTextStyleSheet* styleSheet) { return GetBuffer().PushStyleSheet(styleSheet); }
|
|
|
|
|
|
|
|
/// Pop style sheet from top of stack
|
|
|
|
wxRichTextStyleSheet* PopStyleSheet() { return GetBuffer().PopStyleSheet(); }
|
|
|
|
|
2006-09-29 04:53:23 -04:00
|
|
|
/// Apply the style sheet to the buffer, for example if the styles have changed.
|
|
|
|
bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL);
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
// Command handlers
|
|
|
|
|
2006-07-02 03:17:46 -04:00
|
|
|
void Command(wxCommandEvent& event);
|
2005-10-19 08:52:47 -04:00
|
|
|
void OnDropFiles(wxDropFilesEvent& event);
|
2006-12-29 14:37:04 -05:00
|
|
|
void OnCaptureLost(wxMouseCaptureLostEvent& event);
|
2007-10-27 12:59:24 -04:00
|
|
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
void OnCut(wxCommandEvent& event);
|
|
|
|
void OnCopy(wxCommandEvent& event);
|
|
|
|
void OnPaste(wxCommandEvent& event);
|
|
|
|
void OnUndo(wxCommandEvent& event);
|
|
|
|
void OnRedo(wxCommandEvent& event);
|
|
|
|
void OnSelectAll(wxCommandEvent& event);
|
|
|
|
void OnClear(wxCommandEvent& event);
|
|
|
|
|
|
|
|
void OnUpdateCut(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateCopy(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdatePaste(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateUndo(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateRedo(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateSelectAll(wxUpdateUIEvent& event);
|
|
|
|
void OnUpdateClear(wxUpdateUIEvent& event);
|
|
|
|
|
|
|
|
// Show a context menu for Rich Edit controls (the standard
|
|
|
|
// EDIT control has one already)
|
|
|
|
void OnContextMenu(wxContextMenuEvent& event);
|
2005-10-19 13:00:58 -04:00
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
// Event handlers
|
|
|
|
|
|
|
|
/// Painting
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
void OnEraseBackground(wxEraseEvent& event);
|
|
|
|
|
|
|
|
/// Left-click
|
|
|
|
void OnLeftClick(wxMouseEvent& event);
|
|
|
|
|
|
|
|
/// Left-up
|
|
|
|
void OnLeftUp(wxMouseEvent& event);
|
|
|
|
|
|
|
|
/// Motion
|
|
|
|
void OnMoveMouse(wxMouseEvent& event);
|
|
|
|
|
|
|
|
/// Left-double-click
|
|
|
|
void OnLeftDClick(wxMouseEvent& event);
|
|
|
|
|
|
|
|
/// Middle-click
|
|
|
|
void OnMiddleClick(wxMouseEvent& event);
|
|
|
|
|
|
|
|
/// Right-click
|
|
|
|
void OnRightClick(wxMouseEvent& event);
|
|
|
|
|
|
|
|
/// Key press
|
|
|
|
void OnChar(wxKeyEvent& event);
|
|
|
|
|
|
|
|
/// Sizing
|
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
|
|
|
|
/// Setting/losing focus
|
|
|
|
void OnSetFocus(wxFocusEvent& event);
|
|
|
|
void OnKillFocus(wxFocusEvent& event);
|
|
|
|
|
2005-10-21 09:02:15 -04:00
|
|
|
/// Idle-time processing
|
|
|
|
void OnIdle(wxIdleEvent& event);
|
|
|
|
|
2005-10-21 16:04:53 -04:00
|
|
|
/// Scrolling
|
|
|
|
void OnScroll(wxScrollWinEvent& event);
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Set font, and also default attributes
|
|
|
|
virtual bool SetFont(const wxFont& font);
|
|
|
|
|
|
|
|
/// Set up scrollbars, e.g. after a resize
|
2005-10-20 18:51:57 -04:00
|
|
|
virtual void SetupScrollbars(bool atTop = false);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Keyboard navigation
|
2005-10-25 13:51:10 -04:00
|
|
|
virtual bool KeyboardNavigate(int keyCode, int flags);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Paint the background
|
|
|
|
virtual void PaintBackground(wxDC& dc);
|
2005-10-19 13:00:58 -04:00
|
|
|
|
2006-10-08 10:00:04 -04:00
|
|
|
#if wxRICHTEXT_BUFFERED_PAINTING
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Recreate buffer bitmap if necessary
|
|
|
|
virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
|
2006-10-08 10:00:04 -04:00
|
|
|
#endif
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Write text
|
2006-10-08 18:42:20 -04:00
|
|
|
virtual void DoWriteText(const wxString& value, int flags = 0);
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Should we inherit colours?
|
|
|
|
virtual bool ShouldInheritColours() const { return false; }
|
|
|
|
|
|
|
|
/// Position the caret
|
|
|
|
virtual void PositionCaret();
|
|
|
|
|
|
|
|
/// Extend the selection, returning true if the selection was
|
|
|
|
/// changed. Selections are in caret positions.
|
|
|
|
virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
|
|
|
|
|
|
|
|
/// Scroll into view. This takes a _caret_ position.
|
|
|
|
virtual bool ScrollIntoView(long position, int keyCode);
|
|
|
|
|
2008-04-27 09:29:53 -04:00
|
|
|
/// Refresh the area affected by a selection change
|
|
|
|
bool RefreshForSelectionChange(const wxRichTextRange& oldSelection, const wxRichTextRange& newSelection);
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// 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) ;
|
|
|
|
long GetCaretPosition() const { return m_caretPosition; }
|
|
|
|
|
2006-09-12 04:42:40 -04:00
|
|
|
/// The adjusted caret position is the character position adjusted to take
|
|
|
|
/// into account whether we're at the start of a paragraph, in which case
|
|
|
|
/// style information should be taken from the next position, not current one.
|
|
|
|
long GetAdjustedCaretPosition(long caretPos) const;
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Move caret one visual step forward: this may mean setting a flag
|
|
|
|
/// and keeping the same position if we're going from the end of one line
|
|
|
|
/// to the start of the next, which may be the exact same caret position.
|
|
|
|
void MoveCaretForward(long oldPosition) ;
|
|
|
|
|
|
|
|
/// Move caret one visual step forward: this may mean setting a flag
|
|
|
|
/// and keeping the same position if we're going from the end of one line
|
|
|
|
/// 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);
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
/// on the following line. So let's get the line we're expecting to find
|
|
|
|
/// if this is the case.
|
|
|
|
wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
|
|
|
|
|
|
|
|
/// Gets the command processor
|
|
|
|
wxCommandProcessor* GetCommandProcessor() const { return GetBuffer().GetCommandProcessor(); }
|
|
|
|
|
|
|
|
/// Delete content if there is a selection, e.g. when pressing a key.
|
|
|
|
/// Returns the new caret position in newPos, or leaves it if there
|
|
|
|
/// was no action.
|
|
|
|
bool DeleteSelectedContent(long* newPos= NULL);
|
|
|
|
|
|
|
|
/// Transform logical to physical
|
2005-10-21 09:02:15 -04:00
|
|
|
wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Transform physical to logical
|
2005-10-21 09:02:15 -04:00
|
|
|
wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Finds the caret position for the next word. Direction
|
|
|
|
/// is 1 (forward) or -1 (backwards).
|
|
|
|
virtual long FindNextWordPosition(int direction = 1) const;
|
|
|
|
|
|
|
|
/// Is the given position visible on the screen?
|
|
|
|
bool IsPositionVisible(long pos) const;
|
|
|
|
|
2005-10-21 09:02:15 -04:00
|
|
|
/// Returns the first visible position in the current view
|
|
|
|
long GetFirstVisiblePosition() const;
|
|
|
|
|
2006-09-12 04:42:40 -04:00
|
|
|
/// Returns the caret position since the default formatting was changed. As
|
|
|
|
/// soon as this position changes, we no longer reflect the default style
|
|
|
|
/// in the UI. A value of -2 means that we should only reflect the style of the
|
|
|
|
/// content under the caret.
|
|
|
|
long GetCaretPositionForDefaultStyle() const { return m_caretPositionForDefaultStyle; }
|
|
|
|
|
|
|
|
/// Set the caret position for the default style that the user is selecting.
|
|
|
|
void SetCaretPositionForDefaultStyle(long pos) { m_caretPositionForDefaultStyle = pos; }
|
|
|
|
|
|
|
|
/// Should the UI reflect the default style chosen by the user, rather than the style under
|
|
|
|
/// the caret?
|
|
|
|
bool IsDefaultStyleShowing() const { return m_caretPositionForDefaultStyle != -2; }
|
|
|
|
|
|
|
|
/// Convenience function that tells the control to start reflecting the default
|
|
|
|
/// style, since the user is changing it.
|
2007-10-09 07:20:36 -04:00
|
|
|
void SetAndShowDefaultStyle(const wxTextAttr& attr)
|
2006-09-12 04:42:40 -04:00
|
|
|
{
|
|
|
|
SetDefaultStyle(attr);
|
|
|
|
SetCaretPositionForDefaultStyle(GetCaretPosition());
|
|
|
|
}
|
|
|
|
|
2006-10-30 12:51:38 -05:00
|
|
|
/// Get the first visible point in the window
|
|
|
|
wxPoint GetFirstVisiblePoint() const;
|
|
|
|
|
2006-09-29 04:53:23 -04:00
|
|
|
// Implementation
|
|
|
|
|
2006-10-19 10:04:13 -04:00
|
|
|
/// Font names take a long time to retrieve, so cache them (on demand)
|
|
|
|
static const wxArrayString& GetAvailableFontNames();
|
|
|
|
static void ClearAvailableFontNames();
|
|
|
|
|
2009-03-02 15:43:12 -05:00
|
|
|
WX_FORWARD_TO_SCROLL_HELPER()
|
|
|
|
|
|
|
|
// implement wxTextEntry methods
|
|
|
|
virtual wxString DoGetValue() const;
|
|
|
|
|
|
|
|
protected:
|
2009-03-02 07:25:01 -05:00
|
|
|
// FIXME: this does not work, it allows this code to compile but will fail
|
|
|
|
// during run-time
|
2009-02-27 05:54:12 -05:00
|
|
|
#ifdef __WXMSW__
|
|
|
|
virtual WXHWND GetEditHWND() const { return GetHWND(); }
|
2009-02-27 12:15:57 -05:00
|
|
|
#endif
|
|
|
|
#ifdef __WXGTK__
|
2009-03-02 11:22:30 -05:00
|
|
|
virtual wxWindow *GetEditableWindow() { return this; }
|
2009-02-27 12:15:57 -05:00
|
|
|
virtual GtkEditable *GetEditable() const { return NULL; }
|
2009-02-27 05:54:12 -05:00
|
|
|
#endif
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
// Overrides
|
2006-02-08 16:47:09 -05:00
|
|
|
protected:
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
virtual wxSize DoGetBestSize() const ;
|
|
|
|
|
2006-10-08 18:42:20 -04:00
|
|
|
virtual void DoSetValue(const wxString& value, int flags = 0);
|
|
|
|
|
2008-01-04 19:21:31 -05:00
|
|
|
virtual void DoThaw();
|
|
|
|
|
2006-10-08 18:42:20 -04:00
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
// Data members
|
|
|
|
private:
|
2006-10-08 10:00:04 -04:00
|
|
|
#if wxRICHTEXT_BUFFERED_PAINTING
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Buffer bitmap
|
|
|
|
wxBitmap m_bufferBitmap;
|
2006-10-08 10:00:04 -04:00
|
|
|
#endif
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
/// Text buffer
|
|
|
|
wxRichTextBuffer m_buffer;
|
|
|
|
|
|
|
|
wxMenu* m_contextMenu;
|
|
|
|
|
|
|
|
/// Caret position (1 less than the character position, so -1 is the
|
|
|
|
/// first caret position).
|
|
|
|
long m_caretPosition;
|
|
|
|
|
2006-09-12 04:42:40 -04:00
|
|
|
/// Caret position when the default formatting has been changed. As
|
|
|
|
/// soon as this position changes, we no longer reflect the default style
|
|
|
|
/// in the UI.
|
|
|
|
long m_caretPositionForDefaultStyle;
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
/// Selection range in character positions. -2, -2 means no selection.
|
|
|
|
wxRichTextRange m_selectionRange;
|
|
|
|
|
|
|
|
/// Anchor so we know how to extend the selection
|
|
|
|
/// It's a caret position since it's between two characters.
|
|
|
|
long m_selectionAnchor;
|
|
|
|
|
|
|
|
/// Are we editable?
|
|
|
|
bool m_editable;
|
|
|
|
|
|
|
|
/// Are we showing the caret position at the start of a line
|
|
|
|
/// instead of at the end of the previous one?
|
|
|
|
bool m_caretAtLineStart;
|
|
|
|
|
|
|
|
/// Are we dragging a selection?
|
|
|
|
bool m_dragging;
|
|
|
|
|
|
|
|
/// Start position for drag
|
|
|
|
wxPoint m_dragStart;
|
2005-10-21 09:02:15 -04:00
|
|
|
|
|
|
|
/// Do we need full layout in idle?
|
|
|
|
bool m_fullLayoutRequired;
|
|
|
|
wxLongLong m_fullLayoutTime;
|
|
|
|
long m_fullLayoutSavedPosition;
|
|
|
|
|
|
|
|
/// Threshold for doing delayed layout
|
|
|
|
long m_delayedLayoutThreshold;
|
2006-10-19 10:04:13 -04:00
|
|
|
|
2006-10-26 02:32:47 -04:00
|
|
|
/// Cursors
|
|
|
|
wxCursor m_textCursor;
|
|
|
|
wxCursor m_urlCursor;
|
|
|
|
|
2006-10-19 10:04:13 -04:00
|
|
|
static wxArrayString sm_availableFontNames;
|
2005-10-19 08:52:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxRichTextEvent - the event class for wxRichTextCtrl notifications
|
|
|
|
*/
|
|
|
|
|
2006-06-29 03:16:39 -04:00
|
|
|
class WXDLLIMPEXP_RICHTEXT wxRichTextEvent : public wxNotifyEvent
|
2005-10-19 08:52:47 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
|
|
|
|
: wxNotifyEvent(commandType, winid),
|
2006-11-17 09:28:47 -05:00
|
|
|
m_flags(0), m_position(-1), m_oldStyleSheet(NULL), m_newStyleSheet(NULL),
|
|
|
|
m_char((wxChar) 0)
|
2005-10-19 08:52:47 -04:00
|
|
|
{ }
|
|
|
|
|
|
|
|
wxRichTextEvent(const wxRichTextEvent& event)
|
|
|
|
: wxNotifyEvent(event),
|
2006-11-17 09:28:47 -05:00
|
|
|
m_flags(event.m_flags), m_position(-1),
|
|
|
|
m_oldStyleSheet(event.m_oldStyleSheet), m_newStyleSheet(event.m_newStyleSheet),
|
|
|
|
m_char((wxChar) 0)
|
2005-10-19 08:52:47 -04:00
|
|
|
{ }
|
|
|
|
|
2006-11-17 09:28:47 -05:00
|
|
|
long GetPosition() const { return m_position; }
|
|
|
|
void SetPosition(long pos) { m_position = pos; }
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
int GetFlags() const { return m_flags; }
|
|
|
|
void SetFlags(int flags) { m_flags = flags; }
|
|
|
|
|
2006-10-26 02:32:47 -04:00
|
|
|
wxRichTextStyleSheet* GetOldStyleSheet() const { return m_oldStyleSheet; }
|
|
|
|
void SetOldStyleSheet(wxRichTextStyleSheet* sheet) { m_oldStyleSheet = sheet; }
|
|
|
|
|
|
|
|
wxRichTextStyleSheet* GetNewStyleSheet() const { return m_newStyleSheet; }
|
|
|
|
void SetNewStyleSheet(wxRichTextStyleSheet* sheet) { m_newStyleSheet = sheet; }
|
|
|
|
|
2006-11-17 09:28:47 -05:00
|
|
|
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; }
|
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
virtual wxEvent *Clone() const { return new wxRichTextEvent(*this); }
|
|
|
|
|
|
|
|
protected:
|
2006-10-26 02:32:47 -04:00
|
|
|
int m_flags;
|
2006-11-17 09:28:47 -05:00
|
|
|
long m_position;
|
2006-10-26 02:32:47 -04:00
|
|
|
wxRichTextStyleSheet* m_oldStyleSheet;
|
|
|
|
wxRichTextStyleSheet* m_newStyleSheet;
|
2006-11-17 09:28:47 -05:00
|
|
|
wxRichTextRange m_range;
|
|
|
|
wxChar m_char;
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxRichTextEvent)
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
2008-01-27 08:21:39 -05:00
|
|
|
* wxRichTextCtrl events
|
2005-10-19 08:52:47 -04:00
|
|
|
*/
|
2009-02-07 13:59:25 -05:00
|
|
|
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 );
|
2005-10-19 08:52:47 -04:00
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxRichTextEventFunction)(wxRichTextEvent&);
|
|
|
|
|
2008-01-22 03:23:31 -05:00
|
|
|
#define wxRichTextEventHandler(func) \
|
2009-01-12 09:26:13 -05:00
|
|
|
wxEVENT_HANDLER_CAST(wxRichTextEventFunction, func)
|
|
|
|
|
|
|
|
#define EVT_RICHTEXT_LEFT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_RIGHT_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_MIDDLE_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_LEFT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_RETURN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_RETURN, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_CHARACTER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CHARACTER, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_DELETE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_DELETE, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
|
|
|
|
#define EVT_RICHTEXT_STYLESHEET_CHANGING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_STYLESHEET_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_STYLESHEET_REPLACING(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_STYLESHEET_REPLACED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
|
|
|
|
#define EVT_RICHTEXT_CONTENT_INSERTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_CONTENT_DELETED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_STYLE_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_SELECTION_CHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_SELECTION_CHANGED, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
|
|
|
#define EVT_RICHTEXT_BUFFER_RESET(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_RICHTEXT_BUFFER_RESET, id, -1, wxRichTextEventHandler( fn ), NULL ),
|
2006-11-17 09:28:47 -05:00
|
|
|
|
2005-10-19 08:52:47 -04:00
|
|
|
#endif
|
|
|
|
// wxUSE_RICHTEXT
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_RICHTEXTCTRL_H_
|