1#
2#  tkextlib/blt/graph.rb
3#                               by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
4#
5
6require 'tk'
7require 'tkextlib/blt.rb'
8require 'tkextlib/blt/component.rb'
9
10module Tk::BLT
11  class Graph < TkWindow
12    TkCommandNames = ['::blt::graph'.freeze].freeze
13    WidgetClassName = 'Graph'.freeze
14    WidgetClassNames[WidgetClassName] ||= self
15
16    include PlotComponent
17    include GraphCommand
18
19    def __boolval_optkeys
20      ['bufferelements', 'invertxy']
21    end
22    private :__boolval_optkeys
23
24    def __strval_optkeys
25      ['text', 'label', 'title', 'file', 'plotbackground']
26    end
27    private :__strval_optkeys
28
29=begin
30    BarElement_ID = ['blt_graph_bar'.freeze, TkUtil.untrust('00000')].freeze
31
32    def bar(elem=nil, keys={})
33      if elem.kind_of?(Hash)
34        keys = elem
35        elem = nil
36      end
37      unless elem
38        elem = BarElement_ID.join(TkCore::INTERP._ip_id_).freeze
39        BarElement_ID[1].succ!
40      end
41      tk_send('bar', elem, keys)
42      Element.new(self, elem, :without_creating=>true)
43    end
44=end
45
46    def extents(item)
47      num_or_str(tk_send_without_enc('extents', item))
48    end
49
50    def invtransform(x, y)
51      list(tk_send_without_enc('invtransform', x, y))
52    end
53
54    def inside(x, y)
55      bool(tk_send_without_enc('inside', x, y))
56    end
57
58    def snap(output, keys={})
59      tk_send_without_enc('snap', *(hash_kv(keys, false) + output))
60      self
61    end
62
63    def transform(x, y)
64      list(tk_send_without_enc('transform', x, y))
65    end
66  end
67end
68