2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: hyperlink.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxHyperlinkEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-04-09 23:27:55 -04:00
|
|
|
#define wxHL_CONTEXTMENU 0x0001
|
|
|
|
#define wxHL_ALIGN_LEFT 0x0002
|
|
|
|
#define wxHL_ALIGN_RIGHT 0x0004
|
|
|
|
#define wxHL_ALIGN_CENTRE 0x0008
|
|
|
|
#define wxHL_DEFAULT_STYLE (wxHL_CONTEXTMENU|wxNO_BORDER|wxHL_ALIGN_CENTRE)
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxHyperlinkEvent
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-11-03 09:37:14 -05:00
|
|
|
This event class is used for the events generated by wxHyperlinkCtrl.
|
|
|
|
|
|
|
|
@beginEventTable{wxHyperlinkEvent}
|
|
|
|
@event{EVT_HYPERLINK(id, func)}
|
2018-08-14 11:15:39 -04:00
|
|
|
User clicked on a hyperlink.
|
2008-11-03 09:37:14 -05:00
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2018-08-27 16:52:15 -04:00
|
|
|
@library{wxcore}
|
2008-11-03 09:37:14 -05:00
|
|
|
@category{events}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxHyperlinkEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
The constructor is not normally used by the user code.
|
|
|
|
*/
|
2008-11-03 09:37:14 -05:00
|
|
|
wxHyperlinkEvent(wxObject* generator, int id, const wxString& url);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the URL of the hyperlink where the user has just clicked.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetURL() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the URL associated with the event.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetURL(const wxString& url);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
wxEventType wxEVT_HYPERLINK;
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxHyperlinkCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class shows a static text element which links to an URL.
|
2010-08-17 12:55:32 -04:00
|
|
|
|
2008-11-03 09:37:14 -05:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that standard wxWindow functions like wxWindow::SetBackgroundColour,
|
2008-11-03 09:37:14 -05:00
|
|
|
wxWindow::SetFont, wxWindow::SetCursor, wxWindow::SetLabel can be used to
|
|
|
|
customize appearance of the hyperlink.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHL_ALIGN_LEFT}
|
2008-03-08 08:52:38 -05:00
|
|
|
Align the text to the left.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHL_ALIGN_RIGHT}
|
2010-08-17 12:55:32 -04:00
|
|
|
Align the text to the right. This style is not supported under
|
2015-10-08 04:45:51 -04:00
|
|
|
Windows.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHL_ALIGN_CENTRE}
|
2015-10-08 04:45:51 -04:00
|
|
|
Center the text (horizontally). This style is not supported
|
|
|
|
under Windows.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHL_CONTEXTMENU}
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHL_DEFAULT_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
The default style for wxHyperlinkCtrl:
|
|
|
|
wxBORDER_NONE|wxHL_CONTEXTMENU|wxHL_ALIGN_CENTRE.
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxHyperlinkEvent}
|
2008-11-03 09:37:14 -05:00
|
|
|
@event{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.
|
|
|
|
@endEventTable
|
|
|
|
|
2010-08-17 12:55:32 -04:00
|
|
|
Currently this class is implemented using native support in wxGTK and wxMSW
|
2015-10-08 04:45:51 -04:00
|
|
|
and a generic version is used by the other ports.
|
2008-11-03 09:37:14 -05:00
|
|
|
|
2018-08-27 16:52:15 -04:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{ctrl}
|
2012-11-03 14:32:50 -04:00
|
|
|
@appearance{hyperlinkctrl}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxURL, wxHyperlinkEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxHyperlinkCtrl : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
2012-04-09 23:27:55 -04:00
|
|
|
wxHyperlinkCtrl();
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2008-03-25 08:22:08 -04:00
|
|
|
/**
|
|
|
|
Constructor. See Create() for more info.
|
|
|
|
*/
|
2010-04-16 08:47:27 -04:00
|
|
|
wxHyperlinkCtrl(wxWindow* parent, wxWindowID id,
|
2009-01-08 11:33:08 -05:00
|
|
|
const wxString& label,
|
|
|
|
const wxString& url,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxHL_DEFAULT_STYLE,
|
|
|
|
const wxString& name = wxHyperlinkCtrlNameStr);
|
2008-03-25 08:22:08 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Creates the hyperlink control.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window. Must not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Window identifier. A value of wxID_ANY indicates a default value.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param label
|
2008-03-09 08:33:59 -04:00
|
|
|
The label of the hyperlink.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param url
|
2008-03-09 08:33:59 -04:00
|
|
|
The URL associated with the given label.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Window position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-11-03 09:37:14 -05:00
|
|
|
Window size.
|
|
|
|
If the wxDefaultSize is specified then the window is sized appropriately.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
Window style. See wxHyperlinkCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Window name.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-28 11:36:26 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id, const wxString& label,
|
|
|
|
const wxString& url, const wxPoint& pos = wxDefaultPosition,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-03-25 08:22:08 -04:00
|
|
|
long style = wxHL_DEFAULT_STYLE,
|
2008-10-28 11:36:26 -04:00
|
|
|
const wxString& name = wxHyperlinkCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the colour used to print the label of the hyperlink when the mouse is
|
|
|
|
over the control.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxColour GetHoverColour() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the colour used to print the label when the link has never been clicked
|
2014-05-06 14:16:29 -04:00
|
|
|
before (i.e.\ the link has not been @e visited) and the mouse is not over the control.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxColour GetNormalColour() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the URL associated with the hyperlink.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetURL() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the hyperlink has already been clicked by the user at least
|
|
|
|
one time.
|
|
|
|
*/
|
2008-03-25 08:22:08 -04:00
|
|
|
virtual bool GetVisited() const = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the colour used to print the label when the mouse is not over the
|
2014-05-06 14:16:29 -04:00
|
|
|
control and the link has already been clicked before (i.e.\ the link has
|
2008-11-03 09:37:14 -05:00
|
|
|
been @e visited).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxColour GetVisitedColour() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the colour used to print the label of the hyperlink when the mouse is over
|
|
|
|
the control.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetHoverColour(const wxColour& colour);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-11-03 09:37:14 -05:00
|
|
|
Sets the colour used to print the label when the link has never been clicked before
|
2014-05-06 14:16:29 -04:00
|
|
|
(i.e.\ the link has not been @e visited) and the mouse is not over the control.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetNormalColour(const wxColour& colour);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the URL associated with the hyperlink.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetURL(const wxString& url);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Marks the hyperlink as visited (see wxHyperlinkCtrl::SetVisitedColour).
|
|
|
|
*/
|
2008-03-25 08:22:08 -04:00
|
|
|
virtual void SetVisited(bool visited = true) = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the colour used to print the label when the mouse is not over the control
|
2014-05-06 14:16:29 -04:00
|
|
|
and the link has already been clicked before (i.e.\ the link has been @e visited).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetVisitedColour(const wxColour& colour);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|