/tutorial/vision/modal/modal.e

http://github.com/tybor/Liberty · Specman e · 48 lines · 42 code · 5 blank · 1 comment · 1 complexity · 95ed9788e70b853d908f2de30fbf424c MD5 · raw file

  1. class MODAL
  2. -- This example show how to make modal windows.
  3. inherit
  4. GRAPHIC
  5. creation {ANY}
  6. make
  7. feature {}
  8. make is
  9. do
  10. new_window(0)
  11. io.put_string("The end%N")
  12. end
  13. new_window (level: INTEGER) is
  14. local
  15. message: LABEL; line: HORIZONTAL_LINE; new, quit: BUTTON; win: TOPLEVEL_WINDOW
  16. layout: COLUMN_LAYOUT; txt: UNICODE_STRING
  17. do
  18. if level > 0 then
  19. vision.new_loop
  20. end
  21. create layout
  22. create win.make(layout)
  23. layout.set_border(5)
  24. layout.set_spacing(5)
  25. win.set_title("Hello World - " + level.to_string)
  26. win.set_background_color(white_color)
  27. win.map
  28. txt := U"Hello World ! level = "
  29. level.append_in_unicode(txt)
  30. create message.make(txt)
  31. win.child_attach(message)
  32. create line
  33. win.child_attach(line)
  34. create new.with_label(win, U"New window")
  35. new.when_left_clicked(agent new_window(level + 1))
  36. create quit.with_label(win, U"Exit")
  37. quit.when_left_clicked(agent win.unmap)
  38. quit.when_left_clicked(agent vision.loop_stack.break)
  39. quit.when_right_down(agent win.set_background_color(black_color))
  40. quit.when_right_up(agent win.set_background_color(white_color))
  41. vision.start
  42. end
  43. end -- class MODAL