mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/tk/lib/tkextlib/tile.rb: fixed autoload for Treeview.
* ext/tk/lib/tkextlib/tile/treeview.rb: replaced `ary2tk_list(items)' with `*items'. * ext/tk/sample/tkextlib/tile: added treeview demo. (tile 0.5 or later is needed) [ruby-dev:26668] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
87ecfbd773
commit
b73cd9cb5c
4 changed files with 68 additions and 10 deletions
|
@ -1,3 +1,13 @@
|
|||
2005-08-01 ocean <ocean@ruby-lang.org>
|
||||
|
||||
* lib/tkextlib/tile.rb: fixed autoload for Treeview.
|
||||
|
||||
* lib/tkextlib/tile/treeview.rb: replaced `ary2tk_list(items)' with
|
||||
`*items'.
|
||||
|
||||
* sample/tkextlib/tile: added treeview demo. (tile 0.5 or later is
|
||||
needed) [ruby-dev:26668]
|
||||
|
||||
2005-08-01 ocean <ocean@ruby-lang.org>
|
||||
|
||||
* sample/tkextlib/tile/demo.rb: added combobox demo.
|
||||
|
|
|
@ -142,7 +142,7 @@ module Tk
|
|||
|
||||
autoload :TSquare, 'tkextlib/tile/tsquare'
|
||||
|
||||
autoload :TreeView, 'tkextlib/tile/treeview'
|
||||
autoload :Treeview, 'tkextlib/tile/treeview'
|
||||
|
||||
autoload :Style, 'tkextlib/tile/style'
|
||||
end
|
||||
|
|
|
@ -129,17 +129,17 @@ class Tk::Tile::Treeview < TkWindow
|
|||
list(tk_send_without_enc('children', item))
|
||||
end
|
||||
def children=(item, *items)
|
||||
tk_send_without_enc('children', item, ary2tk_list(items))
|
||||
tk_send_without_enc('children', item, *items)
|
||||
items
|
||||
end
|
||||
|
||||
def delete(*items)
|
||||
tk_send_without_enc('delete', ary2tk_list(items))
|
||||
tk_send_without_enc('delete', *items)
|
||||
self
|
||||
end
|
||||
|
||||
def detach(*items)
|
||||
tk_send_without_enc('detach', ary2tk_list(items))
|
||||
tk_send_without_enc('detach', *items)
|
||||
self
|
||||
end
|
||||
|
||||
|
@ -193,19 +193,19 @@ class Tk::Tile::Treeview < TkWindow
|
|||
end
|
||||
|
||||
def selection_add(*items)
|
||||
tk_send_without_enc('selection', 'add', ary2tk_list(items))
|
||||
tk_send_without_enc('selection', 'add', *items)
|
||||
self
|
||||
end
|
||||
def selection_remove(*items)
|
||||
tk_send_without_enc('selection', 'remove', ary2tk_list(items))
|
||||
tk_send_without_enc('selection', 'remove', *items)
|
||||
self
|
||||
end
|
||||
def selection_set(*items)
|
||||
tk_send_without_enc('selection', 'set', ary2tk_list(items))
|
||||
tk_send_without_enc('selection', 'set', *items)
|
||||
self
|
||||
end
|
||||
def selection_toggle(*items)
|
||||
tk_send_without_enc('selection', 'toggle', ary2tk_list(items))
|
||||
tk_send_without_enc('selection', 'toggle', *items)
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
@ -303,6 +303,8 @@ def makeNotebook
|
|||
|
||||
combo = Tk::Tile::TFrame.new(nb)
|
||||
nb.add(combo, :text=>'Combobox', :underline=>7)
|
||||
tree = Tk::Tile::TFrame.new(nb)
|
||||
nb.add(tree, :text=>'Tree')
|
||||
others = Tk::Tile::TFrame.new(nb)
|
||||
nb.add(others, :text=>'Others', :underline=>4)
|
||||
nb.add(Tk::Tile::TLabel.new(nb, :text=>'Nothing to see here...'),
|
||||
|
@ -310,10 +312,10 @@ def makeNotebook
|
|||
nb.add(Tk::Tile::TLabel.new(nb, :text=>'Nothing to see here either.'),
|
||||
:text=>'More Stuff', :sticky=>:se)
|
||||
|
||||
[nb, client, combo, others]
|
||||
[nb, client, combo, tree, others]
|
||||
end
|
||||
|
||||
nb, client, combo, others = makeNotebook()
|
||||
nb, client, combo, tree, others = makeNotebook()
|
||||
|
||||
#
|
||||
# Side-by side check, radio, and menu button comparison:
|
||||
|
@ -555,6 +557,52 @@ values = %w(list abc def ghi jkl mno pqr stu vwx yz)
|
|||
end
|
||||
}
|
||||
|
||||
#
|
||||
# Treeview widget demo pane:
|
||||
#
|
||||
if TkPackage.vcompare(Tk::Tile.package_version, '0.5') >= 0
|
||||
|
||||
treeview = nil # avoid 'undefined' error
|
||||
scrollbar = Tk::Tile::TScrollbar.new(tree,
|
||||
:command=>proc{|*args| treeview.yview(*args)})
|
||||
treeview = Tk::Tile::Treeview.new(tree, :columns=>%w(Class), :padding=>4,
|
||||
:yscrollcommand=>proc{|*args| scrollbar.set(*args)})
|
||||
|
||||
Tk.grid(treeview, scrollbar, :sticky=>'news')
|
||||
tree.grid_columnconfigure(0, :weight=>1)
|
||||
tree.grid_rowconfigure(0, :weight=>1)
|
||||
tree.grid_propagate(0)
|
||||
|
||||
# Add initial tree node:
|
||||
# Later nodes will be added in <<TreeviewOpen>> binding.
|
||||
treeview.insert('', 0, :id=>'.', :text=>'Main Window', :open=>false,
|
||||
:values=>[TkWinfo.classname('.')])
|
||||
Tk.tk_call(treeview, 'heading', '#0', :text=>'Widget')
|
||||
Tk.tk_call(treeview, 'heading', 'Class', :text=>'Class')
|
||||
treeview.bind('<TreeviewOpen>', proc{fillTree(treeview)})
|
||||
|
||||
def fillTree(treeview)
|
||||
id = treeview.focus_item
|
||||
unless TkWinfo.exist?(id)
|
||||
treeview.delete(id)
|
||||
end
|
||||
# Replace tree item children with current list of child windows.
|
||||
treeview.delete(treeview.children(id))
|
||||
for child in TkWinfo.children(id)
|
||||
treeview.insert(id, :end, :id=>child, :text=>TkWinfo.appname(child),
|
||||
:open=>false, :values=>[TkWinfo.classname(child)])
|
||||
unless TkWinfo.children(child).empty?
|
||||
# insert dummy child to show [+] indicator
|
||||
treeview.insert(child, :end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
Tk::Tile::TLabel.new(tree,
|
||||
:text=>'Treeview is supported on tile 0.5 or later...').pack
|
||||
end
|
||||
|
||||
#
|
||||
# Other demos:
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue