]> git.saurik.com Git - wxWidgets.git/commitdiff
use 'I' cursor when over text
authorVáclav Slavík <vslavik@fastmail.fm>
Sat, 7 Jun 2003 23:31:21 +0000 (23:31 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sat, 7 Jun 2003 23:31:21 +0000 (23:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21003 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/html/htmlcell.h
include/wx/html/htmlwin.h
src/html/htmlcell.cpp
src/html/htmlwin.cpp

index 11066eb8d8cb26a5916bdbf0de57abffb127c901..982e42f4f942a9d3bd71b3410fd5e2ff655983d2 100644 (file)
@@ -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:
index ff0a7d51a33526e4a1a3cf90e30c12f93c408cfc..3fbcbd3cee14e86b642fa3d1a2cf450da1ac6ee2 100644 (file)
@@ -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;
index 8a5cdb1f532bb6155ff59cae3d1a44d8aa6986ee..51ce6a49dd2f596355d5d7bcdce8ea3cda354ce5 100644 (file)
 #include "wx/html/htmlcell.h"
 #include "wx/html/htmlwin.h"
 #include "wx/settings.h"
+#include "wx/module.h"
+
 #include <stdlib.h>
 
+//-----------------------------------------------------------------------------
+// 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
index c025b66edb85c22dac9fc2033aec52745f9989e2..1678191f6282e2283e7a1a76f4eab9e31decf85a 100644 (file)
@@ -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);