diff options
author | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-01 10:25:51 +0000 |
---|---|---|
committer | ocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-01 10:25:51 +0000 |
commit | 90965b65e8ac72d4508052b21d79e0cb2bfd6e2c (patch) | |
tree | c071ecab8586b361e907b3ddcb70f241d93ed05d /ext/tk | |
parent | f11187c41e453ddaa88c0d4e36a790d666c47c32 (diff) | |
download | ruby-90965b65e8ac72d4508052b21d79e0cb2bfd6e2c.tar.gz ruby-90965b65e8ac72d4508052b21d79e0cb2bfd6e2c.tar.xz ruby-90965b65e8ac72d4508052b21d79e0cb2bfd6e2c.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
-rw-r--r-- | ext/tk/ChangeLog.tkextlib | 10 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile.rb | 2 | ||||
-rw-r--r-- | ext/tk/lib/tkextlib/tile/treeview.rb | 14 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tile/demo.rb | 52 |
4 files changed, 68 insertions, 10 deletions
diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib index d9dff5023..85b4cf619 100644 --- a/ext/tk/ChangeLog.tkextlib +++ b/ext/tk/ChangeLog.tkextlib @@ -1,5 +1,15 @@ 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. 2005-07-27 ocean <ocean@ruby-lang.org> diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb index 80f2d0ae2..8c5465e9e 100644 --- a/ext/tk/lib/tkextlib/tile.rb +++ b/ext/tk/lib/tkextlib/tile.rb @@ -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 diff --git a/ext/tk/lib/tkextlib/tile/treeview.rb b/ext/tk/lib/tkextlib/tile/treeview.rb index fcd3c7b48..80c26596f 100644 --- a/ext/tk/lib/tkextlib/tile/treeview.rb +++ b/ext/tk/lib/tkextlib/tile/treeview.rb @@ -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 diff --git a/ext/tk/sample/tkextlib/tile/demo.rb b/ext/tk/sample/tkextlib/tile/demo.rb index d6673f3bd..473e5b4bd 100644 --- a/ext/tk/sample/tkextlib/tile/demo.rb +++ b/ext/tk/sample/tkextlib/tile/demo.rb @@ -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: @@ -556,6 +558,52 @@ values = %w(list abc def ghi jkl mno pqr stu vwx yz) } # +# 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: # $Timers = {:StateMonitor=>nil, :FocusMonitor=>nil} |