X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a48b659563cbb93db2affb995fb4e0711df16d21..c105dda0810d927d8531e4949ada0b407a1cbebd:/src/common/hyperlnkcmn.cpp diff --git a/src/common/hyperlnkcmn.cpp b/src/common/hyperlnkcmn.cpp new file mode 100644 index 0000000000..d72bca7601 --- /dev/null +++ b/src/common/hyperlnkcmn.cpp @@ -0,0 +1,77 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/common/hyperlnkcmn.cpp +// Purpose: Hyperlink control +// Author: David Norris , Otto Wyss +// Modified by: Ryan Norton, Francesco Montorsi +// Created: 04/02/2005 +// RCS-ID: $Id$ +// Copyright: (c) 2005 David Norris +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +//--------------------------------------------------------------------------- +// Pre-compiled header stuff +//--------------------------------------------------------------------------- + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#if wxUSE_HYPERLINKCTRL + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- + +#include "wx/hyperlink.h" + +#ifndef WX_PRECOMP + #include "wx/menu.h" + #include "wx/log.h" + #include "wx/dataobj.h" +#endif + +// ============================================================================ +// implementation +// ============================================================================ + +IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkEvent, wxCommandEvent) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_HYPERLINK) + +const wxChar wxHyperlinkCtrlNameStr[] = wxT("hyperlink"); + +// ---------------------------------------------------------------------------- +// wxHyperlinkCtrlBase +// ---------------------------------------------------------------------------- + +#ifdef __WXDEBUG__ +void wxHyperlinkCtrlBase::CheckParams(const wxString& label, const wxString& url, long style) +{ + wxASSERT_MSG(!url.empty() || !label.empty(), + wxT("Both URL and label are empty ?")); + + int alignment = (int)((style & wxHL_ALIGN_LEFT) != 0) + + (int)((style & wxHL_ALIGN_CENTRE) != 0) + + (int)((style & wxHL_ALIGN_RIGHT) != 0); + wxASSERT_MSG(alignment == 1, + wxT("Specify exactly one align flag!")); +} +#endif + +void wxHyperlinkCtrlBase::SendEvent() +{ + wxString url = GetURL(); + wxHyperlinkEvent linkEvent(this, GetId(), url); + if (!GetEventHandler()->ProcessEvent(linkEvent)) // was the event skipped ? + if (!wxLaunchDefaultBrowser(url)) + wxLogWarning(wxT("Could not launch the default browser with url '%s' !"), url.c_str()); +} + +#endif // wxUSE_HYPERLINKCTRL