]> git.saurik.com Git - wxWidgets.git/blame - include/wx/hyperlink.h
Add some basic tests for wxDataViewCtrl selection handling.
[wxWidgets.git] / include / wx / hyperlink.h
CommitLineData
17e91437 1/////////////////////////////////////////////////////////////////////////////
98159dd8 2// Name: wx/hyperlink.h
17e91437
VZ
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
08809d18
PC
12#ifndef _WX_HYPERLINK_H_
13#define _WX_HYPERLINK_H_
17e91437 14
17e91437
VZ
15#include "wx/defs.h"
16
17#if wxUSE_HYPERLINKCTRL
18
19#include "wx/control.h"
20
21// ----------------------------------------------------------------------------
22// constants
23// ----------------------------------------------------------------------------
24
25#define wxHL_CONTEXTMENU 0x0001
914f5157
VZ
26#define wxHL_ALIGN_LEFT 0x0002
27#define wxHL_ALIGN_RIGHT 0x0004
28#define wxHL_ALIGN_CENTRE 0x0008
29#define wxHL_DEFAULT_STYLE (wxHL_CONTEXTMENU|wxNO_BORDER|wxHL_ALIGN_CENTRE)
17e91437 30
23318a53 31extern WXDLLIMPEXP_DATA_ADV(const char) wxHyperlinkCtrlNameStr[];
17e91437
VZ
32
33
34// ----------------------------------------------------------------------------
35// wxHyperlinkCtrl
36// ----------------------------------------------------------------------------
37
38// A static text control that emulates a hyperlink. The link is displayed
39// in an appropriate text style, derived from the control's normal font.
40// When the mouse rolls over the link, the cursor changes to a hand and the
41// link's color changes to the active color.
42//
43// Clicking on the link does not launch a web browser; instead, a
44// HyperlinkEvent is fired. The event propagates upward until it is caught,
45// just like a wxCommandEvent.
46//
47// Use the EVT_HYPERLINK() to catch link events.
c105dda0 48class WXDLLIMPEXP_ADV wxHyperlinkCtrlBase : public wxControl
17e91437
VZ
49{
50public:
17e91437
VZ
51
52 // get/set
c105dda0
VZ
53 virtual wxColour GetHoverColour() const = 0;
54 virtual void SetHoverColour(const wxColour &colour) = 0;
17e91437 55
c105dda0
VZ
56 virtual wxColour GetNormalColour() const = 0;
57 virtual void SetNormalColour(const wxColour &colour) = 0;
17e91437 58
c105dda0
VZ
59 virtual wxColour GetVisitedColour() const = 0;
60 virtual void SetVisitedColour(const wxColour &colour) = 0;
17e91437 61
c105dda0
VZ
62 virtual wxString GetURL() const = 0;
63 virtual void SetURL (const wxString &url) = 0;
17e91437 64
c105dda0
VZ
65 virtual void SetVisited(bool visited = true) = 0;
66 virtual bool GetVisited() const = 0;
17e91437
VZ
67
68 // NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour,
69 // wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important !
70
3f234d7a
VZ
71 virtual bool HasTransparentBackground() { return true; }
72
17e91437 73protected:
dc797d8e
JS
74 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
75
c105dda0
VZ
76 // checks for validity some of the ctor/Create() function parameters
77 void CheckParams(const wxString& label, const wxString& url, long style);
17e91437 78
c105dda0
VZ
79public:
80 // not part of the public API but needs to be public as used by
81 // GTK+ callbacks:
82 void SendEvent();
17e91437
VZ
83};
84
17e91437
VZ
85// ----------------------------------------------------------------------------
86// wxHyperlinkEvent
87// ----------------------------------------------------------------------------
88
3c778901
VZ
89class WXDLLIMPEXP_FWD_ADV wxHyperlinkEvent;
90
9b11752c 91wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_COMMAND_HYPERLINK, wxHyperlinkEvent );
17e91437
VZ
92
93//
94// An event fired when the user clicks on the label in a hyperlink control.
95// See HyperlinkControl for details.
96//
870597ef 97class WXDLLIMPEXP_ADV wxHyperlinkEvent : public wxCommandEvent
17e91437
VZ
98{
99public:
17e91437
VZ
100 wxHyperlinkEvent() {}
101 wxHyperlinkEvent(wxObject *generator, wxWindowID id, const wxString& url)
258b2ca6
RD
102 : wxCommandEvent(wxEVT_COMMAND_HYPERLINK, id),
103 m_url(url)
104 {
105 SetEventObject(generator);
106 }
17e91437
VZ
107
108 // Returns the URL associated with the hyperlink control
109 // that the user clicked on.
110 wxString GetURL() const { return m_url; }
111 void SetURL(const wxString &url) { m_url=url; }
112
258b2ca6
RD
113 // default copy ctor, assignment operator and dtor are ok
114 virtual wxEvent *Clone() const { return new wxHyperlinkEvent(*this); }
115
17e91437
VZ
116private:
117
118 // URL associated with the hyperlink control that the used clicked on.
119 wxString m_url;
258b2ca6
RD
120
121 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHyperlinkEvent)
17e91437
VZ
122};
123
17e91437 124
258b2ca6
RD
125// ----------------------------------------------------------------------------
126// event types and macros
127// ----------------------------------------------------------------------------
128
129typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&);
17e91437 130
17e91437 131#define wxHyperlinkEventHandler(func) \
3c778901 132 wxEVENT_HANDLER_CAST(wxHyperlinkEventFunction, func)
17e91437 133
258b2ca6
RD
134#define EVT_HYPERLINK(id, fn) \
135 wx__DECLARE_EVT1(wxEVT_COMMAND_HYPERLINK, id, wxHyperlinkEventHandler(fn))
136
c105dda0 137
08809d18 138#if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__)
c105dda0 139 #include "wx/gtk/hyperlink.h"
c0938d85
VZ
140// Note that the native control is only available in Unicode version under MSW.
141#elif defined(__WXMSW__) && wxUSE_UNICODE && !defined(__WXUNIVERSAL__)
b815cf68 142 #include "wx/msw/hyperlink.h"
c105dda0
VZ
143#else
144 #include "wx/generic/hyperlink.h"
b815cf68
VZ
145
146 class WXDLLIMPEXP_ADV wxHyperlinkCtrl : public wxGenericHyperlinkCtrl
147 {
148 public:
149 wxHyperlinkCtrl() { }
150
151 wxHyperlinkCtrl(wxWindow *parent,
152 wxWindowID id,
153 const wxString& label,
154 const wxString& url,
155 const wxPoint& pos = wxDefaultPosition,
156 const wxSize& size = wxDefaultSize,
157 long style = wxHL_DEFAULT_STYLE,
158 const wxString& name = wxHyperlinkCtrlNameStr)
159 : wxGenericHyperlinkCtrl(parent, id, label, url, pos, size,
160 style, name)
161 {
162 }
163
164 private:
165 wxDECLARE_DYNAMIC_CLASS_NO_COPY( wxHyperlinkCtrl );
166 };
c105dda0
VZ
167#endif
168
169
17e91437
VZ
170#endif // wxUSE_HYPERLINKCTRL
171
08809d18 172#endif // _WX_HYPERLINK_H_