PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/tutorial/vision/widget/text_input.e

http://github.com/tybor/Liberty
Specman e | 57 lines | 50 code | 6 blank | 1 comment | 0 complexity | 4a856800ab5337e5adee8885fc1fb7f3 MD5 | raw file
 1class TEXT_INPUT
 2	-- Show how to use TEXT_FIELD to allow keyboard user input.
 3
 4inherit
 5	GRAPHIC
 6
 7creation {ANY}
 8	make
 9
10feature {}
11	make is
12		local
13			toplevel_window: TOPLEVEL_WINDOW; first_name, last_name, display_name, email, phone: TEXT_FIELD
14		do
15			create toplevel_window.default_create
16			toplevel_window.when_close_requested(agent vision.loop_stack.break)
17			toplevel_window.set_background_color(light_grey_color)
18			first_name := new_input(toplevel_window, once U"First Name:")
19			last_name := new_input(toplevel_window, once U"Last Name:")
20			display_name := new_input(toplevel_window, once U"Display Name:")
21			email := new_input(toplevel_window, once U"Email Address:")
22			phone := new_input(toplevel_window, once U"Phone Number:")
23			toplevel_window.map
24			vision.start
25			display(once "First Name:", first_name)
26			display(once "Last Name:", last_name)
27			display(once "Display Name:", display_name)
28			display(once "Email Address:", email)
29			display(once "Phone Number:", phone)
30		end
31
32	new_input (c: CONTAINER; title: UNICODE_STRING): TEXT_FIELD is
33		local
34			label: LABEL; box: CONTAINER; row_layout: ROW_LAYOUT
35		do
36			create row_layout
37			create box.make_layout(c, row_layout)
38			box.set_x_expand(True)
39			create label.make(title)
40			box.child_attach(label)
41			create Result.make(box)
42		end
43
44	display (msg: STRING; text_field: TEXT_FIELD) is
45		local
46			tmp: STRING
47		do
48			io.put_string(msg)
49			io.put_string(once " %"")
50			tmp := once ""
51			tmp.clear_count
52			text_field.text.utf8_encode_in(tmp)
53			io.put_string(tmp)
54			io.put_string(once "%"%N")
55		end
56
57end -- class TEXT_INPUT