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
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@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)}
|
|
|
|
User clicked on an hyperlink.
|
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxadv}
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
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.
|
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}
|
2008-03-08 08:52:38 -05:00
|
|
|
Align the text to the right.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHL_ALIGN_CENTRE}
|
2008-03-08 08:52:38 -05:00
|
|
|
Center the text (horizontally).
|
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
|
|
|
|
2008-11-03 09:37:14 -05:00
|
|
|
@beginEventTable{wxHyperlinkEvent}
|
|
|
|
@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
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxadv}
|
|
|
|
@category{ctrl}
|
2008-10-13 04:05:18 -04:00
|
|
|
@appearance{hyperlinkctrl.png}
|
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:
|
2008-03-25 08:22:08 -04:00
|
|
|
/**
|
|
|
|
Constructor. See Create() for more info.
|
|
|
|
*/
|
|
|
|
wxHyperLink(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 = "hyperlink");
|
|
|
|
|
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
|
2008-11-03 09:37:14 -05: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
|
2008-11-03 09:37:14 -05:00
|
|
|
control 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 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
|
2008-03-08 08:52:38 -05:00
|
|
|
(i.e. the link has not been @e visited) and the mouse is not over the control.
|
|
|
|
*/
|
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
|
2008-11-03 09:37:14 -05: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
|
|
|
|