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