]> git.saurik.com Git - wxWidgets.git/blame - src/common/clipcmn.cpp
really fix handling of trailing periods in abbreviated month names in French locale...
[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
7// RCS-ID: $Id$
8// Copyright: (c) Robert Roebling
65571936 9// Licence: wxWindows licence
b068c4e8
RR
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
b068c4e8
RR
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
24 #pragma hdrstop
25#endif
26
02761f6c
WS
27#if wxUSE_CLIPBOARD
28
b068c4e8
RR
29#include "wx/clipbrd.h"
30
02761f6c 31#ifndef WX_PRECOMP
01fc4932 32 #include "wx/dataobj.h"
02761f6c
WS
33 #include "wx/module.h"
34#endif
41b1047d 35
c220de0b
RR
36// ---------------------------------------------------------
37// wxClipboardEvent
38// ---------------------------------------------------------
39
40IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent,wxEvent)
41
9b11752c 42wxDEFINE_EVENT( wxEVT_CLIPBOARD_CHANGED, wxClipboardEvent );
c220de0b 43
8946ede1
VZ
44// notice that ctors are defined here and not inline to avoid having to include
45// wx/dataobj.h from wx/clipbrd.h
46wxClipboardEvent::wxClipboardEvent(wxEventType evtType)
47 : wxEvent(0, evtType)
48{
49}
50
51wxClipboardEvent::wxClipboardEvent(const wxClipboardEvent& event)
52 : wxEvent(event),
53 m_formats(event.m_formats)
54{
55}
56
8d3166e8
PC
57wxEvent* wxClipboardEvent::Clone() const
58{
59 return new wxClipboardEvent(*this);
60}
61
c220de0b 62bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const
8946ede1 63{
311c1be9 64#ifdef __WXGTK20__
8946ede1
VZ
65 // GTK has an asynchronous API which reports the supported formats one by
66 // one. We may have to add X11 and Motif later.
67 for (wxVector<wxDataFormat>::size_type n = 0; n < m_formats.size(); n++)
68 {
69 if (m_formats[n] == format)
70 return true;
71 }
72
c220de0b 73 return false;
311c1be9
RR
74#else
75 // All other ports just query the clipboard directly
76 // from here
77 wxClipboard* clipboard = (wxClipboard*) GetEventObject();
78 return clipboard->IsSupported( format );
79#endif
8946ede1
VZ
80}
81
82void wxClipboardEvent::AddFormat(const wxDataFormat& format)
83{
c220de0b
RR
84 m_formats.push_back( format );
85}
86
87// ---------------------------------------------------------
88// wxClipboardBase
89// ---------------------------------------------------------
90
5dc43d1f
VS
91static wxClipboard *gs_clipboard = NULL;
92
93/*static*/ wxClipboard *wxClipboardBase::Get()
94{
95 if ( !gs_clipboard )
96 {
97 gs_clipboard = new wxClipboard;
98 }
99 return gs_clipboard;
100}
101
311c1be9
RR
102bool wxClipboardBase::IsSupportedAsync( wxEvtHandler *sink )
103{
104 // We just imitate an asynchronous API on most platforms.
105 // This method is overridden uner GTK.
106 wxClipboardEvent *event = new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED);
107 event->SetEventObject( this );
8946ede1 108
311c1be9 109 sink->QueueEvent( event );
8946ede1 110
311c1be9
RR
111 return true;
112}
113
114
b068c4e8 115// ----------------------------------------------------------------------------
5dc43d1f 116// wxClipboardModule: module responsible for destroying the global clipboard
b068c4e8 117// object
b068c4e8
RR
118// ----------------------------------------------------------------------------
119
120class wxClipboardModule : public wxModule
121{
122public:
5dc43d1f
VS
123 bool OnInit() { return true; }
124 void OnExit() { wxDELETE(gs_clipboard); }
b068c4e8
RR
125
126private:
127 DECLARE_DYNAMIC_CLASS(wxClipboardModule)
128};
129
d54598dd 130IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule)
8ee9d618 131
41b1047d 132#endif // wxUSE_CLIPBOARD