From: Axel S. <A....@ke...> - 2007-12-02 21:47:23
|
Fri Nov 30 09:56:03 PST 2007 hth...@zo... * Tutorial-Port Introduction (Chapter 1) addfile ./docs/tutorial/Tutorial_Port/chap1.xhtml hunk ./docs/tutorial/Tutorial_Port/chap1.xhtml 1 - +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title>Gtk2Hs Tutorial: Introduction</title> + <link href="default.css" type="text/css" rel="stylesheet" /> +</head> + +<body> + +<div id="header"> + <h1>Gtk2Hs Tutorial</h1> + <span class="nav-previous"><!-- a href="chap1.xhtml" --><br /> </span> + <span class="nav-home"><a href="index.xhtml">Home</a></span> + <span class="nav-next"><a href="chap2.xhtml">Next</a></span> +</div> + +<h2>1. Introduction</h2> +<p>From the Gtk2Hs web site: Gtk2Hs is a GUI library for Haskell based on Gtk+. [_$_] +Gtk+ is an extensive and mature multi-platform toolkit for creating graphical user interfaces.</p> +<p>This tutorial is aimed at the intermediate level Haskell programmer, and covers what is +needed to write the most common GUI interfaces. This is summed up by the table of contents of this +tutorial. For advanced users, however, the Gtk2Hs API documentation contains much more.</p> +<p>Gtk+ is largely a library of components called 'widgets', which are organized in an object +oriented hierarchy. In Gtk2Hs this is implemented by giving each widget both a Haskell type and a Haskell [_$_] +type class. Thus the Haskell type system is rigorously preserved, and the programmer has all [_$_] +the advantages of Haskell type checking by the Glasgow Haskell compiler and interpreter. Gtk2Hs also [_$_] +has many functions for type casting.</p> +<p>Widgets have attributes which control their behavior and appearance. There are two general functions +to get and to set attributes. </p> +<p>To set one or more attributes of a widget use:</p> +<pre class="codebox">set widget [widgetAttr1 := foo, widgetAttr2 := fie, widgetAttr3 := bar]</pre> +<p>To get an attribute of a widget use:</p> +<pre class="codebox">x <- get widget widgetAttr1</pre> +<p>Almost always there are specific functions to set and get widget attributes too, but in future +these will be deprecated. For now, however, use of the functions is more common.</p> +<p>What happens in a Gtk2Hs application is determined by user actions, like mouse clicks, button +presses, selection of radio buttons and so on. These are called events and may result in signals + being emitted. Information about events, for example whether the user clicked a right or left + mouse button, may be captured in data fields that can be queried by the Gtk2Hs programmer. + Signals are usually handled by specific functions for that type of widget. They are listed + in the <strong>Signals</strong> section of the API documentation for that widget. [_$_] + Most take a function of type <code>IO ()</code> as parameter, but many have some result. + The Gtk2Hs programmer, of course, must write these parameter functions, which determine the response + to the user action.</p> + <p>Finally, setting up a widget tree for your application and determining the visual + layout (packing) can be done visually with the Glade interface designer. Gtk2Hs fully + supports Glade and there is an introductory tutorial on the Gtk2Hs web site. Using Glade + is actually recommended over the programmatic approach which is described in this tutorial.</p> +<div id="footer"> + <span class="nav-previous"><!-- a href="chap1.xhtml" --><br /> </span> + <span class="nav-home"><a href="index.xhtml">Home</a><br /> </span> + <span class="nav-next"><a href="chap2.xhtml">Next</a><br />2. Getting Started</span> +</div> + +</body> +</html> hunk ./docs/tutorial/Tutorial_Port/chap2.xhtml 14 - <span class="nav-previous"><!-- a href="chap1.xhtml" -->Previous<!-- /a --></span> + <span class="nav-previous"><a href="chap1.xhtml">Previous</a> </span> hunk ./docs/tutorial/Tutorial_Port/chap2.xhtml 183 - <span class="nav-previous"><!-- a href="chap1.xhtml" -->Previous<!-- /a --><br />1. Introduction</span> + <span class="nav-previous"><a href="chap1.xhtml">Previous</a><br />1. Introduction</span> hunk ./docs/tutorial/Tutorial_Port/chap7-2.xhtml 21 - <a href="chap8-1.xhtml">Next</a> + <!--a href="chap8-1.xhtml">Next</a--> hunk ./docs/tutorial/Tutorial_Port/chap7-2.xhtml 333 - <a href="chap8-1.xhtml">Next</a> - <br />8.1</span> + <!--a href="chap8-1.xhtml">Next</a--> + <br />The End</span> hunk ./docs/tutorial/Tutorial_Port/index.xhtml 29 - <a href="chap1.xhtml"></a>1. Introduction [_$_] - <em>— Not Available Yet</em></li> + <a href="chap1.xhtml">1. Introduction</a> [_$_] + </li> hunk ./docs/tutorial/Tutorial_Port/index.xhtml 151 - <!-- a href="chap1.xhtml" -->Next [_$_] - <!-- /a --> + <a href="chap1.xhtml">Next</a > |