]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/hyperlinkg.cpp
Make wxOwnerDrawnComboBox::DoGetBestSize() twice as fast.
[wxWidgets.git] / src / generic / hyperlinkg.cpp
index fb8bc57ba1638395300d04d8ee076dea633c4832..eb8485955d1e5118de88d917d99a74abcbcdab68 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      David Norris <danorris@gmail.com>, Otto Wyss
 // Modified by: Ryan Norton, Francesco Montorsi
 // Created:     04/02/2005
-// RCS-ID:      $Id$
 // Copyright:   (c) 2005 David Norris
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -41,6 +40,7 @@
 #endif
 
 #include "wx/clipbrd.h"
+#include "wx/renderer.h"
 
 // ============================================================================
 // implementation
@@ -89,6 +89,9 @@ bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
     //       with GTK+'s native handling):
 
     Connect( wxEVT_PAINT, wxPaintEventHandler(wxGenericHyperlinkCtrl::OnPaint) );
+    Connect( wxEVT_SET_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) );
+    Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) );
+    Connect( wxEVT_CHAR, wxKeyEventHandler(wxGenericHyperlinkCtrl::OnChar) );
     Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeaveWindow) );
 
     Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftDown) );
@@ -116,7 +119,7 @@ void wxGenericHyperlinkCtrl::ConnectMenuHandlers()
 {
     // Connect the event handlers for the context menu.
     Connect( wxEVT_RIGHT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnRightUp) );
-    Connect( wxHYPERLINK_POPUP_COPY_ID, wxEVT_COMMAND_MENU_SELECTED,
+    Connect( wxHYPERLINK_POPUP_COPY_ID, wxEVT_MENU,
              wxCommandEventHandler(wxGenericHyperlinkCtrl::OnPopUpCopy) );
 }
 
@@ -187,6 +190,32 @@ void wxGenericHyperlinkCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
     dc.SetTextBackground(GetBackgroundColour());
 
     dc.DrawText(GetLabel(), GetLabelRect().GetTopLeft());
+    if (HasFocus())
+    {
+        wxRendererNative::Get().DrawFocusRect(this, dc, GetClientRect(), wxCONTROL_SELECTED);
+    }
+}
+
+void wxGenericHyperlinkCtrl::OnFocus(wxFocusEvent& event)
+{
+    Refresh();
+    event.Skip();
+}
+
+void wxGenericHyperlinkCtrl::OnChar(wxKeyEvent& event)
+{
+    switch (event.m_keyCode)
+    {
+    default:
+        event.Skip();
+        break;
+    case WXK_SPACE:
+    case WXK_NUMPAD_SPACE:
+        SetForegroundColour(m_visitedColour);
+        m_visited = true;
+        SendEvent();
+        break;
+    }
 }
 
 void wxGenericHyperlinkCtrl::OnLeftDown(wxMouseEvent& event)