Provide native wxHyperlinkCtrl implementation for wxMSW.
Use the "syslink" native control to implement wxHyperlinkCtrl under (recent enough, i.e. XP or later) versions of Windows. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65334 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,7 +20,7 @@ class WXDLLIMPEXP_ADV wxGenericHyperlinkCtrl : public wxHyperlinkCtrlBase
|
||||
{
|
||||
public:
|
||||
// Default constructor (for two-step construction).
|
||||
wxGenericHyperlinkCtrl() { }
|
||||
wxGenericHyperlinkCtrl() { Init(); }
|
||||
|
||||
// Constructor.
|
||||
wxGenericHyperlinkCtrl(wxWindow *parent,
|
||||
@@ -31,7 +31,8 @@ public:
|
||||
long style = wxHL_DEFAULT_STYLE,
|
||||
const wxString& name = wxHyperlinkCtrlNameStr)
|
||||
{
|
||||
(void)Create(parent, id, label, url, pos, size, style, name);
|
||||
Init();
|
||||
(void) Create(parent, id, label, url, pos, size, style, name);
|
||||
}
|
||||
|
||||
// Creation function (for two-step construction).
|
||||
@@ -65,6 +66,10 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
// Helper used by this class itself and native MSW implementation that
|
||||
// connects OnRightUp() and OnPopUpCopy() handlers.
|
||||
void ConnectMenuHandlers();
|
||||
|
||||
// event handlers
|
||||
|
||||
// Renders the hyperlink.
|
||||
@@ -100,12 +105,15 @@ protected:
|
||||
|
||||
// Returns the best size for the window, which is the size needed
|
||||
// to display the text label.
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
virtual wxSize DoGetBestClientSize() const;
|
||||
|
||||
// creates a context menu with "Copy URL" menuitem
|
||||
virtual void DoContextMenu(const wxPoint &);
|
||||
|
||||
private:
|
||||
// Common part of all ctors.
|
||||
void Init();
|
||||
|
||||
// URL associated with the link. This is transmitted inside
|
||||
// the HyperlinkEvent fired when the user clicks on the label.
|
||||
wxString m_url;
|
||||
@@ -126,9 +134,6 @@ private:
|
||||
// True if a click is in progress (left button down) and the click
|
||||
// originated inside the label's bounding box.
|
||||
bool m_clicking;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxGenericHyperlinkCtrl)
|
||||
};
|
||||
|
||||
#endif // _WX_GENERICHYPERLINKCTRL_H_
|
||||
|
@@ -135,9 +135,32 @@ typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&);
|
||||
|
||||
#if defined(__WXGTK210__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/gtk/hyperlink.h"
|
||||
#elif defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
||||
#include "wx/msw/hyperlink.h"
|
||||
#else
|
||||
#include "wx/generic/hyperlink.h"
|
||||
#define wxHyperlinkCtrl wxGenericHyperlinkCtrl
|
||||
|
||||
class WXDLLIMPEXP_ADV wxHyperlinkCtrl : public wxGenericHyperlinkCtrl
|
||||
{
|
||||
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,
|
||||
const wxString& name = wxHyperlinkCtrlNameStr)
|
||||
: wxGenericHyperlinkCtrl(parent, id, label, url, pos, size,
|
||||
style, name)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
wxDECLARE_DYNAMIC_CLASS_NO_COPY( wxHyperlinkCtrl );
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
65
include/wx/msw/hyperlink.h
Normal file
65
include/wx/msw/hyperlink.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/msw/hyperlink.h
|
||||
// Purpose: Hyperlink control
|
||||
// Author: Rickard Westerlund
|
||||
// Created: 2010-08-04
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2010 wxWidgets team
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_MSW_HYPERLINK_H_
|
||||
#define _WX_MSW_HYPERLINK_H_
|
||||
|
||||
#include "wx/generic/hyperlink.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHyperlinkCtrl
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_ADV wxHyperlinkCtrl : public wxGenericHyperlinkCtrl
|
||||
{
|
||||
public:
|
||||
// Default constructor (for two-step construction).
|
||||
wxHyperlinkCtrl() { }
|
||||
|
||||
// Constructor.
|
||||
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)
|
||||
{
|
||||
(void)Create(parent, id, label, url, pos, size, style, name);
|
||||
}
|
||||
|
||||
// Creation function (for two-step construction).
|
||||
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);
|
||||
|
||||
|
||||
// overridden base class methods
|
||||
// -----------------------------
|
||||
|
||||
virtual void SetURL(const wxString &url);
|
||||
|
||||
virtual void SetLabel(const wxString &label);
|
||||
|
||||
protected:
|
||||
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
|
||||
virtual wxSize DoGetBestClientSize() const;
|
||||
|
||||
private:
|
||||
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||
|
||||
wxDECLARE_DYNAMIC_CLASS( wxHyperlinkCtrl );
|
||||
};
|
||||
|
||||
#endif // _WX_MSW_HYPERLINK_H_
|
Reference in New Issue
Block a user