]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/hyperlink.h
Add test for absence of events from wxSpinCtrlDouble ctor.
[wxWidgets.git] / interface / wx / hyperlink.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: hyperlink.h
e54c96f1 3// Purpose: interface of wxHyperlinkEvent
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
c328f9d3
RD
8#define wxHL_CONTEXTMENU 0x0001
9#define wxHL_ALIGN_LEFT 0x0002
10#define wxHL_ALIGN_RIGHT 0x0004
11#define wxHL_ALIGN_CENTRE 0x0008
12#define wxHL_DEFAULT_STYLE (wxHL_CONTEXTMENU|wxNO_BORDER|wxHL_ALIGN_CENTRE)
13
23324ae1
FM
14/**
15 @class wxHyperlinkEvent
7c913512 16
9cc56d1f
FM
17 This event class is used for the events generated by wxHyperlinkCtrl.
18
19 @beginEventTable{wxHyperlinkEvent}
20 @event{EVT_HYPERLINK(id, func)}
21 User clicked on an hyperlink.
22 @endEventTable
7c913512 23
23324ae1 24 @library{wxadv}
9cc56d1f 25 @category{events}
23324ae1
FM
26*/
27class wxHyperlinkEvent : public wxCommandEvent
28{
29public:
30 /**
31 The constructor is not normally used by the user code.
32 */
9cc56d1f 33 wxHyperlinkEvent(wxObject* generator, int id, const wxString& url);
23324ae1
FM
34
35 /**
36 Returns the URL of the hyperlink where the user has just clicked.
37 */
328f5751 38 wxString GetURL() const;
23324ae1
FM
39
40 /**
41 Sets the URL associated with the event.
42 */
4cc4bfaf 43 void SetURL(const wxString& url);
23324ae1
FM
44};
45
46
ce7fe42e 47wxEventType wxEVT_HYPERLINK;
e54c96f1 48
23324ae1
FM
49/**
50 @class wxHyperlinkCtrl
7c913512 51
23324ae1 52 This class shows a static text element which links to an URL.
b815cf68 53
9cc56d1f
FM
54 Appearance and behaviour is completely customizable.
55
56 In fact, when the user clicks on the hyperlink, a wxHyperlinkEvent is
57 sent but if that event is not handled (or it's skipped; see wxEvent::Skip),
58 then a call to wxLaunchDefaultBrowser() is done with the hyperlink's URL.
7c913512 59
23324ae1 60 Note that standard wxWindow functions like wxWindow::SetBackgroundColour,
9cc56d1f
FM
61 wxWindow::SetFont, wxWindow::SetCursor, wxWindow::SetLabel can be used to
62 customize appearance of the hyperlink.
7c913512 63
23324ae1 64 @beginStyleTable
8c6791e4 65 @style{wxHL_ALIGN_LEFT}
23324ae1 66 Align the text to the left.
8c6791e4 67 @style{wxHL_ALIGN_RIGHT}
b815cf68
VZ
68 Align the text to the right. This style is not supported under
69 Windows XP but is supported under all the other Windows versions.
8c6791e4 70 @style{wxHL_ALIGN_CENTRE}
b815cf68
VZ
71 Center the text (horizontally). This style is not supported by the
72 native MSW implementation used under Windows XP and later.
8c6791e4 73 @style{wxHL_CONTEXTMENU}
23324ae1
FM
74 Pop up a context menu when the hyperlink is right-clicked. The
75 context menu contains a "Copy URL" menu item which is automatically
76 handled by the hyperlink and which just copies in the clipboard the
77 URL (not the label) of the control.
8c6791e4 78 @style{wxHL_DEFAULT_STYLE}
23324ae1
FM
79 The default style for wxHyperlinkCtrl:
80 wxBORDER_NONE|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.
81 @endStyleTable
7c913512 82
3051a44a 83 @beginEventEmissionTable{wxHyperlinkEvent}
9cc56d1f
FM
84 @event{EVT_HYPERLINK(id, func)}
85 The hyperlink was (left) clicked. If this event is not handled in user's
86 code (or it's skipped; see wxEvent::Skip), then a call to wxLaunchDefaultBrowser
87 is done with the hyperlink's URL.
88 @endEventTable
89
b815cf68
VZ
90 Currently this class is implemented using native support in wxGTK and wxMSW
91 (under Windows XP and later only) and a generic version is used by the
92 other ports.
9cc56d1f 93
23324ae1
FM
94 @library{wxadv}
95 @category{ctrl}
ce154616 96 @appearance{hyperlinkctrl}
7c913512 97
e54c96f1 98 @see wxURL, wxHyperlinkEvent
23324ae1
FM
99*/
100class wxHyperlinkCtrl : public wxControl
101{
102public:
c328f9d3
RD
103 wxHyperlinkCtrl();
104
a6052817
FM
105 /**
106 Constructor. See Create() for more info.
107 */
3db47dfa 108 wxHyperlinkCtrl(wxWindow* parent, wxWindowID id,
ccf39540
FM
109 const wxString& label,
110 const wxString& url,
111 const wxPoint& pos = wxDefaultPosition,
112 const wxSize& size = wxDefaultSize,
113 long style = wxHL_DEFAULT_STYLE,
114 const wxString& name = wxHyperlinkCtrlNameStr);
a6052817 115
23324ae1
FM
116 /**
117 Creates the hyperlink control.
3c4f71cc 118
7c913512 119 @param parent
4cc4bfaf 120 Parent window. Must not be @NULL.
7c913512 121 @param id
4cc4bfaf 122 Window identifier. A value of wxID_ANY indicates a default value.
7c913512 123 @param label
4cc4bfaf 124 The label of the hyperlink.
7c913512 125 @param url
4cc4bfaf 126 The URL associated with the given label.
7c913512 127 @param pos
4cc4bfaf 128 Window position.
7c913512 129 @param size
9cc56d1f
FM
130 Window size.
131 If the wxDefaultSize is specified then the window is sized appropriately.
7c913512 132 @param style
4cc4bfaf 133 Window style. See wxHyperlinkCtrl.
7c913512 134 @param name
4cc4bfaf 135 Window name.
23324ae1 136 */
43c48e1e
FM
137 bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
138 const wxString& url, const wxPoint& pos = wxDefaultPosition,
23324ae1 139 const wxSize& size = wxDefaultSize,
a6052817 140 long style = wxHL_DEFAULT_STYLE,
43c48e1e 141 const wxString& name = wxHyperlinkCtrlNameStr);
23324ae1
FM
142
143 /**
144 Returns the colour used to print the label of the hyperlink when the mouse is
145 over the control.
146 */
adaaa686 147 virtual wxColour GetHoverColour() const;
23324ae1
FM
148
149 /**
150 Returns the colour used to print the label when the link has never been clicked
9cc56d1f 151 before (i.e. the link has not been @e visited) and the mouse is not over the control.
23324ae1 152 */
adaaa686 153 virtual wxColour GetNormalColour() const;
23324ae1
FM
154
155 /**
156 Returns the URL associated with the hyperlink.
157 */
adaaa686 158 virtual wxString GetURL() const;
23324ae1
FM
159
160 /**
161 Returns @true if the hyperlink has already been clicked by the user at least
162 one time.
163 */
a6052817 164 virtual bool GetVisited() const = 0;
23324ae1
FM
165
166 /**
167 Returns the colour used to print the label when the mouse is not over the
9cc56d1f
FM
168 control and the link has already been clicked before (i.e. the link has
169 been @e visited).
23324ae1 170 */
adaaa686 171 virtual wxColour GetVisitedColour() const;
23324ae1
FM
172
173 /**
174 Sets the colour used to print the label of the hyperlink when the mouse is over
175 the control.
176 */
adaaa686 177 virtual void SetHoverColour(const wxColour& colour);
23324ae1
FM
178
179 /**
9cc56d1f 180 Sets the colour used to print the label when the link has never been clicked before
23324ae1
FM
181 (i.e. the link has not been @e visited) and the mouse is not over the control.
182 */
adaaa686 183 virtual void SetNormalColour(const wxColour& colour);
23324ae1
FM
184
185 /**
186 Sets the URL associated with the hyperlink.
187 */
adaaa686 188 virtual void SetURL(const wxString& url);
23324ae1
FM
189
190 /**
191 Marks the hyperlink as visited (see wxHyperlinkCtrl::SetVisitedColour).
192 */
a6052817 193 virtual void SetVisited(bool visited = true) = 0;
23324ae1
FM
194
195 /**
196 Sets the colour used to print the label when the mouse is not over the control
9cc56d1f 197 and the link has already been clicked before (i.e. the link has been @e visited).
23324ae1 198 */
adaaa686 199 virtual void SetVisitedColour(const wxColour& colour);
23324ae1 200};
e54c96f1 201