]>
git.saurik.com Git - wxWidgets.git/blob - src/common/hyperlnkcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/hyperlnkcmn.cpp
3 // Purpose: Hyperlink control
4 // Author: David Norris <danorris@gmail.com>, Otto Wyss
5 // Modified by: Ryan Norton, Francesco Montorsi
8 // Copyright: (c) 2005 David Norris
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 //---------------------------------------------------------------------------
17 // Pre-compiled header stuff
18 //---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #if wxUSE_HYPERLINKCTRL
29 //---------------------------------------------------------------------------
31 //---------------------------------------------------------------------------
33 #include "wx/hyperlink.h"
38 #include "wx/dataobj.h"
41 // ============================================================================
43 // ============================================================================
45 #if wxUSE_EXTENDED_RTTI
46 wxIMPLEMENT_DYNAMIC_CLASS_XTI( wxHyperlinkCtrl
, wxControl
, "wx/hyperlink.h")
48 wxIMPLEMENT_DYNAMIC_CLASS( wxHyperlinkCtrl
, wxControl
)
49 #endif // wxUSE_EXTENDED_RTTI
51 IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkEvent
, wxCommandEvent
)
52 wxDEFINE_EVENT( wxEVT_COMMAND_HYPERLINK
, wxHyperlinkEvent
);
54 const char wxHyperlinkCtrlNameStr
[] = "hyperlink";
56 // ----------------------------------------------------------------------------
57 // wxHyperlinkCtrlBase
58 // ----------------------------------------------------------------------------
61 wxHyperlinkCtrlBase::CheckParams(const wxString
& label
,
66 wxASSERT_MSG(!url
.empty() || !label
.empty(),
67 wxT("Both URL and label are empty ?"));
69 int alignment
= (int)((style
& wxHL_ALIGN_LEFT
) != 0) +
70 (int)((style
& wxHL_ALIGN_CENTRE
) != 0) +
71 (int)((style
& wxHL_ALIGN_RIGHT
) != 0);
72 wxASSERT_MSG(alignment
== 1,
73 wxT("Specify exactly one align flag!"));
74 #else // !wxDEBUG_LEVEL
78 #endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
81 void wxHyperlinkCtrlBase::SendEvent()
83 wxString url
= GetURL();
84 wxHyperlinkEvent
linkEvent(this, GetId(), url
);
85 if (!GetEventHandler()->ProcessEvent(linkEvent
)) // was the event skipped ?
87 if (!wxLaunchDefaultBrowser(url
))
89 wxLogWarning(wxT("Could not launch the default browser with url '%s' !"), url
.c_str());
94 #endif // wxUSE_HYPERLINKCTRL