X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5d7836c47de679f03b1b7e738c77164c11bd3689..e4277538a535d6d6c049f0b0ead9ed2b07cd93f2:/include/wx/richtext/richtextctrl.h diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index aebc1a60b3..e9425ea376 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtextctrl.h +// Name: wx/richtext/richtextctrl.h // Purpose: A rich edit control // Author: Julian Smart -// Modified by: +// Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -12,21 +12,23 @@ #ifndef _WX_RICHTEXTCTRL_H_ #define _WX_RICHTEXTCTRL_H_ -#include "wx/textctrl.h" +#include "wx/richtext/richtextbuffer.h" #if wxUSE_RICHTEXT #include "wx/scrolwin.h" #include "wx/caret.h" -#include "wx/richtext/richtextbuffer.h" - #if wxCHECK_VERSION(2,7,0) #define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 0 #else #define wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE 0 #endif +#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE +#include "wx/textctrl.h" +#endif + /*! * Styles and flags */ @@ -57,6 +59,10 @@ #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 +// 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 /*! * Forward declarations @@ -84,7 +90,7 @@ class WXDLLIMPEXP_ADV wxRichTextCtrl: #else public wxScrolledWindow #endif -{ +{ DECLARE_CLASS( wxRichTextCtrl ) DECLARE_EVENT_TABLE() @@ -136,6 +142,12 @@ public: /// Set filename void SetFilename(const wxString& filename) { m_filename = filename; } + /// 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; } + // Operations // editing @@ -221,7 +233,7 @@ public: virtual void Freeze(); /// Call Thaw to refresh - virtual void Thaw(bool refresh = true); + virtual void Thaw(); /// Call Thaw to refresh virtual bool IsFrozen() const { return m_freezeCount > 0; } @@ -373,7 +385,7 @@ public: /// Layout the buffer: which we must do before certain operations, such as /// setting the caret position. - virtual bool Layout(); + virtual bool LayoutContent(bool onlyVisibleRect = false); /// Move the caret to the given character position virtual bool MoveCaret(long pos, bool showAtLineStart = false); @@ -520,7 +532,7 @@ public: // Show a context menu for Rich Edit controls (the standard // EDIT control has one already) void OnContextMenu(wxContextMenuEvent& event); - + // Event handlers /// Painting @@ -555,20 +567,30 @@ public: void OnSetFocus(wxFocusEvent& event); void OnKillFocus(wxFocusEvent& event); + /// Idle-time processing + void OnIdle(wxIdleEvent& event); + + /// Scrolling + void OnScroll(wxScrollWinEvent& event); + // Implementation +#if wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE + WX_FORWARD_TO_SCROLL_HELPER() +#endif + /// Set font, and also default attributes virtual bool SetFont(const wxFont& font); /// Set up scrollbars, e.g. after a resize - virtual void SetupScrollbars(); + virtual void SetupScrollbars(bool atTop = false); /// Keyboard navigation - virtual bool Navigate(int keyCode, int flags); + virtual bool KeyboardNavigate(int keyCode, int flags); /// Paint the background virtual void PaintBackground(wxDC& dc); - + /// Recreate buffer bitmap if necessary virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize); @@ -633,10 +655,10 @@ public: bool DeleteSelectedContent(long* newPos= NULL); /// Transform logical to physical - wxPoint GetPhysicalPoint(const wxPoint& ptLogical); + wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const; /// Transform physical to logical - wxPoint GetLogicalPoint(const wxPoint& ptPhysical); + wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const; /// Finds the caret position for the next word. Direction /// is 1 (forward) or -1 (backwards). @@ -645,14 +667,18 @@ public: /// Is the given position visible on the screen? bool IsPositionVisible(long pos) const; + /// Returns the first visible position in the current view + long GetFirstVisiblePosition() const; + // Overrides +protected: virtual wxSize DoGetBestSize() const ; // Data members private: - /// Allows nested Freeze/Thaw + /// Allows nested Freeze/Thaw int m_freezeCount; /// Buffer bitmap @@ -689,6 +715,14 @@ private: /// Start position for drag wxPoint m_dragStart; + + /// Do we need full layout in idle? + bool m_fullLayoutRequired; + wxLongLong m_fullLayoutTime; + long m_fullLayoutSavedPosition; + + /// Threshold for doing delayed layout + long m_delayedLayoutThreshold; }; /*! @@ -729,13 +763,13 @@ private: */ BEGIN_DECLARE_EVENT_TYPES() - DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 2600) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 2601) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 2602) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 2603) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 2604) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 2605) - DECLARE_EVENT_TYPE(wxEVT_COMMAND_RICHTEXT_RETURN, 2606) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_RICHTEXT_ITEM_SELECTED, 2600) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_RICHTEXT_ITEM_DESELECTED, 2601) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_RICHTEXT_LEFT_CLICK, 2602) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_RICHTEXT_RIGHT_CLICK, 2603) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_RICHTEXT_MIDDLE_CLICK, 2604) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_RICHTEXT_LEFT_DCLICK, 2605) + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_ADV, wxEVT_COMMAND_RICHTEXT_RETURN, 2606) END_DECLARE_EVENT_TYPES() typedef void (wxEvtHandler::*wxRichTextEventFunction)(wxRichTextEvent&);