1 \section{\class{wxClipboard
}}\label{wxclipboard
}
3 A class for manipulating the clipboard. Note that this is not compatible with the
4 clipboard class from wxWindows
1.xx, which has the same name but a different implementation.
6 To use the clipboard, you call member functions of the global
{\bf wxTheClipboard
} object.
8 See also the
\helpref{wxDataObject overview
}{wxdataobjectoverview
} for further information.
10 Call
\helpref{wxClipboard::Open
}{wxclipboardopen
} to get ownership of the clipboard. If this operation returns true, you
11 now own the clipboard. Call
\helpref{wxClipboard::SetData
}{wxclipboardsetdata
} to put data
12 on the clipboard, or
\helpref{wxClipboard::GetData
}{wxclipboardgetdata
} to
13 retrieve data from the clipboard. Call
\helpref{wxClipboard::Close
}{wxclipboardclose
} to close
14 the clipboard and relinquish ownership. You should keep the clipboard open only momentarily.
19 // Write some text to the clipboard
20 if (wxTheClipboard->Open())
22 // This data objects are held by the clipboard,
23 // so do not delete them in the app.
24 wxTheClipboard->SetData( new wxTextDataObject("Some text") );
25 wxTheClipboard->Close();
29 if (wxTheClipboard->Open())
31 if (wxTheClipboard->IsSupported( wxDF_TEXT ))
33 wxTextDataObject data;
34 wxTheClipboard->GetData( data );
35 wxMessageBox( data.GetText() );
37 wxTheClipboard->Close();
41 \wxheading{Derived from
}
43 \helpref{wxObject
}{wxobject
}
45 \wxheading{Include files
}
51 \helpref{Drag and drop overview
}{wxdndoverview
},
\helpref{wxDataObject
}{wxdataobject
}
53 \latexignore{\rtfignore{\wxheading{Members
}}}
55 \membersection{wxClipboard::wxClipboard
}
57 \func{}{wxClipboard
}{\void}
61 \membersection{wxClipboard::
\destruct{wxClipboard
}}
63 \func{}{\destruct{wxClipboard
}}{\void}
67 \membersection{wxClipboard::AddData
}\label{wxclipboardadddata
}
69 \func{bool
}{AddData
}{\param{wxDataObject*
}{ data
}}
71 Call this function to add the data object to the clipboard. You may call
72 this function repeatedly after having cleared the clipboard using
\helpref{wxClipboard::Clear
}{wxclipboardclear
}.
74 After this function has been called, the clipboard owns the data, so do not delete
79 \helpref{wxClipboard::SetData
}{wxclipboardsetdata
}
81 \membersection{wxClipboard::Clear
}\label{wxclipboardclear
}
83 \func{void
}{Clear
}{\void}
85 Clears the global clipboard object and the system's clipboard if possible.
87 \membersection{wxClipboard::Close
}\label{wxclipboardclose
}
89 \func{bool
}{Close
}{\void}
91 Call this function to close the clipboard, having opened it with
\helpref{wxClipboard::Open
}{wxclipboardopen
}.
93 \membersection{wxClipboard::Flush
}\label{wxclipboardflush
}
95 \func{bool
}{Flush
}{\void}
97 Flushes the clipboard: this means that the data which is currently on
98 clipboard will stay available even after the application exits (possibly
99 eating memory), otherwise the clipboard will be emptied on exit.
100 Returns false if the operation is unsuccesful for any reason.
102 \membersection{wxClipboard::GetData
}\label{wxclipboardgetdata
}
104 \func{bool
}{GetData
}{\param{wxDataObject\&
}{ data
}}
106 Call this function to fill
{\it data
} with data on the clipboard, if available in the required
107 format. Returns true on success.
109 \membersection{wxClipboard::IsOpened
}\label{wxclipboardisopened
}
111 \constfunc{bool
}{IsOpened
}{\void}
113 Returns true if the clipboard has been opened.
115 \membersection{wxClipboard::IsSupported
}\label{wxclipboardissupported
}
117 \func{bool
}{IsSupported
}{\param{const wxDataFormat\&
}{ format
}}
119 Returns true if the format of the given data object is available on the clipboard.
121 \membersection{wxClipboard::Open
}\label{wxclipboardopen
}
123 \func{bool
}{Open
}{\void}
125 Call this function to open the clipboard before calling
\helpref{wxClipboard::SetData
}{wxclipboardsetdata
}
126 and
\helpref{wxClipboard::GetData
}{wxclipboardgetdata
}.
128 Call
\helpref{wxClipboard::Close
}{wxclipboardclose
} when you have finished with the clipboard. You
129 should keep the clipboard open for only a very short time.
131 Returns true on success. This should be tested (as in the sample shown above).
133 \membersection{wxClipboard::SetData
}\label{wxclipboardsetdata
}
135 \func{bool
}{SetData
}{\param{wxDataObject*
}{ data
}}
137 Call this function to set the data object to the clipboard. This function will
138 clear all previous contents in the clipboard, so calling it several times
139 does not make any sense.
141 After this function has been called, the clipboard owns the data, so do not delete
146 \helpref{wxClipboard::AddData
}{wxclipboardadddata
}
148 \membersection{wxClipboard::UsePrimarySelection
}\label{wxclipboarduseprimary
}
150 \func{void
}{UsePrimarySelection
}{\param{bool
}{ primary = true
}}
152 On platforms supporting it (currently only GTK), selects the so called
153 PRIMARY SELECTION as the clipboard as opposed to the normal clipboard,
154 if
{\it primary
} is true.