I've no idea here...
[gtkD.git] / demos / gtk / OtherTests.d
blob1fcc274f0724456013b41dcb6727297f270603d3
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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.Duit;
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
40 Label byeLabel;
41 Timeout timeout;
43 this()
45 super("Duit");
46 setDecorated(true);
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");
54 });
56 button.addOnPressed(&mousePressed);
57 //addOnButtonPress(&mousePressed);
59 box.add(button);
60 byeLabel = new Label("Bye-bye World");
61 box.add(byeLabel);
62 add(box);
63 setBorderWidth(10);
64 move(0,400);
65 showAll();
67 addOnDelete(&onDeleteEvent);
69 timeout = new Timeout(1000, &changeLabel);
72 void mousePressed(Button widget)
74 writefln("mousePressed");
75 return false;
78 bit changeLabel()
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;
87 return true;
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;
101 int i = 0;
102 names[i++] = cast(char*)"Antonio Monteiro (binding/wrapping/proxying/decorating for D)";
103 names[i++] = cast(char*)"www.gtk.org (base C library)";
104 setAuthors(names);
105 setDocumenters(names);
106 setArtists(names);
107 setLicense("License is LGPL");
108 setWebsite("http://lisdev.com");
109 showAll();
113 gboolean onDeleteEvent(Event event, Widget widget)
115 destroy();
116 writefln("Exit by request from HelloWorld");
117 Duit.exit(0);
118 return 0;
121 char[] toString()
123 return "I Am HelloWorld";
128 void main(char[][] args)
130 Duit.init(args);
131 new OtherTests();
132 Duit.main();