]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/clipcmn.cpp
Applied #15375 to stop event-sending in generic wxSpinCtrl ctor (eco)
[wxWidgets.git] / src / common / clipcmn.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/clipcmn.cpp
3// Purpose: common (to all ports) wxClipboard functions
4// Author: Robert Roebling
5// Modified by:
6// Created: 28.06.99
7// Copyright: (c) Robert Roebling
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_CLIPBOARD
27
28#include "wx/clipbrd.h"
29
30#ifndef WX_PRECOMP
31 #include "wx/dataobj.h"
32 #include "wx/module.h"
33#endif
34
35// ---------------------------------------------------------
36// wxClipboardEvent
37// ---------------------------------------------------------
38
39IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent,wxEvent)
40
41wxDEFINE_EVENT( wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent );
42
43bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const
44{
45#ifdef __WXGTK20__
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
52 return false;
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
59}
60
61void wxClipboardEvent::AddFormat(const wxDataFormat& format)
62{
63 m_formats.push_back( format );
64}
65
66// ---------------------------------------------------------
67// wxClipboardBase
68// ---------------------------------------------------------
69
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
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 );
87
88 sink->QueueEvent( event );
89
90 return true;
91}
92
93
94// ----------------------------------------------------------------------------
95// wxClipboardModule: module responsible for destroying the global clipboard
96// object
97// ----------------------------------------------------------------------------
98
99class wxClipboardModule : public wxModule
100{
101public:
102 bool OnInit() { return true; }
103 void OnExit() { wxDELETE(gs_clipboard); }
104
105private:
106 DECLARE_DYNAMIC_CLASS(wxClipboardModule)
107};
108
109IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule)
110
111#endif // wxUSE_CLIPBOARD