]>
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 wxDEFINE_EVENT( wxEVT_CLIPBOARD_CHANGED
, wxClipboardEvent
)
44 // notice that ctors are defined here and not inline to avoid having to include
45 // wx/dataobj.h from wx/clipbrd.h
46 wxClipboardEvent::wxClipboardEvent(wxEventType evtType
)
51 wxClipboardEvent::wxClipboardEvent(const wxClipboardEvent
& event
)
53 m_formats(event
.m_formats
)
57 bool wxClipboardEvent::SupportsFormat( const wxDataFormat
&format
) const
60 // GTK has an asynchronous API which reports the supported formats one by
61 // one. We may have to add X11 and Motif later.
62 for (wxVector
<wxDataFormat
>::size_type n
= 0; n
< m_formats
.size(); n
++)
64 if (m_formats
[n
] == format
)
70 // All other ports just query the clipboard directly
72 wxClipboard
* clipboard
= (wxClipboard
*) GetEventObject();
73 return clipboard
->IsSupported( format
);
77 void wxClipboardEvent::AddFormat(const wxDataFormat
& format
)
79 m_formats
.push_back( format
);
82 // ---------------------------------------------------------
84 // ---------------------------------------------------------
86 static wxClipboard
*gs_clipboard
= NULL
;
88 /*static*/ wxClipboard
*wxClipboardBase::Get()
92 gs_clipboard
= new wxClipboard
;
97 bool wxClipboardBase::IsSupportedAsync( wxEvtHandler
*sink
)
99 // We just imitate an asynchronous API on most platforms.
100 // This method is overridden uner GTK.
101 wxClipboardEvent
*event
= new wxClipboardEvent(wxEVT_CLIPBOARD_CHANGED
);
102 event
->SetEventObject( this );
104 sink
->QueueEvent( event
);
110 // ----------------------------------------------------------------------------
111 // wxClipboardModule: module responsible for destroying the global clipboard
113 // ----------------------------------------------------------------------------
115 class wxClipboardModule
: public wxModule
118 bool OnInit() { return true; }
119 void OnExit() { wxDELETE(gs_clipboard
); }
122 DECLARE_DYNAMIC_CLASS(wxClipboardModule
)
125 IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule
, wxModule
)
127 #endif // wxUSE_CLIPBOARD