Class: TkTree

Inherits:
TkCanvas show all
Defined in:
sample/tktree.rb

Constant Summary collapse

TCL_SCRIPT_PATH =
File.join(File.dirname(__FILE__), 'tktree.tcl')

Instance Method Summary collapse

Instance Method Details

#create_self(keys) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'sample/tktree.rb', line 17

def create_self(keys)
  args = [@path]
  if keys.kind_of?(Hash)
    font = keys.delete('itemfont')
#      font = hash_kv(font) if font.kind_of?(Hash)
    keys['font'] = font if font
#      args.concat(hash_kv(keys))
    args << keys
  end
  begin
    tk_call('::tktree::treecreate', *args)
  rescue NameError, RuntimeError
    Tk.load_tclscript(TkTree::TCL_SCRIPT_PATH)
    tk_call('::tktree::treecreate', *args)
  end
end

#delitem(itempath) ⇒ Object



47
48
49
# File 'sample/tktree.rb', line 47

def delitem(itempath)
  tk_call('::tktree::delitem', @path, itempath)
end

#getselectionObject



55
56
57
# File 'sample/tktree.rb', line 55

def getselection
  tk_call('::tktree::getselection', @path)
end

#labelat(xpos, ypos) ⇒ Object



51
52
53
# File 'sample/tktree.rb', line 51

def labelat(xpos, ypos)
  tk_call('::tktree::delitem', @path, xpos, ypos)
end

#newitem(itempath, keys = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'sample/tktree.rb', line 34

def newitem(itempath, keys = nil)
  if keys.kind_of?(Hash)
    keys = _symbolkey2str(keys)
    font = keys.delete('itemfont')
#      font = hash_kv(font) if font.kind_of?(Hash)
    keys['font'] = font if font
#      tk_call('::tktree::newitem', @path, itempath, *hash_kv(keys))
    tk_call('::tktree::newitem', @path, itempath, keys)
  else
    tk_call('::tktree::newitem', @path, itempath)
  end
end

#setselection(itempath) ⇒ Object



59
60
61
# File 'sample/tktree.rb', line 59

def setselection(itempath)
  tk_call('::tktree::getselection', @path, itempath)
end