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

/tutorial/vision/widget/combo_demo.e

http://github.com/tybor/Liberty
Specman e | 81 lines | 70 code | 10 blank | 1 comment | 0 complexity | dee87a7f73f59d4c116cef4681f00d77 MD5 | raw file
 1class COMBO_DEMO
 2	-- Show how to use COMBO to allow selection from pre-defined values.
 3
 4inherit
 5	GRAPHIC
 6
 7creation {ANY}
 8	make
 9
10feature {}
11	make is
12		local
13			toplevel_window: TOPLEVEL_WINDOW; language, day: COMBO
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			create language.with_text(toplevel_window, languages_names_list)
19			language.map
20			create day.with_text(toplevel_window, days_names_list_en)
21			day.map
22			language.when_value_change(agent change_language(day, ?))
23			toplevel_window.map
24			vision.start
25		end
26
27	change_language (c: COMBO; i: INTEGER) is
28		local
29			memo: INTEGER
30		do
31			memo := c.active_item
32			c.change_items_with_text(languages_list.item(i))
33			c.activate(memo)
34		end
35
36	languages_list: FAST_ARRAY[FAST_ARRAY[UNICODE_STRING]] is
37		once
38			Result := {FAST_ARRAY[FAST_ARRAY[UNICODE_STRING]] << days_names_list_en,
39																				  days_names_list_es,
40																				  days_names_list_fr >> }
41		end
42
43	languages_names_list: FAST_ARRAY[UNICODE_STRING] is
44		once
45			Result := {FAST_ARRAY[UNICODE_STRING] <<U"English", U"Spanish", U"French">> }
46		end
47
48	days_names_list_en: FAST_ARRAY[UNICODE_STRING] is
49		once
50			Result := {FAST_ARRAY[UNICODE_STRING] << U"Monday",
51																  U"Tuesday",
52																  U"Wednesday",
53																  U"Thursday",
54																  U"Friday",
55																  U"Saturday",
56																  U"Sunday" >> }
57		end
58
59	days_names_list_es: FAST_ARRAY[UNICODE_STRING] is
60		once
61			Result := {FAST_ARRAY[UNICODE_STRING] << U"Lunes",
62																  U"Martes",
63																  U"Miercoles",
64																  U"Jueves",
65																  U"Viernes",
66																  U"Sabado",
67																  U"Domingo" >> }
68		end
69
70	days_names_list_fr: FAST_ARRAY[UNICODE_STRING] is
71		once
72			Result := {FAST_ARRAY[UNICODE_STRING] << U"Lundi",
73																  U"Mardi",
74																  U"Mercredi",
75																  U"Jeudi",
76																  U"Vendredi",
77																  U"Samedi",
78																  U"Dimanche" >> }
79		end
80
81end -- class COMBO_DEMO