/////////////////////////////////////////////////////////////////////////////
-// Name: hyperlink.cpp
+// Name: src/generic/hyperlink.cpp
// Purpose: Hyperlink control
// Author: David Norris <danorris@gmail.com>, Otto Wyss
// Modified by: Ryan Norton, Francesco Montorsi
// 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
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));
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