// close the clipboard after Add/SetData() and GetData()
virtual void Close() = 0;
+ // query whether the clipboard is opened
+ virtual bool IsOpened() const = 0;
+
// add to the clipboard data
//
// NB: the clipboard owns the pointer and will delete it, so data must be
// The global clipboard object
WXDLLEXPORT_DATA(extern wxClipboard *) wxTheClipboard;
+// ----------------------------------------------------------------------------
+// helpful class for opening the clipboard and automatically closing it
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxClipboardLocker
+{
+public:
+ wxClipboardLocker(wxClipboard *clipboard = (wxClipboard *)NULL)
+ {
+ m_clipboard = clipboard ? clipboard : wxTheClipboard;
+ if ( m_clipboard )
+ {
+ m_clipboard->Open();
+ }
+ }
+
+ bool IsOk() const { return m_clipboard->IsOpened(); }
+
+ ~wxClipboardLocker()
+ {
+ if ( m_clipboard )
+ {
+ m_clipboard->Close();
+ }
+ }
+
+private:
+ wxClipboard *m_clipboard;
+};
+
#endif // wxUSE_CLIPBOARD
#endif // _WX_CLIPBRD_H_BASE_
// close the clipboard after SetData() and GetData()
virtual void Close();
+ // query whether the clipboard is opened
+ virtual bool IsOpened() const;
+
// set the clipboard data. all other formats will be deleted.
virtual bool SetData( wxDataObject *data );
// close the clipboard after SetData() and GetData()
virtual void Close();
+ // query whether the clipboard is opened
+ virtual bool IsOpened() const;
+
// set the clipboard data. all other formats will be deleted.
virtual bool SetData( wxDataObject *data );
// close the clipboard after SetData() and GetData()
virtual void Close();
+ // query whether the clipboard is opened
+ virtual bool IsOpened() const;
+
// set the clipboard data. all other formats will be deleted.
virtual bool SetData( wxDataObject *data );
m_open = FALSE;
}
+bool wxClipboard::IsOpened() const
+{
+ return m_open;
+}
+
bool wxClipboard::IsSupported( const wxDataFormat& format )
{
/* store requested format to be asked for by callbacks */
m_open = FALSE;
}
+bool wxClipboard::IsOpened() const
+{
+ return m_open;
+}
+
bool wxClipboard::IsSupported( const wxDataFormat& format )
{
/* store requested format to be asked for by callbacks */
#endif
}
+bool wxClipboard::IsOpened() const
+{
+#if wxUSE_OLE_CLIPBOARD
+ return TRUE;
+#else
+ return wxIsClipboardOpened();
+#endif
+}
+
bool wxClipboard::SetData( wxDataObject *data )
{
(void)wxEmptyClipboard();