# wxHyperlinkCtrl Class Reference
[Controls]

`#include <wx/hyperlink.h>`

Inheritance diagram for wxHyperlinkCtrl:
[legend]

## Detailed Description

This class shows a static text element which links to an URL.

Appearance and behaviour is completely customizable.

In fact, when the user clicks on the hyperlink, a wxHyperlinkEvent is sent but if that event is not handled (or it's skipped; see wxEvent::Skip), then a call to wxLaunchDefaultBrowser() is done with the hyperlink's URL.

Note that standard wxWindow functions like wxWindow::SetBackgroundColour, wxWindow::SetFont, wxWindow::SetCursor, wxWindow::SetLabel can be used to customize appearance of the hyperlink.

## Styles

This class supports the following styles:

- wxHL_ALIGN_LEFT:
  Align the text to the left.
- wxHL_ALIGN_RIGHT:
  Align the text to the right. This style is not supported under Windows XP but is supported under all the other Windows versions.
- wxHL_ALIGN_CENTRE:
  Center the text (horizontally). This style is not supported by the native MSW implementation used under Windows XP and later.
- wxHL_CONTEXTMENU:
  Pop up a context menu when the hyperlink is right-clicked. The context menu contains a "Copy URL" menu item which is automatically handled by the hyperlink and which just copies in the clipboard the URL (not the label) of the control.
- wxHL_DEFAULT_STYLE:
  The default style for wxHyperlinkCtrl: wxBORDER_NONE|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxHyperlinkEvent& event)
Event macros for events emitted by this class:

- EVT_HYPERLINK(id, func):
  The hyperlink was (left) clicked. If this event is not handled in user's code (or it's skipped; see wxEvent::Skip), then a call to wxLaunchDefaultBrowser is done with the hyperlink's URL.

Currently this class is implemented using native support in wxGTK and wxMSW (under Windows XP and later only) and a generic version is used by the other ports.

##

Library: wxAdvanced

Category: Controls
Appearance:

wxMSW appearance | wxGTK appearance | wxMac appearance

See also:
  wxURL, wxHyperlinkEvent

## Public Member Functions
| wxHyperlinkCtrl (wxWindow *parent, wxWindowID id, const wxString &label, const wxString &url, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHL_DEFAULT_STYLE, const wxString &name=wxHyperlinkCtrlNameStr)
| Constructor.
bool | Create (wxWindow *parent, wxWindowID id, const wxString &label, const wxString &url, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHL_DEFAULT_STYLE, const wxString &name=wxHyperlinkCtrlNameStr)
| Creates the hyperlink control.
virtual wxColour | GetHoverColour () const
| Returns the colour used to print the label of the hyperlink when the mouse is over the control.
virtual wxColour | GetNormalColour () const
| Returns the colour used to print the label when the link has never been clicked before (i.e.
virtual wxString | GetURL () const
| Returns the URL associated with the hyperlink.
virtual bool | GetVisited () const =0
| Returns true if the hyperlink has already been clicked by the user at least one time.
virtual wxColour | GetVisitedColour () const
| Returns the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e.
virtual void | SetHoverColour (const wxColour &colour)
| Sets the colour used to print the label of the hyperlink when the mouse is over the control.
virtual void | SetNormalColour (const wxColour &colour)
| Sets the colour used to print the label when the link has never been clicked before (i.e.
virtual void | SetURL (const wxString &url)
| Sets the URL associated with the hyperlink.
virtual void | SetVisited (bool visited=true)=0
| Marks the hyperlink as visited (see wxHyperlinkCtrl::SetVisitedColour).
virtual void | SetVisitedColour (const wxColour &colour)
| Sets the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e.

List of all members.

## Constructor & Destructor Documentation

wxHyperlinkCtrl::wxHyperlinkCtrl | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | label,
|  | const wxString & | url,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxHL_DEFAULT_STYLE`,
|  | const wxString & | name = `wxHyperlinkCtrlNameStr` |
| ) |  |  |

Constructor.

See Create() for more info.

## Member Function Documentation

bool wxHyperlinkCtrl::Create | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | label,
|  | const wxString & | url,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxHL_DEFAULT_STYLE`,
|  | const wxString & | name = `wxHyperlinkCtrlNameStr` |
| ) |  |  |

Creates the hyperlink control.

Parameters:

  | parent | Parent window. Must not be NULL.
  | id | Window identifier. A value of wxID_ANY indicates a default value.
  | label | The label of the hyperlink.
  | url | The URL associated with the given label.
  | pos | Window position.
  | size | Window size. If the wxDefaultSize is specified then the window is sized appropriately.
  | style | Window style. See wxHyperlinkCtrl.
  | name | Window name.

virtual wxColour wxHyperlinkCtrl::GetHoverColour | ( |  | ) | const`[virtual]`

Returns the colour used to print the label of the hyperlink when the mouse is over the control.

virtual wxColour wxHyperlinkCtrl::GetNormalColour | ( |  | ) | const`[virtual]`

Returns the colour used to print the label when the link has never been clicked before (i.e.

the link has not been visited) and the mouse is not over the control.

virtual wxString wxHyperlinkCtrl::GetURL | ( |  | ) | const`[virtual]`

Returns the URL associated with the hyperlink.

virtual bool wxHyperlinkCtrl::GetVisited | ( |  | ) | const`[pure virtual]`

Returns true if the hyperlink has already been clicked by the user at least one time.

virtual wxColour wxHyperlinkCtrl::GetVisitedColour | ( |  | ) | const`[virtual]`

Returns the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e.

the link has been visited).

virtual void wxHyperlinkCtrl::SetHoverColour | ( | const wxColour & | colour | ) | `[virtual]`

Sets the colour used to print the label of the hyperlink when the mouse is over the control.

virtual void wxHyperlinkCtrl::SetNormalColour | ( | const wxColour & | colour | ) | `[virtual]`

Sets the colour used to print the label when the link has never been clicked before (i.e.

the link has not been visited) and the mouse is not over the control.

virtual void wxHyperlinkCtrl::SetURL | ( | const wxString & | url | ) | `[virtual]`

Sets the URL associated with the hyperlink.

virtual void wxHyperlinkCtrl::SetVisited | ( | bool | visited = `true` | ) | `[pure virtual]`

Marks the hyperlink as visited (see wxHyperlinkCtrl::SetVisitedColour).

virtual void wxHyperlinkCtrl::SetVisitedColour | ( | const wxColour & | colour | ) | `[virtual]`

Sets the colour used to print the label when the mouse is not over the control and the link has already been clicked before (i.e.

the link has been visited).

|  | [ top ]