| 12
 3
 4
 5
 6
 
 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter16.The Clipboard</title><meta name="generator" content="DocBook XSL Stylesheets V1.64.1"><link rel="home" href="index.html" title="Programming with gtkmm2"><link rel="up" href="index.html" title="Programming with gtkmm2"><link rel="previous" href="ch15s05.html" title="Example"><link rel="next" href="ch16s02.html" title="Copy"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter16.The Clipboard</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch15s05.html">Prev</a></td><th width="60%" align="center"></th><td width="20%" align="right"><a accesskey="n" href="ch16s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="sec-clipboard"></a>Chapter16.The Clipboard</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch16.html#id2517354">Targets</a></span></dt><dt><span class="sect1"><a href="ch16s02.html">Copy</a></span></dt><dt><span class="sect1"><a href="ch16s03.html">Paste</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch16s03.html#id2517519">Discovering the available targets</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch16s04.html">Examples</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch16s04.html#id2517588">Simple</a></span></dt><dt><span class="sect2"><a href="ch16s04.html#id2517733">Ideal</a></span></dt></dl></dd></dl></div><p>Simple text copy-paste functionality is provided for free by widgets such as Gtk::Entry and Gtk::TextView, but you might need special code to deal with your own data formats. For instance, a drawing program would need special code to allow copy and paste within a view, or between documents.</p><p><tt class="literal">Gtk::Clipboard</tt> is a singleton. You can get the one and only instance with <tt class="literal">Gtk::Clipboard::get()</tt>.</p><p>So your application doesn't need to wait for clipboard operations, particularly between the time when the user chooses Copy and then later chooses Paste, most <tt class="literal">Gtk::Clipboard</tt> methods take <tt class="literal">SigC::Slot</tt>s which specify callback methods. When <tt class="literal">Gtk::Clipboard</tt> is ready, it will call these methods, either providing the requested data, or asking for data.  
</p><p><a href="../../reference/html/classGtk_1_1Clipboard.html" target="_top">Reference</a></p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2517354"></a>Targets</h2></div></div><div></div></div><p>
Different applications contain different types of data, and they might make that data available in
a variety of formats. gtkmm calls these data types <tt class="literal">target</tt>s.</p><p>
For instance, gedit can supply and receive the <tt class="literal">"UTF8_STRING"</tt> target, so you can paste data into gedit from any application that supplies that target. Or two different image editing applications might supply and receive a variety of image formats as targets. As long as one application can receive one of the targets that the other supplies then you will be able to copy data from one to the other.
</p><p>A target can be in a variety of binary formats. This chapter, and the examples, assume that the data is 8-bit text. This would allows us to use an XML format for the clipboard data. However this would probably not be appropriate for binary data such as images. <tt class="literal">Gtk::Clipboard</tt> provides overloads that allow you to specify the format in more detail if necessary.</p><p>The <a href="ch15.html" title="Chapter15.Drag and Drop">Drag and Drop</a> API uses the same mechanism. You should probably use the same data targets and formats for both Clipboard and Drag and Drap operations.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch15s05.html">Prev</a></td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"><a accesskey="n" href="ch16s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Example</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">Copy</td></tr></table></div></body></html>
 |