example1.e 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. class EXAMPLE1
  2. inherit
  3. IUP_INTERFACE
  4. create
  5. make
  6. feature
  7. make
  8. local
  9. gui: IUP
  10. i: STRING
  11. a: ARRAY[IUP_WIDGET]
  12. l: IUP_LABEL
  13. b: IUP_BUTTON
  14. f: IUP_FLAT_BUTTON
  15. v: IUP_VBOX
  16. w: IUP_DIALOG
  17. do
  18. gui := iup_open
  19. create l.label("Hello world from Eiffel-IUP!")
  20. create b.button("OK")
  21. b.set_cb_action(agent close)
  22. b.set_rgb_background_color(0, 200, 0) -- This not work on Gtk3, use IUP_FLAT_BUTTON as show below.
  23. create f.flat_button("A flat button")
  24. f.set_cb_flat_action(agent flat_close)
  25. f.set_rgb_background_color(0, 200, 0)
  26. f.set_padding(5, 3)
  27. f.set_border(True)
  28. a := {ARRAY[IUP_WIDGET]} << l, b, f >>
  29. create v.vbox(a)
  30. v.set_alignment("ACENTER")
  31. v.set_gap(10)
  32. v.set_margin(10, 10)
  33. create w.dialog(v)
  34. w.set_title("Hello world")
  35. i := w.show
  36. gui.main_loop
  37. gui.close
  38. end
  39. close (widget: IUP_BUTTON): STRING
  40. do
  41. io.put_string("Executed %N")
  42. Result := "IUP_CLOSE"
  43. end
  44. flat_close (widget: IUP_FLAT_BUTTON): STRING
  45. do
  46. io.put_string("Executed %N")
  47. Result := "IUP_CLOSE"
  48. end
  49. end -- class EXAMPLE1