2006-05-28 17:41:09 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-05-29 07:31:24 +00:00
|
|
|
// Name: wx/hyperlink.h
|
2006-05-28 17:41:09 +00:00
|
|
|
// Purpose: Hyperlink control
|
|
|
|
// Author: David Norris <danorris@gmail.com>, Otto Wyss
|
|
|
|
// Modified by: Ryan Norton, Francesco Montorsi
|
|
|
|
// Created: 04/02/2005
|
|
|
|
// Copyright: (c) 2005 David Norris
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2007-11-04 19:39:12 +00:00
|
|
|
#ifndef _WX_HYPERLINK_H_
|
|
|
|
#define _WX_HYPERLINK_H_
|
2006-05-28 17:41:09 +00:00
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_HYPERLINKCTRL
|
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define wxHL_CONTEXTMENU 0x0001
|
2006-09-10 23:57:26 +00:00
|
|
|
#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)
|
2006-05-28 17:41:09 +00:00
|
|
|
|
2018-08-27 14:34:34 +00:00
|
|
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxHyperlinkCtrlNameStr[];
|
2006-05-28 17:41:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxHyperlinkCtrl
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// A static text control that emulates a hyperlink. The link is displayed
|
|
|
|
// in an appropriate text style, derived from the control's normal font.
|
|
|
|
// When the mouse rolls over the link, the cursor changes to a hand and the
|
|
|
|
// link's color changes to the active color.
|
|
|
|
//
|
|
|
|
// Clicking on the link does not launch a web browser; instead, a
|
|
|
|
// HyperlinkEvent is fired. The event propagates upward until it is caught,
|
|
|
|
// just like a wxCommandEvent.
|
|
|
|
//
|
|
|
|
// Use the EVT_HYPERLINK() to catch link events.
|
2018-08-27 14:34:34 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxHyperlinkCtrlBase : public wxControl
|
2006-05-28 17:41:09 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// get/set
|
2007-03-07 22:12:47 +00:00
|
|
|
virtual wxColour GetHoverColour() const = 0;
|
|
|
|
virtual void SetHoverColour(const wxColour &colour) = 0;
|
2006-05-28 17:41:09 +00:00
|
|
|
|
2007-03-07 22:12:47 +00:00
|
|
|
virtual wxColour GetNormalColour() const = 0;
|
|
|
|
virtual void SetNormalColour(const wxColour &colour) = 0;
|
2006-05-28 17:41:09 +00:00
|
|
|
|
2007-03-07 22:12:47 +00:00
|
|
|
virtual wxColour GetVisitedColour() const = 0;
|
|
|
|
virtual void SetVisitedColour(const wxColour &colour) = 0;
|
2006-05-28 17:41:09 +00:00
|
|
|
|
2007-03-07 22:12:47 +00:00
|
|
|
virtual wxString GetURL() const = 0;
|
|
|
|
virtual void SetURL (const wxString &url) = 0;
|
2006-05-28 17:41:09 +00:00
|
|
|
|
2007-03-07 22:12:47 +00:00
|
|
|
virtual void SetVisited(bool visited = true) = 0;
|
|
|
|
virtual bool GetVisited() const = 0;
|
2006-05-28 17:41:09 +00:00
|
|
|
|
|
|
|
// NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour,
|
|
|
|
// wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important !
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual bool HasTransparentBackground() wxOVERRIDE { return true; }
|
2011-01-16 23:24:21 +00:00
|
|
|
|
2006-05-28 17:41:09 +00:00
|
|
|
protected:
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; }
|
2007-11-13 12:10:34 +00:00
|
|
|
|
2007-03-07 22:12:47 +00:00
|
|
|
// checks for validity some of the ctor/Create() function parameters
|
|
|
|
void CheckParams(const wxString& label, const wxString& url, long style);
|
2006-05-28 17:41:09 +00:00
|
|
|
|
2007-03-07 22:12:47 +00:00
|
|
|
public:
|
2018-11-05 18:35:44 +00:00
|
|
|
// Send wxHyperlinkEvent and open our link in the default browser if it
|
|
|
|
// wasn't handled.
|
|
|
|
//
|
2007-03-07 22:12:47 +00:00
|
|
|
// not part of the public API but needs to be public as used by
|
|
|
|
// GTK+ callbacks:
|
|
|
|
void SendEvent();
|
2006-05-28 17:41:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxHyperlinkEvent
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2018-08-27 14:34:34 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxHyperlinkEvent;
|
2009-01-12 14:26:13 +00:00
|
|
|
|
2018-08-27 14:34:34 +00:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_HYPERLINK, wxHyperlinkEvent );
|
2006-05-28 17:41:09 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// An event fired when the user clicks on the label in a hyperlink control.
|
|
|
|
// See HyperlinkControl for details.
|
|
|
|
//
|
2018-08-27 14:34:34 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxHyperlinkEvent : public wxCommandEvent
|
2006-05-28 17:41:09 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxHyperlinkEvent() {}
|
|
|
|
wxHyperlinkEvent(wxObject *generator, wxWindowID id, const wxString& url)
|
2013-04-25 10:11:03 +00:00
|
|
|
: wxCommandEvent(wxEVT_HYPERLINK, id),
|
2006-06-08 18:27:44 +00:00
|
|
|
m_url(url)
|
|
|
|
{
|
|
|
|
SetEventObject(generator);
|
|
|
|
}
|
2006-05-28 17:41:09 +00:00
|
|
|
|
|
|
|
// Returns the URL associated with the hyperlink control
|
|
|
|
// that the user clicked on.
|
|
|
|
wxString GetURL() const { return m_url; }
|
|
|
|
void SetURL(const wxString &url) { m_url=url; }
|
|
|
|
|
2006-06-08 18:27:44 +00:00
|
|
|
// default copy ctor, assignment operator and dtor are ok
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxEvent *Clone() const wxOVERRIDE { return new wxHyperlinkEvent(*this); }
|
2006-06-08 18:27:44 +00:00
|
|
|
|
2006-05-28 17:41:09 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
// URL associated with the hyperlink control that the used clicked on.
|
|
|
|
wxString m_url;
|
2006-06-08 18:27:44 +00:00
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHyperlinkEvent);
|
2006-05-28 17:41:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-06-08 18:27:44 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// event types and macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&);
|
2006-05-28 17:41:09 +00:00
|
|
|
|
|
|
|
#define wxHyperlinkEventHandler(func) \
|
2009-01-12 14:26:13 +00:00
|
|
|
wxEVENT_HANDLER_CAST(wxHyperlinkEventFunction, func)
|
2006-05-28 17:41:09 +00:00
|
|
|
|
2006-06-08 18:27:44 +00:00
|
|
|
#define EVT_HYPERLINK(id, fn) \
|
2013-04-25 10:11:03 +00:00
|
|
|
wx__DECLARE_EVT1(wxEVT_HYPERLINK, id, wxHyperlinkEventHandler(fn))
|
2006-06-08 18:27:44 +00:00
|
|
|
|
2007-03-07 22:12:47 +00:00
|
|
|
|
2007-11-04 19:39:12 +00:00
|
|
|
#if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__)
|
2007-03-07 22:12:47 +00:00
|
|
|
#include "wx/gtk/hyperlink.h"
|
2010-08-18 22:48:53 +00:00
|
|
|
// Note that the native control is only available in Unicode version under MSW.
|
|
|
|
#elif defined(__WXMSW__) && wxUSE_UNICODE && !defined(__WXUNIVERSAL__)
|
2010-08-17 16:55:32 +00:00
|
|
|
#include "wx/msw/hyperlink.h"
|
2007-03-07 22:12:47 +00:00
|
|
|
#else
|
|
|
|
#include "wx/generic/hyperlink.h"
|
2010-08-17 16:55:32 +00:00
|
|
|
|
2018-08-27 14:34:34 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxHyperlinkCtrl : public wxGenericHyperlinkCtrl
|
2010-08-17 16:55:32 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
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,
|
2019-10-22 10:34:29 +00:00
|
|
|
const wxString& name = wxASCII_STR(wxHyperlinkCtrlNameStr))
|
2010-08-17 16:55:32 +00:00
|
|
|
: wxGenericHyperlinkCtrl(parent, id, label, url, pos, size,
|
|
|
|
style, name)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_COPY( wxHyperlinkCtrl );
|
|
|
|
};
|
2007-03-07 22:12:47 +00:00
|
|
|
#endif
|
|
|
|
|
2013-04-25 10:11:03 +00:00
|
|
|
// old wxEVT_COMMAND_* constants
|
|
|
|
#define wxEVT_COMMAND_HYPERLINK wxEVT_HYPERLINK
|
2007-03-07 22:12:47 +00:00
|
|
|
|
2006-05-28 17:41:09 +00:00
|
|
|
#endif // wxUSE_HYPERLINKCTRL
|
|
|
|
|
2007-11-04 19:39:12 +00:00
|
|
|
#endif // _WX_HYPERLINK_H_
|