Project

General

Profile

Some buttons » History » Version 3

iri, 02/22/2011 02:06 PM

1 1 iri
h1. Some buttons
2
3
This example show a window, a box and six differents buttons.
4
5 3 iri
<pre><code class="php">
6 1 iri
typeof win = ObjGtkWidget;;
7
typeof button = ObjGtkWidget;;
8
typeof button2 = ObjGtkWidget;;
9
typeof button3 = ObjGtkWidget;;
10
typeof button4 = ObjGtkWidget;;
11
typeof button5 = ObjGtkWidget;;
12
typeof button6 = ObjGtkWidget;;
13
typeof vbox = ObjGtkWidget;;
14
15
fun CBend (obj, uparam)=
16
	_fooId uparam;
17
	_gtkMainQuit;
18
	0;;
19
	
20
fun CBbuttonLinked (obj, uparam, uri)=
21
	_fooS "Link !";
22
	_fooS uri;
23
	0;;
24
	
25
fun CBbuttonToggled (obj, uparam, state)=
26
	_fooId state;
27
	uparam;;
28
	
29
fun CBbutton (obj, uparam)=
30
	_fooS strcat "user param is : " uparam;
31
	_fooS if (obj == button) then "Ok, same button" else "No !!";
32
	0;;
33
34
fun main ()=
35
	_showconsole;
36
	
37
	set win = _gtkWindowNew _channel nil "Coool !" [320 50] [500 400];
38
	_gtkWindowCBdestroyed win @CBend 10;
39
	
40
	set vbox = _gtkBoxNew _channel win 1 5 SCOL_GTK_BOX_VT;
41
	
42
	set button = _gtkButtonNew _channel "My button" SCOL_GTK_BUTTON_LABEL nil;
43
	set button2 = _gtkButtonNew _channel "gtk-open" SCOL_GTK_BUTTON_LABEL nil;
44
	set button3 = _gtkButtonNew _channel "A link" SCOL_GTK_BUTTON_LINK "http://www.scolring.org";
45
	set button4 = _gtkButtonNew _channel "Click !" SCOL_GTK_BUTTON_CHECK nil;
46
	set button5 = _gtkButtonNew _channel "Toggle !" SCOL_GTK_BUTTON_TOGGLE 1;
47
	set button6 = _gtkButtonNew _channel nil SCOL_GTK_BUTTON_SWITCH 1;
48
	_gtkButtonCB button @CBbutton "yes !" SCOL_GTK_BUTTON_CB_CLICKED;
49
	_gtkButtonCB button2 @CBbutton "no !" SCOL_GTK_BUTTON_CB_CLICKED;
50
	_gtkButtonCB button4 @CBbuttonToggled 2 SCOL_GTK_BUTTON_CB_TOGGLED;
51
	_gtkButtonCB button3 @CBbuttonLinked 0 SCOL_GTK_BUTTON_CB_LINKED;
52
	
53
	_gtkBoxAddChilds vbox button :: button2 :: button3 :: button4 :: button5 :: button6 :: nil 0;
54
	
55
	_gtkWidgetShowAll win;
56
	_gtkMain;
57
58
	0;;
59
</code></pre>
60
61 2 iri
!http://www.scolring.org/files/divers/scolring_wiki_example_somebuttons.png!
62
63 1 iri
Return [[Examples]]