]>
Commit | Line | Data |
---|---|---|
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 | ||
40 | IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent,wxEvent) | |
41 | ||
42 | DEFINE_EVENT_TYPE(wxEVT_CLIPBOARD_CHANGED) | |
43 | ||
44 | bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const | |
45 | { | |
311c1be9 RR |
46 | #ifdef __WXGTK20__ |
47 | // GTK has an asynchronnous API which reports | |
48 | // the supported formats one by one. | |
49 | // We may have to add X11 and Motif later. | |
c220de0b RR |
50 | wxVector<wxDataFormat>::size_type n; |
51 | for (n = 0; n < m_formats.size(); n++) | |
52 | { if (m_formats[n] == format) return true; } | |
53 | return false; | |
311c1be9 RR |
54 | #else |
55 | // All other ports just query the clipboard directly | |
56 | // from here | |
57 | wxClipboard* clipboard = (wxClipboard*) GetEventObject(); | |
58 | return clipboard->IsSupported( format ); | |
59 | #endif | |
c220de0b RR |
60 | } |
61 | ||
62 | void wxClipboardEvent::AddFormat( const wxDataFormat &format ) | |
63 | { | |
64 | m_formats.push_back( format ); | |
65 | } | |
66 | ||
67 | // --------------------------------------------------------- | |
68 | // wxClipboardBase | |
69 | // --------------------------------------------------------- | |
70 | ||
5dc43d1f VS |
71 | static wxClipboard *gs_clipboard = NULL; |
72 | ||
73 | /*static*/ wxClipboard *wxClipboardBase::Get() | |
74 | { | |
75 | if ( !gs_clipboard ) | |
76 | { | |
77 | gs_clipboard = new wxClipboard; | |
78 | } | |
79 | return gs_clipboard; | |
80 | } | |
81 | ||
311c1be9 RR |
82 | bool wxClipboardBase::IsSupportedAsync( wxEvtHandler *sink ) |
83 | { | |
84 | // We just imitate an asynchronous API on most platforms. | |
85 | // This method is overridden uner GTK. | |
86 | wxClipboardEvent *event = new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED); | |
87 | event->SetEventObject( this ); | |
88 | ||
89 | sink->QueueEvent( event ); | |
90 | ||
91 | return true; | |
92 | } | |
93 | ||
94 | ||
b068c4e8 | 95 | // ---------------------------------------------------------------------------- |
5dc43d1f | 96 | // wxClipboardModule: module responsible for destroying the global clipboard |
b068c4e8 | 97 | // object |
b068c4e8 RR |
98 | // ---------------------------------------------------------------------------- |
99 | ||
100 | class wxClipboardModule : public wxModule | |
101 | { | |
102 | public: | |
5dc43d1f VS |
103 | bool OnInit() { return true; } |
104 | void OnExit() { wxDELETE(gs_clipboard); } | |
b068c4e8 RR |
105 | |
106 | private: | |
107 | DECLARE_DYNAMIC_CLASS(wxClipboardModule) | |
108 | }; | |
109 | ||
d54598dd | 110 | IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule, wxModule) |
8ee9d618 | 111 | |
41b1047d | 112 | #endif // wxUSE_CLIPBOARD |