Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 345aa895e80053137c21f8693106c3a0 > files > 198

gtkmm2.4-documentation-2.17.4-1mdv2010.0.noarch.rpm

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Using a gtkmm widget</title>
<link rel="stylesheet" href="style.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.1">
<link rel="home" href="index.html" title="Programming with gtkmm">
<link rel="up" href="chapter-recommended-techniques.html" title="Chapter 26. Recommended Techniques">
<link rel="prev" href="chapter-recommended-techniques.html" title="Chapter 26. Recommended Techniques">
<link rel="next" href="chapter-contributing.html" title="Chapter 27. Contributing">
</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">Using a <span class="application">gtkmm</span> widget</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="chapter-recommended-techniques.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center">Chapter 26. Recommended Techniques</th>
<td width="20%" align="right"> <a accesskey="n" href="chapter-contributing.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Using a gtkmm widget">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-using-a-gtkmm-widget"></a>Using a <span class="application">gtkmm</span> widget</h2></div></div></div>
<p>
    Our examples all tend to have the same structure. They follow these steps
    for using a <code class="classname">Widget</code>:
</p>
<p>

</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><p>
Declare a variable of the type of <code class="classname">Widget</code> you wish to
use, generally as member variable of a derived container class. You could also
declare a pointer to the widget type, and then create it with
<code class="literal">new</code> in your code. Even when using the widget via a pointer,
it's still probably best to make that pointer a member variable of a container
class so that you can access it later.
</p></li>
<li class="listitem"><p>
 Set the attributes of the widget. If the widget has no default constructor, then you will need to initialize the widget in the initalizer list of your container class's constructor.
</p></li>
<li class="listitem"><p>
Connect any signals you wish to use to the appropriate handlers.
</p></li>
<li class="listitem"><p>
Pack the widget into a container using the appropriate call,
e.g. <code class="methodname">Gtk::Container::add()</code> or
<code class="methodname">pack_start()</code>.
</p></li>
<li class="listitem"><p>
Call <code class="methodname">show()</code> to display the widget.
</p></li>
</ol></div>
<p>

</p>
<p>
<code class="methodname">Gtk::Widget::show()</code> lets <span class="application">gtkmm</span> know that we have
finished setting the attributes of the widget, and that it is ready to be
displayed. You can use <code class="methodname">Gtk::Widget::hide()</code> to make it
disappear again. The order in which you show the widgets is not important, but
we do suggest that you show the top-level window last; this way, the whole
window will appear with its contents already drawn.  Otherwise, the user will
first see a blank window, into which the widgets will be gradually drawn.
</p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="chapter-recommended-techniques.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"><a accesskey="u" href="chapter-recommended-techniques.html"><img src="icons/up.png" alt="Up"></a></td>
<td width="40%" align="right"> <a accesskey="n" href="chapter-contributing.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 26. Recommended Techniques </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"> Chapter 27. Contributing</td>
</tr>
</table>
</div>
</body>
</html>