]> git.saurik.com Git - wxWidgets.git/blame - src/common/clipcmn.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[wxWidgets.git] / src / common / clipcmn.cpp
CommitLineData
b068c4e8 1/////////////////////////////////////////////////////////////////////////////
02761f6c 2// Name: src/common/clipcmn.cpp
b068c4e8
RR
3// Purpose: common (to all ports) wxClipboard functions
4// Author: Robert Roebling
5// Modified by:
6// Created: 28.06.99
b068c4e8 7// Copyright: (c) Robert Roebling
65571936 8// Licence: wxWindows licence
b068c4e8
RR
9/////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
b068c4e8
RR
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
02761f6c
WS
26#if wxUSE_CLIPBOARD
27
b068c4e8
RR
28#include "wx/clipbrd.h"
29
02761f6c 30#ifndef WX_PRECOMP
01fc4932 31 #include "wx/dataobj.h"
02761f6c
WS
32 #include "wx/module.h"
33#endif
41b1047d 34
c220de0b
RR
35// ---------------------------------------------------------
36// wxClipboardEvent
37// ---------------------------------------------------------
38
39IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent,wxEvent)
40
9b11752c 41wxDEFINE_EVENT( wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent );
c220de0b
RR
42
43bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const
8946ede1 44{
311c1be9 45#ifdef __WXGTK20__
8946ede1
VZ
46 for (wxVector<wxDataFormat>::size_type n = 0; n < m_formats.size(); n++)
47 {
48 if (m_formats[n] == format)
49 return true;
50 }
51
c220de0b 52 return false;
311c1be9
RR
53#else
54 // All other ports just query the clipboard directly
55 // from here
56 wxClipboard* clipboard = (wxClipboard*) GetEventObject();
57 return clipboard->IsSupported( format );
58#endif
8946ede1
VZ
59}
60
61void wxClipboardEvent::AddFormat(const wxDataFormat& format)
62{
c220de0b
RR
63 m_formats.push_back( format );
64}
65
66// ---------------------------------------------------------
67// wxClipboardBase
68// ---------------------------------------------------------
69
5dc43d1f
VS
70static wxClipboard *gs_clipboard = NULL;
71
72/*static*/ wxClipboard *wxClipboardBase::Get()
73{
74 if ( !gs_clipboard )
75 {
76 gs_clipboard = new wxClipboard;
77 }
78 return gs_clipboard;
79}
80
311c1be9
RR
81bool wxClipboardBase::IsSupportedAsync( wxEvtHandler *sink )
82{
83 // We just imitate an asynchronous API on most platforms.
84 // This method is overridden uner GTK.
85 wxClipboardEvent *event = new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED);
86 event->SetEventObject( this );
8946ede1 87
311c1be9 88 sink->QueueEvent( event );
8946ede1 89
311c1be9
RR
90 return true;
91}
92
93
b068c4e8 94// ----------------------------------------------------------------------------
5dc43d1f 95// wxClipboardModule: module responsible for destroying the global clipboard
b068c4e8 96// object
b068c4e8
RR
97// ----------------------------------------------------------------------------
98
99class wxClipboardModule : public wxModule
100{
101public:
5dc43d1f
VS
102 bool OnInit() { return true; }
103 void OnExit() { wxDELETE(gs_clipboard); }
b068c4e8
RR
104
105private:
106 DECLARE_DYNAMIC_CLASS(wxClipboardModule)
107};
108
d54598dd 109IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule)
8ee9d618 110
41b1047d 111#endif // wxUSE_CLIPBOARD