]> git.saurik.com Git - wxWidgets.git/blob - src/common/hyperlnkcmn.cpp
Clip drawing in wxRendererGeneric::DrawHeaderButtonContents().
[wxWidgets.git] / 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
6 // Created: 04/02/2005
7 // RCS-ID: $Id$
8 // Copyright: (c) 2005 David Norris
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 //---------------------------------------------------------------------------
17 // Pre-compiled header stuff
18 //---------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_HYPERLINKCTRL
28
29 //---------------------------------------------------------------------------
30 // Includes
31 //---------------------------------------------------------------------------
32
33 #include "wx/hyperlink.h"
34
35 #ifndef WX_PRECOMP
36 #include "wx/menu.h"
37 #include "wx/log.h"
38 #include "wx/dataobj.h"
39 #endif
40
41 // ============================================================================
42 // implementation
43 // ============================================================================
44
45 IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkEvent, wxCommandEvent)
46 wxDEFINE_EVENT( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEvent );
47
48 const char wxHyperlinkCtrlNameStr[] = "hyperlink";
49
50 // ----------------------------------------------------------------------------
51 // wxHyperlinkCtrlBase
52 // ----------------------------------------------------------------------------
53
54 void
55 wxHyperlinkCtrlBase::CheckParams(const wxString& label,
56 const wxString& url,
57 long style)
58 {
59 #if wxDEBUG_LEVEL
60 wxASSERT_MSG(!url.empty() || !label.empty(),
61 wxT("Both URL and label are empty ?"));
62
63 int alignment = (int)((style & wxHL_ALIGN_LEFT) != 0) +
64 (int)((style & wxHL_ALIGN_CENTRE) != 0) +
65 (int)((style & wxHL_ALIGN_RIGHT) != 0);
66 wxASSERT_MSG(alignment == 1,
67 wxT("Specify exactly one align flag!"));
68 #else // !wxDEBUG_LEVEL
69 wxUnusedVar(label);
70 wxUnusedVar(url);
71 wxUnusedVar(style);
72 #endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
73 }
74
75 void wxHyperlinkCtrlBase::SendEvent()
76 {
77 wxString url = GetURL();
78 wxHyperlinkEvent linkEvent(this, GetId(), url);
79 if (!GetEventHandler()->ProcessEvent(linkEvent)) // was the event skipped ?
80 {
81 if (!wxLaunchDefaultBrowser(url))
82 {
83 wxLogWarning(wxT("Could not launch the default browser with url '%s' !"), url.c_str());
84 }
85 }
86 }
87
88 #endif // wxUSE_HYPERLINKCTRL