1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/tk/lib/tk.rb (TkWindow.initialize): accept 'without_creating'

option without 'widgetname' option to allow creating a widget object
  which is used as an argument of Tcl/Tk's widget allocation commands.
* ext/tk/lib/tk/image.rb (TkImage.initialize): accept 'imagename'
  option to create a image object by the given name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2005-04-01 17:22:02 +00:00
parent 011527f455
commit 4f8df7dcc4
8 changed files with 230 additions and 114 deletions

View file

@ -1,3 +1,12 @@
Sat Apr 2 02:19:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tk.rb (TkWindow.initialize): accept 'without_creating'
option without 'widgetname' option to allow creating a widget object
which is used as an argument of Tcl/Tk's widget allocation commands.
* ext/tk/lib/tk/image.rb (TkImage.initialize): accept 'imagename'
option to create a image object by the given name.
Thu Mar 31 23:52:48 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/tk/sample/tkextlib/treectrl/demo.rb: should use Hash#index.

View file

@ -1,3 +1,13 @@
2005-04-02 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* lib/tkextlib/blt/component.rb: add TreeCtrl#legend_window_create().
* sample/tkextlib/blt/graph6.rb: use legend_window_create().
* lib/tkextlib/blt/tree.rb: forget to call tagid().
* lib/tkextlib/blt/treeview.rb: ditto.
2005-04-01 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* sample/tkextlib/treectrl/demo.rb: bridge the gap of

View file

@ -3425,19 +3425,19 @@ class TkWindow<TkObject
widgetname = keys.delete('widgetname')
install_win(if parent then parent.path end, widgetname)
without_creating = keys.delete('without_creating')
if without_creating && !widgetname
fail ArgumentError,
"if set 'without_creating' to true, need to define 'widgetname'"
end
# if without_creating && !widgetname
# fail ArgumentError,
# "if set 'without_creating' to true, need to define 'widgetname'"
# end
elsif keys
keys = _symbolkey2str(keys)
widgetname = keys.delete('widgetname')
install_win(if parent then parent.path end, widgetname)
without_creating = keys.delete('without_creating')
if without_creating && !widgetname
fail ArgumentError,
"if set 'without_creating' to true, need to define 'widgetname'"
end
# if without_creating && !widgetname
# fail ArgumentError,
# "if set 'without_creating' to true, need to define 'widgetname'"
# end
else
install_win(if parent then parent.path end)
end

View file

@ -15,9 +15,16 @@ class TkImage<TkObject
TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear }
def initialize(keys=nil)
# @path = Tk_Image_ID.join('')
@path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
Tk_Image_ID[1].succ!
@path = nil
if keys.kind_of?(Hash)
keys = _symbolkey2str(keys)
@path = keys.delete('imagename')
end
unless @path
# @path = Tk_Image_ID.join('')
@path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
Tk_Image_ID[1].succ!
end
tk_call_without_enc('image', 'create', @type, @path, *hash_kv(keys, true))
Tk_IMGTBL[@path] = self
end

View file

@ -350,6 +350,7 @@ module Tk::BLT
@axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
OBJ_ID[1].succ!
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
Axis::OBJ_TBL[@cpath][@axis] = self
@ -442,14 +443,15 @@ module Tk::BLT
@cpath = @chart.path
Crosshairs::OBJ_TBL[@cpath] = self
@chart.crosshair_configure(keys) unless keys.empty?
@path = @id = 'crosshairs'
end
def id
'crosshairs'
@id
end
def to_eval
'crosshairs'
@id
end
def cget(option)
@ -531,6 +533,7 @@ module Tk::BLT
@element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
OBJ_ID[1].succ!
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
@typename = self.class::ElementTypeName
@ -570,7 +573,6 @@ module Tk::BLT
def activate(*args)
@chart.element_activate(@id, *args)
self
end
def closest(x, y, var, keys={})
@ -625,14 +627,15 @@ module Tk::BLT
@cpath = @chart.path
GridLine::OBJ_TBL[@cpath] = self
@chart.gridline_configure(keys) unless keys.empty?
@path = @id = 'grid'
end
def id
'grid'
@id
end
def to_eval
'grid'
@id
end
def cget(option)
@ -678,14 +681,15 @@ module Tk::BLT
@cpath = @chart.path
Crosshairs::OBJ_TBL[@cpath] = self
@chart.crosshair_configure(keys) unless keys.empty?
@path = @id = 'legend'
end
def id
'legend'
@id
end
def to_eval
'legend'
@id
end
def cget(option)
@ -704,12 +708,10 @@ module Tk::BLT
def activate(*args)
@chart.legend_activate(*args)
self
end
def deactivate(*args)
@chart.legend_deactivate(*args)
self
end
def get(pos, y=nil)
@ -750,6 +752,7 @@ module Tk::BLT
@pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
OBJ_ID[1].succ!
end
@path = @id
@parent = @chart = chart
@cpath = @chart.path
Pen::OBJ_TBL[@cpath][@pen] = self
@ -807,14 +810,15 @@ module Tk::BLT
@cpath = @chart.path
Postscript::OBJ_TBL[@cpath] = self
@chart.postscript_configure(keys) unless keys.empty?
@path = @id = 'postscript'
end
def id
'postscript'
@id
end
def to_eval
'postscript'
@id
end
def cget(option)
@ -925,25 +929,25 @@ module Tk::BLT
obj = self.allocate
obj.instance_eval{
@parent = @chart = chart
@path = chart.path
@cpath = chart.path
@id = id
unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@path]
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@path] = {}
unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath]
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] = {}
end
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@path][@id] = self
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
}
obj
end
def initialize(parent, *args)
@parent = @chart = parent
@path = parent.path
@cpath = parent.path
@id = create_self(*args) # an integer number as 'item id'
unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@path]
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@path] = {}
@path = @id = create_self(*args) # an integer number as 'item id'
unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath]
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] = {}
end
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@path][@id] = self
Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
end
def create_self(*args)
self.class.create(@chart, *args) # return an integer as 'item id'
@ -1397,6 +1401,34 @@ module Tk::BLT
###################
def legend_window_create(parent=nil, keys=nil)
if parent.kind_of?(Hash)
keys = _symbolkey2str(parent)
parent = keys.delete('parent')
widgetname = keys.delete('widgetname')
keys.delete('without_creating')
elsif keys
keys = _symbolkey2str(keys)
widgetname = keys.delete('widgetname')
keys.delete('without_creating')
end
legend = self.class.new(parent, :without_creating=>true,
:widgetname=>widgetname)
class << legend
def __destroy_hook__
TkCore::INTERP.tk_windows.delete(@path)
end
end
if keys
self.legend_configure(keys.update('position'=>legend))
else
self.legend_configure('position'=>legend)
end
legend
end
def legend_activate(*pats)
list(tk_send('legend', 'activate',
*(pats.collect{|pat| tagid(pat)}))).collect{|elem|

View file

@ -12,7 +12,7 @@ module Tk::BLT
###################################
class Node < TkObject
class Node < TkObject
TreeNodeID_TBL = TkCore::INTERP.create_table
TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear }
@ -271,6 +271,10 @@ module Tk::BLT
TreeTagID_TBL[@tpath][@id] = self
end
def id
@id
end
def add(*nodes)
tk_call(@tpath, 'tag', 'add', @id, *nodes)
self
@ -368,6 +372,10 @@ module Tk::BLT
@path = @id = tk_call(@tpath, 'notify', 'create', *args)
end
def id
@id
end
def delete()
tk_call(@tpath, 'notify', 'delete', @id)
NotifyID_TBL[tpath].delete(@id)
@ -445,6 +453,10 @@ module Tk::BLT
})
end
def id
@id
end
def delete()
tk_call(@tpath, 'trace', 'delete', @id)
TraceID_TBL[tpath].delete(@id)
@ -524,6 +536,17 @@ module Tk::BLT
Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
end
def tagid(tag)
if tag.kind_of?(Tk::BLT::Tree::Node) ||
tag.kind_of?(Tk::BLT::Tree::Tag) ||
tag.kind_of?(Tk::BLT::Tree::Notify) ||
tag.kind_of?(Tk::BLT::Tree::Trace)
tag.id
else
tag # maybe an Array of configure paramters
end
end
def destroy()
tk_call('::blt::tree', 'destroy', @id)
self
@ -531,11 +554,11 @@ module Tk::BLT
def ancestor(node1, node2)
Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'ancestor',
node1, node2))
tagid(node1), tagid(node2)))
end
def apply(node, keys={})
tk_call('::blt::tree', 'apply', node, __conv_keyonly_opts(keys))
tk_call('::blt::tree', 'apply', tagid(node), __conv_keyonly_opts(keys))
self
end
@ -545,30 +568,30 @@ module Tk::BLT
end
def children(node)
simplelist(tk_call('::blt::tree', 'children', node)).collect{|n|
simplelist(tk_call('::blt::tree', 'children', tagid(node))).collect{|n|
Tk::BLT::Tree::Node.id2obj(self, n)
}
end
def copy(src, parent, keys={})
id = tk_call('::blt::tree', 'copy', src, parent,
id = tk_call('::blt::tree', 'copy', tagid(src), tagid(parent),
__conv_keyonly_opts(keys))
Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
end
def copy_to(src, dest_tree, parent, keys={})
return copy(src, parent, keys={}) unless dest_tree
id = tk_call('::blt::tree', 'copy', src, dest_tree, parent,
__conv_keyonly_opts(keys))
id = tk_call('::blt::tree', 'copy', tagid(src), dest_tree,
tagid(parent), __conv_keyonly_opts(keys))
Tk::BLT::Tree::Node.new(dest_tree, nil, 'node'=>id)
end
def degree(node)
number(tk_call('::blt::tree', 'degree', node))
number(tk_call('::blt::tree', 'degree', tagid(node)))
end
def delete(*nodes)
tk_call('::blt::tree', 'delete', *nodes)
tk_call('::blt::tree', 'delete', *(nodes.collect{|node| tagid(node)}))
nodes.each{|node|
if node.kind_of?(Tk::BLT::Tree::Node)
Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.id)
@ -580,78 +603,82 @@ module Tk::BLT
end
def depth(node)
number(tk_call('::blt::tree', 'depth', node))
number(tk_call('::blt::tree', 'depth', tagid(node)))
end
def dump(node)
simplelist(tk_call('::blt::tree', 'dump', node)).collect{|n|
simplelist(tk_call('::blt::tree', 'dump', tagid(node))).collect{|n|
simplelist(n)
}
end
def dump_to_file(node, file)
tk_call('::blt::tree', 'dumpfile', node, file)
tk_call('::blt::tree', 'dumpfile', tagid(node), file)
self
end
def exist?(node, key=None)
bool(tk_call('::blt::tree', 'exists', node, key))
bool(tk_call('::blt::tree', 'exists', tagid(node), key))
end
def find(node, keys={})
simplelist(tk_call('::blt::tree', 'find', node,
simplelist(tk_call('::blt::tree', 'find', tagid(node),
__conv_keyonly_opts(keys))).collect{|n|
Tk::BLT::Tree::Node.id2obj(self, n)
}
end
def find_child(node, label)
ret = tk_call('::blt::tree', 'findchild', node, label)
ret = tk_call('::blt::tree', 'findchild', tagid(node), label)
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def first_child(node)
ret = tk_call('::blt::tree', 'firstchild', node)
ret = tk_call('::blt::tree', 'firstchild', tagid(node))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def get(node)
Hash[*simplelist(tk_call('::blt::tree', 'get', node))]
Hash[*simplelist(tk_call('::blt::tree', 'get', tagid(node)))]
end
def get_value(node, key, default_val=None)
tk_call('::blt::tree', 'get', node, key, default_val)
tk_call('::blt::tree', 'get', tagid(node), key, default_val)
end
def index(node)
Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'index', node))
Tk::BLT::Tree::Node.id2obj(self,
tk_call('::blt::tree', 'index', tagid(node)))
end
def insert(parent, keys={})
id = tk_call('::blt::tree', 'insert', parent, keys)
id = tk_call('::blt::tree', 'insert', tagid(parent), keys)
Tk::BLT::Tree::Node.new(self, nil, 'node'=>id)
end
def ancestor?(node1, node2)
bool(tk_call('::blt::tree', 'is', 'ancestor', node1, node2))
bool(tk_call('::blt::tree', 'is', 'ancestor',
tagid(node1), tagid(node2)))
end
def before?(node1, node2)
bool(tk_call('::blt::tree', 'is', 'before', node1, node2))
bool(tk_call('::blt::tree', 'is', 'before',
tagid(node1), tagid(node2)))
end
def leaf?(node)
bool(tk_call('::blt::tree', 'is', 'leaf', node))
bool(tk_call('::blt::tree', 'is', 'leaf', tagid(node)))
end
def link?(node)
bool(tk_call('::blt::tree', 'is', 'link', node))
bool(tk_call('::blt::tree', 'is', 'link', tagid(node)))
end
def root?(node)
bool(tk_call('::blt::tree', 'is', 'root', node))
bool(tk_call('::blt::tree', 'is', 'root', tagid(node)))
end
def keys(node, *nodes)
if nodes.empty?
simplelist(tk_call('blt::tree', 'keys', node))
simplelist(tk_call('blt::tree', 'keys', tagid(node)))
else
simplelist(tk_call('blt::tree', 'keys', node, *nodes)).collect{|lst|
simplelist(tk_call('blt::tree', 'keys', tagid(node),
*(nodes.collect{|n| tagid(n)}))).collect{|lst|
simplelist(lst)
}
end
@ -659,36 +686,36 @@ module Tk::BLT
def label(node, text=nil)
if text
tk_call('::blt::tree', 'label', node, text)
tk_call('::blt::tree', 'label', tagid(node), text)
text
else
tk_call('::blt::tree', 'label', node)
tk_call('::blt::tree', 'label', tagid(node))
end
end
def last_child(node)
ret = tk_call('::blt::tree', 'lastchild', node)
ret = tk_call('::blt::tree', 'lastchild', tagid(node))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def link(parent, node, keys={})
ret = tk_call('::blt::tree', 'link', parent, node,
ret = tk_call('::blt::tree', 'link', tagid(parent), tagid(node),
__conv_keyonly_opts(keys))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def move(node, dest, keys={})
tk_call('::blt::tree', 'move', node, dest, keys)
tk_call('::blt::tree', 'move', tagid(node), tagid(dest), keys)
self
end
def next(node)
ret = tk_call('::blt::tree', 'next', node)
ret = tk_call('::blt::tree', 'next', tagid(node))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def next_sibling(node)
ret = tk_call('::blt::tree', 'nextsibling', node)
ret = tk_call('::blt::tree', 'nextsibling', tagid(node))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
@ -707,7 +734,7 @@ module Tk::BLT
end
def notify_info(id)
lst = simplelist(tk_call(@path, 'notify', 'info', id))
lst = simplelist(tk_call(@path, 'notify', 'info', tagid(id)))
lst[0] = Tk::BLT::Tree::Notify.id2obj(self, lst[0])
lst[1] = simplelist(lst[1]).collect{|flag| flag[1..-1]}
lst[2] = tk_tcl2ruby(lst[2])
@ -721,30 +748,30 @@ module Tk::BLT
end
def parent(node)
ret = tk_call('::blt::tree', 'parent', node)
ret = tk_call('::blt::tree', 'parent', tagid(node))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def fullpath(node)
tk_call('::blt::tree', 'path', node)
tk_call('::blt::tree', 'path', tagid(node))
end
def position(node)
number(tk_call('::blt::tree', 'position', node))
number(tk_call('::blt::tree', 'position', tagid(node)))
end
def previous(node)
ret = tk_call('::blt::tree', 'previous', node)
ret = tk_call('::blt::tree', 'previous', tagid(node))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def prev_sibling(node)
ret = tk_call('::blt::tree', 'prevsibling', node)
ret = tk_call('::blt::tree', 'prevsibling', tagid(node))
(ret == '-1')? nil: Tk::BLT::Tree::Node.id2obj(self, ret)
end
def restore(node, str, keys={})
tk_call('::blt::tree', 'restore', node, str,
tk_call('::blt::tree', 'restore', tagid(node), str,
__conv_keyonly_opts(keys))
self
end
@ -752,12 +779,12 @@ module Tk::BLT
keys = __conv_keyonly_opts(keys)
keys.delete('overwrite')
keys.delete(:overwrite)
tk_call('::blt::tree', 'restore', node, str, '-overwrite', keys)
tk_call('::blt::tree', 'restore', tagid(node), str, '-overwrite', keys)
self
end
def restore_from_file(node, file, keys={})
tk_call('::blt::tree', 'restorefile', node, file,
tk_call('::blt::tree', 'restorefile', tagid(node), file,
__conv_keyonly_opts(keys))
self
end
@ -765,12 +792,14 @@ module Tk::BLT
keys = __conv_keyonly_opts(keys)
keys.delete('overwrite')
keys.delete(:overwrite)
tk_call('::blt::tree', 'restorefile', node, file, '-overwrite', keys)
tk_call('::blt::tree', 'restorefile', tagid(node), file,
'-overwrite', keys)
self
end
def root(node=None)
Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'root', node))
Tk::BLT::Tree::Node.id2obj(self, tk_call('::blt::tree', 'root',
tagid(node)))
end
def set(node, data)
@ -779,26 +808,27 @@ module Tk::BLT
end
args = []
data.each{|k, v| args << k << v}
tk_call('::blt::tree', 'set', node, *args)
tk_call('::blt::tree', 'set', tagid(node), *args)
self
end
def size(node)
number(tk_call('::blt::tree', 'size', node))
number(tk_call('::blt::tree', 'size', tagid(node)))
end
def sort(node, keys={})
tk_call('::blt::tree', 'sort', node, __conv_keyonly_opts(keys))
tk_call('::blt::tree', 'sort', tagid(node), __conv_keyonly_opts(keys))
self
end
def tag_add(tag, *nodes)
tk_call(@path, 'tag', 'add', tag, *nodes)
tk_call(@path, 'tag', 'add', tagid(tag), *(nodes.collect{|n| tagid(n)}))
self
end
def tag_delete(tag, *nodes)
tk_call(@path, 'tag', 'delete', tag, *nodes)
tk_call(@path, 'tag', 'delete', tagid(tag),
*(nodes.collect{|n| tagid(n)}))
self
end
@ -810,30 +840,32 @@ module Tk::BLT
end
def tag_get(node, *patterns)
simplelist(tk_call(@tpath, 'tag', 'get', node, *patterns)).collect{|str|
simplelist(tk_call(@tpath, 'tag', 'get', tagid(node),
*(patterns.collect{|pat| tagid(pat)}))).collect{|str|
Tk::BLT::Tree::Tag.id2obj(self, str)
}
end
def tag_names(node = None)
simplelist(tk_call(@tpath, 'tag', 'names', node)).collect{|str|
simplelist(tk_call(@tpath, 'tag', 'names', tagid(node))).collect{|str|
Tk::BLT::Tree::Tag.id2obj(self, str)
}
end
def tag_nodes(tag)
simplelist(tk_call(@tpath, 'tag', 'nodes',tag)).collect{|node|
simplelist(tk_call(@tpath, 'tag', 'nodes', tagid(tag))).collect{|node|
Tk::BLT::Tree::Node.id2obj(self, node)
}
end
def tag_set(node, *tags)
tk_call(@path, 'tag', 'set', node, *tags)
tk_call(@path, 'tag', 'set', tagid(node), *(tags.collect{|t| tagid(t)}))
self
end
def tag_unset(node, *tags)
tk_call(@path, 'tag', 'unset', node, *tags)
tk_call(@path, 'tag', 'unset', tagid(node),
*(tags.collect{|t| tagid(t)}))
self
end
@ -841,18 +873,28 @@ module Tk::BLT
Tk::BLT::Tree::Trace.new(self, *args, &b)
end
=begin
def trace_delete(*args)
if id.kind_of?(Tk::BLT::Tree::Trace)
id.delete
else
tk_call(@path, 'trace', 'delete', id)
Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)
end
args.each{|id|
if id.kind_of?(Tk::BLT::Tree::Trace)
id.delete
else
tk_call(@path, 'trace', 'delete', id)
Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)
end
self
}
end
=end
def trace_delete(*args)
args = args.collect{|id| tagid(id)}
tk_call(@path, 'trace', 'delete', *args)
args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
self
end
def trace_info(*args)
lst = simplelist(tk_call(@path, 'trace', 'info', id))
def trace_info(id)
lst = simplelist(tk_call(@path, 'trace', 'info', tagid(id)))
lst[0] = Tk::BLT::Tree::Trace.id2obj(self, lst[0])
lst[2] = simplelist(lst[2])
lst[3] = tk_tcl2ruby(lst[3])
@ -866,16 +908,16 @@ module Tk::BLT
end
def type(node, key)
tk_call('::blt::tree', 'type', node, key)
tk_call('::blt::tree', 'type', tagid(node), key)
end
def unset(node, *keys)
tk_call('::blt::tree', 'unset', node, *keys)
tk_call('::blt::tree', 'unset', tagid(node), *keys)
self
end
def values(node, key=None)
simplelist(tk_call('::blt::tree', 'values', node, key))
simplelist(tk_call('::blt::tree', 'values', tagid(node), key))
end
end
end

View file

@ -297,7 +297,7 @@ class Tk::BLT::Treeview
else
cmd = Proc.new
end
_bind([@path, 'bind', tag], seq, cmd, *args)
_bind([@path, 'bind', tagid(tag)], seq, cmd, *args)
self
end
def tag_bind_append(tag, seq, *args)
@ -306,15 +306,15 @@ class Tk::BLT::Treeview
else
cmd = Proc.new
end
_bind_append([@path, 'bind', tag], seq, cmd, *args)
_bind_append([@path, 'bind', tagid(tag)], seq, cmd, *args)
self
end
def tag_bind_remove(tag, seq)
_bind_remove([@path, 'bind', tag], seq)
_bind_remove([@path, 'bind', tagid(tag)], seq)
self
end
def tag_bindinfo(tag, seq=nil)
_bindinfo([@path, 'bind', tag], seq)
_bindinfo([@path, 'bind', tagid(tag)], seq)
end
def button_activate(tag)
@ -328,7 +328,7 @@ class Tk::BLT::Treeview
else
cmd = Proc.new
end
_bind([@path, 'button', 'bind', tag], seq, cmd, *args)
_bind([@path, 'button', 'bind', tagid(tag)], seq, cmd, *args)
self
end
def button_bind_append(tag, seq, *args)
@ -337,15 +337,15 @@ class Tk::BLT::Treeview
else
cmd = Proc.new
end
_bind_append([@path, 'button', 'bind', tag], seq, cmd, *args)
_bind_append([@path, 'button', 'bind', tagid(tag)], seq, cmd, *args)
self
end
def button_bind_remove(tag, seq)
_bind_remove([@path, 'button', 'bind', tag], seq)
_bind_remove([@path, 'button', 'bind', tagid(tag)], seq)
self
end
def button_bindinfo(tag, seq=nil)
_bindinfo([@path, 'button', 'bind', tag], seq)
_bindinfo([@path, 'button', 'bind', tagid(tag)], seq)
end
def close(*tags)
@ -482,7 +482,7 @@ class Tk::BLT::Treeview
def find(first, last, keys={})
keys = _search_flags(keys)
keys['exec'] = _find_exec_flag_value(keys['exec']) if keys.key?('exec')
args = hash_kv(keys) << '--' << first << last
args = hash_kv(keys) << '--' << tagid(first) << tagid(last)
simplelist(tk_send('find', *args)).collect{|id| tagid2obj(id)}
end
@ -505,7 +505,7 @@ class Tk::BLT::Treeview
end
keys = _search_flags(keys)
args = hash_kv(keys) << '--'
args.concat(tags)
args.concat(tags.collect{|t| tagid(t)})
tk_send('hide', *args)
self
end
@ -530,7 +530,7 @@ class Tk::BLT::Treeview
end
keys = _symbolkey2str(keys)
keys['at'] = tag
keys['at'] = tagid(tag)
Tk::BLT::Treeview::Node.new(pos, parent, keys)
end
@ -634,7 +634,7 @@ class Tk::BLT::Treeview
end
keys = _search_flags(keys)
args = hash_kv(keys) << '--'
args.concat(tags)
args.concat(tags.collect{|t| tagid(t)})
tk_send('show', *args)
self
end
@ -991,7 +991,7 @@ class Tk::BLT::Treeview::Node < TkObject
if (id = keys['node'])
@path = @id = id
tk_call(@tpath, 'move', @id, pos, parent) if parent
tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent
else
name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
TreeNode_ID[1].succ!
@ -1004,7 +1004,7 @@ class Tk::BLT::Treeview::Node < TkObject
path = [get_full(parent.id)[0], name]
at = nil # ignore 'at' option
else
path = [parent, name]
path = [parent.to_s, name]
end
else
path = name
@ -1080,20 +1080,32 @@ class Tk::BLT::Treeview::Tag < TkObject
TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
TreeTagID_TBL[@tpath][@id] = self
tk_call(@tpath, 'tag', 'add', @id, *ids) unless ids.empty?
unless ids.empty?
tk_call(@tpath, 'tag', 'add', @id, *(ids.collect{|id| tagid(id)}))
end
end
def tagid(tag)
if tag.kind_of?(Tk::BLT::Treeview::Node) \
|| tag.kind_of?(Tk::BLT::Treeview::Tag)
tag.id
else
tag
end
end
private :tagid
def id
@id
end
def add(*ids)
tk_call(@tpath, 'tag', 'add', @id, *ids)
tk_call(@tpath, 'tag', 'add', @id, *(ids{|id| tagid(id)}))
self
end
def remove(*ids)
tk_call(@tpath, 'tag', 'delete', @id, *ids)
tk_call(@tpath, 'tag', 'delete', @id, *(ids{|id| tagid(id)}))
self
end

View file

@ -70,9 +70,13 @@ class BLT_Graph_Demo
(1..39).each{|i| @graph.element_create("V#{i}", :x=>@x, :y=>@v[i])}
@top = Tk::BLT::Tile::Toplevel.new
=begin
legend = Tk::BLT::Graph.new(@top, :widgetname=>'legend',
:without_creating=>true)
@graph.legend_configure(:position=>legend)
=end
# legend = @graph.legend_window_create(@top, :widgetname=>'legend')
legend = @graph.legend_window_create(@top)
legend.pack(:fill=>:both, :expand=>true)
Tk::BLT::Table.add(@root, @graph, [0,0], :fill=>:both)