\latexignore{\rtfignore{\wxheading{Members}}}
+
\membersection{wxClipboard::wxClipboard}\label{wxclipboardctor}
\func{}{wxClipboard}{\void}
Constructor.
+
\membersection{wxClipboard::\destruct{wxClipboard}}\label{wxclipboarddtor}
\func{}{\destruct{wxClipboard}}{\void}
Destructor.
+
\membersection{wxClipboard::AddData}\label{wxclipboardadddata}
\func{bool}{AddData}{\param{wxDataObject*}{ data}}
\helpref{wxClipboard::SetData}{wxclipboardsetdata}
+
\membersection{wxClipboard::Clear}\label{wxclipboardclear}
\func{void}{Clear}{\void}
Clears the global clipboard object and the system's clipboard if possible.
+
\membersection{wxClipboard::Close}\label{wxclipboardclose}
\func{void}{Close}{\void}
Call this function to close the clipboard, having opened it with \helpref{wxClipboard::Open}{wxclipboardopen}.
+
\membersection{wxClipboard::Flush}\label{wxclipboardflush}
\func{bool}{Flush}{\void}
eating memory), otherwise the clipboard will be emptied on exit.
Returns false if the operation is unsuccessful for any reason.
+
\membersection{wxClipboard::GetData}\label{wxclipboardgetdata}
\func{bool}{GetData}{\param{wxDataObject\&}{ data}}
Call this function to fill {\it data} with data on the clipboard, if available in the required
format. Returns true on success.
+
\membersection{wxClipboard::IsOpened}\label{wxclipboardisopened}
\constfunc{bool}{IsOpened}{\void}
Returns true if the clipboard has been opened.
+
\membersection{wxClipboard::IsSupported}\label{wxclipboardissupported}
\func{bool}{IsSupported}{\param{const wxDataFormat\&}{ format}}
Returns true if there is data which matches the data format of the given data object currently {\bf available} (IsSupported sounds like a misnomer, FIXME: better deprecate this name?) on the clipboard.
+
+\membersection{wxClipboard::IsUsingPrimarySelection}\label{wxclipboardisusingprimaryselection}
+
+\constfunc{bool}{IsUsingPrimarySelection}{\void}
+
+Returns \true if we are using the primary selection, \false if clipboard one.
+See \helpref{UsePrimarySelection}{wxclipboarduseprimary} for more information.
+
+
\membersection{wxClipboard::Open}\label{wxclipboardopen}
\func{bool}{Open}{\void}
Returns true on success. This should be tested (as in the sample shown above).
+
\membersection{wxClipboard::SetData}\label{wxclipboardsetdata}
\func{bool}{SetData}{\param{wxDataObject*}{ data}}
\helpref{wxClipboard::AddData}{wxclipboardadddata}
+
\membersection{wxClipboard::UsePrimarySelection}\label{wxclipboarduseprimary}
\func{void}{UsePrimarySelection}{\param{bool}{ primary = true}}
-On platforms supporting it (currently only GTK), selects the so called
-PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
-if {\it primary} is true.
-
+On platforms supporting it (all X11-based ports), wxClipboard uses the
+CLIPBOARD X11 selection by default. When this function is called with \true
+argument, all subsequent clipboard operations will use PRIMARY selection until
+this function is called again with \false.
+
+On the other platforms, there is no PRIMARY selection and so all clipboard
+operations will fail. This allows to implement the standard X11 handling of the
+clipboard which consists in copying data to the CLIPBOARD selection only when
+the user explicitly requests it (i.e. by selection \texttt{"Copy"} menu
+command) but putting the currently selected text into the PRIMARY selection
+automatically, without overwriting the normal clipboard contents with the
+currently selected text on the other platforms.
class WXDLLEXPORT wxClipboardBase : public wxObject
{
public:
- wxClipboardBase() {}
+ wxClipboardBase() { m_usePrimary = false; }
// open the clipboard before Add/SetData() and GetData()
virtual bool Open() = 0;
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush() { return false; }
- // X11 has two clipboards which get selected by this call. Empty on MSW.
- virtual void UsePrimarySelection( bool WXUNUSED(primary) = false ) { }
+ // this allows to choose whether we work with CLIPBOARD (default) or
+ // PRIMARY selection on X11-based systems
+ //
+ // on the other ones, working with primary selection does nothing: this
+ // allows to write code which sets the primary selection when something is
+ // selected without any ill effects (i.e. without overwriting the
+ // clipboard which would be wrong on the platforms without X11 PRIMARY)
+ virtual void UsePrimarySelection(bool usePrimary = false)
+ {
+ m_usePrimary = usePrimary;
+ }
+
+ // return true if we're using primary selection
+ bool IsUsingPrimarySelection() const { return m_usePrimary; }
// Returns global instance (wxTheClipboard) of the object:
static wxClipboard *Get();
+
+
+ // don't use this directly, it is public for compatibility with some ports
+ // (wxX11, wxMotif, ...) only
+ bool m_usePrimary;
};
// ----------------------------------------------------------------------------
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
- // If primary == TRUE, use primary selection in all further ops,
- // primary == FALSE resets it.
- virtual void UsePrimarySelection(bool primary = TRUE)
- { m_usePrimary = primary; }
-
+
// implementation from now on
// --------------------------
GtkWidget *m_targetsWidget; // for getting list of supported formats
bool m_open;
- bool m_usePrimary;
bool m_formatSupported;
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
- // If primary == TRUE, use primary selection in all further ops,
- // primary == FALSE resets it.
- virtual void UsePrimarySelection(bool primary = TRUE)
- { m_usePrimary = primary; }
-
// implementation from now on
bool m_open;
bool m_ownsClipboard;
bool m_formatSupported;
GdkAtom m_targetRequested;
- bool m_usePrimary;
wxDataObject *m_receivedData;
private:
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush();
- // X11 has two clipboards which get selected by this call. Empty on MSW.
- void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
-
private:
wxDataObject *m_data;
bool m_open;
#endif // wxUSE_CLIPBOARD
-#endif
- // _WX_CLIPBRD_H_
+#endif // _WX_CLIPBRD_H_
/////////////////////////////////////////////////////////////////////////////
-// Name: clipboard.h
+// Name: wx/mgl/clipboard.h
// Purpose:
// Author: Vaclav Slavik
// Id: $Id$
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear() {}
- // If primary == TRUE, use primary selection in all further ops,
- // primary == FALSE resets it.
- virtual void UsePrimarySelection(bool primary = TRUE)
- { m_usePrimary = primary; }
-
// implementation from now on
bool m_open;
bool m_ownsClipboard;
bool m_formatSupported;
GdkAtom m_targetRequested;
- bool m_usePrimary;
wxDataObject *m_receivedData;
private:
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
- virtual void UsePrimarySelection(bool primary = true)
- { m_usePrimary = primary; }
-
// implementation from now on
bool m_open;
wxDataObjectList m_data;
- bool m_usePrimary;
wxDataIdToDataObjectList m_idToObject;
private:
#endif // wxUSE_CLIPBOARD
-#endif
-// _WX_CLIPBRD_H_
+#endif // _WX_CLIPBRD_H_
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush();
- // X11 has two clipboards which get selected by this call. Empty on MSW.
- void UsePrimarySelection( bool WXUNUSED(primary) = false ) { }
-
private:
IDataObject *m_lastDataObject;
bool m_isOpened;
};
#endif // wxUSE_CLIPBOARD
-#endif
- // _WX_CLIPBRD_H_
+
+#endif // _WX_CLIPBRD_H_
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush();
- // X11 has two clipboards which get selected by this call. Empty on MSW.
- void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
-
private:
bool m_clearOnExit;
};
#endif // wxUSE_CLIPBOARD
-#endif
- // _WX_CLIPBRD_H_
+#endif // _WX_CLIPBRD_H_
// eating memory), otherwise the clipboard will be emptied on exit
virtual bool Flush();
- // X11 has two clipboards which get selected by this call. Empty on MSW.
- void UsePrimarySelection( bool WXUNUSED(primary) = FALSE ) { }
-
private:
bool m_clearOnExit;
bool m_isOpened;
/////////////////////////////////////////////////////////////////////////////
-// Name: clipbrd.h
+// Name: wx/x11/clipbrd.h
// Purpose: Clipboard functionality.
// Author: Robert Roebling
// Created: 17/09/98
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifndef __X11CLIPBOARDH__
-#define __X11CLIPBOARDH__
+#ifndef _WX_X11_CLIPBRD_H_
+#define _WX_X11_CLIPBRD_H_
#if wxUSE_CLIPBOARD
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
- // If primary == TRUE, use primary selection in all further ops,
- // primary == FALSE resets it.
- virtual void UsePrimarySelection(bool primary = TRUE)
- { m_usePrimary = primary; }
-
// implementation from now on
bool m_open;
bool m_ownsClipboard;
bool m_formatSupported;
Atom m_targetRequested;
- bool m_usePrimary;
wxDataObject *m_receivedData;
private:
DECLARE_DYNAMIC_CLASS(wxClipboard)
};
-#endif
- // wxUSE_CLIPBOARD
+#endif // wxUSE_CLIPBOARD
-#endif
- // __X11CLIPBOARDH__
+#endif // _WX_X11_CLIPBRD_H_
m_formatSupported = false;
m_targetRequested = 0;
- m_usePrimary = false;
-
// we use m_targetsWidget to query what formats are available
m_targetsWidget = gtk_window_new( GTK_WINDOW_POPUP );
gtk_widget_realize( m_targetsWidget );
m_formatSupported = false;
m_targetRequested = 0;
-
- m_usePrimary = false;
}
wxClipboard::~wxClipboard()
void wxClipboard::Clear()
{
+ if ( IsUsingPrimarySelection() )
+ return;
+
if (m_data != NULL)
{
delete m_data;
bool wxClipboard::SetData( wxDataObject *data )
{
+ if ( IsUsingPrimarySelection() )
+ return false;
+
wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
wxCHECK_MSG( data, false, wxT("data is invalid") );
bool wxClipboard::AddData( wxDataObject *data )
{
+ if ( IsUsingPrimarySelection() )
+ return false;
+
wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
wxCHECK_MSG( data, false, wxT("data is invalid") );
bool wxClipboard::IsSupported( const wxDataFormat &dataFormat )
{
+ if ( IsUsingPrimarySelection() )
+ return false;
+
if ( m_data )
return m_data->IsSupported( dataFormat );
bool wxClipboard::GetData( wxDataObject& data )
{
+ if ( IsUsingPrimarySelection() )
+ return false;
+
wxCHECK_MSG( m_open, false, wxT("clipboard not open") );
size_t formatcount = data.GetFormatCount() + 1;
void wxClipboard::Clear()
{
+ if ( IsUsingPrimarySelection() )
+ return;
+
#if wxUSE_OLE_CLIPBOARD
if (m_lastDataObject)
{
bool wxClipboard::SetData( wxDataObject *data )
{
+ if ( IsUsingPrimarySelection() )
+ return false;
+
#if !wxUSE_OLE_CLIPBOARD
(void)wxEmptyClipboard();
#endif // wxUSE_OLE_CLIPBOARD
bool wxClipboard::AddData( wxDataObject *data )
{
+ if ( IsUsingPrimarySelection() )
+ return false;
+
wxCHECK_MSG( data, false, wxT("data is invalid") );
#if wxUSE_OLE_CLIPBOARD
bool wxClipboard::IsSupported( const wxDataFormat& format )
{
- return wxIsClipboardFormatAvailable(format);
+ return !IsUsingPrimarySelection() && wxIsClipboardFormatAvailable(format);
}
bool wxClipboard::GetData( wxDataObject& data )
{
+ if ( IsUsingPrimarySelection() )
+ return false;
+
#if wxUSE_OLE_CLIPBOARD
IDataObject *pDataObject = NULL;
HRESULT hr = OleGetClipboard(&pDataObject);
m_formatSupported = false;
m_targetRequested = 0;
-
- m_usePrimary = false;
}
wxClipboard::~wxClipboard()