]>
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 wxEvent
* wxClipboardEvent::Clone() const
59 return new wxClipboardEvent(*this);
62 bool wxClipboardEvent::SupportsFormat( const wxDataFormat
&format
) const
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
++)
69 if (m_formats
[n
] == format
)
75 // All other ports just query the clipboard directly
77 wxClipboard
* clipboard
= (wxClipboard
*) GetEventObject();
78 return clipboard
->IsSupported( format
);
82 void wxClipboardEvent::AddFormat(const wxDataFormat
& format
)
84 m_formats
.push_back( format
);
87 // ---------------------------------------------------------
89 // ---------------------------------------------------------
91 static wxClipboard
*gs_clipboard
= NULL
;
93 /*static*/ wxClipboard
*wxClipboardBase::Get()
97 gs_clipboard
= new wxClipboard
;
102 bool wxClipboardBase::IsSupportedAsync( wxEvtHandler
*sink
)
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 );
109 sink
->QueueEvent( event
);
115 // ----------------------------------------------------------------------------
116 // wxClipboardModule: module responsible for destroying the global clipboard
118 // ----------------------------------------------------------------------------
120 class wxClipboardModule
: public wxModule
123 bool OnInit() { return true; }
124 void OnExit() { wxDELETE(gs_clipboard
); }
127 DECLARE_DYNAMIC_CLASS(wxClipboardModule
)
130 IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule
, wxModule
)
132 #endif // wxUSE_CLIPBOARD