PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/vision/widget/menu_demo.e

http://github.com/tybor/Liberty
Specman e | 64 lines | 56 code | 8 blank | 0 comment | 0 complexity | 40d96a7fd1b8a987abc9581714044c11 MD5 | raw file
 1class MENU_DEMO
 2
 3inherit
 4	GRAPHIC
 5
 6creation {ANY}
 7	make
 8
 9feature {}
10	make is
11		local
12			toplevel_window, help_window: TOPLEVEL_WINDOW; menu_bar: MENU_BAR; help_label: LABEL
13		do
14			create help_window
15			create label.make(U"Waiting...")
16			help_window.set_background_color(white_color)
17			help_window.child_attach(create {LABEL}.make(U"This is the %
18                                                       %help Window"))
19			help_window.when_close_requested(agent help_window.unmap)
20			help_window.when_close_requested(agent vision.loop_stack.break)
21			create toplevel_window
22			toplevel_window.set_background_color(white_color)
23			create menu_bar.make(toplevel_window)
24			menu_bar.add_text_entry(U"File", file_menu)
25			menu_bar.add_text_entry(U"Edit", edit_menu)
26			menu_bar.add_space
27			create help_label.make(U"Help")
28			menu_bar.add_entry(help_label, agent show(help_window))
29			menu_bar.map
30			label.set_expand(True)
31			toplevel_window.child_attach(label)
32			toplevel_window.when_close_requested(agent vision.loop_stack.break)
33			toplevel_window.map
34			vision.start
35		end
36
37feature {}
38	label: LABEL
39
40	show (toplevel_window: TOPLEVEL_WINDOW) is
41		do
42			vision.new_loop
43			toplevel_window.map
44		end
45
46	file_menu: MENU is
47		do
48			create Result.make
49			Result.add_text_entry(U"Open", agent label.set_text(U"Open"))
50			Result.add_text_entry(U"Save", agent label.set_text(U"Save"))
51			Result.add_space
52			Result.add_text_entry(U"Exit", agent vision.loop_stack.break)
53		end
54
55	edit_menu: MENU is
56		do
57			create Result.make
58			Result.add_text_entry(U"Undo", agent label.set_text(U"Undo"))
59			Result.add_space
60			Result.add_text_entry(U"Copy", agent label.set_text(U"Copy"))
61			Result.add_text_entry(U"Paste", agent label.set_text(U"Paste"))
62		end
63
64end -- class MENU_DEMO