]> git.saurik.com Git - wxWidgets.git/blame - src/common/hyperlnkcmn.cpp
Disable handling of wxEVT_MOUSEWHEEL in wxVarScrollHelperEvtHandler in wxGTK.
[wxWidgets.git] / src / common / hyperlnkcmn.cpp
CommitLineData
c105dda0
VZ
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
c105dda0
VZ
7// Copyright: (c) 2005 David Norris
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15//---------------------------------------------------------------------------
16// Pre-compiled header stuff
17//---------------------------------------------------------------------------
18
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_HYPERLINKCTRL
27
28//---------------------------------------------------------------------------
29// Includes
30//---------------------------------------------------------------------------
31
32#include "wx/hyperlink.h"
33
34#ifndef WX_PRECOMP
35 #include "wx/menu.h"
36 #include "wx/log.h"
37 #include "wx/dataobj.h"
38#endif
39
40// ============================================================================
41// implementation
42// ============================================================================
43
59566396
SC
44wxDEFINE_FLAGS( wxHyperlinkStyle )
45wxBEGIN_FLAGS( wxHyperlinkStyle )
46// new style border flags, we put them first to
47// use them for streaming out
48wxFLAGS_MEMBER(wxBORDER_SIMPLE)
49wxFLAGS_MEMBER(wxBORDER_SUNKEN)
50wxFLAGS_MEMBER(wxBORDER_DOUBLE)
51wxFLAGS_MEMBER(wxBORDER_RAISED)
52wxFLAGS_MEMBER(wxBORDER_STATIC)
53wxFLAGS_MEMBER(wxBORDER_NONE)
54
55// old style border flags
56wxFLAGS_MEMBER(wxSIMPLE_BORDER)
57wxFLAGS_MEMBER(wxSUNKEN_BORDER)
58wxFLAGS_MEMBER(wxDOUBLE_BORDER)
59wxFLAGS_MEMBER(wxRAISED_BORDER)
60wxFLAGS_MEMBER(wxSTATIC_BORDER)
61wxFLAGS_MEMBER(wxBORDER)
62
63// standard window styles
64wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
65wxFLAGS_MEMBER(wxCLIP_CHILDREN)
66wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
67wxFLAGS_MEMBER(wxWANTS_CHARS)
68wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
69wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
70wxFLAGS_MEMBER(wxVSCROLL)
71wxFLAGS_MEMBER(wxHSCROLL)
72
73wxFLAGS_MEMBER(wxHL_CONTEXTMENU)
74wxFLAGS_MEMBER(wxHL_ALIGN_LEFT)
75wxFLAGS_MEMBER(wxHL_ALIGN_RIGHT)
76wxFLAGS_MEMBER(wxHL_ALIGN_CENTRE)
77wxEND_FLAGS( wxHyperlinkStyle )
78
79wxIMPLEMENT_DYNAMIC_CLASS_XTI( wxHyperlinkCtrl, wxControl, "wx/hyperlink.h")
b815cf68 80
c105dda0 81IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkEvent, wxCommandEvent)
ce7fe42e 82wxDEFINE_EVENT( wxEVT_HYPERLINK, wxHyperlinkEvent );
c105dda0 83
59566396
SC
84wxBEGIN_PROPERTIES_TABLE(wxHyperlinkCtrl)
85wxPROPERTY( Label, wxString, SetLabel, GetLabel, wxString(), \
86 0 /*flags*/, wxT("The link label"), wxT("group") )
87
88wxPROPERTY( URL, wxString, SetURL, GetURL, wxString(), \
89 0 /*flags*/, wxT("The link URL"), wxT("group") )
90wxPROPERTY_FLAGS( WindowStyle, wxHyperlinkStyle, long, SetWindowStyleFlag, \
91 GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
92 wxT("The link style"), wxT("group")) // style
93wxEND_PROPERTIES_TABLE()
94
95wxEMPTY_HANDLERS_TABLE(wxHyperlinkCtrl)
96
97wxCONSTRUCTOR_7( wxHyperlinkCtrl, wxWindow*, Parent, wxWindowID, Id, wxString, \
98 Label, wxString, URL, wxPoint, Position, wxSize, Size, long, WindowStyle )
99
100
23318a53 101const char wxHyperlinkCtrlNameStr[] = "hyperlink";
c105dda0
VZ
102
103// ----------------------------------------------------------------------------
104// wxHyperlinkCtrlBase
105// ----------------------------------------------------------------------------
106
657a8a35
VZ
107void
108wxHyperlinkCtrlBase::CheckParams(const wxString& label,
109 const wxString& url,
110 long style)
c105dda0 111{
657a8a35 112#if wxDEBUG_LEVEL
c105dda0
VZ
113 wxASSERT_MSG(!url.empty() || !label.empty(),
114 wxT("Both URL and label are empty ?"));
115
116 int alignment = (int)((style & wxHL_ALIGN_LEFT) != 0) +
117 (int)((style & wxHL_ALIGN_CENTRE) != 0) +
118 (int)((style & wxHL_ALIGN_RIGHT) != 0);
119 wxASSERT_MSG(alignment == 1,
120 wxT("Specify exactly one align flag!"));
657a8a35
VZ
121#else // !wxDEBUG_LEVEL
122 wxUnusedVar(label);
123 wxUnusedVar(url);
124 wxUnusedVar(style);
125#endif // wxDEBUG_LEVEL/!wxDEBUG_LEVEL
c105dda0 126}
c105dda0
VZ
127
128void wxHyperlinkCtrlBase::SendEvent()
129{
130 wxString url = GetURL();
131 wxHyperlinkEvent linkEvent(this, GetId(), url);
132 if (!GetEventHandler()->ProcessEvent(linkEvent)) // was the event skipped ?
af588446 133 {
c105dda0 134 if (!wxLaunchDefaultBrowser(url))
af588446 135 {
c105dda0 136 wxLogWarning(wxT("Could not launch the default browser with url '%s' !"), url.c_str());
af588446
VZ
137 }
138 }
c105dda0
VZ
139}
140
141#endif // wxUSE_HYPERLINKCTRL