Added on-demand image loading option to wxRTC.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76110 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2014-03-10 11:08:42 +00:00
parent 3772880ce6
commit cd3fc53163
7 changed files with 420 additions and 21 deletions

View File

@@ -17,7 +17,7 @@
#include "wx/scrolwin.h"
#include "wx/caret.h"
#include "wx/timer.h"
#include "wx/textctrl.h"
#if wxUSE_DRAG_AND_DROP
@@ -79,6 +79,8 @@ class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleDefinition;
#define wxRICHTEXT_DEFAULT_DELAYED_LAYOUT_THRESHOLD 20000
// Milliseconds before layout occurs after resize
#define wxRICHTEXT_DEFAULT_LAYOUT_INTERVAL 50
// Milliseconds before delayed image processing occurs
#define wxRICHTEXT_DEFAULT_DELAYED_IMAGE_PROCESSING_INTERVAL 200
/* Identifiers
*/
@@ -1980,6 +1982,12 @@ public:
*/
bool RefreshForSelectionChange(const wxRichTextSelection& oldSelection, const wxRichTextSelection& newSelection);
/**
Overrides standard refresh in order to provoke delayed image loading.
*/
virtual void Refresh( bool eraseBackground = true,
const wxRect *rect = (const wxRect *) NULL );
/**
Sets the caret position.
@@ -2134,6 +2142,38 @@ public:
bool GetImagesEnabled() const { return m_enableImages; }
/**
Enable or disable delayed image loading
*/
void EnableDelayedImageLoading(bool b) { m_enableDelayedImageLoading = b; }
/**
Returns @true if delayed image loading is enabled.
*/
bool GetDelayedImageLoading() const { return m_enableDelayedImageLoading; }
/**
Gets the flag indicating that delayed image processing is required.
*/
bool GetDelayedImageProcessingRequired() const { return m_delayedImageProcessingRequired; }
/**
Sets the flag indicating that delayed image processing is required.
*/
void SetDelayedImageProcessingRequired(bool b) { m_delayedImageProcessingRequired = b; }
/**
Returns the last time delayed image processing was performed.
*/
wxLongLong GetDelayedImageProcessingTime() const { return m_delayedImageProcessingTime; }
/**
Sets the last time delayed image processing was performed.
*/
void SetDelayedImageProcessingTime(wxLongLong t) { m_delayedImageProcessingTime = t; }
#ifdef DOXYGEN
/**
Returns the content of the entire control as a string.
@@ -2209,6 +2249,22 @@ public:
// implement wxTextEntry methods
virtual wxString DoGetValue() const;
/**
Do delayed image loading and garbage-collect other images
*/
bool ProcessDelayedImageLoading(bool refresh);
bool ProcessDelayedImageLoading(const wxRect& screenRect, wxRichTextParagraphLayoutBox* box, int& loadCount);
/**
Request delayed image processing.
*/
void RequestDelayedImageProcessing();
/**
Respond to timer events.
*/
void OnTimer(wxTimerEvent& event);
protected:
// implement the wxTextEntry pure virtual method
virtual wxWindow *GetEditableWindow() { return this; }
@@ -2336,6 +2392,12 @@ protected:
/// Whether images are enabled for this control
bool m_enableImages;
/// Whether delayed image loading is enabled for this control
bool m_enableDelayedImageLoading;
bool m_delayedImageProcessingRequired;
wxLongLong m_delayedImageProcessingTime;
wxTimer m_delayedImageProcessingTimer;
};
#if wxUSE_DRAG_AND_DROP