graphic.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. module Zori
  2. # Helper module for everyhing that uses Graphs
  3. module Graphic
  4. attr_reader :graph
  5. def initialize(params={}, &block)
  6. init_graph()
  7. end
  8. def init_graph()
  9. @graph = []
  10. end
  11. def hide_graph
  12. @graph.each { |g| g.visible = false }
  13. end
  14. def show_graph
  15. @graph.each { |g| g.visible = true }
  16. end
  17. def move_graph(x, y)
  18. @graph.each { |g| g.position= [x, y] }
  19. end
  20. def graph_box(x, y, w, h, rx = 4, ry = 4, style_id = -1)
  21. gr = Graph.make_box(x, y, w, h, rx, ry, style_id)
  22. graph_add(gr)
  23. return gr
  24. end
  25. def graph_image(x, y, store_id, style_id = -1)
  26. gr = Graph.make_image(x, y, store_id, style_id)
  27. graph_add(gr)
  28. return gr
  29. end
  30. def graph_text(x, y, w, h, text, style_id = -1)
  31. gr = Graph.make_text(x, y, w, h, text, style_id)
  32. graph_add(gr)
  33. return gr
  34. end
  35. def graph_longtext(x, y, w, h, text, style_id = -1)
  36. gr = Graph.make_longtext(x, y, w, h, text, style_id)
  37. graph_add(gr)
  38. return gr
  39. end
  40. def graph_add(gr)
  41. @graph << gr
  42. end
  43. def graph_delete(gr)
  44. @graph.delete(gr)
  45. end
  46. end
  47. end