1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxHyperlinkEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
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)
16 @class wxHyperlinkEvent
18 This event class is used for the events generated by wxHyperlinkCtrl.
20 @beginEventTable{wxHyperlinkEvent}
21 @event{EVT_HYPERLINK(id, func)}
22 User clicked on an hyperlink.
28 class wxHyperlinkEvent
: public wxCommandEvent
32 The constructor is not normally used by the user code.
34 wxHyperlinkEvent(wxObject
* generator
, int id
, const wxString
& url
);
37 Returns the URL of the hyperlink where the user has just clicked.
39 wxString
GetURL() const;
42 Sets the URL associated with the event.
44 void SetURL(const wxString
& url
);
48 wxEventType wxEVT_COMMAND_HYPERLINK
;
51 @class wxHyperlinkCtrl
53 This class shows a static text element which links to an URL.
55 Appearance and behaviour is completely customizable.
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.
61 Note that standard wxWindow functions like wxWindow::SetBackgroundColour,
62 wxWindow::SetFont, wxWindow::SetCursor, wxWindow::SetLabel can be used to
63 customize appearance of the hyperlink.
66 @style{wxHL_ALIGN_LEFT}
67 Align the text to the left.
68 @style{wxHL_ALIGN_RIGHT}
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.
71 @style{wxHL_ALIGN_CENTRE}
72 Center the text (horizontally). This style is not supported by the
73 native MSW implementation used under Windows XP and later.
74 @style{wxHL_CONTEXTMENU}
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.
79 @style{wxHL_DEFAULT_STYLE}
80 The default style for wxHyperlinkCtrl:
81 wxBORDER_NONE|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.
84 @beginEventEmissionTable{wxHyperlinkEvent}
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.
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
97 @appearance{hyperlinkctrl.png}
99 @see wxURL, wxHyperlinkEvent
101 class wxHyperlinkCtrl
: public wxControl
107 Constructor. See Create() for more info.
109 wxHyperlinkCtrl(wxWindow
* parent
, wxWindowID id
,
110 const wxString
& label
,
112 const wxPoint
& pos
= wxDefaultPosition
,
113 const wxSize
& size
= wxDefaultSize
,
114 long style
= wxHL_DEFAULT_STYLE
,
115 const wxString
& name
= wxHyperlinkCtrlNameStr
);
118 Creates the hyperlink control.
121 Parent window. Must not be @NULL.
123 Window identifier. A value of wxID_ANY indicates a default value.
125 The label of the hyperlink.
127 The URL associated with the given label.
132 If the wxDefaultSize is specified then the window is sized appropriately.
134 Window style. See wxHyperlinkCtrl.
138 bool Create(wxWindow
* parent
, wxWindowID id
, const wxString
& label
,
139 const wxString
& url
, const wxPoint
& pos
= wxDefaultPosition
,
140 const wxSize
& size
= wxDefaultSize
,
141 long style
= wxHL_DEFAULT_STYLE
,
142 const wxString
& name
= wxHyperlinkCtrlNameStr
);
145 Returns the colour used to print the label of the hyperlink when the mouse is
148 virtual wxColour
GetHoverColour() const;
151 Returns the colour used to print the label when the link has never been clicked
152 before (i.e. the link has not been @e visited) and the mouse is not over the control.
154 virtual wxColour
GetNormalColour() const;
157 Returns the URL associated with the hyperlink.
159 virtual wxString
GetURL() const;
162 Returns @true if the hyperlink has already been clicked by the user at least
165 virtual bool GetVisited() const = 0;
168 Returns the colour used to print the label when the mouse is not over the
169 control and the link has already been clicked before (i.e. the link has
172 virtual wxColour
GetVisitedColour() const;
175 Sets the colour used to print the label of the hyperlink when the mouse is over
178 virtual void SetHoverColour(const wxColour
& colour
);
181 Sets the colour used to print the label when the link has never been clicked before
182 (i.e. the link has not been @e visited) and the mouse is not over the control.
184 virtual void SetNormalColour(const wxColour
& colour
);
187 Sets the URL associated with the hyperlink.
189 virtual void SetURL(const wxString
& url
);
192 Marks the hyperlink as visited (see wxHyperlinkCtrl::SetVisitedColour).
194 virtual void SetVisited(bool visited
= true) = 0;
197 Sets the colour used to print the label when the mouse is not over the control
198 and the link has already been clicked before (i.e. the link has been @e visited).
200 virtual void SetVisitedColour(const wxColour
& colour
);