]>
git.saurik.com Git - wxWidgets.git/blob - src/common/clipcmn.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/clipcmn.cpp
3 // Purpose: common (to all ports) wxClipboard functions
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/clipbrd.h"
32 #include "wx/dataobj.h"
33 #include "wx/module.h"
36 // ---------------------------------------------------------
38 // ---------------------------------------------------------
40 IMPLEMENT_DYNAMIC_CLASS(wxClipboardEvent
,wxEvent
)
42 DEFINE_EVENT_TYPE(wxEVT_CLIPBOARD_CHANGED
)
44 bool wxClipboardEvent::SupportsFormat( const wxDataFormat
&format
) const
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.
50 wxVector
<wxDataFormat
>::size_type n
;
51 for (n
= 0; n
< m_formats
.size(); n
++)
52 { if (m_formats
[n
] == format
) return true; }
55 // All other ports just query the clipboard directly
57 wxClipboard
* clipboard
= (wxClipboard
*) GetEventObject();
58 return clipboard
->IsSupported( format
);
62 void wxClipboardEvent::AddFormat( const wxDataFormat
&format
)
64 m_formats
.push_back( format
);
67 // ---------------------------------------------------------
69 // ---------------------------------------------------------
71 static wxClipboard
*gs_clipboard
= NULL
;
73 /*static*/ wxClipboard
*wxClipboardBase::Get()
77 gs_clipboard
= new wxClipboard
;
82 bool wxClipboardBase::IsSupportedAsync( wxEvtHandler
*sink
)
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 );
89 sink
->QueueEvent( event
);
95 // ----------------------------------------------------------------------------
96 // wxClipboardModule: module responsible for destroying the global clipboard
98 // ----------------------------------------------------------------------------
100 class wxClipboardModule
: public wxModule
103 bool OnInit() { return true; }
104 void OnExit() { wxDELETE(gs_clipboard
); }
107 DECLARE_DYNAMIC_CLASS(wxClipboardModule
)
110 IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule
, wxModule
)
112 #endif // wxUSE_CLIPBOARD