From 17e914373a348a6c1f432d06ecab0bced95773ac Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 28 May 2006 17:41:09 +0000 Subject: [PATCH] added wxHyperlinkCtrl (patch 1476781 from Francesco) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39384 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/bakefiles/files.bkl | 4 + configure.in | 10 ++ docs/changes.txt | 1 + docs/latex/wx/category.tex | 1 + docs/latex/wx/hyperlink.tex | 220 ++++++++++++++++++++++++++++++++++ include/wx/chkconf.h | 8 ++ include/wx/hyperlink.h | 210 ++++++++++++++++++++++++++++++++ include/wx/mac/setup0.h | 51 ++++---- include/wx/motif/setup0.h | 51 ++++---- include/wx/msw/setup0.h | 51 ++++---- include/wx/msw/wince/setup.h | 51 ++++---- include/wx/os2/setup0.h | 51 ++++---- include/wx/palmos/setup0.h | 51 ++++---- include/wx/setup_inc.h | 51 ++++---- include/wx/xrc/xh_all.h | 1 + include/wx/xrc/xh_hyperlink.h | 44 +++++++ setup.h.in | 51 ++++---- src/common/datacmn.cpp | 1 + src/generic/hyperlink.cpp | 219 +++++++++++++++++++++++++++++++++ src/xrc/xh_hyperlink.cpp | 75 ++++++++++++ src/xrc/xmlrsall.cpp | 3 + 21 files changed, 1005 insertions(+), 200 deletions(-) create mode 100644 docs/latex/wx/hyperlink.tex create mode 100644 include/wx/hyperlink.h create mode 100644 include/wx/xrc/xh_hyperlink.h create mode 100644 src/generic/hyperlink.cpp create mode 100644 src/xrc/xh_hyperlink.cpp diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 7e551233f9..d2b1b67286 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -2528,6 +2528,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/generic/gridctrl.cpp src/generic/gridsel.cpp src/generic/helpext.cpp + src/generic/hyperlink.cpp src/generic/laywin.cpp src/generic/odcombo.cpp src/generic/propdlg.cpp @@ -2560,6 +2561,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/generic/splash.h wx/generic/wizard.h wx/grid.h + wx/hyperlink.h wx/joystick.h wx/laywin.h wx/odcombo.h @@ -2804,6 +2806,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/xrc/xh_gdctl.cpp src/xrc/xh_grid.cpp src/xrc/xh_html.cpp + src/xrc/xh_hyperlink.cpp src/xrc/xh_listb.cpp src/xrc/xh_listbk.cpp src/xrc/xh_listc.cpp @@ -2852,6 +2855,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/xrc/xh_gdctl.h wx/xrc/xh_grid.h wx/xrc/xh_html.h + wx/xrc/xh_hyperlink.h wx/xrc/xh_listb.h wx/xrc/xh_listbk.h wx/xrc/xh_listc.h diff --git a/configure.in b/configure.in index 92c02b8e2b..47bddd854b 100644 --- a/configure.in +++ b/configure.in @@ -514,6 +514,7 @@ if test $DEBUG_CONFIGURE = 1; then DEFAULT_wxUSE_DISPLAY=no DEFAULT_wxUSE_GAUGE=no DEFAULT_wxUSE_GRID=no + DEFAULT_wxUSE_HYPERLINKCTRL=no DEFAULT_wxUSE_DATAVIEWCTRL=no DEFAULT_wxUSE_IMAGLIST=no DEFAULT_wxUSE_LISTBOOK=no @@ -720,6 +721,7 @@ else DEFAULT_wxUSE_DISPLAY=yes DEFAULT_wxUSE_GAUGE=yes DEFAULT_wxUSE_GRID=yes + DEFAULT_wxUSE_HYPERLINKCTRL=yes DEFAULT_wxUSE_DATAVIEWCTRL=no DEFAULT_wxUSE_IMAGLIST=yes DEFAULT_wxUSE_LISTBOOK=yes @@ -1032,6 +1034,7 @@ if test "$wxUSE_CONTROLS" = "yes"; then DEFAULT_wxUSE_DATEPICKCTRL=yes DEFAULT_wxUSE_GAUGE=yes DEFAULT_wxUSE_GRID=yes + DEFAULT_wxUSE_HYPERLINKCTRL=yes DEFAULT_wxUSE_DATAVIEWCTRL=no DEFAULT_wxUSE_IMAGLIST=yes DEFAULT_wxUSE_LISTBOOK=yes @@ -1075,6 +1078,7 @@ elif test "$wxUSE_CONTROLS" = "no"; then DEFAULT_wxUSE_DATEPICKCTRL=no DEFAULT_wxUSE_GAUGE=no DEFAULT_wxUSE_GRID=no + DEFAULT_wxUSE_HYPERLINKCTRL=no DEFAULT_wxUSE_DATAVIEWCTRL=no DEFAULT_wxUSE_IMAGLIST=no DEFAULT_wxUSE_LISTBOOK=no @@ -1122,6 +1126,7 @@ WX_ARG_ENABLE(display, [ --enable-display use wxDisplay class], wxUS WX_ARG_ENABLE(gauge, [ --enable-gauge use wxGauge class], wxUSE_GAUGE) WX_ARG_ENABLE(grid, [ --enable-grid use wxGrid class], wxUSE_GRID) WX_ARG_ENABLE(dataviewctrl,[ --enable-dataviewctrl, use wxDataViewCtrl class], wxUSE_DATAVIEWCTRL) +WX_ARG_ENABLE(hyperlink, [ --enable-hyperlink use wxHyperlinkCtrl class], wxUSE_HYPERLINKCTRL) WX_ARG_ENABLE(imaglist, [ --enable-imaglist use wxImageList class], wxUSE_IMAGLIST) WX_ARG_ENABLE(listbook, [ --enable-listbook use wxListbook class], wxUSE_LISTBOOK) WX_ARG_ENABLE(listbox, [ --enable-listbox use wxListBox class], wxUSE_LISTBOX) @@ -6328,6 +6333,11 @@ if test "$wxUSE_GRID" = "yes"; then SAMPLES_SUBDIRS="$SAMPLES_SUBDIRS grid" fi +if test "$wxUSE_HYPERLINKCTRL" = "yes"; then + AC_DEFINE(wxUSE_HYPERLINKCTRL) + USES_CONTROLS=1 +fi + if test "$wxUSE_DATAVIEWCTRL" = "yes"; then AC_DEFINE(wxUSE_DATAVIEWCTRL) USES_CONTROLS=1 diff --git a/docs/changes.txt b/docs/changes.txt index 0626cd708e..040bdaf073 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -86,6 +86,7 @@ All (GUI): - Added wxComboCtrl and wxOwnerDrawnComboBox (Jaakko Salli) - Added wxTreebook (uses a wxTreeCtrl to control pages). - Added wxDC::GradientFillLinear/Concentric() +- Added wxHyperlinkCtrl (Francesco Montorsi) - Added clipboard events (wxEVT_COMMAND_TEXT_COPY/CUT/PASTE) - Added wxRadioBox::SetItemToolTip() - Added wxKeyEvent::GetModifiers() diff --git a/docs/latex/wx/category.tex b/docs/latex/wx/category.tex index 3c5d54fba5..96bb9525bf 100644 --- a/docs/latex/wx/category.tex +++ b/docs/latex/wx/category.tex @@ -108,6 +108,7 @@ that are not static can have \helpref{validators}{wxvalidator} associated with t \twocolitem{\helpref{wxSpinButton}{wxspinbutton}}{A spin or `up-down' control} \twocolitem{\helpref{wxSpinCtrl}{wxspinctrl}}{A spin control - i.e. spin button and text control} \twocolitem{\helpref{wxStaticText}{wxstatictext}}{One or more lines of non-editable text} +\twocolitem{\helpref{wxHyperlinkCtrl}{wxhyperlinkctrl}}{A static text which opens an URL when clicked} \twocolitem{\helpref{wxStaticBitmap}{wxstaticbitmap}}{A control to display a bitmap} \twocolitem{\helpref{wxRadioBox}{wxradiobox}}{A group of radio buttons} \twocolitem{\helpref{wxRadioButton}{wxradiobutton}}{A round button to be used with others in a mutually exclusive way} diff --git a/docs/latex/wx/hyperlink.tex b/docs/latex/wx/hyperlink.tex new file mode 100644 index 0000000000..3068b8ebcf --- /dev/null +++ b/docs/latex/wx/hyperlink.tex @@ -0,0 +1,220 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Name: hyperlink.tex +%% Purpose: wxHyperLink documentation +%% Author: Otto Wyss +%% Modified by: Francesco Montorsi +%% Created: 25.4.2004 +%% RCS-ID: $Id$ +%% Copyright: (c) 2004 wxCode, Francesco Montorsi +%% License: wxWindows +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\section{\class{wxHyperLinkCtrl}}\label{wxhyperlinkctrl} + +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 \helpref{wxHyperlinkEvent}{wxhyperlinkctrlevent} is sent but if that event is not handled (or it's skipped; see \helpref{wxEvent::Skip}{wxeventskip}), then a call to \helpref{wxLaunchDefaultBrowser}{wxlaunchdefaultbrowser} is done with the hyperlink's URL. + +Note that standard \helpref{wxWindow}{wxwindow} functions like \helpref{SetBackgroundColour}{wxwindowsetbackgroundcolour}, \helpref{SetFont}{wxwindowsetfont}, \helpref{SetCursor}{wxwindowsetcursor}, \helpref{SetLabel}{wxwindowsetlabel} can be used to customize appearance of the hyperlink. + + +\wxheading{Derived from} + +\helpref{wxControl}{wxcontrol} + + +\wxheading{Include files} + + + + +\wxheading{Window styles} + +\twocolwidtha{7cm} +\begin{twocollist}\itemsep=0pt +\twocolitem{\windowstyle{wxHL\_CONTEXTMENU}}{Pop up a context menu when the hyperlink is right-clicked. The context menu contains a \texttt{``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.} +\twocolitem{\windowstyle{wxHL\_DEFAULT\_STYLE}}{The default style for wxHyperlinkCtrl: \texttt{wxNO\_BORDER|wxHL\_CONTEXTMENU}.} +\end{twocollist} + +See also \helpref{window styles overview}{windowstyles}. + + +\wxheading{Event handling} + +To process input from a list control, use these event handler macros to direct input to member +functions that take a \helpref{wxHyperlinkEvent}{wxhyperlinkctrlevent} argument. + +\twocolwidtha{7cm} +\begin{twocollist}\itemsep=0pt +\twocolitem{{\bf EVT\_HYPERLINK(id, func)}}{The hyperlink was (left) clicked. If this event is not handled in user's code (or it's skipped; see \helpref{wxEvent::Skip}{wxeventskip}), then a call to \helpref{wxLaunchDefaultBrowser}{wxlaunchdefaultbrowser} is done with the hyperlink's URL.} +\end{twocollist} + + +\wxheading{See also} + +\helpref{wxURL}{wxurl} + + +\latexignore{\rtfignore{\wxheading{Members}}} + +\membersection{wxHyperLinkCtrl::wxHyperLink}\label{wxhyperlinkctrlctor} + +\func{}{wxHyperLink}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id}, \param{const wxString \&}{ label}, \param{const wxString \&}{ url}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize}, \param{long}{ style}, \param{const wxString\& }{name = ``hyperlink"}} + +Constructor. See \helpref{Create}{wxhyperlinkctrlcreate} for more info. + + +\membersection{wxHyperLinkCtrl::Create}\label{wxhyperlinkctrlcreate} + +\func{}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID}{ id = -1} \param{const wxString \&}{ label}, \param{const wxString \&}{ url}, \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},\param{long}{ style}, \param{const wxString\& }{name = ``hyperlink"}} + +Creates the hyperlink control. + +\wxheading{Parameters} + +\docparam{parent}{Parent window. Must not be \NULL.} + +\docparam{id}{Window identifier. A value of -1 indicates a default value.} + +\docparam{label}{The label of the hyperlink.} + +\docparam{url}{The URL which is .} + +\docparam{pos}{Window position.} + +\docparam{size}{Window size. If the default size (-1, -1) is specified then the window is sized +appropriately.} + +\docparam{style}{Window style. See \helpref{wxHyperlinkCtrl}{wxhyperlinkctrl}.} + +\docparam{validator}{Window validator.} + +\docparam{name}{Window name.} + + +\membersection{wxHyperLinkCtrl::GetHoverColour}\label{wxhyperlinkctrlgethovercolour} + +\constfunc{wxColour}{GetHoverColour}{\void} + +Returns the colour used to print the label of the hyperlink when the mouse is over the control. + + +\membersection{wxHyperLinkCtrl::SetHoverColour}\label{wxhyperlinkctrlsethovercolour} + +\func{void}{SetHoverColour}{\param{const wxColour \&}{ colour}} + +Sets the colour used to print the label of the hyperlink when the mouse is over the control. + + +\membersection{wxHyperLinkCtrl::GetNormalColour}\label{wxhyperlinkctrlgetnormalcolour} + +\constfunc{wxColour}{GetNormalColour}{\void} + +Returns the colour used to print the label when the link has never been clicked before +(i.e. the link has not been {\it visited}) and the mouse is not over the control. + + +\membersection{wxHyperLinkCtrl::SetNormalColour}\label{wxhyperlinkctrlsetnormalcolour} + +\func{void}{SetNormalColour}{\param{const wxColour \&}{ colour}} + +Sets the colour used to print the label when the link has never been clicked before +(i.e. the link has not been {\it visited}) and the mouse is not over the control. + + +\membersection{wxHyperLinkCtrl::GetVisitedColour}\label{wxhyperlinkctrlgetvisitedcolour} + +\constfunc{wxColour}{GetVisitedColour}{\void} + +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 {\it visited}). + + +\membersection{wxHyperLinkCtrl::SetVisitedColour}\label{wxhyperlinkctrlsetvisitedcolour} + +\func{void}{SetVisitedColour}{\param{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. the link has been {\it visited}). + + +\membersection{wxHyperLinkCtrl::GetVisited}\label{wxhyperlinkctrlgetvisited} + +\constfunc{bool}{GetVisited}{\void} + +Returns \true if the hyperlink has already been clicked by the user at least one time. + + +\membersection{wxHyperLinkCtrl::SetVisited}\label{wxhyperlinkctrlsetvisited} + +\func{void}{SetVisited}{\param{bool}{ visited = true}} + +Marks the hyperlink as visited (see \helpref{SetVisitedColour}{wxhyperlinkctrlsetvisitedcolour}). + + +\membersection{wxHyperLinkCtrl::GetURL}\label{wxhyperlinkctrlgeturl} + +\constfunc{wxString}{GetURL}{\void} + +Returns the URL associated with the hyperlink. + + +\membersection{wxHyperLinkCtrl::SetURL}\label{wxhyperlinkctrlseturl} + +\func{void}{SetURL}{\param{const wxString \&}{ url}} + +Sets the URL associated with the hyperlink. + + + + + + +\section{\class{wxHyperlinkEvent}}\label{wxhyperlinkctrlevent} + +This event class is used for the events generated by +\helpref{wxHyperlinkCtrl}{wxhyperlinkctrl}. + +\wxheading{Derived from} + +\helpref{wxCommandEvent}{wxcommandevent}\\ +\helpref{wxEvent}{wxevent}\\ +\helpref{wxObject}{wxobject} + +\wxheading{Include files} + + + +\wxheading{Event handling} + +To process input from a wxHyperlinkCtrl, use one of these event handler macros to +direct input to member function that take a +\helpref{wxHyperlinkEvent}{wxhyperlinkctrlevent} argument: + +\twocolwidtha{7cm} +\begin{twocollist} +\twocolitem{{\bf EVT\_HYPERLINK(id, func)}}{User clicked on an hyperlink.} +\end{twocollist} + + +\latexignore{\rtfignore{\wxheading{Members}}} + +\membersection{wxHyperlinkEvent::wxHyperlinkEvent}\label{wxhyperlinkctrlctor} + +\func{}{wxHyperlinkEvent}{\param{wxObject *}{ generator}, \param{int}{ id}, \param{const wxString \&}{ url}} + +The constructor is not normally used by the user code. + + +\membersection{wxHyperlinkEvent::GetURL}\label{wxhyperlinkctrlgeturl} + +\constfunc{wxString}{GetURL}{\void} + +Returns the URL of the hyperlink where the user has just clicked. + + +\membersection{wxHyperlinkEvent::SetURL}\label{wxhyperlinkctrlseturl} + +\func{void}{SetURL}{\param{const wxString \&}{ url}} + +Sets the URL associated with the event. + diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index 5f8264eaed..e0ed14ff41 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -496,6 +496,14 @@ # endif #endif /* !defined(wxUSE_HELP) */ +#ifndef wxUSE_HYPERLINKCTRL +# ifdef wxABORT_ON_CONFIG_ERROR +# error "wxUSE_HYPERLINKCTRL must be defined." +# else +# define wxUSE_HYPERLINKCTRL 0 +# endif +#endif /* !defined(wxUSE_HYPERLINKCTRL) */ + #ifndef wxUSE_HTML # ifdef wxABORT_ON_CONFIG_ERROR # error "wxUSE_HTML must be defined." diff --git a/include/wx/hyperlink.h b/include/wx/hyperlink.h new file mode 100644 index 0000000000..474951d97c --- /dev/null +++ b/include/wx/hyperlink.h @@ -0,0 +1,210 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: hyperlink.h +// Purpose: Hyperlink control +// Author: David Norris , Otto Wyss +// Modified by: Ryan Norton, Francesco Montorsi +// Created: 04/02/2005 +// RCS-ID: $Id$ +// Copyright: (c) 2005 David Norris +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_HYPERLINK_H__ +#define _WX_HYPERLINK_H__ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) + #pragma interface "hyperlink.h" +#endif + +#include "wx/defs.h" + +#if wxUSE_HYPERLINKCTRL + +#include "wx/control.h" + +// ---------------------------------------------------------------------------- +// constants +// ---------------------------------------------------------------------------- + +#define wxHL_CONTEXTMENU 0x0001 +#define wxHL_DEFAULT_STYLE wxHL_CONTEXTMENU|wxNO_BORDER + +extern WXDLLEXPORT_DATA(const wxChar) wxHyperlinkCtrlNameStr[]; + + +// ---------------------------------------------------------------------------- +// 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. +class WXDLLIMPEXP_CORE wxHyperlinkCtrl : public wxControl +{ +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); + + + // get/set + wxColour GetHoverColour() const { return m_hoverColour; } + void SetHoverColour(const wxColour &colour) { m_hoverColour = colour; } + + wxColour GetNormalColour() const { return m_normalColour; } + void SetNormalColour(const wxColour &colour); + + wxColour GetVisitedColour() const { return m_visitedColour; } + void SetVisitedColour(const wxColour &colour); + + wxString GetURL() const { return m_url; } + void SetURL (const wxString &url) { m_url=url; } + + void SetVisited(bool visited = true) { m_visited=visited; } + bool GetVisited() const { return m_visited; } + + // NOTE: also wxWindow::Set/GetLabel, wxWindow::Set/GetBackgroundColour, + // wxWindow::Get/SetFont, wxWindow::Get/SetCursor are important ! + + +protected: + // event handlers + + // Renders the hyperlink. + void OnPaint(wxPaintEvent& event); + + // If the click originates inside the bounding box of the label, + // a flag is set so that an event will be fired when the left + // button is released. + void OnLeftDown(wxMouseEvent& event); + + // If the click both originated and finished inside the bounding box + // of the label, a HyperlinkEvent is fired. + void OnLeftUp(wxMouseEvent& event); + void OnRightUp(wxMouseEvent& event); + + // Changes the cursor to a hand, if the mouse is inside the label's + // bounding box. + void OnEnterWindow(wxMouseEvent& event); + + // Changes the cursor back to the default, if necessary. + void OnLeaveWindow(wxMouseEvent& event); + + // handles "Copy URL" menuitem + void OnPopUpCopy(wxCommandEvent& event); + + + // overridden base class virtuals + + // Returns the best size for the window, which is the size needed + // to display the text label. + virtual void DoGetSize(int *width, int *height) const; + virtual wxSize DoGetBestSize() const; + + // creates a context menu with "Copy URL" menuitem + virtual void DoContextMenu(const wxPoint &); + +private: + // URL associated with the link. This is transmitted inside + // the HyperlinkEvent fired when the user clicks on the label. + wxString m_url; + + // Foreground colours for various link types. + // NOTE: wxWindow::m_backgroundColour is used for background, + // wxWindow::m_foregroundColour is used to render non-visited links + wxColour m_hoverColour; + wxColour m_normalColour; + wxColour m_visitedColour; + + // True if the mouse cursor is inside the label's bounding box. + bool m_rollover; + + // True if the link has been clicked before. + bool m_visited; + + // 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(wxHyperlinkCtrl) + DECLARE_EVENT_TABLE() +}; + + +// ---------------------------------------------------------------------------- +// wxHyperlinkEvent +// ---------------------------------------------------------------------------- + +// Declare an event identifier. +BEGIN_DECLARE_EVENT_TYPES() + DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_CORE, wxEVT_COMMAND_HYPERLINK, 3700) +END_DECLARE_EVENT_TYPES() + +// +// An event fired when the user clicks on the label in a hyperlink control. +// See HyperlinkControl for details. +// +class WXDLLIMPEXP_CORE wxHyperlinkEvent : public wxCommandEvent +{ +public: + + wxHyperlinkEvent() {} + wxHyperlinkEvent(wxObject *generator, wxWindowID id, const wxString& url) + : wxCommandEvent(wxEVT_COMMAND_HYPERLINK, id), m_url(url) + { SetEventObject(generator); } + + // 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; } + +private: + + // URL associated with the hyperlink control that the used clicked on. + wxString m_url; +}; + +// Define a typedef for event handler functions. +typedef void (wxEvtHandler::*wxHyperlinkEventFunction)(wxHyperlinkEvent&); + +// Define an event table macro. +#define EVT_HYPERLINK(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_HYPERLINK, \ + id, id, (wxObjectEventFunction) (wxEventFunction) \ + wxStaticCastEvent(wxHyperlinkEventFunction, &fn), (wxObject *) NULL), + +// Newer event macro +#define wxHyperlinkEventHandler(func) \ + (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxHyperlinkEventFunction, &func) + +#endif // wxUSE_HYPERLINKCTRL + +#endif // _WX_HYPERLINK_H__ + diff --git a/include/wx/mac/setup0.h b/include/wx/mac/setup0.h index 25b21864fd..207602f783 100644 --- a/include/wx/mac/setup0.h +++ b/include/wx/mac/setup0.h @@ -570,31 +570,32 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl +#define wxUSE_GAUGE 1 // wxGauge +#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 1 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 1 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 1 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h index 8e31688536..eb9a6a88dd 100644 --- a/include/wx/motif/setup0.h +++ b/include/wx/motif/setup0.h @@ -569,31 +569,32 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl +#define wxUSE_GAUGE 1 // wxGauge +#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 1 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 1 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 1 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index f0defc66f2..bdc82da1cb 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -569,31 +569,32 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl +#define wxUSE_GAUGE 1 // wxGauge +#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 1 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 1 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 1 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. diff --git a/include/wx/msw/wince/setup.h b/include/wx/msw/wince/setup.h index 6d334b72ae..56d77b8169 100644 --- a/include/wx/msw/wince/setup.h +++ b/include/wx/msw/wince/setup.h @@ -569,31 +569,32 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl +#define wxUSE_GAUGE 1 // wxGauge +#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 1 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 1 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 1 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. diff --git a/include/wx/os2/setup0.h b/include/wx/os2/setup0.h index 274b6e1fdb..7b0b6a2114 100644 --- a/include/wx/os2/setup0.h +++ b/include/wx/os2/setup0.h @@ -569,31 +569,32 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl +#define wxUSE_GAUGE 1 // wxGauge +#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 1 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 1 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 1 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. diff --git a/include/wx/palmos/setup0.h b/include/wx/palmos/setup0.h index 8ae37af672..140b3f9562 100644 --- a/include/wx/palmos/setup0.h +++ b/include/wx/palmos/setup0.h @@ -569,31 +569,32 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl +#define wxUSE_GAUGE 1 // wxGauge +#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 1 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 1 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 1 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h index 9f1e88f05e..3a5b04ca8a 100644 --- a/include/wx/setup_inc.h +++ b/include/wx/setup_inc.h @@ -565,31 +565,32 @@ // Default is 1 // // Recommended setting: 1 -#define wxUSE_BUTTON 1 // wxButton -#define wxUSE_BMPBUTTON 1 // wxBitmapButton -#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl -#define wxUSE_CHECKBOX 1 // wxCheckBox -#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) -#define wxUSE_CHOICE 1 // wxChoice -#define wxUSE_COMBOBOX 1 // wxComboBox -#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl -#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl -#define wxUSE_GAUGE 1 // wxGauge -#define wxUSE_LISTBOX 1 // wxListBox -#define wxUSE_LISTCTRL 1 // wxListCtrl -#define wxUSE_RADIOBOX 1 // wxRadioBox -#define wxUSE_RADIOBTN 1 // wxRadioButton -#define wxUSE_SCROLLBAR 1 // wxScrollBar -#define wxUSE_SLIDER 1 // wxSlider -#define wxUSE_SPINBTN 1 // wxSpinButton -#define wxUSE_SPINCTRL 1 // wxSpinCtrl -#define wxUSE_STATBOX 1 // wxStaticBox -#define wxUSE_STATLINE 1 // wxStaticLine -#define wxUSE_STATTEXT 1 // wxStaticText -#define wxUSE_STATBMP 1 // wxStaticBitmap -#define wxUSE_TEXTCTRL 1 // wxTextCtrl -#define wxUSE_TOGGLEBTN 1 // requires wxButton -#define wxUSE_TREECTRL 1 // wxTreeCtrl +#define wxUSE_BUTTON 1 // wxButton +#define wxUSE_BMPBUTTON 1 // wxBitmapButton +#define wxUSE_CALENDARCTRL 1 // wxCalendarCtrl +#define wxUSE_CHECKBOX 1 // wxCheckBox +#define wxUSE_CHECKLISTBOX 1 // wxCheckListBox (requires wxUSE_OWNER_DRAWN) +#define wxUSE_CHOICE 1 // wxChoice +#define wxUSE_COMBOBOX 1 // wxComboBox +#define wxUSE_DATAVIEWCTRL 1 // wxDataViewCtrl +#define wxUSE_DATEPICKCTRL 1 // wxDatePickerCtrl +#define wxUSE_GAUGE 1 // wxGauge +#define wxUSE_HYPERLINKCTRL 1 // wxHyperlinkCtrl +#define wxUSE_LISTBOX 1 // wxListBox +#define wxUSE_LISTCTRL 1 // wxListCtrl +#define wxUSE_RADIOBOX 1 // wxRadioBox +#define wxUSE_RADIOBTN 1 // wxRadioButton +#define wxUSE_SCROLLBAR 1 // wxScrollBar +#define wxUSE_SLIDER 1 // wxSlider +#define wxUSE_SPINBTN 1 // wxSpinButton +#define wxUSE_SPINCTRL 1 // wxSpinCtrl +#define wxUSE_STATBOX 1 // wxStaticBox +#define wxUSE_STATLINE 1 // wxStaticLine +#define wxUSE_STATTEXT 1 // wxStaticText +#define wxUSE_STATBMP 1 // wxStaticBitmap +#define wxUSE_TEXTCTRL 1 // wxTextCtrl +#define wxUSE_TOGGLEBTN 1 // requires wxButton +#define wxUSE_TREECTRL 1 // wxTreeCtrl // Use a status bar class? Depending on the value of wxUSE_NATIVE_STATUSBAR // below either wxStatusBar95 or a generic wxStatusBar will be used. diff --git a/include/wx/xrc/xh_all.h b/include/wx/xrc/xh_all.h index 14a4b03b5d..9a248de5da 100644 --- a/include/wx/xrc/xh_all.h +++ b/include/wx/xrc/xh_all.h @@ -57,5 +57,6 @@ #include "wx/xrc/xh_statbar.h" #include "wx/xrc/xh_mdi.h" #include "wx/xrc/xh_grid.h" +#include "wx/xrc/xh_hyperlink.h" #endif // _WX_XH_ALL_H_ diff --git a/include/wx/xrc/xh_hyperlink.h b/include/wx/xrc/xh_hyperlink.h new file mode 100644 index 0000000000..6a31109fcb --- /dev/null +++ b/include/wx/xrc/xh_hyperlink.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: xh_hyperlink.h +// Purpose: Hyperlink control (wxAdv) +// Author: David Norris +// Modified by: Ryan Norton, Francesco Montorsi +// Created: 04/02/2005 +// RCS-ID: $Id$ +// Copyright: (c) 2005 David Norris +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_XH_HYPERLINKH__ +#define _WX_XH_HYPERLINKH__ + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) + #pragma interface "hyperlink.h" +#endif + +#include "wx/defs.h" + +#if wxUSE_HYPERLINKCTRL + +#include "wx/hyperlink.h" +#include "wx/xrc/xmlres.h" + +class WXDLLIMPEXP_XRC wxHyperlinkCtrlXmlHandler : public wxXmlResourceHandler +{ +public: + // Constructor. + wxHyperlinkCtrlXmlHandler(); + + // Creates the control and returns a pointer to it. + virtual wxObject *DoCreateResource(); + + // Returns true if we know how to create a control for the given node. + virtual bool CanHandle(wxXmlNode *node); + + // Register with wxWindows' dynamic class subsystem. + DECLARE_DYNAMIC_CLASS(wxHyperlinkCtrlXmlHandler) +}; + +#endif // wxUSE_HYPERLINKCTRL +#endif // _WX_XH_HYPERLINKH__ + diff --git a/setup.h.in b/setup.h.in index 30c24e7a17..0e9057241d 100644 --- a/setup.h.in +++ b/setup.h.in @@ -293,31 +293,32 @@ #define wxUSE_TIPWINDOW 0 -#define wxUSE_BUTTON 0 -#define wxUSE_BMPBUTTON 0 -#define wxUSE_CALENDARCTRL 0 -#define wxUSE_CHECKBOX 0 -#define wxUSE_CHECKLISTBOX 0 -#define wxUSE_CHOICE 0 -#define wxUSE_COMBOBOX 0 -#define wxUSE_DATAVIEWCTRL 0 -#define wxUSE_DATEPICKCTRL 0 -#define wxUSE_GAUGE 0 -#define wxUSE_LISTBOX 0 -#define wxUSE_LISTCTRL 0 -#define wxUSE_RADIOBOX 0 -#define wxUSE_RADIOBTN 0 -#define wxUSE_SCROLLBAR 0 -#define wxUSE_SLIDER 0 -#define wxUSE_SPINBTN 0 -#define wxUSE_SPINCTRL 0 -#define wxUSE_STATBOX 0 -#define wxUSE_STATLINE 0 -#define wxUSE_STATTEXT 0 -#define wxUSE_STATBMP 0 -#define wxUSE_TEXTCTRL 0 -#define wxUSE_TOGGLEBTN 0 -#define wxUSE_TREECTRL 0 +#define wxUSE_BUTTON 0 +#define wxUSE_BMPBUTTON 0 +#define wxUSE_CALENDARCTRL 0 +#define wxUSE_CHECKBOX 0 +#define wxUSE_CHECKLISTBOX 0 +#define wxUSE_CHOICE 0 +#define wxUSE_COMBOBOX 0 +#define wxUSE_DATAVIEWCTRL 0 +#define wxUSE_DATEPICKCTRL 0 +#define wxUSE_GAUGE 0 +#define wxUSE_HYPERLINKCTRL 0 +#define wxUSE_LISTBOX 0 +#define wxUSE_LISTCTRL 0 +#define wxUSE_RADIOBOX 0 +#define wxUSE_RADIOBTN 0 +#define wxUSE_SCROLLBAR 0 +#define wxUSE_SLIDER 0 +#define wxUSE_SPINBTN 0 +#define wxUSE_SPINCTRL 0 +#define wxUSE_STATBOX 0 +#define wxUSE_STATLINE 0 +#define wxUSE_STATTEXT 0 +#define wxUSE_STATBMP 0 +#define wxUSE_TEXTCTRL 0 +#define wxUSE_TOGGLEBTN 0 +#define wxUSE_TREECTRL 0 #define wxUSE_STATUSBAR 0 diff --git a/src/common/datacmn.cpp b/src/common/datacmn.cpp index bb7935b58b..44e529bc76 100644 --- a/src/common/datacmn.cpp +++ b/src/common/datacmn.cpp @@ -79,3 +79,4 @@ extern WXDLLEXPORT_DATA(const wxChar) wxDirDialogDefaultFolderStr[] = wxT("/"); #if defined(__WXMSW__) || defined(__OS2__) WXDLLEXPORT_DATA(const wxChar *) wxUserResourceStr = wxT("TEXT"); #endif +extern WXDLLEXPORT_DATA(const wxChar) wxHyperlinkCtrlNameStr[] = wxT("hyperlink"); diff --git a/src/generic/hyperlink.cpp b/src/generic/hyperlink.cpp new file mode 100644 index 0000000000..6f078ca9fe --- /dev/null +++ b/src/generic/hyperlink.cpp @@ -0,0 +1,219 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: hyperlink.cpp +// Purpose: Hyperlink control +// Author: David Norris , Otto Wyss +// Modified by: Ryan Norton, Francesco Montorsi +// Created: 04/02/2005 +// RCS-ID: $Id$ +// Copyright: (c) 2005 David Norris +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +//--------------------------------------------------------------------------- +// Pre-compiled header stuff +//--------------------------------------------------------------------------- + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "hyperlink.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- + +#include "wx/hyperlink.h" +#include "wx/utils.h" // for wxLaunchDefaultBrowser +#include "wx/clipbrd.h" + + +#if wxUSE_HYPERLINKCTRL + +// ============================================================================ +// implementation +// ============================================================================ + +IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkCtrl, wxControl) +DEFINE_EVENT_TYPE(wxEVT_COMMAND_HYPERLINK) + +// reserved for internal use only +#define wxHYPERLINKCTRL_POPUP_COPY_ID 16384 + +// ---------------------------------------------------------------------------- +// wxHyperlinkCtrl +// ---------------------------------------------------------------------------- + +BEGIN_EVENT_TABLE(wxHyperlinkCtrl, wxControl) + EVT_PAINT(wxHyperlinkCtrl::OnPaint) + EVT_LEFT_DOWN(wxHyperlinkCtrl::OnLeftDown) + EVT_LEFT_UP(wxHyperlinkCtrl::OnLeftUp) + EVT_RIGHT_UP(wxHyperlinkCtrl::OnRightUp) + EVT_ENTER_WINDOW(wxHyperlinkCtrl::OnEnterWindow) + EVT_LEAVE_WINDOW(wxHyperlinkCtrl::OnLeaveWindow) + + // for the context menu + EVT_MENU(wxHYPERLINKCTRL_POPUP_COPY_ID, wxHyperlinkCtrl::OnPopUpCopy) +END_EVENT_TABLE() + +bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id, + const wxString& label, const wxString& url, const wxPoint& pos, + const wxSize& size, long style, const wxString& name) +{ + wxASSERT_MSG(!url.IsEmpty() || !label.IsEmpty(), + wxT("Both URL and label are empty ?")); + + if (!wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name)) + return false; + + // set to non empty strings both the url and the label + SetURL(url.IsEmpty() ? label : url); + SetLabel(label.IsEmpty() ? url : label); + + // by default the cursor to use in this window is wxCURSOR_HAND + SetCursor(wxCursor(wxCURSOR_HAND)); + + m_rollover = false; + m_clicking = false; + m_visited = false; + + // colours + m_normalColour = *wxBLUE; + m_hoverColour = *wxRED; + SetForegroundColour(m_normalColour); + + // by default the font of an hyperlink control is underlined + wxFont f = GetFont(); + f.SetUnderlined(true); + SetFont(f); + + CacheBestSize(DoGetBestSize()); + SetMinSize(GetBestSize()); + SetSize (DoGetBestSize()); + + return true; +} + +wxSize wxHyperlinkCtrl::DoGetBestSize() const +{ + int w, h; + + wxClientDC dc((wxWindow *)this); + dc.SetFont(GetFont()); + dc.GetTextExtent(GetLabel(), &w, &h); + + return wxSize(w, h); +} + +void wxHyperlinkCtrl::DoGetSize(int *width, int *height) const +{ + if (width) *width = GetBestSize().GetWidth(); + if (height) *height = GetBestSize().GetHeight(); +} + +void wxHyperlinkCtrl::SetNormalColour(const wxColour &colour) +{ + m_normalColour = colour; + if (!m_visited) + { + SetForegroundColour(m_normalColour); + Refresh(); + } +} + +void wxHyperlinkCtrl::SetVisitedColour(const wxColour &colour) +{ + m_visitedColour = colour; + if (m_visited) + { + SetForegroundColour(m_visitedColour); + Refresh(); + } +} + +void wxHyperlinkCtrl::DoContextMenu(const wxPoint &pos) +{ + wxMenu *menuPopUp = new wxMenu(wxEmptyString, wxMENU_TEAROFF); + menuPopUp->Append(wxHYPERLINKCTRL_POPUP_COPY_ID, wxT("Copy URL")); + PopupMenu( menuPopUp, pos ); + delete menuPopUp; +} + + + +// ---------------------------------------------------------------------------- +// wxHyperlinkCtrl - event handlers +// ---------------------------------------------------------------------------- + +void wxHyperlinkCtrl::OnPaint(wxPaintEvent& WXUNUSED(event)) +{ + wxPaintDC dc(this); + dc.SetFont(GetFont()); + dc.SetTextForeground(GetForegroundColour()); + dc.SetTextBackground(GetBackgroundColour()); + dc.DrawText(GetLabel(), 0, 0); +} + +void wxHyperlinkCtrl::OnLeftDown(wxMouseEvent& WXUNUSED(event)) +{ + m_clicking = true; +} + +void wxHyperlinkCtrl::OnLeftUp(wxMouseEvent& WXUNUSED(event)) +{ + if (!m_clicking) return; + + SetForegroundColour(m_visitedColour); + m_visited = true; + m_clicking = false; + + // send the event + wxHyperlinkEvent linkEvent(this, GetId(), m_url); + if (!GetEventHandler()->ProcessEvent(linkEvent)) // was the event skipped ? + if (!wxLaunchDefaultBrowser(m_url)) + wxLogWarning(wxT("Could not launch the default browser with url '%s' !"), m_url.c_str()); +} + +void wxHyperlinkCtrl::OnRightUp(wxMouseEvent& event) +{ + if( GetWindowStyle() & wxHL_CONTEXTMENU ) + DoContextMenu(wxPoint(event.m_x, event.m_y)); +} + +void wxHyperlinkCtrl::OnEnterWindow(wxMouseEvent& WXUNUSED(event)) +{ + SetForegroundColour(m_hoverColour); + m_rollover = true; + Refresh(); +} + +void wxHyperlinkCtrl::OnLeaveWindow(wxMouseEvent& WXUNUSED(event)) +{ + if (m_rollover) + { + SetForegroundColour(!m_visited ? m_normalColour : m_visitedColour); + m_rollover = false; + Refresh(); + } +} + +void wxHyperlinkCtrl::OnPopUpCopy( wxCommandEvent& WXUNUSED(event) ) +{ + if (!wxTheClipboard->Open()) + return; + + wxTextDataObject *data = new wxTextDataObject( m_url ); + wxTheClipboard->SetData( data ); + wxTheClipboard->Close(); +} + +#endif // wxUSE_HYPERLINKCTRL diff --git a/src/xrc/xh_hyperlink.cpp b/src/xrc/xh_hyperlink.cpp new file mode 100644 index 0000000000..21ea787243 --- /dev/null +++ b/src/xrc/xh_hyperlink.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: hyperlink.cpp +// Purpose: Hyperlink control +// Author: David Norris +// Modified by: Ryan Norton, Francesco Montorsi +// Created: 04/02/2005 +// RCS-ID: $Id$ +// Copyright: (c) 2005 David Norris +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +//=========================================================================== +// Declarations +//=========================================================================== + +//--------------------------------------------------------------------------- +// Pre-compiled header stuff +//--------------------------------------------------------------------------- + +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "hyperlink.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +//--------------------------------------------------------------------------- +// Includes +//--------------------------------------------------------------------------- + +#include "wx/hyperlink.h" +#include "wx/utils.h" // wxLaunchDefaultBrowser +#include "wx/xrc/xmlres.h" +#include "wx/xrc/xh_hyperlink.h" + +#if wxUSE_HYPERLINKCTRL + +//=========================================================================== +// Implementation +//=========================================================================== + +//--------------------------------------------------------------------------- +// wxHyperlinkCtrlXmlHandler +//--------------------------------------------------------------------------- + +// Register with wxWindows' dynamic class subsystem. +IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkCtrlXmlHandler, wxXmlResourceHandler) + +wxHyperlinkCtrlXmlHandler::wxHyperlinkCtrlXmlHandler() +{ + AddWindowStyles(); +} + +wxObject *wxHyperlinkCtrlXmlHandler::DoCreateResource() +{ + XRC_MAKE_INSTANCE(control, wxHyperlinkCtrl) + + SetupWindow(control); + control->Create(m_parentAsWindow, GetID(), + GetParamValue(wxT("label")), GetParamValue(wxT("url")), + GetPosition(), GetSize(), GetStyle()); + + return control; +} + +bool wxHyperlinkCtrlXmlHandler::CanHandle(wxXmlNode *node) +{ + return IsOfClass(node, wxT("wxHyperlinkCtrl")); +} + +#endif // wxUSE_HYPERLINKCTRL diff --git a/src/xrc/xmlrsall.cpp b/src/xrc/xmlrsall.cpp index df66f1d675..3d2aa269bf 100644 --- a/src/xrc/xmlrsall.cpp +++ b/src/xrc/xmlrsall.cpp @@ -121,6 +121,9 @@ void wxXmlResource::InitAllHandlers() #if wxUSE_GRID AddHandler( new wxGridXmlHandler); #endif +#if wxUSE_HYPERLINKCTRL + AddHandler( new wxHyperlinkCtrlXmlHandler); +#endif } #endif // wxUSE_XRC -- 2.45.2