I've no idea here...
[gtkD.git] / demos / duit / TestEntries.d
blob320a81a109806f1e68e999c39768f07daae22630
1 /*
2 * This file is part of dui.
3 *
4 * dui 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 * dui 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 dui; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 module duit.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 gtk.gtktypes;
29 private import glib.Str;
30 /**
31 * This tests the DUI Entry widget
33 class TestEntries : Table
35 /**
36 * Out main widget to test
38 Entry entry;
40 /**
41 * Creates a new TestEntries
43 this()
45 super(3,2,false);
47 // create the main test widget
48 entry = new Entry("Change me!");
49 attach(new Label("Input text"),0,1,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
50 attach(entry,1,2,0,1,AttachOptions.EXPAND,AttachOptions.EXPAND,4,4);
52 // create a button that will print the content of the entry to stdout
53 Button testButton = new Button("Show entry", &showEntry);
54 attach(testButton,2,3,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
55 //testButton.setTooltip("This is just a test",null);
57 // create a button that will change the entry display mode to invisible
58 // i.e. like a password entry
59 CheckButton entryVisible = new CheckButton("Visible", &entryVisible);
60 entryVisible.setActive(true);
61 attach(entryVisible,2,3,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
63 // create a button that will change the entry mode to not editable
64 CheckButton entryEditable = new CheckButton("Editable", &entryEditable);
65 entryEditable.setActive(true);
66 attach(entryEditable,1,2,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
69 void showEntry(Button button)
71 printf("text field contains %s\n",Str.toStringz(entry.getText()));
74 void entryEditable(CheckButton button)
76 entry.setEditable(button.getActive());
79 void entryVisible(CheckButton button)
81 entry.setVisibility(button.getActive());