wxClipboard::IsOpened() and wxCLipboardLocker helper class added
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4105 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -46,6 +46,9 @@ public:
|
||||
// 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
|
||||
@@ -102,6 +105,36 @@ public:
|
||||
// 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_
|
||||
|
@@ -39,6 +39,9 @@ public:
|
||||
// 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 );
|
||||
|
||||
|
@@ -39,6 +39,9 @@ public:
|
||||
// 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 );
|
||||
|
||||
|
@@ -66,6 +66,9 @@ public:
|
||||
// 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 );
|
||||
|
||||
|
@@ -544,6 +544,11 @@ void wxClipboard::Close()
|
||||
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 */
|
||||
|
@@ -544,6 +544,11 @@ void wxClipboard::Close()
|
||||
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 */
|
||||
|
@@ -474,6 +474,15 @@ bool wxClipboard::Open()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxClipboard::IsOpened() const
|
||||
{
|
||||
#if wxUSE_OLE_CLIPBOARD
|
||||
return TRUE;
|
||||
#else
|
||||
return wxIsClipboardOpened();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wxClipboard::SetData( wxDataObject *data )
|
||||
{
|
||||
(void)wxEmptyClipboard();
|
||||
|
Reference in New Issue
Block a user