]> git.saurik.com Git - wxWidgets.git/blob - src/common/clipcmn.cpp
09a62dc49664e49fb3dfef7d0cb7352f0d324e1a
[wxWidgets.git] / src / common / clipcmn.cpp
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 // RCS-ID: $Id$
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_CLIPBOARD
28
29 #include "wx/clipbrd.h"
30
31 #ifndef WX_PRECOMP
32 #include "wx/dataobj.h"
33 #include "wx/module.h"
34 #endif
35
36 // ---------------------------------------------------------
37 // wxClipboardEvent
38 // ---------------------------------------------------------
39
40 IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent,wxEvent)
41
42 DEFINE_EVENT_TYPE(wxEVT_CLIPBOARD_CHANGED)
43
44 bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const
45 {
46 wxVector<wxDataFormat>::size_type n;
47 for (n = 0; n < m_formats.size(); n++)
48 { if (m_formats[n] == format) return true; }
49 return false;
50 }
51
52 void wxClipboardEvent::AddFormat( const wxDataFormat &format )
53 {
54 m_formats.push_back( format );
55 }
56
57 // ---------------------------------------------------------
58 // wxClipboardBase
59 // ---------------------------------------------------------
60
61 static wxClipboard *gs_clipboard = NULL;
62
63 /*static*/ wxClipboard *wxClipboardBase::Get()
64 {
65 if ( !gs_clipboard )
66 {
67 gs_clipboard = new wxClipboard;
68 }
69 return gs_clipboard;
70 }
71
72 // ----------------------------------------------------------------------------
73 // wxClipboardModule: module responsible for destroying the global clipboard
74 // object
75 // ----------------------------------------------------------------------------
76
77 class wxClipboardModule : public wxModule
78 {
79 public:
80 bool OnInit() { return true; }
81 void OnExit() { wxDELETE(gs_clipboard); }
82
83 private:
84 DECLARE_DYNAMIC_CLASS(wxClipboardModule)
85 };
86
87 IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule)
88
89 #endif // wxUSE_CLIPBOARD