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