Method: TkTextImage#initialize

Defined in:
lib/tk/textimage.rb

#initialize(parent, index, keys) ⇒ TkTextImage

Returns a new instance of TkTextImage.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tk/textimage.rb', line 11

def initialize(parent, index, keys)
  #unless parent.kind_of?(Tk::Text)
  #  fail ArgumentError, "expect Tk::Text for 1st argument"
  #end
  @t = parent
  if index == 'end' || index == :end
    @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars'))
  elsif index.kind_of? TkTextMark
    if tk_call_without_enc(@t.path,'index',index.path) == tk_call_without_enc(@t.path,'index','end')
      @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
                                                     'end - 1 chars'))
    else
      @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
                                                     index.path))
    end
  else
    @path = TkTextMark.new(@t, tk_call_without_enc(@t.path, 'index',
                                                   _get_eval_enc_str(index)))
  end
  @path.gravity = 'left'
  @index = @path.path
  @id = tk_call_without_enc(@t.path, 'image', 'create', @index,
                            *hash_kv(keys, true)).freeze
  @path.gravity = 'right'
end