don't show the I-beam cursor over text in wxHtmlListBox

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38706 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2006-04-14 11:38:36 +00:00
parent b887dc7b5a
commit 88a1b6485f
8 changed files with 127 additions and 61 deletions

View File

@@ -18,6 +18,10 @@ INCOMPATIBLE CHANGES SINCE 2.6.x
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

View File

@@ -171,6 +171,16 @@ See \helpref{wxHtmlLinkInfo}{wxhtmllinkinfo}.
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}

View File

@@ -202,7 +202,12 @@ public:
{ 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;}
@@ -370,7 +375,7 @@ public:
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; }

View File

@@ -109,6 +109,22 @@ public:
/// 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;
};
/**
@@ -357,6 +373,8 @@ public:
virtual void OnInternalIdle();
/// Returns standard HTML cursor as used by wxHtmlWindow
static wxCursor GetDefaultHTMLCursor(HTMLCursor type);
protected:
void Init();
@@ -427,6 +445,7 @@ private:
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);
@@ -512,6 +531,10 @@ private:
// 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)
};

View File

@@ -139,6 +139,7 @@ private:
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;

View File

@@ -438,6 +438,16 @@ void wxHtmlListBox::SetHTMLStatusText(const wxString& WXUNUSED(text))
// 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
// ----------------------------------------------------------------------------

View File

@@ -31,14 +31,6 @@
#include <stdlib.h>
//-----------------------------------------------------------------------------
// Global variables
//-----------------------------------------------------------------------------
static wxCursor *gs_cursorLink = NULL;
static wxCursor *gs_cursorText = NULL;
//-----------------------------------------------------------------------------
// Helper classes
//-----------------------------------------------------------------------------
@@ -198,17 +190,34 @@ void wxHtmlCell::OnMouseClick(wxWindow *, int, int, const wxMouseEvent& event)
#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);
}
}
@@ -607,16 +616,16 @@ wxString wxHtmlWordCell::ConvertToText(wxHtmlSelection *s) const
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);
}
}
@@ -1558,29 +1567,4 @@ const wxHtmlCell* wxHtmlTerminalCellsInterator::operator++()
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

View File

@@ -194,9 +194,11 @@ void wxHtmlWindowMouseHelper::HandleIdle(wxHtmlCell *rootCell,
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)
@@ -242,6 +244,22 @@ void wxHtmlWindowMouseHelper::OnCellMouseHover(wxHtmlCell * WXUNUSED(cell),
// 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()
{
@@ -816,21 +834,6 @@ void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor)
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);
@@ -1557,6 +1560,32 @@ void wxHtmlWindow::SetHTMLStatusText(const wxString& text)
#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