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 3 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.
13  *
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., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
17  */
18 
19 module TestEntries;
20 
21 private import gtk.Table;
22 
23 private import gtk.Entry;
24 private import gtk.CheckButton;
25 private import gtk.Button;
26 private import gtk.Label;
27 
28 private import glib.Str;
29 
30 private import std.stdio;
31 /**
32  * This tests the GtkD Entry widget
33  */
34 class TestEntries : Table
35 {
36 	/**
37 	 * Out main widget to test
38 	 */
39 	Entry entry;
40 
41 	/**
42 	 * Creates a new TestEntries
43 	 */
44 	this()
45 	{
46 		super(3,2,false);
47 
48 		// create the main test widget
49 		entry = new Entry("Change me!");
50 		attach(new Label("Input text"),0,1,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
51 		attach(entry,1,2,0,1,AttachOptions.EXPAND,AttachOptions.EXPAND,4,4);
52 
53 		// create a button that will print the content of the entry to stdout
54 		Button testButton = new Button("Show entry", &showEntry);
55 		attach(testButton,2,3,0,1,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
56 		//testButton.setTooltip("This is just a test",null);
57 
58 		// create a button that will change the entry display mode to invisible
59 		// i.e. like a password entry
60 		CheckButton entryVisible = new CheckButton("Visible", &entryVisible);
61 		entryVisible.setActive(true);
62 		attach(entryVisible,2,3,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
63 
64 		// create a button that will change the entry mode to not editable
65 		CheckButton entryEditable = new CheckButton("Editable", &entryEditable);
66 		entryEditable.setActive(true);
67 		attach(entryEditable,1,2,1,2,AttachOptions.SHRINK,AttachOptions.SHRINK,4,4);
68 	}
69 
70 	void showEntry(Button button)
71 	{
72 		writef("text field contains '%s'\n",entry.getText());
73 	}
74 
75 	void entryEditable(CheckButton button)
76 	{
77 		entry.setEditable(button.getActive());
78 	}
79 
80 	void entryVisible(CheckButton button)
81 	{
82 		entry.setVisibility(button.getActive());
83 	}
84 
85 }