Sophie

Sophie

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

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

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Widgets</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-basics.html" title="Chapter 3. Basics">
<link rel="prev" href="sec-headers-and-linking.html" title="Headers and Linking">
<link rel="next" href="sec-signals-overview.html" title="Signals">
</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</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="sec-headers-and-linking.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<th width="60%" align="center">Chapter 3. Basics</th>
<td width="20%" align="right"> <a accesskey="n" href="sec-signals-overview.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Widgets">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="sec-widgets-overview"></a>Widgets</h2></div></div></div>
<p><span class="application">gtkmm</span> applications consist of windows containing widgets, such as buttons and text boxes. In some other systems, widgets are called "controls". For each widget in your application's windows, there is a C++ object in your application's code. So you just need to call a method of the widget's class to affect the visible widget.</p>
<p>Widgets are arranged inside container widgets such as frames and notebooks, in a hierarchy of widgets within widgets. Some of these container widgets, such as Gtk::VBox, are not visible - they exist only to arrange other widgets. Here is some example code that adds 2 Gtk::Button widgets to a Gtk::VBox container widgets:
</p>
<pre class="programlisting">m_box.pack_start(m_Button1);
m_box.pack_start(m_Button2);</pre>
<p>
and here is how to add the Gtk::VBox, containing those buttons, to a Gtk::Frame, which has a visible frame and title:
</p>
<pre class="programlisting">m_frame.add(m_box);</pre>
<p>
</p>
<p>
Most of the chapters in this book deal with specific widgets. See the <a class="link" href="chapter-container-widgets.html" title="Chapter 7. Container Widgets">Container Widgets</a> section for more details about adding widgets to container widgets.
</p>
<p>Although you can specify the layout and appearance of windows and widgets with C++ code, you will probably find it more convenient to design your user interfaces with <code class="literal">Glade</code> and load them at runtime with <code class="literal">Gtk::Builder</code>. See the <a class="link" href="chapter-builder.html" title="Chapter 23. Glade and Gtk::Builder">Glade and Gtk::Builder</a> chapter.
</p>
<p>Although <span class="application">gtkmm</span> widget instances have lifetimes and scopes just like those of other C++ classes, <span class="application">gtkmm</span> has an optional time-saving feature that you will see in some of the examples. <code class="function">Gtk::manage()</code> allows you to say that a child widget is owned by the container into which you place it. This allows you to <code class="function">new</code> the widget, add it to the container and forget about deleting it. You can learn more about <span class="application">gtkmm</span> memory management techniques in the <a class="link" href="chapter-memory.html" title="Chapter 22. Memory management">Memory Management chapter</a>.
</p>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="sec-headers-and-linking.html"><img src="icons/prev.png" alt="Prev"></a> </td>
<td width="20%" align="center"><a accesskey="u" href="chapter-basics.html"><img src="icons/up.png" alt="Up"></a></td>
<td width="40%" align="right"> <a accesskey="n" href="sec-signals-overview.html"><img src="icons/next.png" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Headers and Linking </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"> Signals</td>
</tr>
</table>
</div>
</body>
</html>