From: Václav Slavík Date: Sat, 7 Jun 2003 23:31:21 +0000 (+0000) Subject: use 'I' cursor when over text X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/77bae5e228394870a2c2a8444fd50ec622faf502?ds=sidebyside use 'I' cursor when over text git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index 11066eb8d8..982e42f4f9 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -184,6 +184,9 @@ public: int WXUNUSED(y) = 0) const { return m_Link; } + // Returns cursor to be used when mouse is over the cell: + virtual wxCursor GetCursor() const; + // return next cell among parent's cells wxHtmlCell *GetNext() const {return m_Next;} // returns first child cell (if there are any, i.e. if this is container): @@ -329,6 +332,7 @@ public: wxHtmlWordCell(const wxString& word, wxDC& dc); void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, wxHtmlRenderingInfo& info); + wxCursor GetCursor() const; wxString ConvertToText(wxHtmlSelection *sel) const; protected: diff --git a/include/wx/html/htmlwin.h b/include/wx/html/htmlwin.h index ff0a7d51a3..3fbcbd3cee 100644 --- a/include/wx/html/htmlwin.h +++ b/include/wx/html/htmlwin.h @@ -323,9 +323,6 @@ private: // this filter is used when no filter is able to read some file static wxHtmlFilter *m_DefaultFilter; - static wxCursor *s_cur_hand; - static wxCursor *s_cur_arrow; - wxHtmlHistoryArray *m_History; // browser history int m_HistoryPos; diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 8a5cdb1f53..51ce6a49dd 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -30,8 +30,18 @@ #include "wx/html/htmlcell.h" #include "wx/html/htmlwin.h" #include "wx/settings.h" +#include "wx/module.h" + #include +//----------------------------------------------------------------------------- +// Global variables +//----------------------------------------------------------------------------- + +static wxCursor *gs_cursorLink = NULL; +static wxCursor *gs_cursorText = NULL; + + //----------------------------------------------------------------------------- // Helper classes //----------------------------------------------------------------------------- @@ -105,6 +115,18 @@ void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, } +wxCursor wxHtmlCell::GetCursor() const +{ + if ( GetLink() ) + { + if ( !gs_cursorLink ) + gs_cursorLink = new wxCursor(wxCURSOR_HAND); + return *gs_cursorLink; + } + else + return *wxSTANDARD_CURSOR; +} + bool wxHtmlCell::AdjustPagebreak(int *pagebreak, int* WXUNUSED(known_pagebreaks), int WXUNUSED(number_of_pages)) const { @@ -129,7 +151,6 @@ void wxHtmlCell::SetLink(const wxHtmlLinkInfo& link) } - void wxHtmlCell::Layout(int WXUNUSED(w)) { SetPos(0, 0); @@ -427,6 +448,18 @@ wxString wxHtmlWordCell::ConvertToText(wxHtmlSelection *s) const return m_Word; } +wxCursor wxHtmlWordCell::GetCursor() const +{ + if ( !GetLink() ) + { + if ( !gs_cursorText ) + gs_cursorText = new wxCursor(wxCURSOR_IBEAM); + return *gs_cursorText; + } + else + return wxHtmlCell::GetCursor(); +} + //----------------------------------------------------------------------------- @@ -1167,4 +1200,29 @@ 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 diff --git a/src/html/htmlwin.cpp b/src/html/htmlwin.cpp index c025b66edb..1678191f62 100644 --- a/src/html/htmlwin.cpp +++ b/src/html/htmlwin.cpp @@ -691,8 +691,6 @@ void wxHtmlWindow::AddProcessor(wxHtmlProcessor *processor) wxList wxHtmlWindow::m_Filters; wxHtmlFilter *wxHtmlWindow::m_DefaultFilter = NULL; -wxCursor *wxHtmlWindow::s_cur_hand = NULL; -wxCursor *wxHtmlWindow::s_cur_arrow = NULL; wxHtmlProcessorList *wxHtmlWindow::m_GlobalProcessors = NULL; void wxHtmlWindow::CleanUpStatics() @@ -701,8 +699,6 @@ void wxHtmlWindow::CleanUpStatics() m_Filters.DeleteContents(TRUE); m_Filters.Clear(); wxDELETE(m_GlobalProcessors); - wxDELETE(s_cur_hand); - wxDELETE(s_cur_arrow); } @@ -926,12 +922,6 @@ void wxHtmlWindow::OnMouseUp(wxMouseEvent& event) void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) { - if (s_cur_hand == NULL) - { - s_cur_hand = new wxCursor(wxCURSOR_HAND); - s_cur_arrow = new wxCursor(wxCURSOR_ARROW); - } - if (m_tmpMouseMoved && (m_Cell != NULL)) { int xc, yc, x, y; @@ -1023,19 +1013,23 @@ void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) if ( cell != m_tmpLastCell ) { wxHtmlLinkInfo *lnk = cell ? cell->GetLink(x, y) : NULL; + wxCursor cur; + if (cell) + cur = cell->GetCursor(); + else + cur = *wxSTANDARD_CURSOR; + SetCursor(cur); if (lnk != m_tmpLastLink) { if (lnk == NULL) { - SetCursor(*s_cur_arrow); if (m_RelatedStatusBar != -1) m_RelatedFrame->SetStatusText(wxEmptyString, m_RelatedStatusBar); } else { - SetCursor(*s_cur_hand); if (m_RelatedStatusBar != -1) m_RelatedFrame->SetStatusText(lnk->GetHref(), m_RelatedStatusBar);