2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 module gtk
.OtherTests
;
21 private import gtk
.AboutDialog
;
22 private import gtk
.Widget
;
23 private import gtk
.Window
;
24 private import gtk
.Label
;
25 private import gtk
.Button
;
26 private import gtk
.VBox
;
27 private import gtk
.GtkD
;
28 private import std
.stdio
;
29 private import gtk
.Image
;
31 private import gdk
.gdktypes
;
32 private import gobject
.Signals
;
33 private import gtk
.Timeout
;
35 private import gdk
.Event
;
37 public class OtherTests
: Window
47 VBox box
= new VBox(false, 2);
48 box
.add(new Label("Hello World"));
49 Button button
= new Button("About");
50 button
.addOnClicked(&onClicked
);
51 button
.addOnClicked(&popupAbout
);
52 button
.addOnClicked(delegate void(Button b
){
53 writefln("\nliterally clicked");
56 button
.addOnPressed(&mousePressed
);
57 //addOnButtonPress(&mousePressed);
60 byeLabel
= new Label("Bye-bye World");
67 addOnDelete(&onDeleteEvent
);
69 timeout
= new Timeout(1000, &changeLabel
);
72 void mousePressed(Button widget
)
74 writefln("mousePressed");
80 switch ( byeLabel
.getText() )
82 case "Bye-bye World": byeLabel
.setText("still here"); break;
83 case "still here": byeLabel
.setText("close window"); break;
84 case "close window": byeLabel
.setText("to terminate"); break;
85 default : byeLabel
.setText("Bye-bye World"); break;
90 void onClicked(Button button
)
92 writefln("\nOn click from Hello World %s", button
);
95 void popupAbout(Button button
)
97 with (new AboutDialog())
100 char** names
= (new char*[2]).ptr
;
102 names
[i
++] = cast(char*)"Antonio Monteiro (binding/wrapping/proxying/decorating for D)";
103 names
[i
++] = cast(char*)"www.gtk.org (base C library)";
105 setDocumenters(names
);
107 setLicense("License is LGPL");
108 setWebsite("http://lisdev.com");
113 gboolean
onDeleteEvent(Event event
, Widget widget
)
116 writefln("Exit by request from HelloWorld");
123 return "I Am HelloWorld";
128 void main(char[][] args
)