2 # tk/textimage.rb - treat Tk text image object
7 class TkTextImage<TkObject
8 include Tk::Text::IndexModMethods
10 def initialize(parent, index, keys)
11 #unless parent.kind_of?(Tk::Text)
12 # fail ArgumentError, "expect Tk::Text for 1st argument"
15 if index == 'end' || index == :end
16 @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
17 elsif index.kind_of? TkTextMark
18 if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
19 @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
22 @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
26 @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
27 _get_eval_enc_str(index)))
29 @path.gravity = 'left'
31 @id = tk_call_without_enc(@t.path, 'image', 'create', @index,
32 *hash_kv(keys, true)).freeze
33 @path.gravity = 'right'
37 Tk::Text::IndexString.new(@id)
47 configure(slot, value)
52 @t.image_cget(@index, slot)
56 @t.image_cget_strict(@index, slot)
59 def configure(slot, value=None)
60 @t.image_configure(@index, slot, value)
63 # def configure(slot, value)
64 # tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value
67 def configinfo(slot = nil)
68 @t.image_configinfo(@index, slot)
71 def current_configinfo(slot = nil)
72 @t.current_image_configinfo(@index, slot)
76 img = tk_call_without_enc(@t.path, 'image', 'cget', @index, '-image')
77 TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img
81 tk_call_without_enc(@t.path, 'image', 'configure', @index, '-image',
82 _get_eval_enc_str(value))
88 TktImage = TkTextImage