X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03647350fc7cd141953c72e0284e928847d30f44..75595b9750de618c1ccc6356159aad0918bc4786:/src/generic/hyperlinkg.cpp diff --git a/src/generic/hyperlinkg.cpp b/src/generic/hyperlinkg.cpp index 4e81ddad9f..fb8bc57ba1 100644 --- a/src/generic/hyperlinkg.cpp +++ b/src/generic/hyperlinkg.cpp @@ -46,8 +46,6 @@ // implementation // ============================================================================ -IMPLEMENT_DYNAMIC_CLASS(wxGenericHyperlinkCtrl, wxControl) - // reserved for internal use only #define wxHYPERLINK_POPUP_COPY_ID 16384 @@ -72,13 +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; + Init(); SetForegroundColour(m_normalColour); // by default the font of an hyperlink control is underlined @@ -101,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() +{ + m_rollover = false; + m_clicking = false; + m_visited = false; + + // colours + m_normalColour = *wxBLUE; + m_hoverColour = *wxRED; + m_visitedColour = wxColour("#551a8b"); +} + +void wxGenericHyperlinkCtrl::ConnectMenuHandlers() { - int w, h; + // 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()); }