Sophie

Sophie

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

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

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 13. ToolPalette</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-menus-examples.html" title="Examples">
<link rel="next" href="toolpalette-example.html" title="ToolPalette Example">
</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 13. ToolPalette</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="sec-menus-examples.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="toolpalette-example.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-toolpalette"></a>Chapter 13. ToolPalette</h1></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<ul class="toc">
<li><span class="sect1"><a href="chapter-toolpalette.html#toolpallete-dranganddrop">Drag and Drop</a></span></li>
<li><span class="sect1"><a href="toolpalette-example.html">ToolPalette Example</a></span></li>
</ul>
</div>
<p>A <code class="classname">ToolPalette</code> is similar to a <code class="classname">Toolbar</code> but can contain a grid of items, categorized into groups. The user may hide or expand each group. As in a toolbar, the items may be displayed as only icons, as only text, or as icons with text.
</p>
<p>The <code class="classname">ToolPalette</code>'s items might be dragged or simply activated. For instance, the user might drag objects to a canvas to create new items there. Or the user might click an item to activate a certain brush size in a drawing application.</p>
<p><code class="classname">ToolItemGroup</code>s should be added to the tool palette via the base class's <code class="function">Gtk::Container::add()</code> method, for instance like so:
</p>
<p>
</p>
<pre class="programlisting">
Gtk::ToolItemGroup* group_brushes =
  Gtk::manage(new Gtk::ToolItemGroup("Brushes"));
m_ToolPalette.add(*group_brushes);
</pre>
<p>
</p>
<p>
<code class="classname">Gtk::ToolItem</code>s can then be added to the group. For instance, like so:
</p>
<p>
</p>
<pre class="programlisting">
Gtk::ToolButton* button = Gtk::manage(new Gtk::ToolButton(icon, "Big"));
button-&gt;set_tooltip_text("Big Brush);
group_brushes-&gt;insert(*button);
</pre>
<p>
</p>
<p>You might then handle the <code class="classname">ToolButton</code>'s <code class="literal">clicked</code> signal. Alternatively, you could allow the item to be dragged to another widget, by calling <code class="methodname">Gtk::ToolPalette::add_drag_dest()</code> and then using <code class="methodname">Gtk::ToolPalette::get_drag_item()</code> in the other widget's <code class="literal">drag_data_received</code> signal handler.</p>
<p><a class="ulink" href="http://developer.gnome.org/gtkmm/3.24/classGtk_1_1ToolPalette.html" target="_top">ToolPalette Reference</a></p>
<p><a class="ulink" href="http://developer.gnome.org/gtkmm/3.24/classGtk_1_1ToolItemGroup.html" target="_top">ToolItemGroup Reference</a></p>
<p><a class="ulink" href="http://developer.gnome.org/gtkmm/3.24/classGtk_1_1ToolItem.html" target="_top">ToolItem Reference</a></p>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="toolpallete-dranganddrop"></a>Drag and Drop</h2></div></div></div>
<p>Call <code class="methodname">add_drag_dest()</code> to allow items or groups to be dragged from the tool palette to a particular destination widget. You can then use <code class="methodname">get_drag_item()</code> to discover which ToolItem or ToolItemGroup is being dragged. You can use <code class="literal">dynamic_cast</code> to discover whether it is an item or a group. For instance, you might use this in your <code class="literal">drag_data_received</code> signal handler, to add a dropped item, or to show a suitable icon while dragging.</p>
<p>See the <a class="link" href="chapter-draganddrop.html" title="Chapter 18. Drag and Drop">Drag and Drop</a> chapter for general advice about Drag and Drop with gtkmm.</p>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="sec-menus-examples.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="toolpalette-example.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Examples </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"> ToolPalette Example</td>
</tr>
</table>
</div>
</body>
</html>