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