alternative to assert
[gtkD.git] / gtkD / demos / gtkD / TestEntries.d
blob90a4fd3420c870f8b1fa26c5665a6d3f50e247ee
1 /*
2 * This file is part of gtkD.
3 *
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.
8 *
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 gtkD.TestEntries;
21 private import gtk.Table;
23 private import gtk.Entry;
24 private import gtk.CheckButton;
25 private import gtk.Button;
26 private import gtk.Label;
27 private import gtkc.gtktypes;
29 private import glib.Str;
31 version(Tango) private import tango.io.Stdout;
32 /**
33 * This tests the GtkD Entry widget
35 class TestEntries : Table
37 /**
38 * Out main widget to test
40 Entry entry;
42 /**
43 * Creates a new TestEntries
45 this()
47 super(3,2,false);
49 // create the main test widget
50 entry = new Entry("Change me!");
51 attach(new Label("Input text"),0,1,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
52 attach(entry,1,2,0,1,AttachOptions.EXPAND,AttachOptions.EXPAND,4,4);
54 // create a button that will print the content of the entry to stdout
55 Button testButton = new Button("Show entry", &showEntry);
56 attach(testButton,2,3,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
57 //testButton.setTooltip("This is just a test",null);
59 // create a button that will change the entry display mode to invisible
60 // i.e. like a password entry
61 CheckButton entryVisible = new CheckButton("Visible", &entryVisible);
62 entryVisible.setActive(true);
63 attach(entryVisible,2,3,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
65 // create a button that will change the entry mode to not editable
66 CheckButton entryEditable = new CheckButton("Editable", &entryEditable);
67 entryEditable.setActive(true);
68 attach(entryEditable,1,2,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
71 void showEntry(Button button)
73 version(Tango) Stdout.format("text field contains '{}'\n",entry.getText()).newline;
74 else printf("text field contains '%s'\n",Str.toStringz(entry.getText()));
77 void entryEditable(CheckButton button)
79 entry.setEditable(button.getActive());
82 void entryVisible(CheckButton button)
84 entry.setVisibility(button.getActive());