Provide native wxHyperlinkCtrl implementation for wxMSW.

Use the "syslink" native control to implement wxHyperlinkCtrl under (recent
enough, i.e. XP or later) versions of Windows.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65334 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-08-17 16:55:32 +00:00
parent 8fe8b421fc
commit b815cf68d2
23 changed files with 495 additions and 41 deletions

View File

@@ -46,8 +46,6 @@
// implementation
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxGenericHyperlinkCtrl, wxControl)
// reserved for internal use only
#define wxHYPERLINK_POPUP_COPY_ID 16384
@@ -72,14 +70,7 @@ bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
SetURL(url.empty() ? label : url);
SetLabel(label.empty() ? url : label);
m_rollover = false;
m_clicking = false;
m_visited = false;
// colours
m_normalColour = *wxBLUE;
m_hoverColour = *wxRED;
m_visitedColour = wxColour("#551a8b");
Init();
SetForegroundColour(m_normalColour);
// by default the font of an hyperlink control is underlined
@@ -102,26 +93,37 @@ bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftDown) );
Connect( wxEVT_LEFT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftUp) );
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnRightUp) );
Connect( wxEVT_MOTION, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnMotion) );
Connect( wxHYPERLINK_POPUP_COPY_ID, wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler(wxGenericHyperlinkCtrl::OnPopUpCopy) );
ConnectMenuHandlers();
return true;
}
wxSize wxGenericHyperlinkCtrl::DoGetBestSize() const
void wxGenericHyperlinkCtrl::Init()
{
int w, h;
m_rollover = false;
m_clicking = false;
m_visited = false;
// colours
m_normalColour = *wxBLUE;
m_hoverColour = *wxRED;
m_visitedColour = wxColour("#551a8b");
}
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,
wxCommandEventHandler(wxGenericHyperlinkCtrl::OnPopUpCopy) );
}
wxSize wxGenericHyperlinkCtrl::DoGetBestClientSize() const
{
wxClientDC dc((wxWindow *)this);
dc.SetFont(GetFont());
dc.GetTextExtent(GetLabel(), &w, &h);
wxSize best(w, h);
CacheBestSize(best);
return best;
return dc.GetTextExtent(GetLabel());
}