]> git.saurik.com Git - wxWidgets.git/blobdiff - src/html/htmlwin.cpp
make it possible to open files from XRC in wxHtmlWindow
[wxWidgets.git] / src / html / htmlwin.cpp
index 9db304ff227e1b7d41951b8f0a2b501c2edaa1d9..147e7636130e71b8284f5debcbd64d4aeea33bf1 100644 (file)
 #endif
 
 #ifndef WXPRECOMP
-#include "wx/wx.h"
+    #include "wx/log.h"
+    #include "wx/intl.h"
+    #include "wx/dcclient.h"
+    #include "wx/frame.h"
 #endif
 
 #include "wx/html/htmlwin.h"
 #include "wx/html/forcelnk.h"
 #include "wx/html/htmlproc.h"
-#include "wx/log.h"
-#include "wx/arrimpl.cpp"
 #include "wx/list.h"
+
+#include "wx/arrimpl.cpp"
 #include "wx/listimpl.cpp"
 
 //-----------------------------------------------------------------------------
@@ -306,10 +309,15 @@ bool wxHtmlWindow::LoadPage(const wxString& location)
     {
         int c = m_History->GetCount() - (m_HistoryPos + 1);
 
-        m_HistoryPos++;
-        for (int i = 0; i < c; i++)
-            m_History->Remove(m_HistoryPos);
-        m_History->Add(new wxHtmlHistoryItem(m_OpenedPage, m_OpenedAnchor));
+        if (m_HistoryPos < 0 ||
+            (*m_History)[m_HistoryPos].GetPage() != m_OpenedPage ||
+            (*m_History)[m_HistoryPos].GetAnchor() != m_OpenedAnchor)
+        {
+            m_HistoryPos++;
+            for (int i = 0; i < c; i++)
+                m_History->RemoveAt(m_HistoryPos);
+            m_History->Add(new wxHtmlHistoryItem(m_OpenedPage, m_OpenedAnchor));
+        }
     }
 
     if (m_OpenedPageTitle == wxEmptyString)
@@ -651,11 +659,11 @@ void wxHtmlWindow::OnMouseEvent(wxMouseEvent& event)
     if (event.ButtonDown())
     {
         int sx, sy;
-        wxPoint pos;
-        wxString lnk;
+        GetViewStart(&sx, &sy);
+        sx *= wxHTML_SCROLL_STEP;
+        sy *= wxHTML_SCROLL_STEP;
 
-        GetViewStart(&sx, &sy); sx *= wxHTML_SCROLL_STEP; sy *= wxHTML_SCROLL_STEP;
-        pos = event.GetPosition();
+        wxPoint pos = event.GetPosition();
 
         if (m_Cell)
             m_Cell->OnMouseClick(this, sx + pos.x, sy + pos.y, event);
@@ -675,13 +683,15 @@ void wxHtmlWindow::OnIdle(wxIdleEvent& WXUNUSED(event))
     if (m_tmpMouseMoved && (m_Cell != NULL))
     {
         int sx, sy;
-        int x, y;
-        wxHtmlLinkInfo *lnk;
+        GetViewStart(&sx, &sy);
+        sx *= wxHTML_SCROLL_STEP;
+        sy *= wxHTML_SCROLL_STEP;
 
-        GetViewStart(&sx, &sy); sx *= wxHTML_SCROLL_STEP; sy *= wxHTML_SCROLL_STEP;
+        int x, y;
         wxGetMousePosition(&x, &y);
         ScreenToClient(&x, &y);
-        lnk = m_Cell->GetLink(sx + x, sy + y);
+
+        wxHtmlLinkInfo *lnk = m_Cell->GetLink(sx + x, sy + y);
 
         if (lnk != m_tmpLastLink)
         {
@@ -710,6 +720,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxHtmlWindow,wxScrolledWindow)
 BEGIN_EVENT_TABLE(wxHtmlWindow, wxScrolledWindow)
     EVT_SIZE(wxHtmlWindow::OnSize)
     EVT_LEFT_DOWN(wxHtmlWindow::OnMouseEvent)
+    EVT_RIGHT_DOWN(wxHtmlWindow::OnMouseEvent)
     EVT_MOTION(wxHtmlWindow::OnMouseEvent)
     EVT_IDLE(wxHtmlWindow::OnIdle)
 END_EVENT_TABLE()