Project

General

Profile

Hello world » History » Version 3

iri, 02/22/2011 02:06 PM

1 1 iri
h1. Hello world
2
3
Here is a famous "Hello world" !
4
5 3 iri
<pre><code class="php">
6 1 iri
typeof win = ObjGtkWidget;;
7
typeof button = ObjGtkWidget;;
8
9
fun CBend (obj, uparam)=
10
    _gtkMainQuit;
11
    0;;
12
13
fun CBbutton (obj, uparam)=
14
    _fooS strcat "user param is : " uparam;
15
    _fooS if (obj == button) then "Ok, same button" else "No !!";
16
    0;;
17
18
fun main ()=
19
    /* display the console */
20
    _showconsole;
21
22
    /* create a window */
23
    set win = _gtkWindowNew _channel nil "First example" [320 50] [500 400];
24
    /* define acallback when the window will be destroyed */
25
    _gtkWindowCBdestroyed win @CBend 0;
26
27
    /* create a button */
28
    set button = _gtkButtonNew _channel "Hello World !" SCOL_GTK_BUTTON_LABEL nil;
29
    /* define a callback when the button will be clicked */
30
    _gtkButtonCBclicked button @CBbutton "It's great !";
31
32
    /* Add the button to the window */
33
    _gtkWindowAddChild win button;
34
    /* Show all */
35
    _gtkWidgetShowAll win;
36
    /* Run the GTK+ loop */
37
    _gtkMain;
38
    0;;   
39
</code></pre>
40 2 iri
41
Return [[Examples]]