<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Widgets and ChildAnchors</title> <link rel="stylesheet" href="style.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.73.2"> <link rel="start" href="index.html" title="Programming with gtkmm"> <link rel="up" href="ch10.html" title="Chapter 10. TextView"> <link rel="prev" href="ch10.html" title="Chapter 10. TextView"> <link rel="next" href="ch10s03.html" title="Examples"> </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">Widgets and ChildAnchors</th></tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="ch10.html"><img src="../icons/prev.png" alt="Prev"></a> </td> <th width="60%" align="center">Chapter 10. TextView</th> <td width="20%" align="right"> <a accesskey="n" href="ch10s03.html"><img src="../icons/next.png" alt="Next"></a> </td> </tr> </table> <hr> </div> <div class="sect1" lang="en"> <div class="titlepage"><div><div><h2 class="title" style="clear: both"> <a name="sec-widgets_and_childanchors"></a>Widgets and ChildAnchors</h2></div></div></div> <p> You can embed widgets, such as <code class="classname">Gtk::Button</code>s, in the text. Each such child widget needs a <code class="classname">ChildAnchor</code>. ChildAnchors are associated with <code class="classname">iterators</code>. For instance, to create a child anchor at a particular position, use <code class="function">Gtk::TextBuffer::create_child_anchor()</code>: </p> <pre class="programlisting">Glib::RefPtr<Gtk::TextChildAnchor> refAnchor = refBuffer->create_child_anchor(iter);</pre> <p> Then, to add a widget at that position, use <code class="function">Gtk::TextView::add_child_at_anchor()</code>: </p> <pre class="programlisting">m_TextView.add_child_at_anchor(m_Button, refAnchor);</pre> <p><a class="ulink" href="../../reference/html/classGtk_1_1TextChildAnchor.html" target="_top">Reference</a></p> </div> <div class="navfooter"> <hr> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="ch10.html"><img src="../icons/prev.png" alt="Prev"></a> </td> <td width="20%" align="center"><a accesskey="u" href="ch10.html"><img src="../icons/up.png" alt="Up"></a></td> <td width="40%" align="right"> <a accesskey="n" href="ch10s03.html"><img src="../icons/next.png" alt="Next"></a> </td> </tr> <tr> <td width="40%" align="left" valign="top">Chapter 10. TextView </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"> Examples</td> </tr> </table> </div> </body> </html>