X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17e914373a348a6c1f432d06ecab0bced95773ac..a87f2821adee59d00f99cad1f9bcf61b0accbcb6:/src/generic/hyperlink.cpp?ds=inline diff --git a/src/generic/hyperlink.cpp b/src/generic/hyperlink.cpp index 6f078ca9fe..fb245d32b2 100644 --- a/src/generic/hyperlink.cpp +++ b/src/generic/hyperlink.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: hyperlink.cpp +// Name: src/generic/hyperlink.cpp // Purpose: Hyperlink control // Author: David Norris , Otto Wyss // Modified by: Ryan Norton, Francesco Montorsi @@ -17,33 +17,37 @@ // 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 + #pragma hdrstop #endif +#if wxUSE_HYPERLINKCTRL + //--------------------------------------------------------------------------- // Includes //--------------------------------------------------------------------------- #include "wx/hyperlink.h" -#include "wx/utils.h" // for wxLaunchDefaultBrowser -#include "wx/clipbrd.h" +#ifndef WX_PRECOMP + #include "wx/utils.h" // for wxLaunchDefaultBrowser + #include "wx/dcclient.h" + #include "wx/menu.h" + #include "wx/log.h" + #include "wx/dataobj.h" +#endif -#if wxUSE_HYPERLINKCTRL +#include "wx/clipbrd.h" // ============================================================================ // implementation // ============================================================================ IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkCtrl, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxHyperlinkEvent, wxCommandEvent) DEFINE_EVENT_TYPE(wxEVT_COMMAND_HYPERLINK) // reserved for internal use only @@ -69,15 +73,22 @@ 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(), + wxASSERT_MSG(!url.empty() || !label.empty(), 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); + if(url.empty()) + SetURL(label); + else + SetURL(url); + + if(label.empty()) + SetLabel(url); + else + SetLabel(label); // by default the cursor to use in this window is wxCURSOR_HAND SetCursor(wxCursor(wxCURSOR_HAND)); @@ -208,12 +219,14 @@ void wxHyperlinkCtrl::OnLeaveWindow(wxMouseEvent& WXUNUSED(event)) void wxHyperlinkCtrl::OnPopUpCopy( wxCommandEvent& WXUNUSED(event) ) { +#if wxUSE_CLIPBOARD if (!wxTheClipboard->Open()) return; wxTextDataObject *data = new wxTextDataObject( m_url ); wxTheClipboard->SetData( data ); wxTheClipboard->Close(); +#endif // wxUSE_CLIPBOARD } #endif // wxUSE_HYPERLINKCTRL