1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxHyperlinkEvent
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
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)
15 @class wxHyperlinkEvent
17 This event class is used for the events generated by wxHyperlinkCtrl.
19 @beginEventTable{wxHyperlinkEvent}
20 @event{EVT_HYPERLINK(id, func)}
21 User clicked on an hyperlink.
27 class wxHyperlinkEvent
: public wxCommandEvent
31 The constructor is not normally used by the user code.
33 wxHyperlinkEvent(wxObject
* generator
, int id
, const wxString
& url
);
36 Returns the URL of the hyperlink where the user has just clicked.
38 wxString
GetURL() const;
41 Sets the URL associated with the event.
43 void SetURL(const wxString
& url
);
47 wxEventType wxEVT_HYPERLINK
;
50 @class wxHyperlinkCtrl
52 This class shows a static text element which links to an URL.
54 Appearance and behaviour is completely customizable.
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.
60 Note that standard wxWindow functions like wxWindow::SetBackgroundColour,
61 wxWindow::SetFont, wxWindow::SetCursor, wxWindow::SetLabel can be used to
62 customize appearance of the hyperlink.
65 @style{wxHL_ALIGN_LEFT}
66 Align the text to the left.
67 @style{wxHL_ALIGN_RIGHT}
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.
70 @style{wxHL_ALIGN_CENTRE}
71 Center the text (horizontally). This style is not supported by the
72 native MSW implementation used under Windows XP and later.
73 @style{wxHL_CONTEXTMENU}
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.
78 @style{wxHL_DEFAULT_STYLE}
79 The default style for wxHyperlinkCtrl:
80 wxBORDER_NONE|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.
83 @beginEventEmissionTable{wxHyperlinkEvent}
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.
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
96 @appearance{hyperlinkctrl}
98 @see wxURL, wxHyperlinkEvent
100 class wxHyperlinkCtrl
: public wxControl
106 Constructor. See Create() for more info.
108 wxHyperlinkCtrl(wxWindow
* parent
, wxWindowID id
,
109 const wxString
& label
,
111 const wxPoint
& pos
= wxDefaultPosition
,
112 const wxSize
& size
= wxDefaultSize
,
113 long style
= wxHL_DEFAULT_STYLE
,
114 const wxString
& name
= wxHyperlinkCtrlNameStr
);
117 Creates the hyperlink control.
120 Parent window. Must not be @NULL.
122 Window identifier. A value of wxID_ANY indicates a default value.
124 The label of the hyperlink.
126 The URL associated with the given label.
131 If the wxDefaultSize is specified then the window is sized appropriately.
133 Window style. See wxHyperlinkCtrl.
137 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& label
,
138 const wxString
& url
, const wxPoint
& pos
= wxDefaultPosition
,
139 const wxSize
& size
= wxDefaultSize
,
140 long style
= wxHL_DEFAULT_STYLE
,
141 const wxString
& name
= wxHyperlinkCtrlNameStr
);
144 Returns the colour used to print the label of the hyperlink when the mouse is
147 virtual wxColour
GetHoverColour() const;
150 Returns the colour used to print the label when the link has never been clicked
151 before (i.e. the link has not been @e visited) and the mouse is not over the control.
153 virtual wxColour
GetNormalColour() const;
156 Returns the URL associated with the hyperlink.
158 virtual wxString
GetURL() const;
161 Returns @true if the hyperlink has already been clicked by the user at least
164 virtual bool GetVisited() const = 0;
167 Returns the colour used to print the label when the mouse is not over the
168 control and the link has already been clicked before (i.e. the link has
171 virtual wxColour
GetVisitedColour() const;
174 Sets the colour used to print the label of the hyperlink when the mouse is over
177 virtual void SetHoverColour(const wxColour
& colour
);
180 Sets the colour used to print the label when the link has never been clicked before
181 (i.e. the link has not been @e visited) and the mouse is not over the control.
183 virtual void SetNormalColour(const wxColour
& colour
);
186 Sets the URL associated with the hyperlink.
188 virtual void SetURL(const wxString
& url
);
191 Marks the hyperlink as visited (see wxHyperlinkCtrl::SetVisitedColour).
193 virtual void SetVisited(bool visited
= true) = 0;
196 Sets the colour used to print the label when the mouse is not over the control
197 and the link has already been clicked before (i.e. the link has been @e visited).
199 virtual void SetVisitedColour(const wxColour
& colour
);