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
This commit is contained in:
Vadim Zeitlin
2013-12-18 16:00:43 +00:00
parent 3150676c08
commit fba8b37345
4 changed files with 55 additions and 2 deletions

View File

@@ -12,4 +12,5 @@ Note: This file contains the list of changes since wxWidgets 3.x, please see
All (GUI): All (GUI):
- XRC handler for wxAuiToolBar added (Kinaou Hervé). - XRC handler for wxAuiToolBar added (Kinaou Hervé).
- Add wxHtmlWindow::SetDefaultHTMLCursor() (Jeff A. Marr).
- Add default ctor and Create() to wxContextHelpButton (Hanmac). - Add default ctor and Create() to wxContextHelpButton (Hanmac).

View File

@@ -387,6 +387,7 @@ public:
/// Returns standard HTML cursor as used by wxHtmlWindow /// Returns standard HTML cursor as used by wxHtmlWindow
static wxCursor GetDefaultHTMLCursor(HTMLCursor type); static wxCursor GetDefaultHTMLCursor(HTMLCursor type);
static void SetDefaultHTMLCursor(HTMLCursor type, const wxCursor& cursor);
protected: protected:
void Init(); void Init();
@@ -552,6 +553,7 @@ private:
// standard mouse cursors // standard mouse cursors
static wxCursor *ms_cursorLink; static wxCursor *ms_cursorLink;
static wxCursor *ms_cursorText; static wxCursor *ms_cursorText;
static wxCursor *ms_cursorDefault;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
wxDECLARE_NO_COPY_CLASS(wxHtmlWindow); wxDECLARE_NO_COPY_CLASS(wxHtmlWindow);

View File

@@ -466,6 +466,31 @@ public:
virtual void WriteCustomization(wxConfigBase* cfg, virtual void WriteCustomization(wxConfigBase* cfg,
wxString path = wxEmptyString); 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: protected:
/** /**

View File

@@ -283,6 +283,7 @@ wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL; wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL;
wxCursor *wxHtmlWindow::ms_cursorLink = NULL; wxCursor *wxHtmlWindow::ms_cursorLink = NULL;
wxCursor *wxHtmlWindow::ms_cursorText = NULL; wxCursor *wxHtmlWindow::ms_cursorText = NULL;
wxCursor *wxHtmlWindow::ms_cursorDefault = NULL;
void wxHtmlWindow::CleanUpStatics() void wxHtmlWindow::CleanUpStatics()
{ {
@@ -293,6 +294,7 @@ void wxHtmlWindow::CleanUpStatics()
wxDELETE(m_GlobalProcessors); wxDELETE(m_GlobalProcessors);
wxDELETE(ms_cursorLink); wxDELETE(ms_cursorLink);
wxDELETE(ms_cursorText); wxDELETE(ms_cursorText);
wxDELETE(ms_cursorDefault);
} }
void wxHtmlWindow::Init() void wxHtmlWindow::Init()
@@ -1787,7 +1789,9 @@ wxCursor wxHtmlWindow::GetDefaultHTMLCursor(HTMLCursor type)
case HTMLCursor_Default: case HTMLCursor_Default:
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); 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 // wxHtmlWinModule