1999-10-21 10:23:30 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2006-08-31 19:31:43 +00:00
|
|
|
// Name: src/common/clipcmn.cpp
|
1999-10-21 10:23:30 +00:00
|
|
|
// Purpose: common (to all ports) wxClipboard functions
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Modified by:
|
|
|
|
// Created: 28.06.99
|
|
|
|
// Copyright: (c) Robert Roebling
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-10-21 10:23:30 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
2006-08-31 19:31:43 +00:00
|
|
|
#if wxUSE_CLIPBOARD
|
|
|
|
|
1999-10-21 10:23:30 +00:00
|
|
|
#include "wx/clipbrd.h"
|
|
|
|
|
2006-08-31 19:31:43 +00:00
|
|
|
#ifndef WX_PRECOMP
|
2008-12-22 17:11:15 +00:00
|
|
|
#include "wx/dataobj.h"
|
2006-08-31 19:31:43 +00:00
|
|
|
#include "wx/module.h"
|
|
|
|
#endif
|
1999-12-13 16:16:52 +00:00
|
|
|
|
2008-12-21 22:15:50 +00:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxClipboardEvent
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent,wxEvent)
|
|
|
|
|
2009-02-07 18:59:25 +00:00
|
|
|
wxDEFINE_EVENT( wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent );
|
2008-12-21 22:15:50 +00:00
|
|
|
|
|
|
|
bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const
|
2009-01-12 11:56:56 +00:00
|
|
|
{
|
2008-12-23 12:05:06 +00:00
|
|
|
#ifdef __WXGTK20__
|
2009-01-12 11:56:56 +00:00
|
|
|
for (wxVector<wxDataFormat>::size_type n = 0; n < m_formats.size(); n++)
|
|
|
|
{
|
|
|
|
if (m_formats[n] == format)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-12-21 22:15:50 +00:00
|
|
|
return false;
|
2008-12-23 12:05:06 +00:00
|
|
|
#else
|
|
|
|
// All other ports just query the clipboard directly
|
|
|
|
// from here
|
|
|
|
wxClipboard* clipboard = (wxClipboard*) GetEventObject();
|
|
|
|
return clipboard->IsSupported( format );
|
|
|
|
#endif
|
2009-01-12 11:56:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxClipboardEvent::AddFormat(const wxDataFormat& format)
|
|
|
|
{
|
2008-12-21 22:15:50 +00:00
|
|
|
m_formats.push_back( format );
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
// wxClipboardBase
|
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
2004-06-20 17:19:26 +00:00
|
|
|
static wxClipboard *gs_clipboard = NULL;
|
|
|
|
|
|
|
|
/*static*/ wxClipboard *wxClipboardBase::Get()
|
|
|
|
{
|
|
|
|
if ( !gs_clipboard )
|
|
|
|
{
|
|
|
|
gs_clipboard = new wxClipboard;
|
|
|
|
}
|
|
|
|
return gs_clipboard;
|
|
|
|
}
|
|
|
|
|
2008-12-23 12:05:06 +00:00
|
|
|
bool wxClipboardBase::IsSupportedAsync( wxEvtHandler *sink )
|
|
|
|
{
|
|
|
|
// We just imitate an asynchronous API on most platforms.
|
|
|
|
// This method is overridden uner GTK.
|
|
|
|
wxClipboardEvent *event = new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED);
|
|
|
|
event->SetEventObject( this );
|
2009-01-12 11:56:56 +00:00
|
|
|
|
2008-12-23 12:05:06 +00:00
|
|
|
sink->QueueEvent( event );
|
2009-01-12 11:56:56 +00:00
|
|
|
|
2008-12-23 12:05:06 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-21 10:23:30 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
2004-06-20 17:19:26 +00:00
|
|
|
// wxClipboardModule: module responsible for destroying the global clipboard
|
1999-10-21 10:23:30 +00:00
|
|
|
// object
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxClipboardModule : public wxModule
|
|
|
|
{
|
|
|
|
public:
|
2004-06-20 17:19:26 +00:00
|
|
|
bool OnInit() { return true; }
|
|
|
|
void OnExit() { wxDELETE(gs_clipboard); }
|
1999-10-21 10:23:30 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxClipboardModule)
|
|
|
|
};
|
|
|
|
|
1999-10-21 13:40:07 +00:00
|
|
|
IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule)
|
1999-10-23 23:40:55 +00:00
|
|
|
|
1999-12-13 16:16:52 +00:00
|
|
|
#endif // wxUSE_CLIPBOARD
|