<!doctype book public "-//Davenport//DTD DocBook V3.0//EN" [
<!entity % ISOnum PUBLIC "ISO 8879-1986//ENTITIES Numeric and Special Graphic//EN">
%ISOnum;
<!entity gtkmm "<application>Gtk--</application>">
<!entity gtk   "<application>Gtk</application>">
<!entity gnu   "<acronym>GNU</acronym>">
<!entity cxx   "<application>C++</application>">
<!entity c     "<application>C</application>">
<!entity referencebook SYSTEM "../reference/reference.sgml">
<!entity % examplelist SYSTEM "../examples/examplelist.sgml">
%examplelist;
<!entity ch_creating_new_widgets SYSTEM "ch_creating_new_widgets.sgml">
]>

<book status="in progress">
  <bookinfo><title>&gtkmm; Tutorial</title>
    <bookbiblio>
      <authorgroup>
	<author><honorific>Stud</honorific><honorific>rer</honorific>
	  <honorific>nat</honorific>
	  <firstname>Marcus</firstname><surname>Brinkmann</surname>
	  <AuthorBlurb><para>Marcus studies mathematic and collects experiences
            with Linux since early 1996.</para></AuthorBlurb>
	</author>
	<OtherCredit>
	  <firstname>Tero</firstname><surname>Pulkkinen</surname>
	  <authorblurb><para>
            <graphic fileref="pictures/tero_pulkkinen.gif" format="GIF"></graphic>
            Tero maintains and develops &gtkmm;.</para></authorblurb>
	</othercredit>
      </authorgroup>
      <abstract><para>A comprehensive and easy understandable guide to the upcoming
	  graphical user interface &gtkmm;.</para>
      </abstract>
      <revhistory>
	<revision>
	  <revnumber>0.1</revnumber>
	  <date>June 1998</date>
	  <authorinitials>M.B.</authorinitials>
	  <revremark>Initial release.</revremark>
	</revision>
      </revhistory>
      <copyright><year>1998</year><holder>Marcus Brinkmann</holder></copyright>
    </bookbiblio>
    <legalnotice><title>Copyright Conditions</title>
      <para>
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
</para>
<para>
Permission is granted to process this file through TeX and other text
processing systems (for example <acronym>DSSSL</acronym> engines) and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
</para>
<para>
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.
</para>
<para>
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by the copyright holder.
</para>
<para>
The example program files are in the Public Domain.
</para>
<para>The following address is for your information only.
	<address>
	  Free Software Foundation, Inc.
	  <street>59 Temple Place - Suite 330</street>
	  <city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>
	  <country>USA</country>
	</address>
      </para>
    </legalnotice>
  </bookinfo>
  <preface><title>Preface</title>
    <para>
      With <application>Linux</application>, a great variety of applications are accesible at
      no for low costs, and many of them are of high quality.  Unfortunately, the lack of
      documentation is in high contrast to this.  The reasons are easy to see: For most
      developers, programming is a lot more fun than explaining the apparently obvious.
    </para>
    <para>
      For me, programming in &cxx; using the &gtkmm; environment is new and far from obvious,
      and I hope that laying down the basic principles I understood along the way will help me
      to clear my mind and help others to understand it more easily.
    </para>
    <para>
      If you have corrections, remarks, answers or questions about this document, please feel
      free to contact me. My address is:
      <address>
	Marcus Brinkmann
	<email>Marcus.Brinkmann@ruhr-uni-bochum.de</email>
      </address>
    </para>
  </preface>
  <part><title>Getting Started</title>
    <partintro><title>What is &gtkmm;</title>
      <para>
	Today, software can interact in many ways with the user, and it is not an easy task for
	the programmer to make a decision which input and output devices he should support and
	which not. Standards and abstract interfaces can help a lot to make this decision less
	important, because many devices can be used in a unique way, at least from the
	programmers point of view. Under Linux, for example, there is no need to bother about
	data storage devices, because the kernel provides a filesystem as an abstract interface
	and a library provides a clean wy to access the file system.
      </para>
      <para>
	However, there are still enough forms of output that differ in a more fundamental
	way. For example, it is likely to be of some importance if the output consists only of
	text (and with text I mean a stream of characters encoded by a standard like
	<acronym>ANSI</acronym>), or if the output is graphical (when it consists of pixel).
      </para>
      <para>
	The situation becomes even more confusing when the programmer has to write a user
	interface for interactive communication with the user.  There are a lot of input
	devices available, beginning with a variety of keyboards, mices, pads and not ending
	with speak recognition. Also the programmer can make use of different ways to present
	the possibilities, in which the user can control the application.
      </para>
      <para>
	There are standard protocols for input and output devices, and programmers can make use
	of them to be independent of the actual situation of input and output devices. However,
	there are several libraries available that provide a consistent graphical user
	interface (<acronym>GUI</acronym>). It is desirable that every program uses the same
	user interface, to make the situation less confusing for the user, but the current
	situation is far from this ideal situation.
      </para>
      <para>
	To write a extensible, portable and consistent user interface of high quality, that can
	be used to write <application>X</application> applications in a comfortable way, is the
	goal of the &gtk; project. It is written in and for &c;, and many features known from
	object oriented programming languages had to be reimplemented in &c;. &gtkmm; provides
	a wrapper around the &gtk; to be used in &cxx; and has the advantages of a typesafe
	environment (even for signals) and integrated object oriented capabilities like
	inheritance to extend the capabilities of &gtk;.
      </para>
    </partintro>
    <chapter><title>Requirements</title>
      <para>
	There are some things you need before you can even start to work with &gtkmm;, but
	there are also some things you will need to learn side by side with &gtkmm; if you
	don't already know them, or you will hardly succeed writing good software, regardless
	what tools or libraries you use.
      </para>
      <para>
	But be careful and don't take the words in this chapter too literally.  It is unlikely
	that I really know what exactly the requirements are.  Free software is evolving fast
	at the moment, and facts are outdated after a short time. For this reason, some
	requirements will not spelled out precise, but intentionally be kept vague. Please
	check the latest documentation that comes with the software package for newest
	information.
      </para>
      <sect1><title>The Obvious</title>
	<para>
	  You need a platform that is supported by <application>Gtk</application>, a complete
	  <application>Gtk</application> installation and &gtkmm;.
	</para>
	<para>
	  Probably the distribution you use will provide binary packages. Then all you have to
	  do is to install the appropriate packages for development with &gtk; and &gtkmm;. If
	  you have to build the package by yourself for some reason, get the latest source
	  packages per anonymous ftp. Thanks to <application>autoconf</application>, building
	  and installing should be easy.
	</para>	
	<para>
	  After building and installing the libraries, you can link them in applications that
	  make use of &gtkmm;. Note that the name of the &gtkmm; library will be
	  <filename>libgtkmm</filename>, because dashes in library names may be confusing to
	  the system tools.
	</para>
      </sect1>
      <sect1><title>The Compiler</title>
	<para>
	  Furthermore, you need a working &cxx; compiler.  A good compiler is
	  <application>gcc</application>, the &gnu; &c;/&cxx; compiler.
	</para>
	<para>
	  You need to know how you can compile and link a program you have written in your
	  environment. On a <application>Linux</application> platform, for example, you can
	  compile and link a program <filename>stardust.cc</filename> with
	  <application>gcc</application> with one command:
<screen><prompt>$</prompt> <userinput>g++ -o stardust startdust.cc -lgtkmm `gtk-config --cflags` `gtk-config libs`</userinput></screen>
	</para>
	<para>
	  However, the last part is only necessary if your system does not handle
	  inter-dependencies between shared libraries correctly. On some systems, you can live
	  without the call for <userinput>gtk-config libs`</userinput>.
	</para>
      </sect1>
      <sect1><title>What Else?</title>
	<para>
	  I need more informations here.
	</para>
      </sect1>

    <chapter><title>Basics</title>
      <epigraph>
	<attribution>Zippy</attribution><para>Kids, the seven basic food groups are GUM, PUFF
	  PASTRY, PIZZA, PESTICIDES, ANTIBIOTICS, NUTRA-SWEET and MILK DUDS!!</para>
      </epigraph>
      <sect1><title>The Shortest Example</title>
	<para>
	  There is a smallest possible
	    &cxx; program that uses &gtkmm;. Please consider the
	  following code:
<example><title/Shortest &gtkmm; Program/
<programlisting role="C++">
&shortest-program;
</programlisting>
</example>
</para>
	<para>
	  The first line includes the classes and templates from that you can derive your
	  objects and signals. The third line is the declaration of the
	  <function>main()</function> function.
          <indexterm><primary sortas="main"><function>main</function></primary></indexterm>
          This is the function that will be called when
	  the program is compiled and run. Every program must include one and only one
	  <function>main()</function> function, which should return an '<type>int</type>' value
	  that will be returned to the shell (the error value of the program). The shell gives
	  two parameters to the main function, an <type>int</type> value (here called
	  <parameter>argc</parameter>) and a pointer to an array of standard &c; strings. The
	  former is a number one more than the number of arguments given to the program on the
	  command line, the latter is the complete command line broken in the name of the
	  program (<parameter>argv[0]</parameter>) and the arguments
	  (<parameter>argv</parameter>[1] to
	  <parameter>argv</parameter>[<parameter>argc</parameter>-1]).
	</para>
	<para>
	  Lines 4 to 12 are the definition of the main function. This is the code actually
	  executed. In line 5, a variable <parameter>eventLoop</parameter> of the type
	  <classname>Gtk_Main</classname> is declared and defined.
	  <classname>Gtk_Main</classname> is the most important class of &gtkmm;.  Every
	  &gtkmm; program must have an instance of the class <classname>Gtk_Main</classname>,
	  which handles the signals and program flow. There is exactly one constructor for
	  <classname>Gtk_Main</classname>, and this expects two arguments. Those are pointers
	  to the two arguments given to the main function by the shell. The reason is that
	  <classname>Gtk_Main</classname> will parse the command line for &gtkmm; specific
	  arguments. Those will be stripped and processed.
	</para>
	<para>
	  After all essential &gtkmm; objects are constructed and initialized (here in the
	  lines 7 and 8), the program flow will be given to &gtkmm; by calling the method
	  <function>run()</function> of the <classname>Gtk_Main</classname> instance
	  <parameter>eventLoop</parameter> (line 10). Eventually &gtkmm; will return the
	  control to the main function, and then the main function returns with success (line
	  11).
	</para>
	<para>
	  In this simple example, only one visible &gtkmm; object is created, an object
	  <parameter>helloWorldWindow</parameter> of type
	  <classname>Gtk_Window</classname>. After construction, the window will not be realized.
          To build and make it visible, one has to call the member method
          <function>show()</function>.  This is true for all visible &gtkmm; objects.
          In our example, this happens in line 8.
          Try the program the and without line 8, and you will see the difference.
	</para>
	<para>
	  If you run the program, you will see a window of a default size (200x200) and with a
	  title equal to the programs name on the command line. The default size is only
	  applied if the window is empty (if it contains no children objects), because a window
	  of size 0x0 is hard to manipulate or even to see. Further you will see that the
	  program will not return, even if it recieves the close signal from your window
	  manager. This is because we haven't included signal handling yet, and we will not do
	  so for some time.  Please interrupt the program with
	  <keycombo><keycap>Ctrl</keycap><keycap>C</keycap></keycombo> or destroy the window.
	</para>
      </sect1>
      
      <sect1><title>Window properties</title>
	<para>
	  We can already change some properties of the <parameter>helloWorldWindow</parameter>,
	  for example the title string or the minimum size. For example, the following body
	  will change both at once:
<programlisting role="C">
Gtk_Window helloWorldWindow;
helloWorldWindow.set_title("Hello, world!");
helloWorldWindow.set_usize(200,20);
helloWorldWindow.show();
</programlisting>
	</para>
	<para>
	  The <classname>Gtk_Window</classname> class provides a method
	  <function>set_title(<type>char *</type>)</function> to change the title of the
	  window. But if you check the header file or documentation, you will find out that
	  <classname>Gtk_Window</classname> <emphasis>does not</emphasis> provide a method
	  <function>set_usize(<type>gint</type> <parameter>width</parameter>, <type>gint</type>
	  <parameter>height</parameter>)</function>, that sets the size of the
	  widget. <function>set_usize</function> is provided by
	  <classname>Gtk_Widget</classname>, and <classname>Gtk_Window</classname> is a class
	  derived from <classname>Gtk_Widget</classname>. You should always remember that you
	  can also use member methods from parent classes to change the proberties of your
	  &gtkmm; objects.
	</para>
	<para>
	  The way your window instance is handled by the window manager can be changed by a
	  variable of type <type>GtkWindowType</type> given to the constructor of
	  <classname>Gtk_Window</classname>. There are three possible values,
	  <symbol>GTK_WINDOW_TOPLEVEL</symbol> (the default),
	  <symbol>GTK_WINDOW_DIALOG</symbol> and <symbol>GTK_WINDOW_POPUP</symbol>. To find out
	  what they are doing, change line 7 in the example to something similar to:
<programlisting role="C">
Gtk_Window helloWorldWindow(GTK_WINDOW_TOPLEVEL);
</programlisting>
	  and then replace <symbol>GTK_WINDOW_TOPLEVEL</symbol> with one of the other two
	  possibilities. You will see, that windows of the type
	  <symbol>GTK_WINDOW_TOPLEVEL</symbol> are fully handled by the window manager. Further
	  more you will see that windows of type <symbol>GTK_WINDOW_DIALOG</symbol> are missing
	  some handles (resizing and closing buttons for example) and that windows of type
	  <symbol>GTK_WINDOW_POPUP</symbol> are not handled by the window manager at all (no
	  border, no buttons).
	</para>
      </sect1>

      <sect1><title>The Label Widget</title>
	<para>
	  Now let's come to another &gtkmm; object, the widget class
	  <classname>Gtk_Label</classname>.  The constructor requests a <type>const
	  char*</type> that contains the text of the label.
	</para>
	<para>
	  Consider this example program:
	  <example><title>Label Widget</title>
<programlisting role="C">
&label-widget;
</programlisting>
	  </example>
	</para>
	<para>
	  Most parts of this program are already explained, only lines 7, 8 and 11 are new. If
	  you compile and run this example, you won't see a window that is set to the default
	  size of 200x200, but a window that has exactly the size needed to contain the text
	  "Hello, world!".  Normally, a Widget will have a default size to fit exactly the
	  child widget it contains.
	</para>
	<para>
	  A widget can be added to the window with the member method
	  <function>add(<type>Gtk_Widget*</type>)</function>. Because this requires a pointer
	  to the widget to be added, we give the pointer of the
	  <classname>Gtk_Label</classname> widget as parameter. Note that
	  <function>add()</function> is a member method of class
	  <classname>Gtk_Container</classname>, from which <classname>Gtk_Window</classname> is
	  derived, not from Gtk_Window itself. You can use this procedure to add a widget to
	  every container, not only to a window, as you will see later.
	</para>
	<para>
	  As already said, we have to make the label visible with the
	  <function>show()</function> member method. Note that we can first
	  <function>show()</function> the label, and then the window. If you
	  change the order, you will first see the empty window and you can
	  watch how the label will be drawn. In most cases it is preferable
	  to draw the widget internally, and then as the last step make the
	  window visible.
	</para>
	<para>
	  The class <classname>Gtk_Label</classname> has two member methods,
	  <function>set(<type>const gchar*</type> <parameter>str</parameter>)</function> and
	  <function>get(<type>gchar**</type> <parameter>str</parameter>)</function>, so you can
	  change the label and see what it reads. Please remember that the
	  <classname>Gtk_Label</classname> is derived from other classes, and you can use
	  member methods from parent classes to change further properties of
	  <classname>Gtk_Label</classname>. For example, you can change the minimum size of the label
	  with the <function>set_usize(<type>gint</type>, <type>gint</type>)</function> member
	  method of the <classname>Gtk_Widget</classname> class.
	</para>
      </sect1>

      <sect1><title>The Button Widget</title>
	<para>
	  Labels are quite boring, because they are passive. If you want to
	  interact with the user, you most certainly want to provide buttons
	  in your application. For this purpose, a
	  <classname>Gtk_Button</classname> widget class is available similar
	  to <classname>Gtk_Label</classname>.
	</para>
	<para>
	  But the <classname>Gtk_Button</classname> class is more complex,
	  because it is a container (it is derived from the
	  <classname>Gtk_Container</classname> class), so you can add a
	  label to it or a small graphic or whatever you want. Widgets are
	  added to a button in the same way they are added to a window, with
	  the member method <function>add(<type>Gtk_Widget *</type>)</function>.
	</para>
	<para>
	  If you just want to add a label to a <classname>Gtk_Button</classname>
	  container, you can give the text string to the
	  <classname>Gtk_Button</classname> constructor. This is a convenient
	  and common abbreviation. This means, the following pieces of code are
	  aequivalent:
<programlisting role="C">
Gtk_Label someLabel("Hello, world!");
someLabel.show();

Gtk_Button someButton;
someButton.add(&amp;someLabel);
someButton.show();
</programlisting>
	  is the hard way to achieve:
<programlisting role="C">
Gtk_Button someButton("Hello, world!");
someButton.show();
</programlisting>
	</para>
	<para>
	  There is currently no way to access the label created by
	  <function>Gtk_Button(<type>const gchar*</type>)</function>, so you have to use the
	  more verbose form if you want to work with it, for example, if you want to change the
	  text of the button.
	</para>
	<para>
	  Change the "Hello, world!" example to use a button instead of a label and try to run
	  it. You will see that the color of button changes if you move the mouse pointer to
	  the button and if you click the button.  But nothing else happens. It is possible to
	  make something happen, and this is the purpose of signals.
	</para>
      </sect1>

      <sect1><title>Signals</title>
	<para>
	  Signals are emitted by &gtkmm; whenever something interesting happens, for example
	  when a window was resized or a button was pressed. You can connect to those signals,
	  this means, you can attach a function to the queue of functions which will be called
	  whenever a signal is emitted. You can attach several functions to one and the same
	  signal, and you can attach the same functions to multiple signals. However, the
	  return value and the arguments of the function have to match the arguments and return
	  value of the signal.
	</para>
	<para>
	  Consider the following program that is a long version of the
	  exercise in the previous section:
	  <example><title>No Signal yet</title>
<programlisting role="C">
&signal-1;
</programlisting>
	  </example>
	</para>
	<para>
	  Note the absence of the <function>show()</function> call for the
	  <classname>Gtk_Label</classname>, <classname>Gtk_Button</classname> and
	  <classname>Gtk_Window</classname> element. They are replaced by a single call of the
	  member method <function>show_all()</function> of the
	  <classname>Gtk_Window</classname> instance
	  <parameter>helloWorldWindow</parameter>. <function>show_all()</function> is a useful
	  and common abbreviation, it calls <function>show()</function> for the widget itself
	  and all elements it contains. <function>show()</function> and
	  <function>show_all()</function> will be discussed more thoroughly later in this
	  tutorial, when we speak about containers.
	</para>
	<para>
	  We want to make something happen whenever the button is pressed. For
	  example, we want to change the text of the label (and this is the
	  reason why we didn't gave the text to the constructor of the button).
	  To be able to do this, &gtkmm; has to notice us when the button is
	  pressed. It does so by making a function call. Well, it is a bit
	  more complex in reality, but for now it is sufficient to think of
	  signals as function calls that are done by &gtkmm; as reaction to
	  an event.
	</para>
	<para>
	  There is only one thing left to do for our program, it has to tell &gtkmm;
	  <emphasis>what function</emphasis> should be called when <emphasis>which
	  action</emphasis> is taken on <emphasis>which element</emphasis>. This is done by
	  <function>connect_to_function</function>. To try it, please add the following
	  function to the example above, and also add the
	  <function>connect_to_function</function> call to the <function>main</function>
	  function.
	</para>

	<para>
<programlisting role="C">
 2a   static void changeLabel(Gtk_Label&amp; theLabel)
 2b   {
 2c     static bool flag=true;
 2d
 2e     flag = !flag;
 2f     flag ? theLabel.set("Bye, bye!")
 2g          : theLabel.set("Hello, World!");
 2h   }

11a  connect_to_function(helloWorldButton.clicked, &amp;changeLabel, helloWorldLabel);
</programlisting>
	</para>
	<para>
	  <function>changeLabel</function> uses a static variable of type boolean to store
	  the current status of the label (we could also query it with the
	  <function>get</function> member method of <classname>Gtk_Label</classname>, but this
	  would require a string comparison, a useless complication in this small example) and
	  toggles the text of the label when called. The
	  <function>connect_to_function</function> call requires some explanation.
	</para>
	<para>Usually, <function>connect_to_function</function> takes two arguments, the first
	  is the signal you want connect to, and the second is the function you want connect to
	  the signal. An optional third argument will be passed on to the connected function
	  whenever the signal is emitted. In our example, the signal
	  <function>helloWorldButton->clicked</function> is emitted whenever the button is
	  clicked (i.e. pressed and released) and
	  <function>changeLabel(helloWorldLabel)</function> is called. If the third argument of
	  <function>connect_to_function</function> is omitted, no argument will be passed on.
	</para>
	<para>
	  You can connect as many function calls to a signal as you like, they are called one
	  after another. In addition, you can not nly connect function calls to a signal, but
	  also member methods of class instances and even other signals. Signals control the
	  flow of an interactive program.
      </sect1>
    </chapter>

    <chapter><title>Getting Serious</title>
      <sect1><title>Packaging</title>
	<para>
	  Until now, every <classname>Gtk_Container</classname> instance only had one
	  <classname>Gtk_Widget</classname> instance inside (for example, a window with one
	  label in it). Obviously, this is not sufficient for most cases. The naive way to add
	  a second label probably would be something like the following:
	  <example><title>This won't work!</title>
<programlisting role="C">
&packaging-1;
</programlisting>
	  </example>
	</para>
	<para>
	  Please try to compile and run this example. Are you surprised?  You will see exactly
	  the same output as if the lines 9 and 13 would not be there. Swapping lines 12 and 13
	  will only show the other text "Bye, world!", but not "Hello, world!". Although this
	  does not make sense at the first glance, you will soon find out why there is a
	  <emphasis>strong reason</emphasis> for this behaviour.
	</para>
	<para>
	  It is all about placement. There is a sensible default for the placement of a single
	  widget inside a container (it is centered), there is no obvious preference for the
	  placement of more than one widget. They could be placed vertically or horizontally,
	  left or right bounded or centered. The placement could also be different for every
	  widget, for example some at the top of the container and others on the right. As
	  placement of widgets is such a complex task, there are many different ways to do it.
	</para>
        <para>
          Therefore it is forbidden to place more than one object in a
          container, and &gtk; will complain with an error message at run time.
        </para>
	<para>
	  The easiest way to place widgets is to place them in a row (horizontally) or in a
	  column (vertically). For this purpose there are two classes provided by &gtkmm;, the
	  <classname>Gtk_HBox</classname> and <classname>Gtk_VBox</classname>.  As both classes
	  provide a very similar functionality, they are derived from a common base, the
	  <classname>Gtk_Box</classname> class, which is never directly used. For the following
	  explanations, the <classname>Gtk_HBox</classname> is used as an example, but the same
	  facts are true for the <classname>Gtk_VBox</classname> as well, because the interface
	  is provided by the <classname>Gtk_Box</classname> class, not by one of the
	  specializations.
	</para>
	<para>
	  The main idea is to add a box to the container, and then to add the widgets to the
	  box. For this purpose, two methods are provided by <classname>Gtk_Box</classname>,
	  <function>pack_start(<type>Gtk_Widget*</type>)</function> and
	  <function>pack_end(<type>Gtk_Widget*</type>)</function>.
	  <function>pack_start</function> will add widgets starting at the beginning of the box
	  in direction to the end of it, whereas <function>pack_end</function> will add widgets
	  starting at the end of the box in direction to the beginning. Therefore the order in
	  which the methods are called is important. A simple example shows both ways to add
	  widgets to a box.  <example><title>Horizontal Packaging</title>
<programlisting role="C">
&packaging-2;
</programlisting>
	  </example>
	</para>
	<para>
	  If you try this example, you should resize the window to force a different
	  placement. As a <classname>Gtk_HBox</classname> has a default size to match the sum
	  of the default sizes of the widgets it contains, you will not see the different
	  placement of the widgets until resizing. Please note the different order of the
	  <function>pack_start</function> and <function>pack_end</function> calls in lines 14
	  to 17.
	</para>
	<para>
	  A <classname>Gtk_Box</classname> is an unvisible box, that means, it does not add
	  anything visible to the container it is added to.  But nevertheless you have to call
	  <function>show()</function> to make the widgets visible it
	  contains. <function>show()</function> makes a widget only visible to its direct
	  parent. If it should show up in the window, all widgets on the way down to it have to
	  be visible, too. This is an excellent example why <function>show_all()</function> is
	  indeed a great convenience for the programmer.
	</para>
	<para>
	  You can nest multiple horizontal and vertical boxes to achieve a finer control on
	  placement. You can also add other widgets to a box than labels. You can adjust the
	  placement of the elements in a box, but this is subject of a later section in this
	  tutorial.
	</para>
      </sect1>

      <sect1><title/An example/
	<para>
	  At this point, the reader should already become a bit familiar with &gtkmm;. It is a
	  good moment now to summarize all features of &gtkmm; presented in the previous
	  sections with a more complex example. The program shown below will present the user a
	  list of three checkbuttons, each with the name of a base color on it (red, green and
	  blue). The user can tag and untag the colors with a click on the checkbox, and the
	  program will calculate the resulting color that is produced by mixing the tagged colors.
	</para>
	<para>
	  A check button provides a container together with a small checkbox to the
	  left. This checkbox can be toggled with a mouse click to indicate if the item
	  should be on or off. A check button is provided by the
	  <classname>Gtk_CheckButton</classname> class. For your convenience, a default
	  constructor is provided that accepts a string (similar to
	  <classname>Gtk_Button</classname>. As <classname>Gtk_CheckButton</classname> is
	  derived from <classname>Gtk_Button</classname>, all signals and member methods you
	  already know can be used. In addition, you can query the current state with
	  <function><type>bool</type> get_state()</function> and you can set it with
	  <function><type>void</type> set_state(<type>bool</type> state)</function>. A signal
	  <function>toggled</function> will be emitted whenever the current state changes.
	</para>
	<para>
	  A simple example shows you how this button can be used. The example contains also
	  everything you learned before, so if you have trouble understanding it go back and
	  read again from the beginning of the tutorial. One function, however, you are not
	  assumed to be familiar with. It is the <function>connect_to_method</function> call,
	  that is used to connect a member method to a signal. For now it is sufficient to
	  know that this call is used to run <function>updateColor()</function> whenever the
	  state of a check button changes.
	  <example><title/Check Button/
<programlisting role="C">
&checkbutton;
</programlisting>
	  </example>
	</para>
	<para>
	  You must have noticed that the design of the program changed substantially from the
	  design used in prior examples. Earlier, we put all objects in the main function,
	  which was fair enough because we used relatively few widgets. With a raising number
	  of objects to cope with, we need a more sophisticated design. It is a good idea to
	  seperate the widgets by the location were they appear in the program. For example,
	  you can create seperate classes for every window that is used in your program. But
	  also boxes and other things can be considered a seperate entity. Often, there are
	  several possible and good solutions.  For our case, I choosed to make a class
	  <classname>ColorMix</classname> that represents the content of our window. This
	  way, we could use the <classname>ColorMix</classname> entity in other locations,
	  for example as a part of a bigger window.
	</para>
	<para>
	  Another very important design issue is the use of
	  <emphasis>inheritance</emphasis>. Because the class <classname>ColorMix</classname>
	  is derived from <classname>Gtk_HBox</classname>, it became in fact a &gtkmm; object
	  by itself! In the example above one can see how easy &gtkmm; can be extended with
	  more complex widgets. It is true that <classname>ColorMix</classname> is too
	  specialised to be of much use in different contexts, but it is easy to see that
	  this is not a limitation of the inheritance capablities. Using constructors that
	  accept appropriate parameters, you can easily create your own abstract widgets and
	  other &gtkmm; objects.
	</para>
      </sect1>
      <sect1><title>Menus</title>
	<para>
	  Menus are an essential part of every user application. They
	  provide fast access to the main functionalities of the
	  program. Menus are organized in submenus, which are accessed
	  by a menu bar, usually placed at the top of the window.
	</para>
	<para>
	  Menu items are connected to functions by signals: If a user
	  selects an item in a menu, an event occures and the
	  appropriate signal is emitted. You can connect one or more
	  functions to this signal to make something happen through
	  the menu. A common way to respond to a menu selection is to
	  open a dialog window, but also direct actions may be appropriate.
	</para>
	<para>
	  You can build menus directly from the &gtkmm; widgets, but
	  this is inconvenient as a lot of overhead is involved in
	  implementing the necessary objects. For the special case of
	  menus, &gtkmm; provides a better way to realize the set of
	  widgets needed. This system is called
	  <classname>MenuFactory</classname>.
	</para>

      </sect1>
      <sect1><title>More on Signals</title>
	<para>EMPTY</para>
      </sect1>
    </chapter>
  </part>
  <part><title/Extending &gtkmm;/
  &ch_creating_new_widgets;
  </part>
  <part><title/Reference Book/
    <partintro><title/Read the sources, man!/
      <para>
        This part of the tutorial contains a complete class reference of
        &gtkmm;. Every class and its member functions are listed here as
        well as the signals you can connect to. This reference book is
        directly created from the current &gtkmm; source tree.
      </para>
      <para>Programm used to create reference book.</para>
      <para>
        You can use this reference book during your walk throuth the
        tutorial and while programming applications. If the output format
        allows this, the classes in the tutorial are linked to the entry in
        this reference as they occure.
      </para>
    </partintro>
    &referencebook;
  </part>
<!--  <appendix label="A"><title/A/
  <appendix label="B"><title/B/
  <appendix label="C"><title/C/
  <appendix label="D"><title/Development/
  <appendix label="F"><title/F/
  <appendix label="G"><title/Gtk/
  <index><title/Index/
  </index> -->
</book>



