Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > e40b0b2b839eccdb3c85993a7b738115 > files > 11

gtkmm-documentation-3.24.0-1.mga7.noarch.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 19. The Clipboard</title>
<link rel="stylesheet" type="text/css" href="style.css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Programming with gtkmm 3">
<link rel="up" href="index.html" title="Programming with gtkmm 3">
<link rel="prev" href="sec-dnd-example.html" title="Example">
<link rel="next" href="sec-clipboard-copy.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">Chapter 19. The Clipboard</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="sec-dnd-example.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="sec-clipboard-copy.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h1 class="title">
<a name="chapter-clipboard"></a>Chapter 19. The Clipboard</h1></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<ul class="toc">
<li><span class="sect1"><a href="chapter-clipboard.html#sec-clipboard-targets">Targets</a></span></li>
<li><span class="sect1"><a href="sec-clipboard-copy.html">Copy</a></span></li>
<li><span class="sect1"><a href="sec-clipboard-paste.html">Paste</a></span></li>
<li><span class="sect1"><a href="sec-clipboard-examples.html">Examples</a></span></li>
</ul>
</div>
<p>Simple text copy-paste functionality is provided for free by widgets such as
<code class="classname">Gtk::Entry</code> and <code class="classname">Gtk::TextView</code>,
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>
You can usually pretend that <code class="classname">Gtk::Clipboard</code> is a singleton.
You can get the default clipboard instance with <code class="methodname">Gtk::Clipboard::get()</code>.
This is probably the only clipboard you will ever need.
</p>
<p>
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
<code class="classname">Gtk::Clipboard</code> methods take
<code class="classname">sigc::slot</code>s which specify callback methods. When
<code class="classname">Gtk::Clipboard</code> is ready, it will call these methods,
either providing the requested data, or asking for data.
</p>
<p><a class="ulink" href="http://developer.gnome.org/gtkmm/3.24/classGtk_1_1Clipboard.html" target="_top">Reference</a></p>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-clipboard-targets"></a>Targets</h2></div></div></div>
<p>
Different applications contain different types of data, and they might make that data available in
a variety of formats. <span class="application">gtkmm</span> calls these data types <code class="literal">target</code>s.</p>
<p>
For instance, <span class="application">gedit</span> can supply and receive the <code class="literal">"UTF8_STRING"</code>
target, so you can paste data into <span class="application">gedit</span> 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 allow us to use an XML format
for the clipboard data. However this would probably not be appropriate for
binary data such as images. <code class="classname">Gtk::Clipboard</code> provides
overloads that allow you to specify the format in more detail if
necessary.
</p>
<p>The <a class="link" href="chapter-draganddrop.html" title="Chapter 18. 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 Drop operations.</p>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="sec-dnd-example.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="sec-clipboard-copy.html"><img src="icons/next.png" alt="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"><img src="icons/home.png" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Copy</td>
</tr>
</table>
</div>
</body>
</html>