/tutorial/vision/layout/shrink_expand.e

http://github.com/tybor/Liberty · Specman e · 68 lines · 52 code · 9 blank · 7 comment · 0 complexity · 435a451a6af5dd2dddfd3ca587b1e63f MD5 · raw file

  1. class SHRINK_EXPAND
  2. --
  3. -- This example show how standards layouts (row / column) handle *_shrink_allowed and *_expand_allowed
  4. -- widget's properties.
  5. --
  6. -- See also WIDGET and LAYOUT for more information.
  7. --
  8. inherit
  9. GRAPHIC
  10. creation {ANY}
  11. make
  12. feature {}
  13. toplevel_window: TOPLEVEL_WINDOW
  14. make is
  15. local
  16. sub_window: SUB_WINDOW; label: LABEL
  17. do
  18. create toplevel_window
  19. -- The default layout is column.
  20. toplevel_window.set_title("Layout example")
  21. toplevel_window.set_background_color(white_color)
  22. toplevel_window.when_close_requested(agent vision.loop_stack.break)
  23. toplevel_window.map
  24. toplevel_window.set_x_shrink(True)
  25. toplevel_window.set_y_shrink(True)
  26. toplevel_window.child_attach(create {LABEL}.make(U"Fixed size label"))
  27. create sub_window.make(toplevel_window)
  28. sub_window.set_background_color(light_sky_blue_color)
  29. sub_window.child_attach(create {LABEL}.make(U"Expand area"))
  30. sub_window.set_x_expand(True)
  31. sub_window.set_y_expand(True)
  32. sub_window.map
  33. create sub_window.make(toplevel_window)
  34. sub_window.set_background_color(pink_color)
  35. create label.make(U"Expand and shrink area")
  36. label.set_x_shrink(True)
  37. label.set_y_shrink(True)
  38. label.set_min_width(0)
  39. label.set_min_height(0)
  40. sub_window.child_attach(label)
  41. sub_window.set_x_expand(True)
  42. sub_window.set_y_expand(True)
  43. sub_window.set_x_shrink(True)
  44. sub_window.set_y_shrink(True)
  45. sub_window.map
  46. create sub_window.make(toplevel_window)
  47. sub_window.set_background_color(light_green_color)
  48. create label.make(U"Shrink area")
  49. label.set_x_shrink(True)
  50. label.set_y_shrink(True)
  51. label.set_min_width(0)
  52. label.set_min_height(0)
  53. sub_window.child_attach(label)
  54. sub_window.set_x_shrink(True)
  55. sub_window.set_y_shrink(True)
  56. sub_window.map
  57. vision.start
  58. end
  59. end -- class SHRINK_EXPAND