From fba8b37345430cce6aa0806ab31250158b0dacaf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Dec 2013 16:00:43 +0000 Subject: [PATCH] Add wxHtmlWindow::SetDefaultHTMLCursor(). This allows to change the cursors used by any HTML windows, before creating them. Closes #15324. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75398 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/html/htmlwin.h | 2 ++ interface/wx/html/htmlwin.h | 27 ++++++++++++++++++++++++++- src/html/htmlwin.cpp | 27 ++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 3b44fa3b83..805ba0a177 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -12,4 +12,5 @@ Note: This file contains the list of changes since wxWidgets 3.x, please see All (GUI): - XRC handler for wxAuiToolBar added (Kinaou Hervé). +- Add wxHtmlWindow::SetDefaultHTMLCursor() (Jeff A. Marr). - Add default ctor and Create() to wxContextHelpButton (Hanmac). diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index 7c716df115..e36685c031 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -387,6 +387,7 @@ public: /// Returns standard HTML cursor as used by wxHtmlWindow static wxCursor GetDefaultHTMLCursor(HTMLCursor type); + static void SetDefaultHTMLCursor(HTMLCursor type, const wxCursor& cursor); protected: void Init(); @@ -552,6 +553,7 @@ private: // standard mouse cursors static wxCursor *ms_cursorLink; static wxCursor *ms_cursorText; + static wxCursor *ms_cursorDefault; DECLARE_EVENT_TABLE() wxDECLARE_NO_COPY_CLASS(wxHtmlWindow); diff --git a/interface/wx/html/htmlwin.h b/interface/wx/html/htmlwin.h index 330ff938d7..cb00713da5 100644 --- a/interface/wx/html/htmlwin.h +++ b/interface/wx/html/htmlwin.h @@ -465,7 +465,32 @@ public: */ virtual void WriteCustomization(wxConfigBase* cfg, wxString path = wxEmptyString); - + + /** + Retrieves the default cursor for a given HTMLCursor type. + + @param type + HTMLCursor type to retrieve. + + @since 3.1.0 + */ + static wxCursor GetDefaultHTMLCursor(HTMLCursor type); + + /** + Sets the default cursor for a given HTMLCursor type. + + These cursors are used for all wxHtmlWindow objects by default, but can + be overridden on a per-window basis. + + @param type + HTMLCursor type to retrieve. + @param cursor + The default cursor for the specified cursor type. + + @since 3.1.0 + */ + static void SetDefaultHTMLCursor(HTMLCursor type, const wxCursor& cursor); + protected: /** diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index 4410fa73c3..a6ae16e7b3 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -283,6 +283,7 @@ wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL; wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL; wxCursor *wxHtmlWindow::ms_cursorLink = NULL; wxCursor *wxHtmlWindow::ms_cursorText = NULL; +wxCursor *wxHtmlWindow::ms_cursorDefault = NULL; void wxHtmlWindow::CleanUpStatics() { @@ -293,6 +294,7 @@ void wxHtmlWindow::CleanUpStatics() wxDELETE(m_GlobalProcessors); wxDELETE(ms_cursorLink); wxDELETE(ms_cursorText); + wxDELETE(ms_cursorDefault); } void wxHtmlWindow::Init() @@ -1787,7 +1789,9 @@ wxCursor wxHtmlWindow::GetDefaultHTMLCursor(HTMLCursor type) case HTMLCursor_Default: default: - return *wxSTANDARD_CURSOR; + if ( !ms_cursorDefault ) + ms_cursorDefault = new wxCursor(wxCURSOR_ARROW); + return *ms_cursorDefault; } } @@ -1796,6 +1800,27 @@ wxCursor wxHtmlWindow::GetHTMLCursor(HTMLCursor type) const return GetDefaultHTMLCursor(type); } +/*static*/ +void wxHtmlWindow::SetDefaultHTMLCursor(HTMLCursor type, const wxCursor& cursor) +{ + switch (type) + { + case HTMLCursor_Link: + delete ms_cursorLink; + ms_cursorLink = new wxCursor(cursor); + return; + + case HTMLCursor_Text: + delete ms_cursorText; + ms_cursorText = new wxCursor(cursor); + return; + + case HTMLCursor_Default: + default: + delete ms_cursorText; + ms_cursorDefault = new wxCursor(cursor); + } +} //----------------------------------------------------------------------------- // wxHtmlWinModule