summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tkextlib
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-26 13:58:11 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-03-26 13:58:11 +0000
commit7738391d237112db43bb47f793fc0939fb561d00 (patch)
tree6ee086fb50b03430ed910426c6cd676ea8de237d /ext/tk/lib/tkextlib
parentee46b19927ceb9993077579f0ede19afdc21e1be (diff)
* ext/tk/lib/tk.rb (_callback_entry_class?): add for checking whether
a class is available for a callback entry. * ext/tk/lib/tk.rb (after_cancel): add Tk.after_cancel(afterID) method. * ext/tk/lib/tk.rb (array2tk_list): change from private module method of TkComm to public module method. * ext/tk/lib/tk.rb (cget): add check that slot argument is not empty string. * ext/tk/lib/tk.rb (configinfo): ditto. * ext/tk/lib/tk/itemconfig.rb (itemcget): add check that slot argument is not empty string. * ext/tk/lib/tk/itemconfig.rb (itemconfiginfo): ditto. * ext/tk/lib/tk/entry.rb: add TkEntry#icursor and icursor= (alias of cursor and cursor= method). * ext/tk/lib/tk/font.rb: improve font treatment when the font name is empty string. * ext/tk/lib/tk/variable.rb: add :variable, :window and :procedure type. * ext/tk/lib/tk/variable.rb: improve treatment of array-type tkvariable. * ext/tk/lib/tkextlib/blt.rb: add commands for zooming. * ext/tk/lib/tkextlib/blt/*: bug fix. * ext/tk/lib/tkextlib/treectrl/tktreectrl.rb: bug fix and add methods to call TreeCtrl commands for bindings. * ext/tk/sample/tkextlib/blt/*: new sample scritps. * ext/tk/sample/tkextlib/treectrl/*: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib')
-rw-r--r--ext/tk/lib/tkextlib/SUPPORT_STATUS15
-rw-r--r--ext/tk/lib/tkextlib/blt.rb41
-rw-r--r--ext/tk/lib/tkextlib/blt/barchart.rb1
-rw-r--r--ext/tk/lib/tkextlib/blt/bitmap.rb35
-rw-r--r--ext/tk/lib/tkextlib/blt/busy.rb42
-rw-r--r--ext/tk/lib/tkextlib/blt/component.rb251
-rw-r--r--ext/tk/lib/tkextlib/blt/graph.rb1
-rw-r--r--ext/tk/lib/tkextlib/blt/htext.rb5
-rw-r--r--ext/tk/lib/tkextlib/blt/stripchart.rb1
-rw-r--r--ext/tk/lib/tkextlib/blt/table.rb17
-rw-r--r--ext/tk/lib/tkextlib/treectrl/tktreectrl.rb280
11 files changed, 561 insertions, 128 deletions
diff --git a/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS
index 9cfc02d473..085de3bdf6 100644
--- a/ext/tk/lib/tkextlib/SUPPORT_STATUS
+++ b/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -73,6 +73,14 @@ ICONS 1.0 http://www.satisoft.com/tcltk/icons/ ==> ICONS
TkImg 1.3 http://sf.net/projects/tkimg ==> tkimg
+BLT 2.4z http://sourceforge.net/projects/blt
+ * see also tcltk-ext library on RAA
+ (http://raa.ruby-lang.org/)
+ ==> blt
+
+TkTreeCtrl 1.1 http://tktreectrl.sourceforge.net/ ==> treectrl
+
+
===< support (may be alpha or beta quality) >=================================
@@ -84,19 +92,12 @@ TclX CVS/Hd(2005-02-07)
==> tclx (partial support; infox command and
XPG/3 message catalogs only)
-TkTreeCtrl 1.1 http://tktreectrl.sourceforge.net/ ==> treectrl
-
Tile 0.6 http://tktable.sourceforge.net/tile/ ==> tile
===< possibly available (not tested; alpha quality) >=========================
-BLT 2.4z http://sourceforge.net/projects/blt
- * see also tcltk-ext library on RAA
- (http://raa.ruby-lang.org/)
- ==> blt
-
winico CVS/Hd(2004-11-02)
http://tktable.sourceforge.net
==> winico (win32 only)
diff --git a/ext/tk/lib/tkextlib/blt.rb b/ext/tk/lib/tkextlib/blt.rb
index 965886762e..60ed39a0cf 100644
--- a/ext/tk/lib/tkextlib/blt.rb
+++ b/ext/tk/lib/tkextlib/blt.rb
@@ -105,6 +105,47 @@ module Tk
####################################################
+ def self.active_legend(graph)
+ tk_call_without_enc('Blt_ActiveLegend', graph)
+ end
+ def self.crosshairs(graph)
+ tk_call_without_enc('Blt_Crosshairs', graph)
+ end
+ def self.zoom_stack(graph)
+ tk_call_without_enc('Blt_ZoomStack', graph)
+ end
+ def self.print_key(graph)
+ tk_call_without_enc('Blt_PrintKey', graph)
+ end
+ def self.closest_point(graph)
+ tk_call_without_enc('Blt_ClosestPoint', graph)
+ end
+
+ module GraphCommand
+ def active_legend
+ tk_call_without_enc('Blt_ActiveLegend', @path)
+ self
+ end
+ def crosshairs
+ tk_call_without_enc('Blt_Crosshairs', @path)
+ self
+ end
+ def zoom_stack
+ tk_call_without_enc('Blt_ZoomStack', @path)
+ self
+ end
+ def print_key
+ tk_call_without_enc('Blt_PrintKey', @path)
+ self
+ end
+ def closest_point
+ tk_call_without_enc('Blt_ClosestPoint', @path)
+ self
+ end
+ end
+
+ ####################################################
+
autoload :PlotComponent,'tkextlib/blt/component.rb'
autoload :Barchart, 'tkextlib/blt/barchart.rb'
diff --git a/ext/tk/lib/tkextlib/blt/barchart.rb b/ext/tk/lib/tkextlib/blt/barchart.rb
index 624906b8bd..d8ecad834f 100644
--- a/ext/tk/lib/tkextlib/blt/barchart.rb
+++ b/ext/tk/lib/tkextlib/blt/barchart.rb
@@ -14,6 +14,7 @@ module Tk::BLT
WidgetClassNames[WidgetClassName] = self
include PlotComponent
+ include GraphCommand
def __boolval_optkeys
['bufferelements', 'invertxy']
diff --git a/ext/tk/lib/tkextlib/blt/bitmap.rb b/ext/tk/lib/tkextlib/blt/bitmap.rb
index 11ad5883d0..31cf8d4229 100644
--- a/ext/tk/lib/tkextlib/blt/bitmap.rb
+++ b/ext/tk/lib/tkextlib/blt/bitmap.rb
@@ -42,26 +42,41 @@ module Tk::BLT
alias _new new
def new(data, keys={})
- _new(:data, data, keys)
+ _new(:data, nil, data, keys)
end
alias define new
+ def new_with_name(name, data, keys={})
+ _new(:data, name, data, keys)
+ end
+ alias define_with_name new_with_name
+
def compose(text, keys={})
- _new(:text, text, keys)
+ _new(:text, nil, text, keys)
+ end
+
+ def compose_with_name(name, text, keys={})
+ _new(:text, name, text, keys)
end
end
- def initialize(type, data, keys = {})
- @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
- BITMAP_ID[1].succ!
- BITMAP_ID_TBL[@id] = self
+ def initialize(type, name, data, keys = {})
+ if name
+ @id = name
+ else
+ @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
+ BITMAP_ID[1].succ!
+ BITMAP_ID_TBL[@id] = self
+ end
@path = @id
- if type == :text
- tk_call('::blt::bitmap', 'compose', @id, *hash_kv(keys))
- else # :data
- tk_call('::blt::bitmap', 'define', @id, *hash_kv(keys))
+ unless bool(tk_call('::blt::bitmap', 'exists', @id))
+ if type == :text
+ tk_call('::blt::bitmap', 'compose', @id, data, *hash_kv(keys))
+ else # :data
+ tk_call('::blt::bitmap', 'define', @id, data, *hash_kv(keys))
+ end
end
end
diff --git a/ext/tk/lib/tkextlib/blt/busy.rb b/ext/tk/lib/tkextlib/blt/busy.rb
index c0740dc2d7..4726e466f4 100644
--- a/ext/tk/lib/tkextlib/blt/busy.rb
+++ b/ext/tk/lib/tkextlib/blt/busy.rb
@@ -13,6 +13,27 @@ module Tk::BLT
extend TkItemConfigMethod
TkCommandNames = ['::blt::busy'.freeze].freeze
+
+ ###########################
+
+ class Shield < TkWindow
+ def self.shield_path(win)
+ win = window(win) unless win.kind_of?(TkWindow)
+ if win.kind_of?(TkToplevel)
+ win.path + '._Busy'
+ else
+ win.path + '_Busy'
+ end
+ end
+
+ def initialize(win)
+ @path = self.class.shield_path(win)
+ end
+ end
+
+ def self.shield_path(win)
+ Tk::BLT::Busy::Shield.shield_path(win)
+ end
end
end
@@ -30,27 +51,6 @@ class << Tk::BLT::Busy
##################################
- class Shield < TkWindow
- def self.shield_path(win)
- win = window(win) unless win.kind_of?(TkWindow)
- if win.kind_of?(TkToplevel)
- win.path + '._Busy'
- else
- win.path + '_Busy'
- end
- end
-
- def initialize(win)
- @path = self.class.shield_path(win)
- end
- end
-
- def shield_path(win)
- Tk::BLT::Busy::Shield.shield_path(win)
- end
-
- ##################################
-
def hold(win, keys={})
tk_call('::blt::busy', 'hold', win, *hash_kv(keys))
end
diff --git a/ext/tk/lib/tkextlib/blt/component.rb b/ext/tk/lib/tkextlib/blt/component.rb
index 8e36946d0b..c5152ddab4 100644
--- a/ext/tk/lib/tkextlib/blt/component.rb
+++ b/ext/tk/lib/tkextlib/blt/component.rb
@@ -34,7 +34,7 @@ module Tk::BLT
end
private :__item_strval_optkeys
- def _item_listval_optkeys(id)
+ def __item_listval_optkeys(id)
['bindtags']
end
private :__item_listval_optkeys
@@ -266,8 +266,9 @@ module Tk::BLT
@cpath = @chart.path
Axis::OBJ_TBL[@cpath][@axis] = self
keys = _symbolkey2str(keys)
- unless keys.delete['without_creating']
- @chart.axis_create(@axis, keys)
+ unless keys.delete('without_creating')
+ # @chart.axis_create(@axis, keys)
+ tk_call(@chart, 'axis', 'create', @axis, keys)
end
end
@@ -420,8 +421,9 @@ module Tk::BLT
@cpath = @chart.path
Element::OBJ_TBL[@cpath][@element] = self
keys = _symbolkey2str(keys)
- unless keys.delete['without_creating']
- @chart.element_create(@element, keys)
+ unless keys.delete('without_creating')
+ # @chart.element_create(@element, keys)
+ tk_call(@chart, 'element', 'create', @element, keys)
end
end
@@ -623,8 +625,9 @@ module Tk::BLT
@cpath = @chart.path
Pen::OBJ_TBL[@cpath][@pen] = self
keys = _symbolkey2str(keys)
- unless keys.delete['without_creating']
- @chart.pen_create(@pen, keys)
+ unless keys.delete('without_creating')
+ # @chart.pen_create(@pen, keys)
+ tk_call(@chart, 'pen', 'create', @pen, keys)
end
end
@@ -784,6 +787,24 @@ module Tk::BLT
idnum.to_i # 'item id' is an integer number
end
+ def self.create_type(chart, type, keys={})
+ args, fontkeys = _parse_create_args(keys)
+ idnum = tk_call_without_enc(chart.path, 'create', type, *args)
+ chart.marker_configure(idnum, fontkeys) unless fontkeys.empty?
+ id = idnum.to_i # 'item id' is an integer number
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @chart = chart
+ @path = chart.path
+ @id = id
+ unless Tk::BLT::PlotComponent::MarkerID_TBL[@path]
+ Tk::BLT::PlotComponent::MarkerID_TBL[@path] = {}
+ end
+ Tk::BLT::PlotComponent::MarkerID_TBL[@path][@id] = self
+ }
+ obj
+ end
+
def initialize(parent, *args)
@parent = @chart = parent
@path = parent.path
@@ -980,12 +1001,10 @@ module Tk::BLT
###################
- def marker_create(type, *args)
- type.create(self, *args)
+ def axis_create(id=nil, keys={})
+ # tk_send('axis', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Axis.new(self, id, keys)
end
-
- ###################
-
def axis_delete(*ids)
tk_send('axis', 'delete', *(ids.collect{|id| tagid(id)}))
self
@@ -1033,6 +1052,10 @@ module Tk::BLT
###################
+ def element_create(id=nil, keys={})
+ # tk_send('element', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Element.new(self, id, keys)
+ end
def element_activate(id, *indices)
tk_send('element', 'activate', tagid(id), *indices)
self
@@ -1109,6 +1132,10 @@ module Tk::BLT
###################
+ def pen_create(id=nil, keys={})
+ # tk_send('pen', 'create', tagid(id), keys)
+ Tk::BLT::PlotComponent::Pen.new(self, id, keys)
+ end
def pen_delete(*ids)
tk_send('pen', 'delete', *(ids.collect{|id| tagid(id)}))
self
@@ -1137,6 +1164,28 @@ module Tk::BLT
###################
+ def marker_create(type, keys={})
+ case type
+ when :text, 'text'
+ Tk::BLT::PlotComponent::TextMarker.new(self, keys)
+ when :line, 'line'
+ Tk::BLT::PlotComponent::LineMarker.new(self, keys)
+ when :bitmap, 'bitmap'
+ Tk::BLT::PlotComponent::BitmapMarker.new(self, keys)
+ when :image, 'image'
+ Tk::BLT::PlotComponent::ImageMarker.new(self, keys)
+ when :polygon, 'polygon'
+ Tk::BLT::PlotComponent::PolygonMarker.new(self, keys)
+ when :window, 'window'
+ Tk::BLT::PlotComponent::WindowMarker.new(self, keys)
+ else
+ if type.kind_of?(Tk::BLT::PlotComponent::Marker)
+ type.new(self, keys)
+ else
+ Tk::BLT::PlotComponent::Marker.create_type(self, type, keys)
+ end
+ end
+ end
def marker_after(id, target=nil)
if target
tk_send_without_enc('marker', 'after', tagid(id), tagid(target))
@@ -1183,103 +1232,219 @@ module Tk::BLT
###################
def xaxis_cget(option)
- axis_cget('xaxis', option)
+ itemcget('xaxis', option)
end
def xaxis_configure(slot, value=None)
- axis_configure('xaxis', slot, value)
+ itemconfigure('xaxis', slot, value)
end
def xaxis_configinfo(slot=nil)
- axis_configinfo('xaxis', slot)
+ itemconfiginfo('xaxis', slot)
end
def current_xaxis_configinfo(slot=nil)
- current_axis_configinfo('xaxis', slot)
+ current_itemconfiginfo('xaxis', slot)
+ end
+ def xaxis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'xaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def xaxis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'xaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def xaxis_bind_remove(context)
+ _bind_remove([path, 'xaxis', 'bind'], context)
+ self
+ end
+ def xaxis_bindinfo(context=nil)
+ _bindinfo([path, 'xaxis', 'bind'], context)
end
def xaxis_invtransform(val)
- axis_invtransform('xaxis', val)
+ list(tk_send('xaxis', 'invtransform', val))
end
def xaxis_limits
- axis_limits('xaxis')
+ list(tk_send('xaxis', 'limits'))
end
def xaxis_transform(val)
- axis_transform('xaxis', val)
+ list(tk_send('xaxis', 'transform', val))
end
def xaxis_use(target=nil)
- axis_use('xaxis', target)
+ if target
+ Axis.id2obj(self, tk_send('xaxis', 'use', tagid(target)))
+ else
+ Axis.id2obj(self, tk_send('xaxis', 'use'))
+ end
end
def x2axis_cget(option)
- axis_cget('x2axis', option)
+ itemcget('x2axis', option)
end
def x2axis_configure(slot, value=None)
- axis_configure('x2axis', slot, value)
+ itemconfigure('x2axis', slot, value)
end
def x2axis_configinfo(slot=nil)
- axis_configinfo('x2axis', slot)
+ itemconfiginfo('x2axis', slot)
end
def current_x2axis_configinfo(slot=nil)
- current_axis_configinfo('x2axis', slot)
+ current_itemconfiginfo('x2axis', slot)
+ end
+ def x2axis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'x2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def x2axis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'x2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def x2axis_bind_remove(context)
+ _bind_remove([path, 'x2axis', 'bind'], context)
+ self
+ end
+ def x2axis_bindinfo(context=nil)
+ _bindinfo([path, 'x2axis', 'bind'], context)
end
def x2axis_invtransform(val)
- axis_invtransform('x2axis', val)
+ list(tk_send('x2axis', 'invtransform', val))
end
def x2axis_limits
- axis_limits('x2axis')
+ list(tk_send('x2axis', 'limits'))
end
def x2axis_transform(val)
- axis_transform('x2axis', val)
+ list(tk_send('x2axis', 'transform', val))
end
def x2axis_use(target=nil)
- axis_use('x2axis', target)
+ if target
+ Axis.id2obj(self, tk_send('x2axis', 'use', tagid(target)))
+ else
+ Axis.id2obj(self, tk_send('x2axis', 'use'))
+ end
end
def yaxis_cget(option)
- axis_cget('yaxis', option)
+ itemcget('yaxis', option)
end
def yaxis_configure(slot, value=None)
- axis_configure('yaxis', slot, value)
+ itemconfigure('yaxis', slot, value)
end
def yaxis_configinfo(slot=nil)
- axis_configinfo('yaxis', slot)
+ itemconfiginfo('yaxis', slot)
end
def current_yaxis_configinfo(slot=nil)
- current_axis_configinfo('yaxis', slot)
+ current_itemconfiginfo('yaxis', slot)
+ end
+ def yaxis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'yaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def yaxis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'yaxis', 'bind'], context, cmd, *args)
+ self
+ end
+ def yaxis_bind_remove(context)
+ _bind_remove([path, 'yaxis', 'bind'], context)
+ self
+ end
+ def yaxis_bindinfo(context=nil)
+ _bindinfo([path, 'yaxis', 'bind'], context)
end
def yaxis_invtransform(val)
- axis_invtransform('yaxis', val)
+ list(tk_send('yaxis', 'invtransform', val))
end
def yaxis_limits
- axis_limits('yaxis')
+ list(tk_send('yaxis', 'limits'))
end
def yaxis_transform(val)
- axis_transform('yaxis', val)
+ list(tk_send('yaxis', 'transform', val))
end
def yaxis_use(target=nil)
- axis_use('yaxis', target)
+ if target
+ Axis.id2obj(self, tk_send('yaxis', 'use', tagid(target)))
+ else
+ Axis.id2obj(self, tk_send('yaxis', 'use'))
+ end
end
def y2axis_cget(option)
- axis_cget('y2axis', option)
+ itemcget('y2axis', option)
end
def y2axis_configure(slot, value=None)
- axis_configure('y2axis', slot, value)
+ itemconfigure('y2axis', slot, value)
end
def y2axis_configinfo(slot=nil)
axis_configinfo('y2axis', slot)
end
def current_y2axis_configinfo(slot=nil)
- current_axis_configinfo('y2axis', slot)
+ current_itemconfiginfo('y2axis', slot)
+ end
+ def y2axis_bind(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind([path, 'y2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def y2axis_bind_append(context, *args)
+ if TkComm._callback_entry?(args[0]) || !block_given?
+ cmd = args.shift
+ else
+ cmd = Proc.new
+ end
+ _bind_append([path, 'y2axis', 'bind'], context, cmd, *args)
+ self
+ end
+ def y2axis_bind_remove(context)
+ _bind_remove([path, 'y2axis', 'bind'], context)
+ self
+ end
+ def y2axis_bindinfo(context=nil)
+ _bindinfo([path, 'y2axis', 'bind'], context)
end
def y2axis_invtransform(val)
- axis_invtransform('y2axis', val)
+ list(tk_send('y2axis', 'invtransform', val))
end
def y2axis_limits
- axis_limits('y2axis')
+ list(tk_send('y2axis', 'limits'))
end
def y2axis_transform(val)
- axis_transform('y2axis', val)
+ list(tk_send('y2axis', 'transform', val))
end
def y2axis_use(target=nil)
- axis_use('y2axis', target)
+ if target
+ Axis.id2obj(self, tk_send('y2axis', 'use', tagid(target)))
+ else
+ Axis.id2obj(self, tk_send('y2axis', 'use'))
+ end
end
end
end
diff --git a/ext/tk/lib/tkextlib/blt/graph.rb b/ext/tk/lib/tkextlib/blt/graph.rb
index 0c49a70ec4..b16c72458a 100644
--- a/ext/tk/lib/tkextlib/blt/graph.rb
+++ b/ext/tk/lib/tkextlib/blt/graph.rb
@@ -14,6 +14,7 @@ module Tk::BLT
WidgetClassNames[WidgetClassName] = self
include PlotComponent
+ include GraphCommand
def __boolval_optkeys
['bufferelements', 'invertxy']
diff --git a/ext/tk/lib/tkextlib/blt/htext.rb b/ext/tk/lib/tkextlib/blt/htext.rb
index 29da9aa87f..3bc35b7e10 100644
--- a/ext/tk/lib/tkextlib/blt/htext.rb
+++ b/ext/tk/lib/tkextlib/blt/htext.rb
@@ -9,6 +9,11 @@ require 'tkextlib/blt.rb'
module Tk::BLT
class Htext<TkWindow
+ Htext_Var = TkVarAccess.new_hash('htext')
+ Htext_Widget = TkVarAccess.new('htext(widget)', :window)
+ Htext_File = TkVarAccess.new('htext(file)')
+ Htext_Line = TkVarAccess.new('htext(line)')
+
include TkItemConfigMethod
include Scrollable
diff --git a/ext/tk/lib/tkextlib/blt/stripchart.rb b/ext/tk/lib/tkextlib/blt/stripchart.rb
index faac8d830b..b8cbf8bc34 100644
--- a/ext/tk/lib/tkextlib/blt/stripchart.rb
+++ b/ext/tk/lib/tkextlib/blt/stripchart.rb
@@ -14,6 +14,7 @@ module Tk::BLT
WidgetClassNames[WidgetClassName] = self
include PlotComponent
+ include GraphCommand
def __boolval_optkeys
['bufferelements', 'buffergraph', 'invertxy']
diff --git a/ext/tk/lib/tkextlib/blt/table.rb b/ext/tk/lib/tkextlib/blt/table.rb
index c80e9ac55c..dc9cd0627e 100644
--- a/ext/tk/lib/tkextlib/blt/table.rb
+++ b/ext/tk/lib/tkextlib/blt/table.rb
@@ -256,11 +256,20 @@ class << Tk::BLT::Table
container
end
- def add(container, win=nil, *args)
- if win
- tk_call('::blt::table', container, _epath(win), *args)
- else
+ def add(container, *args)
+ if args.empty?
tk_call('::blt::table', container)
+ else
+ args = args.collect{|arg|
+ if arg.kind_of?(TkWindow)
+ _epath(arg)
+ elsif arg.kind_of?(Array) # index
+ arg.join(',')
+ else
+ arg
+ end
+ }
+ tk_call('::blt::table', container, *args)
end
end
diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
index 0e8fd86c0f..655ad87185 100644
--- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
+++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
@@ -17,6 +17,8 @@ TkPackage.require('treectrl')
module Tk
class TreeCtrl < TkWindow
+ BindTag_FileList = TkBindTag.new_by_name('TreeCtrlFileList')
+
def self.package_version
begin
TkPackage.require('treectrl')
@@ -25,6 +27,9 @@ module Tk
end
end
+ HasColumnCreateCommand =
+ (TkPackage.vcompare(self.package_version, '1.1') >= 0)
+
# dummy ::
# pkgIndex.tcl of TreeCtrl-1.0 doesn't support auto_load for
# 'loupe' command (probably it is bug, I think).
@@ -146,7 +151,7 @@ module Tk::TreeCtrl::ConfigMethod
None
when 'dragimage'
- obj
+ None
when 'element'
obj
@@ -155,7 +160,7 @@ module Tk::TreeCtrl::ConfigMethod
obj
when 'marquee'
- obj
+ None
when 'notify'
obj
@@ -171,6 +176,10 @@ module Tk::TreeCtrl::ConfigMethod
def tagid(mixed_id)
if mixed_id == 'debug'
['debug', None]
+ elsif mixed_id == 'dragimage'
+ ['dragimage', None]
+ elsif mixed_id == 'marquee'
+ ['marquee', None]
elsif mixed_id.kind_of?(Array)
[mixed_id[0], treectrl_tagid(*mixed_id)]
else
@@ -237,6 +246,17 @@ module Tk::TreeCtrl::ConfigMethod
end
private :__item_configinfo_struct
+
+ def __item_font_optkeys(id)
+ if id.kind_of?(Array) && (id[0] == 'element' ||
+ (id[0].kind_of?(Array) && id[0][1] == 'element'))
+ []
+ else
+ ['font']
+ end
+ end
+ private :__item_font_optkeys
+
def __item_numstrval_optkeys(id)
if id == 'debug'
['displaydelay']
@@ -249,14 +269,28 @@ module Tk::TreeCtrl::ConfigMethod
def __item_boolval_optkeys(id)
if id == 'debug'
['data', 'display', 'enable']
+ elsif id == 'dragimage'
+ ['visible']
+ elsif id == 'marquee'
+ ['visible']
elsif id.kind_of?(Array)
case id[0]
+ when 'item'
+ ['button', 'visible']
when 'column'
['button', 'expand', 'squeeze', 'sunken', 'visible', 'widthhack']
when 'element'
['filled', 'showfocus']
+ when 'notify'
+ ['active']
+ when 'style'
+ ['detach']
else
- super(id)
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
+ ['filled', 'showfocus']
+ else
+ super(id)
+ end
end
else
super(id)
@@ -280,8 +314,14 @@ module Tk::TreeCtrl::ConfigMethod
['itembackground']
when 'element'
['relief']
+ when 'style'
+ ['union']
else
- []
+ if id[0].kind_of?(Array) && id[0][1] == 'element'
+ ['relief']
+ else
+ []
+ end
end
else
[]
@@ -328,17 +368,17 @@ module Tk::TreeCtrl::ConfigMethod
current_itemconfiginfo('debug', slot)
end
- def dragimage_cget(tagOrId, option)
- itemcget(['dragimage', tagOrId], option)
+ def dragimage_cget(option)
+ itemcget('dragimage', option)
end
- def dragimage_configure(tagOrId, slot, value=None)
- itemconfigure(['dragimage', tagOrId], slot, value)
+ def dragimage_configure(slot, value=None)
+ itemconfigure('dragimage', slot, value)
end
- def dragimage_configinfo(tagOrId, slot=nil)
- itemconfiginfo(['dragimage', tagOrId], slot)
+ def dragimage_configinfo(slot=nil)
+ itemconfiginfo('dragimage', slot)
end
- def current_dragimage_configinfo(tagOrId, slot=nil)
- current_itemconfiginfo(['dragimage', tagOrId], slot)
+ def current_dragimage_configinfo(slot=nil)
+ current_itemconfiginfo('dragimage', slot)
end
def element_cget(tagOrId, option)
@@ -380,17 +420,17 @@ module Tk::TreeCtrl::ConfigMethod
current_itemconfiginfo([['item', 'element'], [item, column, elem]], slot)
end
- def marquee_cget(tagOrId, option)
- itemcget(['marquee', tagOrId], option)
+ def marquee_cget(option)
+ itemcget('marquee', option)
end
- def marquee_configure(tagOrId, slot, value=None)
- itemconfigure(['marquee', tagOrId], slot, value)
+ def marquee_configure(slot, value=None)
+ itemconfigure('marquee', slot, value)
end
- def marquee_configinfo(tagOrId, slot=nil)
- itemconfiginfo(['marquee', tagOrId], slot)
+ def marquee_configinfo(slot=nil)
+ itemconfiginfo('marquee', slot)
end
- def current_marquee_configinfo(tagOrId, slot=nil)
- current_itemconfiginfo(['marquee', tagOrId], slot)
+ def current_marquee_configinfo(slot=nil)
+ current_itemconfiginfo('marquee', slot)
end
def notify_cget(win, pattern, option)
@@ -757,17 +797,20 @@ class Tk::TreeCtrl
end
alias item_first_child item_firstchild
- def item_hashbutton(item, st=None)
+ def item_hasbutton(item, st=None)
if st == None
- bool(tk_send('item', 'hashbutton'))
+ bool(tk_send('item', 'hasbutton'))
else
- tk_send('item', 'hashbutton', st)
+ tk_send('item', 'hasbutton', st)
self
end
end
- def item_hashbutton?(item)
- item_hashbutton(item)
+ alias item_has_button item_hasbutton
+
+ def item_hasbutton?(item)
+ item_hasbutton(item)
end
+ alias item_has_button? item_hasbutton?
def item_index(item)
list(tk_send('item', 'index', item))
@@ -811,8 +854,8 @@ class Tk::TreeCtrl
end
alias item_next_sibling item_nextsibling
- def item_numchildren()
- number(tk_send('item', 'numchildren'))
+ def item_numchildren(item)
+ number(tk_send('item', 'numchildren', item))
end
alias item_num_children item_numchildren
alias item_children_size item_numchildren
@@ -850,10 +893,10 @@ class Tk::TreeCtrl
opts = opts.collect{|param|
if param.kind_of?(Hash)
param = _symbolkey2str(param)
- if param.key('column')
+ if param.key?('column')
key = '-column'
desc = param.delete('column')
- elsif param.key('element')
+ elsif param.key?('element')
key = '-element'
desc = param.delete('element')
else
@@ -863,7 +906,7 @@ class Tk::TreeCtrl
if param.empty?
param = None
else
- param = __conv_item_keyonly_opts(item, param).to_a
+ param = hash_kv(__conv_item_keyonly_opts(item, param))
end
if key
@@ -874,7 +917,7 @@ class Tk::TreeCtrl
elsif param.kind_of?(Array)
if param[2].kind_of?(Hash)
- param[2] = __conv_item_keyonly_opts(item, param[2]).to_a
+ param[2] = hash_kv(__conv_item_keyonly_opts(item, param[2]))
end
param
@@ -898,17 +941,15 @@ class Tk::TreeCtrl
end
private :_item_sort_core
- def item_sort_not_really(item, *opts)
- _item_sort_core(false, item, *opts)
- end
-
def item_sort(item, *opts)
_item_sort_core(true, item, *opts)
end
+ def item_sort_not_really(item, *opts)
+ _item_sort_core(false, item, *opts)
+ end
def item_state_forcolumn(item, column, *args)
tk_send('item', 'state', 'forcolumn', item, column, *args)
- self
end
alias item_state_for_column item_state_forcolumn
@@ -922,7 +963,6 @@ class Tk::TreeCtrl
def item_state_set(item, *args)
tk_send('item', 'state', 'set', item, *args)
- self
end
def item_style_elements(item, column)
@@ -1230,7 +1270,8 @@ class Tk::TreeCtrl
def _conv_style_layout_val(sty, val)
case sty.to_s
when 'padx', 'pady', 'ipadx', 'ipady'
- number(val)
+ lst = list(val)
+ (lst.size == 1)? lst[0]: lst
when 'detach'
bool(val)
when 'union'
@@ -1256,6 +1297,7 @@ class Tk::TreeCtrl
else
ret = Hash.new
Hash[*simplelist(tk_send('style', 'layout', style, elem))].each{|k, v|
+ k = k[1..-1]
ret[k] = _conv_style_layout_val(k, v)
}
ret
@@ -1599,18 +1641,20 @@ class Tk::TreeCtrl::Item < TkObject
end
alias first_child firstchild
- def hashbutton(st=None)
+ def hasbutton(st=None)
if st == None
- @tree.item_hashbutton(@id)
+ @tree.item_hasbutton(@id)
else
- @tree.item_hashbutton(@id, st)
+ @tree.item_hasbutton(@id, st)
self
end
end
+ alias has_button hasbutton
- def hashbutton?
- @tree.item_hashbutton(@id)
+ def hasbutton?
+ @tree.item_hasbutton(@id)
end
+ alias has_button? hasbutton?
def index
@tree.item_index(@id)
@@ -1685,6 +1729,10 @@ class Tk::TreeCtrl::Item < TkObject
def sort(*opts)
@tree.item_sort(@id, *opts)
end
+ def sort_not_really(*opts)
+ @tree.item_sort_not_really(@id, *opts)
+ self
+ end
def state_forcolumn(column, *args)
@tree.item_state_forcolumn(@id, column, *args)
@@ -1829,3 +1877,149 @@ class Tk::TreeCtrl::Style < TkObject
end
end
end
+
+module Tk::TreeCtrl::BindCallback
+ include Tk
+ extend Tk
+end
+
+class << Tk::TreeCtrl::BindCallback
+ def cursorCheck(w, x, y)
+ tk_call('::TreeCtrl::CursorCheck', w, x, y)
+ end
+ def cursorCheckAux(w)
+ tk_call('::TreeCtrl::CursorCheckAux', w)
+ end
+ def cursorCancel(w)
+ tk_call('::TreeCtrl::CursorCancel', w)
+ end
+ def buttonPress1(w, x, y)
+ tk_call('::TreeCtrl::ButtonPress1', w, x, y)
+ end
+ def doubleButton1(w, x, y)
+ tk_call('::TreeCtrl::DoubleButton1', w, x, y)
+ end
+ def motion1(w, x, y)
+ tk_call('::TreeCtrl::Motion1', w, x, y)
+ end
+ def leave1(w, x, y)
+ tk_call('::TreeCtrl::Leave1', w, x, y)
+ end
+ def release1(w, x, y)
+ tk_call('::TreeCtrl::Release1', w, x, y)
+ end
+ def beginSelect(w, el)
+ tk_call('::TreeCtrl::BeginSelect', w, el)
+ end
+ def motion(w, le)
+ tk_call('::TreeCtrl::Motion', w, el)
+ end
+ def beginExtend(w, el)
+ tk_call('::TreeCtrl::BeginExtend', w, el)
+ end
+ def beginToggle(w, el)
+ tk_call('::TreeCtrl::BeginToggle', w, el)
+ end
+ def cancelRepeat
+ tk_call('::TreeCtrl::CancelRepeat')
+ end
+ def autoScanCheck(w, x, y)
+ tk_call('::TreeCtrl::AutoScanCheck', w, x, y)
+ end
+ def autoScanCheckAux(w)
+ tk_call('::TreeCtrl::AutoScanCheckAux', w)
+ end
+ def autoScanCancel(w)
+ tk_call('::TreeCtrl::AutoScanCancel', w)
+ end
+ def up_down(w, n)
+ tk_call('::TreeCtrl::UpDown', w, n)
+ end
+ def left_right(w, n)
+ tk_call('::TreeCtrl::LeftRight', w, n)
+ end
+ def setActiveItem(w, idx)
+ tk_call('::TreeCtrl::SetActiveItem', w, idx)
+ end
+ def extendUpDown(w, amount)
+ tk_call('::TreeCtrl::ExtendUpDown', w, amount)
+ end
+ def dataExtend(w, el)
+ tk_call('::TreeCtrl::DataExtend', w, el)
+ end
+ def cancel(w)
+ tk_call('::TreeCtrl::Cancel', w)
+ end
+ def selectAll(w)
+ tk_call('::TreeCtrl::selectAll', w)
+ end
+ def marqueeBegin(w, x, y)
+ tk_call('::TreeCtrl::MarqueeBegin', w, x, y)
+ end
+ def marqueeUpdate(w, x, y)
+ tk_call('::TreeCtrl::MarqueeUpdate', w, x, y)
+ end
+ def marqueeEnd(w, x, y)
+ tk_call('::TreeCtrl::MarqueeEnd', w, x, y)
+ end
+ def scanMark(w, x, y)
+ tk_call('::TreeCtrl::ScanMark', w, x, y)
+ end
+ def scanDrag(w, x, y)
+ tk_call('::TreeCtrl::ScanDrag', w, x, y)
+ end
+
+ # filelist-bindings
+ def fileList_button1(w, x, y)
+ tk_call('::TreeCtrl::FileListButton1', w, x, y)
+ end
+ def fileList_motion1(w, x, y)
+ tk_call('::TreeCtrl::FileListMotion1', w, x, y)
+ end
+ def fileList_motion(w, x, y)
+ tk_call('::TreeCtrl::FileListMotion', w, x, y)
+ end
+ def fileList_leave1(w, x, y)
+ tk_call('::TreeCtrl::FileListLeave1', w, x, y)
+ end
+ def fileList_release1(w, x, y)
+ tk_call('::TreeCtrl::FileListRelease1', w, x, y)
+ end
+ def fileList_edit(w, i, s, e)
+ tk_call('::TreeCtrl::FileListEdit', w, i, s, e)
+ end
+ def fileList_editCancel(w)
+ tk_call('::TreeCtrl::FileListEditCancel', w)
+ end
+ def fileList_autoScanCheck(w, x, y)
+ tk_call('::TreeCtrl::FileListAutoScanCheck', w, x, y)
+ end
+ def fileList_autoScanCheckAux(w)
+ tk_call('::TreeCtrl::FileListAutoScanCheckAux', w)
+ end
+
+ def entryOpen(w, item, col, elem)
+ tk_call('::::TreeCtrl::EntryOpen', w, item, col, elem)
+ end
+ def entryExpanderOpen(w, item, col, elem)
+ tk_call('::TreeCtrl::EntryExpanderOpen', w, item, col, elem)
+ end
+ def entryClose(w, accept)
+ tk_call('::TreeCtrl::EntryClose', w, accept)
+ end
+ def entryExpanderKeypress(w)
+ tk_call('::TreeCtrl::EntryExpanderKeypress', w)
+ end
+ def textOpen(w, item, col, elem, width=0, height=0)
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width, height)
+ end
+ def textExpanderOpen(w, item, col, elem, width)
+ tk_call('::TreeCtrl::TextOpen', w, item, col, elem, width)
+ end
+ def textClose(w, accept)
+ tk_call('::TreeCtrl::TextClose', w, accept)
+ end
+ def textExpanderKeypress(w)
+ tk_call('::TreeCtrl::TextExpanderKeypress', w)
+ end
+end