wxHtmlCell::ProcessMouseClick(); old code overriding OnMouseClick() will
continue to work with WXWIN_COMPATIBILITY_2_6, but should be rewritten to
use ProcessMouseClick().
+- wxHtmlCell::GetCursor() was deprecated and replaced with
+ wxHtmlCell::GetMouseCursor(); old code overriding GetCursor() will
+ continue to work with WXWIN_COMPATIBILITY_2_6, but should be rewritten to
+ use GetMouseCursor().
Deprecated methods since 2.6.x and their replacements
These coordinates are used e.g. by COLORMAP. Values are relative to the
upper left corner of THIS cell (i.e. from 0 to m\_Width or m\_Height)}
+\membersection{wxHtmlCell::GetMouseCursor}\label{wxhtmlcellgetmousecursor}
+
+\func{virtual wxCursor}{GetMouseCursor}{\param{wxHtmlWindowInterface* }{window}}
+
+Returns cursor to show when mouse pointer is over the cell.
+
+\wxheading{Parameters}
+
+\docparam{window}{interface to the parent HTML window}
+
\membersection{wxHtmlCell::GetNext}\label{wxhtmlcellgetnext}
\constfunc{wxHtmlCell*}{GetNext}{\void}
{ return m_Link; }
// Returns cursor to be used when mouse is over the cell:
+ virtual wxCursor GetMouseCursor(wxHtmlWindowInterface *window) const;
+
+#if WXWIN_COMPATIBILITY_2_6
+ // this was replaced by GetMouseCursor, don't use in new code!
virtual wxCursor GetCursor() const;
+#endif
// return next cell among parent's cells
wxHtmlCell *GetNext() const {return m_Next;}
wxHtmlWordCell(const wxString& word, const wxDC& dc);
void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2,
wxHtmlRenderingInfo& info);
- wxCursor GetCursor() const;
+ virtual wxCursor GetMouseCursor(wxHtmlWindowInterface *window) const;
wxString ConvertToText(wxHtmlSelection *sel) const;
bool IsLinebreakAllowed() const { return m_allowLinebreak; }
/// Sets status bar text.
virtual void SetHTMLStatusText(const wxString& text) = 0;
+
+ /// Type of mouse cursor
+ enum HTMLCursor
+ {
+ /// Standard mouse cursor (typically an arrow)
+ HTMLCursor_Default,
+ /// Cursor shown over links
+ HTMLCursor_Link,
+ /// Cursor shown over selectable text
+ HTMLCursor_Text
+ };
+
+ /**
+ Returns mouse cursor of given @a type.
+ */
+ virtual wxCursor GetHTMLCursor(HTMLCursor type) const = 0;
};
/**
virtual void OnInternalIdle();
+ /// Returns standard HTML cursor as used by wxHtmlWindow
+ static wxCursor GetDefaultHTMLCursor(HTMLCursor type);
protected:
void Init();
virtual void SetHTMLBackgroundColour(const wxColour& clr);
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
virtual void SetHTMLStatusText(const wxString& text);
+ virtual wxCursor GetHTMLCursor(HTMLCursor type) const;
// implementation of SetPage()
bool DoSetPage(const wxString& source);
// is supposed to have been done in OnEraseBackground())
bool m_eraseBgInOnPaint;
+ // standard mouse cursors
+ static wxCursor *ms_cursorLink;
+ static wxCursor *ms_cursorText;
+
DECLARE_EVENT_TABLE()
DECLARE_NO_COPY_CLASS(wxHtmlWindow)
};
virtual void SetHTMLBackgroundColour(const wxColour& clr);
virtual void SetHTMLBackgroundImage(const wxBitmap& bmpBg);
virtual void SetHTMLStatusText(const wxString& text);
+ virtual wxCursor GetHTMLCursor(HTMLCursor type) const;
// returns index of item that contains given HTML cell
size_t GetItemForCell(const wxHtmlCell *cell) const;
// nothing to do
}
+wxCursor wxHtmlListBox::GetHTMLCursor(HTMLCursor type) const
+{
+ // we don't want to show text selection cursor in listboxes
+ if (type == HTMLCursor_Text)
+ return wxHtmlWindow::GetDefaultHTMLCursor(HTMLCursor_Default);
+
+ // in all other cases, use the same cursor as wxHtmlWindow:
+ return wxHtmlWindow::GetDefaultHTMLCursor(type);
+}
+
// ----------------------------------------------------------------------------
// wxHtmlListBox handling of HTML links
// ----------------------------------------------------------------------------
#include <stdlib.h>
-//-----------------------------------------------------------------------------
-// Global variables
-//-----------------------------------------------------------------------------
-
-static wxCursor *gs_cursorLink = NULL;
-static wxCursor *gs_cursorText = NULL;
-
-
//-----------------------------------------------------------------------------
// Helper classes
//-----------------------------------------------------------------------------
#endif // WXWIN_COMPATIBILITY_2_6
}
-
+#if WXWIN_COMPATIBILITY_2_6
wxCursor wxHtmlCell::GetCursor() const
{
+ return wxNullCursor;
+}
+#endif // WXWIN_COMPATIBILITY_2_6
+
+wxCursor wxHtmlCell::GetMouseCursor(wxHtmlWindowInterface *window) const
+{
+#if WXWIN_COMPATIBILITY_2_6
+ // NB: Older versions of wx used GetCursor() virtual method in place of
+ // GetMouseCursor(interface). This code ensures that user code that
+ // overriden GetCursor() continues to work. The trick is that the base
+ // wxHtmlCell::GetCursor() method simply returns wxNullCursor, so we
+ // know that GetCursor() was overriden iff it returns valid cursor.
+ wxCursor cur = GetCursor();
+ if (cur.Ok())
+ return cur;
+#endif // WXWIN_COMPATIBILITY_2_6
+
if ( GetLink() )
{
- if ( !gs_cursorLink )
- gs_cursorLink = new wxCursor(wxCURSOR_HAND);
- return *gs_cursorLink;
+ return window->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Link);
}
else
- return *wxSTANDARD_CURSOR;
+ {
+ return window->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Default);
+ }
}
return m_Word;
}
-wxCursor wxHtmlWordCell::GetCursor() const
+wxCursor wxHtmlWordCell::GetMouseCursor(wxHtmlWindowInterface *window) const
{
if ( !GetLink() )
{
- if ( !gs_cursorText )
- gs_cursorText = new wxCursor(wxCURSOR_IBEAM);
- return *gs_cursorText;
+ return window->GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Text);
}
else
- return wxHtmlCell::GetCursor();
+ {
+ return wxHtmlCell::GetMouseCursor(window);
+ }
}
return m_pos;
}
-
-
-
-
-
-
-//-----------------------------------------------------------------------------
-// Cleanup
-//-----------------------------------------------------------------------------
-
-class wxHtmlCellModule: public wxModule
-{
-DECLARE_DYNAMIC_CLASS(wxHtmlCellModule)
-public:
- wxHtmlCellModule() : wxModule() {}
- bool OnInit() { return true; }
- void OnExit()
- {
- wxDELETE(gs_cursorLink);
- wxDELETE(gs_cursorText);
- }
-};
-
-IMPLEMENT_DYNAMIC_CLASS(wxHtmlCellModule, wxModule)
-
#endif
wxCursor cur;
if (cell)
- cur = cell->GetCursor();
+ cur = cell->GetMouseCursor(m_interface);
else
- cur = *wxSTANDARD_CURSOR;
+ cur = m_interface->GetHTMLCursor(
+ wxHtmlWindowInterface::HTMLCursor_Default);
+
m_interface->GetHTMLWindow()->SetCursor(cur);
if (lnk != m_tmpLastLink)
// wxHtmlWindow
//-----------------------------------------------------------------------------
+wxList wxHtmlWindow::m_Filters;
+wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
+wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL;
+wxCursor *wxHtmlWindow::ms_cursorLink = NULL;
+wxCursor *wxHtmlWindow::ms_cursorText = NULL;
+
+void wxHtmlWindow::CleanUpStatics()
+{
+ wxDELETE(m_DefaultFilter);
+ WX_CLEAR_LIST(wxList, m_Filters);
+ if (m_GlobalProcessors)
+ WX_CLEAR_LIST(wxHtmlProcessorList, *m_GlobalProcessors);
+ wxDELETE(m_GlobalProcessors);
+ wxDELETE(ms_cursorLink);
+ wxDELETE(ms_cursorText);
+}
void wxHtmlWindow::Init()
{
-wxList wxHtmlWindow::m_Filters;
-wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL;
-wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL;
-
-void wxHtmlWindow::CleanUpStatics()
-{
- wxDELETE(m_DefaultFilter);
- WX_CLEAR_LIST(wxList, m_Filters);
- if (m_GlobalProcessors)
- WX_CLEAR_LIST(wxHtmlProcessorList, *m_GlobalProcessors);
- wxDELETE(m_GlobalProcessors);
-}
-
-
-
void wxHtmlWindow::AddFilter(wxHtmlFilter *filter)
{
m_Filters.Append(filter);
#endif // wxUSE_STATUSBAR
}
+/*static*/
+wxCursor wxHtmlWindow::GetDefaultHTMLCursor(HTMLCursor type)
+{
+ switch (type)
+ {
+ case HTMLCursor_Link:
+ if ( !ms_cursorLink )
+ ms_cursorLink = new wxCursor(wxCURSOR_HAND);
+ return *ms_cursorLink;
+
+ case HTMLCursor_Text:
+ if ( !ms_cursorText )
+ ms_cursorText = new wxCursor(wxCURSOR_IBEAM);
+ return *ms_cursorText;
+
+ case HTMLCursor_Default:
+ default:
+ return *wxSTANDARD_CURSOR;
+ }
+}
+
+wxCursor wxHtmlWindow::GetHTMLCursor(HTMLCursor type) const
+{
+ return GetDefaultHTMLCursor(type);
+}
+
//-----------------------------------------------------------------------------
// wxHtmlWinModule