summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tkextlib
diff options
context:
space:
mode:
authornagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-29 05:25:45 +0000
committernagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-29 05:25:45 +0000
commitaff4ce9c77784a9663852102a717d0385f18a0ea (patch)
tree4edda8b86d097e14db74ee59d1da40361e30d9f1 /ext/tk/lib/tkextlib
parent058c981311f809ee48e3db9264ef82ce1e950c1b (diff)
* ext/tk/*: full update Ruby/Tk to support Ruby(1.9|1.8) and Tc/Tk8.5.
* ext/tk/lib/tkextlib/tile.rb: [incompatible] remove TileWidgets' instate/state/identify method to avoid the conflict with standard widget options. Those methods are renamed to ttk_instate/ttk_state/ ttk_identify (tile_instate/tile_state/tile_identify are available too). Although I don't recommend, if you realy need old methods, please define "Tk::USE_OBSOLETE_TILE_STATE_METHOD = true" before "require 'tkextlib/tile'". * ext/tk/lib/tkextlib/tile.rb: "Tk::Tile::__Import_Tile_Widgets__!" is obsolete. It outputs warning. To control default widget set, use "Tk.default_widget_set = :Ttk". * ext/tk/lib/tk.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind as module methods of TkConfigMethod. It may help users to wrap old Ruby/Tk scripts (use standard widgets) to force to use Ttk widgets. Ttk widgets don't have some options of standard widgets which are control the view of widgets. When set ignore-mode true, configure method tries to ignoure such unknown options with no exception. Of course, it may raise other troubles on the GUI design. So, those are a little danger methods. * ext/tk/lib/tk/itemconfig.rb: __IGNORE_UNKNOWN_CONFIGURE_OPTION__ method and __set_IGNORE_UNKNOWN_CONFIGURE_OPTION__!(mode) method are defind as module methods of TkItemConfigMethod as the same purpose as TkConfigMethod's ones. * ext/tk/sample/ttk_wrapper.rb: A new example. This is a tool for wrapping old Ruby/Tk scripts (which use standard widgets) to use Ttk (Tile) widgets as default. * ext/tk/sample/tkextlib/tile/demo.rb: use ttk_instate/ttk_state method instead of instate/state method. * ext/tk/lib/tk/root, ext/tk/lib/tk/namespace.rb, ext/tk/lib/tk/text.rb, ext/tk/lib/tkextlib/*: some 'instance_eval's are replaced to "instance_exec(self)". * ext/tk/lib/tk/event.rb: bug fix on KEY_TBL and PROC_TBL (?x is not a character code on Ruby1.9). * ext/tk/lib/tk/variable.rb: support new style of operation argument on Tcl/Tk's 'trace' command for variables. * ext/tk/sample/demos-jp/widget, ext/tk/sample/demos-en/widget: bug fix * ext/tk/sammple/demos-jp/textpeer.rb, ext/tk/sammple/demos-en/textpeer.rb: new widget demo. * ext/tk/tcltklib.c: decrase SEGV troubles (probably) * ext/tk/lib/tk.rb: remove Thread.critical access if Ruby1.9 * ext/tk/lib/tk/multi-tk.rb: support Ruby1.9 (probably) * ext/tk/lib/tkextlib/tile.rb: add method to define Tcl/Tk command to make Tcl/Tk theme sources (based on different version of Tile extension) available. (Tk::Tile::__define_LoadImages_proc_for_comaptibility__) * ext/tk/lib/tk.rb, ext/tk/lib/tk/wm.rb: support dockable frames (Tcl/Tk8.5 feature). 'wm' command can treat many kinds of widgets as toplevel widgets. * ext/tk/lib/tkextlib/tile/style.rb: ditto. (Tk::Tile::Style.__define_wrapper_proc_for_compatibility__) * ext/tk/lib/tk/font.rb: add actual_hash and metrics_hash to get properties as a hash. metrics_hash method returns a boolean value for 'fixed' option. But metrics method returns numeric value (0 or 1) for 'fixed' option, because of backward compatibility. * ext/tk/lib/tk/timer.rb: somtimes fail to set callback procedure. * ext/tk/lib/tk.rb: add Tk.sleep and Tk.wakeup method. Tk.sleep doesn't block the eventloop. It will be better to use the method in event callbacks. * ext/tk/sample/tksleep_sample.rb: sample script about Tk.sleep. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@15849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib')
-rw-r--r--ext/tk/lib/tkextlib/SUPPORT_STATUS2
-rw-r--r--ext/tk/lib/tkextlib/blt/bitmap.rb21
-rw-r--r--ext/tk/lib/tkextlib/blt/busy.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/component.rb351
-rw-r--r--ext/tk/lib/tkextlib/blt/dragdrop.rb48
-rw-r--r--ext/tk/lib/tkextlib/blt/eps.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tabset.rb77
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/button.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/checkbutton.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/frame.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/label.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/radiobutton.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/scrollbar.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tile/toplevel.rb2
-rw-r--r--ext/tk/lib/tkextlib/blt/tree.rb341
-rw-r--r--ext/tk/lib/tkextlib/blt/treeview.rb197
-rw-r--r--ext/tk/lib/tkextlib/blt/vector.rb37
-rw-r--r--ext/tk/lib/tkextlib/blt/watch.rb28
-rw-r--r--ext/tk/lib/tkextlib/bwidget/button.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/buttonbox.rb20
-rw-r--r--ext/tk/lib/tkextlib/bwidget/combobox.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/dialog.rb26
-rw-r--r--ext/tk/lib/tkextlib/bwidget/entry.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/label.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/labelentry.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/labelframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/listbox.rb34
-rw-r--r--ext/tk/lib/tkextlib/bwidget/mainframe.rb48
-rw-r--r--ext/tk/lib/tkextlib/bwidget/messagedlg.rb5
-rw-r--r--ext/tk/lib/tkextlib/bwidget/notebook.rb24
-rw-r--r--ext/tk/lib/tkextlib/bwidget/pagesmanager.rb16
-rw-r--r--ext/tk/lib/tkextlib/bwidget/panedwindow.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/panelframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/progressdlg.rb4
-rw-r--r--ext/tk/lib/tkextlib/bwidget/scrollableframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/selectcolor.rb28
-rw-r--r--ext/tk/lib/tkextlib/bwidget/selectfont.rb7
-rw-r--r--ext/tk/lib/tkextlib/bwidget/spinbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/bwidget/statusbar.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/titleframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/bwidget/tree.rb34
-rw-r--r--ext/tk/lib/tkextlib/bwidget/widget.rb8
-rw-r--r--ext/tk/lib/tkextlib/itcl/incr_tcl.rb12
-rw-r--r--ext/tk/lib/tkextlib/itk/incr_tk.rb44
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/calendar.rb17
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/checkbox.rb16
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/entryfield.rb17
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/hierarchy.rb52
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/notebook.rb11
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/radiobox.rb11
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb10
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb5
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectionbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb2
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/spinner.rb17
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb16
-rw-r--r--ext/tk/lib/tkextlib/iwidgets/tabset.rb44
-rw-r--r--ext/tk/lib/tkextlib/tcllib/autoscroll.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ctext.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/datefield.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ico.rb6
-rw-r--r--ext/tk/lib/tkextlib/tcllib/ip_entry.rb2
-rw-r--r--ext/tk/lib/tkextlib/tcllib/plotchart.rb77
-rw-r--r--ext/tk/lib/tkextlib/tcllib/tkpiechart.rb14
-rw-r--r--ext/tk/lib/tkextlib/tile.rb217
-rw-r--r--ext/tk/lib/tkextlib/tile/sizegrip.rb4
-rw-r--r--ext/tk/lib/tkextlib/tile/style.rb191
-rw-r--r--ext/tk/lib/tkextlib/tile/tbutton.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tcheckbutton.rb8
-rw-r--r--ext/tk/lib/tkextlib/tile/tcombobox.rb3
-rw-r--r--ext/tk/lib/tkextlib/tile/tentry.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tframe.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tlabel.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tlabelframe.rb8
-rw-r--r--ext/tk/lib/tkextlib/tile/tmenubutton.rb12
-rw-r--r--ext/tk/lib/tkextlib/tile/tnotebook.rb3
-rw-r--r--ext/tk/lib/tkextlib/tile/tpaned.rb12
-rw-r--r--ext/tk/lib/tkextlib/tile/tprogressbar.rb3
-rw-r--r--ext/tk/lib/tkextlib/tile/tradiobutton.rb8
-rw-r--r--ext/tk/lib/tkextlib/tile/treeview.rb133
-rw-r--r--ext/tk/lib/tkextlib/tile/tscale.rb7
-rw-r--r--ext/tk/lib/tkextlib/tile/tscrollbar.rb28
-rw-r--r--ext/tk/lib/tkextlib/tile/tseparator.rb3
-rw-r--r--ext/tk/lib/tkextlib/tkDND/tkdnd.rb16
-rw-r--r--ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb17
-rw-r--r--ext/tk/lib/tkextlib/tktable/tktable.rb167
-rw-r--r--ext/tk/lib/tkextlib/tktrans/tktrans.rb4
-rw-r--r--ext/tk/lib/tkextlib/treectrl/tktreectrl.rb233
-rw-r--r--ext/tk/lib/tkextlib/version.rb2
-rw-r--r--ext/tk/lib/tkextlib/vu/pie.rb73
-rw-r--r--ext/tk/lib/tkextlib/vu/spinbox.rb2
-rw-r--r--ext/tk/lib/tkextlib/winico/winico.rb49
93 files changed, 2410 insertions, 650 deletions
diff --git a/ext/tk/lib/tkextlib/SUPPORT_STATUS b/ext/tk/lib/tkextlib/SUPPORT_STATUS
index 15925cba72..cfbe274c86 100644
--- a/ext/tk/lib/tkextlib/SUPPORT_STATUS
+++ b/ext/tk/lib/tkextlib/SUPPORT_STATUS
@@ -83,7 +83,7 @@ BLT 2.4z http://sourceforge.net/projects/blt
TkTreeCtrl CVS/Hd(2005-12-02)
http://sourceforge.net/projects/tktreectrl ==> treectrl
-Tile 0.7.8
+Tile 0.8.0/8.5.1
http://sourceforge.net/projects/tktable ==> tile
diff --git a/ext/tk/lib/tkextlib/blt/bitmap.rb b/ext/tk/lib/tkextlib/blt/bitmap.rb
index 31cf8d4229..23c6d2d064 100644
--- a/ext/tk/lib/tkextlib/blt/bitmap.rb
+++ b/ext/tk/lib/tkextlib/blt/bitmap.rb
@@ -13,7 +13,16 @@ module Tk::BLT
TkCommandNames = ['::blt::bitmap'.freeze].freeze
BITMAP_ID_TBL = TkCore::INTERP.create_table
- BITMAP_ID = ['blt_bitmap_id'.freeze, '00000'.taint].freeze
+
+ (BITMAP_ID = ['blt_bitmap_id'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ BITMAP_ID_TBL.mutex.synchronize{ BITMAP_ID_TBL.clear }
+ }
def self.data(name)
dat = tk_simple_list(tk_call('::blt::bitmap', 'data', name))
@@ -64,9 +73,13 @@ module Tk::BLT
if name
@id = name
else
- @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
- BITMAP_ID[1].succ!
- BITMAP_ID_TBL[@id] = self
+ BITMAP_ID.mutex.synchronize{
+ @id = BITMAP_ID.join(TkCore::INTERP._ip_id_)
+ BITMAP_ID[1].succ!
+ }
+ BITMAP_ID_TBL.mutex.synchronize{
+ BITMAP_ID_TBL[@id] = self
+ }
end
@path = @id
diff --git a/ext/tk/lib/tkextlib/blt/busy.rb b/ext/tk/lib/tkextlib/blt/busy.rb
index 4726e466f4..2f807fcd9c 100644
--- a/ext/tk/lib/tkextlib/blt/busy.rb
+++ b/ext/tk/lib/tkextlib/blt/busy.rb
@@ -19,7 +19,7 @@ module Tk::BLT
class Shield < TkWindow
def self.shield_path(win)
win = window(win) unless win.kind_of?(TkWindow)
- if win.kind_of?(TkToplevel)
+ if win.kind_of?(Tk::Toplevel)
win.path + '._Busy'
else
win.path + '_Busy'
diff --git a/ext/tk/lib/tkextlib/blt/component.rb b/ext/tk/lib/tkextlib/blt/component.rb
index ad78a5430b..dd387634ee 100644
--- a/ext/tk/lib/tkextlib/blt/component.rb
+++ b/ext/tk/lib/tkextlib/blt/component.rb
@@ -327,13 +327,24 @@ module Tk::BLT
#################
class Axis < TkObject
- OBJ_ID = ['blt_chart_axis'.freeze, '00000'.taint].freeze
- OBJ_TBL={}
+ (OBJ_ID = ['blt_chart_axis'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ AxisID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ AxisID_TBL.mutex.synchronize{ AxisID_TBL.clear }
+ }
def self.id2obj(chart, id)
cpath = chart.path
- return id unless OBJ_TBL[cpath]
- OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
+ AxisID_TBL.mutex.synchronize{
+ return id unless AxisID_TBL[cpath]
+ AxisID_TBL[cpath][id]? AxisID_TBL[cpath][id]: id
+ }
end
def self.new(chart, axis=nil, keys={})
@@ -341,12 +352,48 @@ module Tk::BLT
keys = axis
axis = nil
end
- OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path]
- return OBJ_TBL[chart.path][axis] if axis && OBJ_TBL[chart.path][axis]
- super(chart, axis, keys)
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ AxisID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ AxisID_TBL[chart_path] ||= {}
+ if axis && AxisID_TBL[chart_path][axis]
+ obj = AxisID_TBL[chart_path][axis]
+ else
+ (obj = self.allocate).instance_eval{
+ if axis
+ @axis = @id = axis.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Axis::AxisID_TBL[@cpath][@axis] = self
+ unless not_create
+ tk_call(@chart, 'axis', 'create', @axis, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
end
def initialize(chart, axis=nil, keys={})
+ # dummy:: not called by 'new' method
+
if axis.kind_of?(Hash)
keys = axis
axis = nil
@@ -354,13 +401,15 @@ module Tk::BLT
if axis
@axis = @id = axis.to_s
else
- @axis = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
+ OBJ_ID.mutex.synchronize{
+ @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
+ # Axis::AxisID_TBL[@cpath][@axis] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.axis_create(@axis, keys)
@@ -438,17 +487,34 @@ module Tk::BLT
#################
class Crosshairs < TkObject
- OBJ_TBL={}
+ CrosshairsID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ CrosshairsID_TBL.mutex.synchronize{ CrosshairsID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(chart, keys)
+ obj = nil
+ CrosshairsID_TBL.mutex.synchronize{
+ unless (obj = CrosshairsID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'crosshairs'
+ Crosshairs::CrosshairsID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.crosshair_configure(keys) if obj && ! keys.empty?
+ obj
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- Crosshairs::OBJ_TBL[@cpath] = self
+ # Crosshairs::CrosshairsID_TBL[@cpath] = self
@chart.crosshair_configure(keys) unless keys.empty?
@path = @id = 'crosshairs'
end
@@ -500,12 +566,18 @@ module Tk::BLT
ElementTypeName = 'element'
ElementTypeToClass = { ElementTypeName=>self }
+
ElementID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ ElementID_TBL.clear }
+ TkCore::INTERP.init_ip_env{
+ ElementID_TBL.mutex.synchronize{ ElementID_TBL.clear }
+ }
- OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint].freeze
- OBJ_TBL={}
+ (OBJ_ID = ['blt_chart_element'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
def Element.type2class(type)
ElementTypeToClass[type]
@@ -513,8 +585,10 @@ module Tk::BLT
def Element.id2obj(chart, id)
cpath = chart.path
- return id unless OBJ_TBL[cpath]
- OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
+ ElementID_TBL.mutex.synchronize{
+ return id unless ElementID_TBL[cpath]
+ ElementID_TBL[cpath][id]? ElementID_TBL[cpath][id]: id
+ }
end
def self.new(chart, element=nil, keys={})
@@ -522,14 +596,49 @@ module Tk::BLT
keys = element
element = nil
end
- OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path]
- if element && OBJ_TBL[chart.path][element]
- return OBJ_TBL[chart.path][element]
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
end
- super(chart, element, keys)
+
+ obj = nil
+ ElementID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ ElementID_TBL[chart_path] ||= {}
+ if element && ElementID_TBL[chart_path][element]
+ obj = ElementID_TBL[chart_path][element]
+ else
+ (obj = self.allocate).instance_eval{
+ if element
+ @element = @id = element.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @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
+ Element::ElementID_TBL[@cpath][@element] = self
+ unless not_create
+ tk_call(@chart, @typename, 'create', @element, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
end
def initialize(chart, element=nil, keys={})
+ # dummy:: not called by 'new' method
+
if element.kind_of?(Hash)
keys = element
element = nil
@@ -537,14 +646,16 @@ module Tk::BLT
if element
@element = @id = element.to_s
else
- @element = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
+ OBJ_ID.mutex.synchronize{
+ @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
- Element::OBJ_TBL[@cpath][@element] = self
+ # Element::ElementID_TBL[@cpath][@element] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.element_create(@element, keys)
@@ -622,17 +733,33 @@ module Tk::BLT
#################
class GridLine < TkObject
- OBJ_TBL={}
+ GridLineID_TBL = TkCore::INTERP.create_table
+ TkCore::INTERP.init_ip_env{
+ GridLineID_TBL.mutex.synchronize{ GridLineID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(chart, keys)
+ obj = nil
+ GridLineID_TBL.mutex.synchronize{
+ unless (obj = GridLineID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'grid'
+ GridLine::GridLineID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.gridline_configure(keys) if obj && ! keys.empty?
+ obj
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- GridLine::OBJ_TBL[@cpath] = self
+ # GridLine::GridLineID_TBL[@cpath] = self
@chart.gridline_configure(keys) unless keys.empty?
@path = @id = 'grid'
end
@@ -676,18 +803,35 @@ module Tk::BLT
#################
class Legend < TkObject
- OBJ_TBL={}
+ LegendID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ LegendID_TBL.mutex.synchronize{ LegendID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(chart, keys)
+ obj = nil
+ LegenedID_TBL.mutex.synchronize{
+ unless (obj = LegenedID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'crosshairs'
+ Legend::LegenedID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.legend_configure(keys) if obj && ! keys.empty?
+ obj
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- Crosshairs::OBJ_TBL[@cpath] = self
- @chart.crosshair_configure(keys) unless keys.empty?
+ # Legend::LegendID_TBL[@cpath] = self
+ @chart.legend_configure(keys) unless keys.empty?
@path = @id = 'legend'
end
@@ -729,13 +873,24 @@ module Tk::BLT
#################
class Pen < TkObject
- OBJ_ID = ['blt_chart_pen'.freeze, '00000'.taint].freeze
- OBJ_TBL={}
+ (OBJ_ID = ['blt_chart_pen'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ PenID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ PenID_TBL.mutex.synchronize{ PenID_TBL.clear }
+ }
def self.id2obj(chart, id)
cpath = chart.path
- return id unless OBJ_TBL[cpath]
- OBJ_TBL[cpath][id]? OBJ_TBL[cpath][id]: id
+ PenID_TBL.mutex.synchronize{
+ return id unless PenID_TBL[cpath]
+ PenID_TBL[cpath][id]? PenID_TBL[cpath][id]: id
+ }
end
def self.new(chart, pen=nil, keys={})
@@ -743,9 +898,43 @@ module Tk::BLT
keys = pen
pen = nil
end
- OBJ_TBL[chart.path] = {} unless OBJ_TBL[chart.path]
- return OBJ_TBL[chart.path][pen] if pen && OBJ_TBL[chart.path][pen]
- super(chart, pen, keys)
+ if keys
+ keys = _symbolkey2str(keys)
+ not_create = keys.delete('without_creating')
+ else
+ not_create = false
+ end
+
+ obj = nil
+ PenID_TBL.mutex.synchronize{
+ chart_path = chart.path
+ PenID_TBL[chart_path] ||= {}
+ if pen && PenID_TBL[chart_path][pen]
+ obj = PenID_TBL[chart_path][pen]
+ else
+ (obj = self.allocate).instance_eval{
+ if pen
+ @pen = @id = pen.to_s
+ else
+ OBJ_ID.mutex.synchronize{
+ @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
+ OBJ_ID[1].succ!
+ }
+ end
+ @path = @id
+ @parent = @chart = chart
+ @cpath = @chart.path
+ Pen::PenID_TBL[@cpath][@pen] = self
+ unless not_create
+ tk_call(@chart, 'pen', 'create', @pen, keys)
+ return obj
+ end
+ }
+ end
+ }
+
+ obj.configure(keys) if obj && ! keys.empty?
+ obj
end
def initialize(chart, pen=nil, keys={})
@@ -756,13 +945,15 @@ module Tk::BLT
if pen
@pen = @id = pen.to_s
else
- @pen = @id = OBJ_ID.join(TkCore::INTERP._ip_id_).freeze
- OBJ_ID[1].succ!
+ OBJ_ID.mutex.synchronize{
+ @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
+ Pen::PenID_TBL[@cpath][@pen] = self
keys = _symbolkey2str(keys)
unless keys.delete('without_creating')
# @chart.pen_create(@pen, keys)
@@ -805,17 +996,34 @@ module Tk::BLT
#################
class Postscript < TkObject
- OBJ_TBL={}
+ PostscriptID_TBL = TkCore::INTERP.create_table
+
+ TkCore::INTERP.init_ip_env{
+ PostscriptID_TBL.mutex.synchronize{ PostscriptID_TBL.clear }
+ }
def self.new(chart, keys={})
- return OBJ_TBL[chart.path] if OBJ_TBL[chart.path]
- super(chart, keys)
+ obj = nil
+ PostscriptID_TBL.mutex.synchronize{
+ unless (obj = PostscriptID_TBL[chart.path])
+ (obj = self.allocate).instance_eval{
+ @parent = @chart = chart
+ @cpath = @chart.path
+ @path = @id = 'postscript'
+ Postscript::PostscriptID_TBL[@cpath] = self
+ }
+ end
+ }
+ chart.postscript_configure(keys) if obj && ! keys.empty?
+ obj
end
def initialize(chart, keys={})
+ # dummy:: not called by 'new' method
+
@parent = @chart = chart
@cpath = @chart.path
- Postscript::OBJ_TBL[@cpath] = self
+ # Postscript::PostscriptID_TBL[@cpath] = self
@chart.postscript_configure(keys) unless keys.empty?
@path = @id = 'postscript'
end
@@ -870,7 +1078,9 @@ module Tk::BLT
MarkerTypeToClass = {}
MarkerID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ MarkerID_TBL.clear }
+ TkCore::INTERP.init_ip_env{
+ MarkerID_TBL.mutex.synchronize{ MarkerID_TBL.clear }
+ }
def Marker.type2class(type)
MarkerTypeToClass[type]
@@ -878,8 +1088,13 @@ module Tk::BLT
def Marker.id2obj(chart, id)
cpath = chart.path
- return id unless MarkerID_TBL[cpath]
- MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
+ MarkerID_TBL.mutex.synchronize{
+ if MarkerID_TBL[cpath]
+ MarkerID_TBL[cpath][id]? MarkerID_TBL[cpath][id]: id
+ else
+ id
+ end
+ }
end
def self._parse_create_args(keys)
@@ -943,10 +1158,10 @@ module Tk::BLT
@parent = @chart = chart
@cpath = chart.path
@id = id
- unless Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath]
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] = {}
- end
- Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath][@id] = self
+ }
}
obj
end
@@ -956,10 +1171,10 @@ module Tk::BLT
@cpath = parent.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[@cpath][@id] = self
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL.mutex.synchronize{
+ Tk::BLT::PlotComponent::Marker::MarkerID_TBL[@cpath] ||= {}
+ 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'
@@ -1037,14 +1252,14 @@ module Tk::BLT
#################
def __destroy_hook__
- Axis::OBJ_TBL.delete(@path)
- Crosshairs::OBJ_TBL.delete(@path)
- Element::OBJ_TBL.delete(@path)
- GridLine::OBJ_TBL.delete(@path)
- Legend::OBJ_TBL.delete(@path)
- Pen::OBJ_TBL.delete(@path)
- Postscript::OBJ_TBL.delete(@path)
- Marker::OBJ_TBL.delete(@path)
+ Axis::AxisID_TBL.delete(@path)
+ Crosshairs::CrosshairsID_TBL.delete(@path)
+ Element::ElementID_TBL.delete(@path)
+ GridLine::GridLineID_TBL.delete(@path)
+ Legend::LegendID_TBL.delete(@path)
+ Pen::PenID_TBL.delete(@path)
+ Postscript::PostscriptID_TBL.delete(@path)
+ Marker::MarkerID_TBL.delete(@path)
super()
end
diff --git a/ext/tk/lib/tkextlib/blt/dragdrop.rb b/ext/tk/lib/tkextlib/blt/dragdrop.rb
index 68fb9e591a..98b1a4832f 100644
--- a/ext/tk/lib/tkextlib/blt/dragdrop.rb
+++ b/ext/tk/lib/tkextlib/blt/dragdrop.rb
@@ -81,6 +81,22 @@ module Tk::BLT
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL)
def self.ret_val(val)
@@ -107,6 +123,22 @@ module Tk::BLT
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL)
def self.ret_val(val)
@@ -145,6 +177,22 @@ module Tk::BLT
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL)
end
diff --git a/ext/tk/lib/tkextlib/blt/eps.rb b/ext/tk/lib/tkextlib/blt/eps.rb
index 586a42470c..0dba87a7cc 100644
--- a/ext/tk/lib/tkextlib/blt/eps.rb
+++ b/ext/tk/lib/tkextlib/blt/eps.rb
@@ -14,7 +14,7 @@ module Tk::BLT
end
end
-class TkCanvas
+class Tk::Canvas
alias __BLT_EPS_item_strval_optkeys __item_strval_optkeys
def __item_strval_optkeys(id)
__BLT_EPS_item_strval_optkeys(id) + [
diff --git a/ext/tk/lib/tkextlib/blt/tabset.rb b/ext/tk/lib/tkextlib/blt/tabset.rb
index c26b6ee001..1a0f312c4c 100644
--- a/ext/tk/lib/tkextlib/blt/tabset.rb
+++ b/ext/tk/lib/tkextlib/blt/tabset.rb
@@ -12,14 +12,26 @@ module Tk::BLT
include TkTreatItemFont
TabID_TBL = TkCore::INTERP.create_table
- TabsetTab_ID = ['blt_tabset_tab'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TabID_TBL.clear }
+ (TabsetTab_ID = ['blt_tabset_tab'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TabID_TBL.mutex.synchronize{ TabID_TBL.clear }
+ }
def self.id2obj(tabset, id)
tpath = tabset.path
- return id unless TabID_TBL[tpath]
- TabID_TBL[tpath][id]? TabID_TBL[tpath]: id
+ TabID_TBL.mutex.synchronize{
+ if TabID_TBL[tpath]
+ TabID_TBL[tpath][id]? TabID_TBL[tpath]: id
+ else
+ id
+ end
+ }
end
def self.new(parent, pos=nil, name=nil, keys={})
@@ -32,12 +44,20 @@ module Tk::BLT
keys = name
name = nil
end
-
- if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
- TabID_TBL[parent.path][name]
- else
- super(parent, pos, name, keys)
- end
+ obj = nil
+ TabID_TBL.mutex.synchronize{
+ if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
+ obj = TabID_TBL[parent.path][name]
+ obj.configure if keys && ! keys.empty?
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(parent, pos, name, keys)
+ TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
+ TabID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj
end
def initialize(parent, pos, name, keys)
@@ -45,9 +65,6 @@ module Tk::BLT
@tpath = parent.path
if name
@path = @id = name
- TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
- TabID_TBL[@tpath][@id] = self
-
unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
if pos
idx = tk_call(@tpath, 'index', '-name', @id)
@@ -58,18 +75,18 @@ module Tk::BLT
end
end
tk_call(@tpath, 'tab', 'configure', @id, keys)
- return
+ else
+ pos = 'end' unless pos
+ tk_call(@tpath, 'insert', pos, @id, keys)
end
-
else
- @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_)
- TabID_TBL[@tpath] = {} unless TabID_TBL[@tpath]
- TabID_TBL[@tpath][@id] = self
- TabsetTab_ID[1].succ!
+ TabsetTab_ID.mutex.synchronize{
+ @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_)
+ TabsetTab_ID[1].succ!
+ }
+ pos = 'end' unless pos
+ tk_call(@tpath, 'insert', pos, @id, keys)
end
-
- pos = 'end' unless pos
- tk_call(@tpath, 'insert', pos, @id, keys)
end
#def bind(context, cmd=Proc.new, *args)
@@ -123,7 +140,9 @@ module Tk::BLT
def delete()
@t.delete(@id)
- TabID_TBL[@tpath].delete(@id)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@tpath].delete(@id)
+ }
self
end
@@ -184,7 +203,9 @@ module Tk::BLT
WidgetClassNames[WidgetClassName] = self
def __destroy_hook__
- Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
+ Tk::BLT::Tabset::Tab::TabID_TBL.mutex.synchronize{
+ Tk::BLT::Tabset::Tab::TabID_TBL.delete(@path)
+ }
end
########################################
@@ -291,11 +312,15 @@ module Tk::BLT
def delete(first, last=None)
tk_send('delete', tagindex(first), tagindex(last))
if first.kind_of?(Tk::BLT::Tabset::Tab)
- TabID_TBL[@path].delete(first.id)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@path].delete(first.id)
+ }
end
# middle tabs of the range are unknown
if last.kind_of?(Tk::BLT::Tabset::Tab)
- TabID_TBL[@path].delete(last.id)
+ TabID_TBL.mutex.synchronize{
+ TabID_TBL[@path].delete(last.id)
+ }
end
self
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/button.rb b/ext/tk/lib/tkextlib/blt/tile/button.rb
index dd715c8b98..2e0863cfbe 100644
--- a/ext/tk/lib/tkextlib/blt/tile/button.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/button.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Button < TkButton
+ class Button < Tk::Button
TkCommandNames = ['::blt::tile::button'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
index ad58999d86..da230b5925 100644
--- a/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/checkbutton.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class CheckButton < TkCheckButton
+ class CheckButton < Tk::CheckButton
TkCommandNames = ['::blt::tile::checkbutton'.freeze].freeze
end
Checkbutton = CheckButton
diff --git a/ext/tk/lib/tkextlib/blt/tile/frame.rb b/ext/tk/lib/tkextlib/blt/tile/frame.rb
index 10469fd35f..5434af4b72 100644
--- a/ext/tk/lib/tkextlib/blt/tile/frame.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/frame.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Frame < TkFrame
+ class Frame < Tk::Frame
TkCommandNames = ['::blt::tile::frame'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/label.rb b/ext/tk/lib/tkextlib/blt/tile/label.rb
index ec67babd58..f370c1403b 100644
--- a/ext/tk/lib/tkextlib/blt/tile/label.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/label.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Label < TkLabel
+ class Label < Tk::Label
TkCommandNames = ['::blt::tile::label'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
index 2316923b19..814f9a5cc4 100644
--- a/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/radiobutton.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class RadioButton < TkRadioButton
+ class RadioButton < Tk::RadioButton
TkCommandNames = ['::blt::tile::radiobutton'.freeze].freeze
end
Radiobutton = RadioButton
diff --git a/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb b/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
index ba3bf316f0..2ae871d518 100644
--- a/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/scrollbar.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Scrollbar < TkScrollbar
+ class Scrollbar < Tk::Scrollbar
TkCommandNames = ['::blt::tile::scrollbar'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tile/toplevel.rb b/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
index 6cc2c91415..76d5f86b1b 100644
--- a/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
+++ b/ext/tk/lib/tkextlib/blt/tile/toplevel.rb
@@ -9,7 +9,7 @@ require 'tkextlib/blt/tile.rb'
module Tk::BLT
module Tile
- class Toplevel < TkToplevel
+ class Toplevel < Tk::Toplevel
TkCommandNames = ['::blt::tile::toplevel'.freeze].freeze
end
end
diff --git a/ext/tk/lib/tkextlib/blt/tree.rb b/ext/tk/lib/tkextlib/blt/tree.rb
index 07dc7ef7e8..77b85f1717 100644
--- a/ext/tk/lib/tkextlib/blt/tree.rb
+++ b/ext/tk/lib/tkextlib/blt/tree.rb
@@ -12,53 +12,77 @@ module Tk::BLT
###################################
- class Node < TkObject
+ class Node < TkObject
TreeNodeID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TreeNodeID_TBL[tpath]
- if TreeNodeID_TBL[tpath][id]
- TreeNodeID_TBL[tpath][id]
- else
- begin
- self.new(tree, nil, 'node'=>Integer(id))
- rescue
+ TreeNodeID_TBL.mutex.synchronize{
+ if TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, nil, 'node'=>Integer(id))
+ id = Integer(id)
+ if bool(tk_call(@tpath, 'exists', id))
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = tpath
+ @path = @id = id
+ TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
+ TreeNodeID_TBL[@tpath][@id] = self
+ }
+ obj
+ else
+ id
+ end
+ rescue
+ id
+ end
+ end
+ else
id
end
- end
+ }
end
def self.new(tree, parent, keys={})
keys = _symbolkey2str(keys)
tpath = tree.path
- if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
- keys.delete('node')
- tk_call(tree.path, 'move', id, parent, keys) if parent
- return obj
- end
+ TreeNodeID_TBL.mutex.synchronize{
+ TreeNodeID_TBL[tpath] ||= {}
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, parent, keys) if parent
+ return obj
+ end
- super(tree, parent, keys)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
end
def initialize(tree, parent, keys={})
@parent = @tree = tree
@tpath = @parent.path
- parent = tk_call(@tpath, 'root') unless parent
-
if (id = keys['node']) && bool(tk_call(@tpath, 'exists', id))
@path = @id = id
keys.delete('node')
tk_call(@tpath, 'move', @id, parent, keys) if parent
else
+ parent = tk_call(@tpath, 'root') unless parent
@path = @id = tk_call(@tpath, 'insert', parent, keys)
end
-
- TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
- TreeNodeID_TBL[@tpath][@id] = self
end
def id
@@ -243,17 +267,42 @@ module Tk::BLT
class Tag < TkObject
TreeTagID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ TreeTagID_TBL.clear }
- TreeTag_ID = ['blt_tree_tag'.freeze, '00000'.taint].freeze
+
+ TkCore::INTERP.init_ip_env{
+ TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
+ }
+
+ (TreeTag_ID = ['blt_tree_tag'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TreeTagID_TBL[tpath]
- if TreeTagID_TBL[tpath][id]
- TreeTagID_TBL[tpath][id]
- else
- self.new(tree, id)
- end
+ TreeTagID_TBL.mutex.synchronize{
+ if TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][id]
+ TreeTagID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, id)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id.dup.freeze if id
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ rescue
+ id
+ end
+ end
+ else
+ id
+ end
+ }
end
def initialize(tree, tag_str = nil)
@@ -263,12 +312,15 @@ module Tk::BLT
if tag_str
@path = @id = tag_str.dup.freeze
else
- @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
- TreeTagID_TBL[@id] = self
- TreeTag_ID[1].succ!
+ TreeTag_ID.mutex.synchronize{
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_)
+ TreeTag_ID[1].succ!
+ }
end
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
end
def id
@@ -287,7 +339,9 @@ module Tk::BLT
def forget()
tk_call(@tpath, 'tag', 'forget', @id)
- TreeTagID_TBL[@tpath].delete(@id)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@tpath].delete(@id)
+ }
self
end
@@ -312,44 +366,63 @@ module Tk::BLT
class Notify < TkObject
NotifyID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ NotifyID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ NotifyID_TBL.mutex.synchronize{ NotifyID_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless NotifyID_TBL[tpath]
- if NotifyID_TBL[tpath][id]
- NotifyID_TBL[tpath][id]
- else
- begin
- self.new([tree, id])
- rescue
- id
+ NotifyID_TBL.mutex.synchronize{
+ if NotifyID_TBL[tpath]
+ if NotifyID_TBL[tpath][id]
+ NotifyID_TBL[tpath][id]
+ else
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id
+ NotifyID_TBL[@tpath] ||= {}
+ NotifyID_TBL[@tpath][@id] = self
+ }
+ obj
+ end
+ else
+ return id
end
- end
+ }
end
def self.new(tree, *args, &b)
- if tree.kind_of?(Array)
- # not create
- if obj = NotifyID_TBL[tree[0].path][tree[1]]
+ NotifyID_TBL.mutex.synchronize{
+ if tree.kind_of?(Array)
+ # not create
+ tpath = tree[0].path
+ NotifyID_TBL[tpath] ||= {}
+ unless (obj = NotifyID_TBL[tpath][tree[1]])
+ (NotifyID_TBL[tpath][tree[1]] =
+ obj = self.allocate).instance_eval{
+ @parent = @tree = tree[0]
+ @tpath = @parent.path
+ @path = @id = tree[1]
+ }
+ end
return obj
- else
- return super(false, tree[0], tree[1])
end
- end
- super(true, tree, *args, &b)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, *args, &b)
+ NotifyID_TBL[@tpath] ||= {}
+ NotifyID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
end
- def initialize(create, tree, *args, &b)
+ def initialize(tree, *args, &b)
@parent = @tree = tree
@tpath = @parent.path
- unless create
- @path = @id = args[0]
- return
- end
-
# if args[0].kind_of?(Proc) || args[0].kind_of?(Method)
if TkComm._callback_entry?(args[0])
cmd = args.shift
@@ -378,7 +451,9 @@ module Tk::BLT
def delete()
tk_call(@tpath, 'notify', 'delete', @id)
- NotifyID_TBL[tpath].delete(@id)
+ NotifyID_TBL.mutex.synchronize{
+ NotifyID_TBL[@tpath].delete(@id)
+ }
self
end
@@ -395,44 +470,69 @@ module Tk::BLT
class Trace < TkObject
TraceID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ TraceID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ TraceID_TBL.mutex.synchronize{ TraceID_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TraceID_TBL[tpath]
- if TraceID_TBL[tpath][id]
- TraceID_TBL[tpath][id]
- else
- begin
- self.new([tree, id])
- rescue
+ TraceID_TBL.mutex.synchronize{
+ if TraceID_TBL[tpath]
+ if TraceID_TBL[tpath][id]
+ TraceID_TBL[tpath][id]
+ else
+ begin
+ # self.new([tree, id])
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = node # == traceID
+ TraceID_TBL[@tpath] ||= {}
+ TraceID_TBL[@tpath][@id] = self
+ }
+ obj
+ rescue
+ id
+ end
+ end
+ else
id
end
- end
+ }
end
def self.new(tree, *args, &b)
- if tree.kind_of?(Array)
- # not create
- if obj = TraceID_TBL[tree[0].path][tree[1]]
+ TraceID_TBL.mutex.synchronize{
+ if tree.kind_of?(Array)
+ # not create
+ tpath = tree[0].path
+ TraceID_TBL[tpath] ||= {}
+ unless (obj = TraceID_TBL[tpath][tree[1]])
+ (TraceID_TBL[tpath][tree[1]] =
+ obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = tree[1] # == traceID
+ }
+ end
return obj
- else
- return super(false, tree[0], tree[1])
end
- end
- super(true, tree, *args, &b)
+ # super(true, tree, *args, &b)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, *args, &b)
+ TraceID_TBL[@tpath] ||= {}
+ TraceID_TBL[@tpath][@id] = self
+ }
+ return obj
+ }
end
- def initialize(create, tree, node, key, opts, cmd=nil, &b)
+ def initialize(tree, node, key, opts, cmd=nil, &b)
@parent = @tree = tree
@tpath = @parent.path
- unless create
- @path = @id = node # == traceID
- return
- end
-
if !cmd
if b
cmd = Proc.new(&b)
@@ -459,7 +559,9 @@ module Tk::BLT
def delete()
tk_call(@tpath, 'trace', 'delete', @id)
- TraceID_TBL[tpath].delete(@id)
+ TraceID_TBL.mutex.synchronize{
+ TraceID_TBL[tpath].delete(@id)
+ }
self
end
@@ -475,7 +577,12 @@ module Tk::BLT
###################################
TreeID_TBL = TkCore::INTERP.create_table
- Tree_ID = ['blt_tree'.freeze, '00000'.taint].freeze
+
+ (Tree_ID = ['blt_tree'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
def __keyonly_optkeys
{
@@ -498,7 +605,9 @@ module Tk::BLT
end
def self.id2obj(id)
- TreeID_TBL[id]? TreeID_TBL[id]: id
+ TreeID_TBL.mutex.synchronize{
+ TreeID_TBL[id]? TreeID_TBL[id]: id
+ }
end
def self.names(pat = None)
@@ -513,27 +622,45 @@ module Tk::BLT
end
def self.new(name = nil)
- return TreeID_TBL[name] if name && TreeID_TBL[name]
- super(name)
+ TreeID_TBL.mutex.synchronize{
+ if name && TreeID_TBL[name]
+ TreeID_TBL[name]
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(name)
+ TreeID_TBL[@id] = self
+ }
+ obj
+ end
+ }
end
def initialzie(name = nil)
if name
@path = @id = name
else
- @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
- TreeID_TBL[@id] = self
- Tree_ID[1].succ!
+ Tree_ID.mutex.synchronize{
+ @path = @id = Tree_ID.join(TkCore::INTERP._ip_id_)
+ Tree_ID[1].succ!
+ }
end
- TreeID_TBL[@id] = self
+
tk_call('::blt::tree', 'create', @id)
end
def __destroy_hook__
- Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path)
- Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path)
- Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path)
- Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Tag::TreeTagID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Tag::TreeTagID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Notify::NotifyID_TBL.delete(@path)
+ }
+ Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Trace::TraceID_TBL.delete(@path)
+ }
end
def tagid(tag)
@@ -592,12 +719,14 @@ module Tk::BLT
def 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)
- else
- Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.to_s)
- end
+ Tk::BLT::Tree::Node::TreeNodeID_TBL.mutex.synchronize{
+ nodes.each{|node|
+ if node.kind_of?(Tk::BLT::Tree::Node)
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.id)
+ else
+ Tk::BLT::Tree::Node::TreeNodeID_TBL[@path].delete(node.to_s)
+ end
+ }
}
self
end
@@ -728,7 +857,9 @@ module Tk::BLT
id.delete
else
tk_call(@path, 'notify', 'delete', id)
- Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
+ Tk::BLT::Tree::Notify::NotifyID_TBL.mutex.synchronize{
+ Tk::BLT::Tree::Notify::NotifyID_TBL[@path].delete(id.to_s)
+ }
end
self
end
@@ -835,7 +966,9 @@ module Tk::BLT
def tag_forget(tag)
tag = tag.id if tag.kind_of?(Tk::BLT::Tree::Tag)
tk_call(@path, 'tag', 'forget', tag)
- TreeTagID_TBL[@path].delete(tag)
+ TreeTagID_TBL.mutex.synchronize{
+ TreeTagID_TBL[@path].delete(tag)
+ }
self
end
@@ -889,7 +1022,9 @@ module Tk::BLT
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)}
+ Tk::BLT::Tree::Trace::TraceID_TBL.mutex.synchronize{
+ args.each{|id| Tk::BLT::Tree::Trace::TraceID_TBL[@path].delete(id.to_s)}
+ }
self
end
diff --git a/ext/tk/lib/tkextlib/blt/treeview.rb b/ext/tk/lib/tkextlib/blt/treeview.rb
index 0343d28b9c..fc890614be 100644
--- a/ext/tk/lib/tkextlib/blt/treeview.rb
+++ b/ext/tk/lib/tkextlib/blt/treeview.rb
@@ -239,6 +239,22 @@ class Tk::BLT::Treeview
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -273,8 +289,12 @@ class Tk::BLT::Treeview
########################
def __destroy_hook__
- Tk::BLT::Treeview::Node::TreeNodeID_TBL.delete(@path)
- Tk::BLT::Treeview::Tag::TreeTagID_TBL.delete(@path)
+ Tk::BLT::Treeview::Node::TreeNodeID_TBL.mutex.synchronize{
+ Tk::BLT::Treeview::Node::TreeNodeID_TBL.delete(@path)
+ }
+ Tk::BLT::Treeview::Tag::TreeTagID_TBL.mutex.synchronize{
+ Tk::BLT::Treeview::Tag::TreeTagID_TBL.delete(@path)
+ }
end
def tagid(tag)
@@ -472,6 +492,22 @@ class Tk::BLT::Treeview
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -967,22 +1003,47 @@ class Tk::BLT::Treeview::Node < TkObject
include Tk::BLT::Treeview::TagOrID_Methods
TreeNodeID_TBL = TkCore::INTERP.create_table
- TreeNode_ID = ['blt_treeview_node'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TreeNodeID_TBL.clear }
+ (TreeNode_ID = ['blt_treeview_node'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNodeID_TBL.mutex.synchronize{ TreeNodeID_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TreeNodeID_TBL[tpath]
- if TreeNodeID_TBL[tpath][id]
- TreeNodeID_TBL[tpath][id]
- else
- begin
- self.new(tree, nil, nil, 'node'=>Integer(id))
- rescue
+ TreeNodeID_TBL.mutex.synchronize{
+ if TreeNodeID_TBL[tpath]
+ if TreeNodeID_TBL[tpath][id]
+ TreeNodeID_TBL[tpath][id]
+ else
+ begin
+ # self.new(tree, nil, nil, 'node'=>Integer(id))
+ unless (tk_call(@tpath, 'get', id)).empty?
+ id = Integer(id)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = id
+ TreeNodeID_TBL[@tpath] ||= {}
+ TreeNodeID_TBL[@tpath][@id] = self
+ }
+ obj
+ else
+ id
+ end
+ rescue
+ id
+ end
+ end
+ else
id
end
- end
+ }
end
def self.new(tree, pos, parent=nil, keys={})
@@ -994,13 +1055,21 @@ class Tk::BLT::Treeview::Node < TkObject
keys = _symbolkey2str(keys)
tpath = tree.path
- if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
- keys.delete('node')
- tk_call(tree.path, 'move', id, pos, parent) if parent
- return obj
- end
+ TreeNodeID_TBL.mutex.synchronize{
+ TreeNodeID_TBL[tpath] ||= {}
+ if (id = keys['node']) && (obj = TreeNodeID_TBL[tpath][id])
+ keys.delete('node')
+ tk_call(tree.path, 'move', id, pos, parent) if parent
+ return obj
+ end
- super(tree, pos, parent, keys)
+ #super(tree, pos, parent, keys)
+ (obj = self.allocate).instance_eval{
+ initialize(tree, pos, parent, keys)
+ TreeNodeID_TBL[tpath][@id] = self
+ }
+ obj
+ }
end
def initialize(tree, pos, parent, keys)
@@ -1008,11 +1077,18 @@ class Tk::BLT::Treeview::Node < TkObject
@tpath = @parent.path
if (id = keys['node'])
+ # if tk_call(@tpath, 'get', id).empty?
+ # fail RuntimeError, "not exist the node '#{id}'"
+ # end
@path = @id = id
tk_call(@tpath, 'move', @id, pos, tagid(parent)) if parent
+ configure(keys) if keys && ! keys.empty?
else
- name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
- TreeNode_ID[1].succ!
+ name = nil
+ TreeNode_ID.mutex.synchronize{
+ name = TreeNode_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeNode_ID[1].succ!
+ }
at = keys.delete['at']
@@ -1035,9 +1111,6 @@ class Tk::BLT::Treeview::Node < TkObject
end
@path = @id
end
-
- TreeNodeID_TBL[@tpath] = {} unless TreeNodeID_TBL[@tpath]
- TreeNodeID_TBL[@tpath][@id] = self
end
def id
@@ -1051,37 +1124,66 @@ class Tk::BLT::Treeview::Tag < TkObject
include Tk::BLT::Treeview::TagOrID_Methods
TreeTagID_TBL = TkCore::INTERP.create_table
- TreeTag_ID = ['blt_treeview_tag'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TreeTagID_TBL.clear }
+ (TreeTag_ID = ['blt_treeview_tag'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
- def self.id2obj(tree, id)
+ TkCore::INTERP.init_ip_env{
+ TreeTagID_TBL.mutex.synchronize{ TreeTagID_TBL.clear }
+ }
+
+ def self.id2obj(tree, name)
tpath = tree.path
- return id unless TreeTagID_TBL[tpath]
- if TreeTagID_TBL[tpath][id]
- TreeTagID_TBL[tpath][id]
- else
- begin
- self.new(tree, nil, nil, 'name'=>Integer(id))
- rescue
+ TreeTagID_TBL.mutex.synchronize{
+ if TreeTagID_TBL[tpath]
+ if TreeTagID_TBL[tpath][name]
+ TreeTagID_TBL[tpath][name]
+ else
+ #self.new(tree, name)
+ (obj = self.allocate).instance_eval{
+ @parent = @tree = tree
+ @tpath = @parent.path
+ @path = @id = name
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ end
+ else
id
end
- end
+ }
end
def self.new_by_name(tree, name, *ids)
- if (obj = TreeTagID_TBL[tree.path][name])
- return obj
- end
- new([tree, name], ids)
+ TreeTagID_TBL.mutex.synchronize{
+ unless (obj = TreeTagID_TBL[tree.path][name])
+ (obj = self.allocate).instance_eval{
+ initialize(tree, name, ids)
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ end
+ obj
+ }
end
def self.new(tree, *ids)
- if tree.kind_of?(Array)
- super(tree[0], tree[1], ids)
- else
- super(tree, nil, ids)
- end
+ TreeTagID_TBL.mutex.synchronize{
+ (obj = self.allocate).instance_eval{
+ if tree.kind_of?(Array)
+ initialize(tree[0], tree[1], ids)
+ else
+ initialize(tree, nil, ids)
+ end
+ TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
+ TreeTagID_TBL[@tpath][@id] = self
+ }
+ obj
+ }
end
def initialize(tree, name, ids)
@@ -1091,13 +1193,12 @@ class Tk::BLT::Treeview::Tag < TkObject
if name
@path = @id = name
else
- @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
- TreeTag_ID[1].succ!
+ TreeTag_ID.mutex.synchronize{
+ @path = @id = TreeTag_ID.join(TkCore::INTERP._ip_id_).freeze
+ TreeTag_ID[1].succ!
+ }
end
- TreeTagID_TBL[@tpath] = {} unless TreeTagID_TBL[@tpath]
- TreeTagID_TBL[@tpath][@id] = self
-
unless ids.empty?
tk_call(@tpath, 'tag', 'add', @id, *(ids.collect{|id| tagid(id)}))
end
diff --git a/ext/tk/lib/tkextlib/blt/vector.rb b/ext/tk/lib/tkextlib/blt/vector.rb
index 540b6b9102..76c12a24e8 100644
--- a/ext/tk/lib/tkextlib/blt/vector.rb
+++ b/ext/tk/lib/tkextlib/blt/vector.rb
@@ -23,14 +23,17 @@ module Tk::BLT
end
def self.names(pat=None)
- simplelist(tk_call('::blt::vector', 'names', pat)).collect{|name|
- if TkVar_ID_TBL[name]
- TkVar_ID_TBL[name]
- elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
- TkVar_ID_TBL[name[2..-1]]
- else
- name
- end
+ list = simplelist(tk_call('::blt::vector', 'names', pat))
+ TkVar_ID_TBL.mutex.synchronize{
+ list.collect{|name|
+ if TkVar_ID_TBL[name]
+ TkVar_ID_TBL[name]
+ elsif name[0..1] == '::' && TkVar_ID_TBL[name[2..-1]]
+ TkVar_ID_TBL[name[2..-1]]
+ else
+ name
+ end
+ }
}
end
@@ -53,7 +56,9 @@ module Tk::BLT
"#auto", *hash_kv(keys))
end
- TkVar_ID_TBL[@id] = self
+ TkVar_ID_TBL.mutex.synchronize{
+ TkVar_ID_TBL[@id] = self
+ }
@def_default = false
@default_val = nil
@@ -221,13 +226,21 @@ module Tk::BLT
class VectorAccess < Vector
def self.new(name)
- return TkVar_ID_TBL[name] if TkVar_ID_TBL[name]
- super(name, size=nil, keys={})
+ TkVar_ID_TBL.mutex.synchronize{
+ if TkVar_ID_TBL[name]
+ TkVar_ID_TBL[name]
+ else
+ (obj = self.allocate).instance_eval{
+ initialize(name)
+ TkVar_ID_TBL[@id] = self
+ }
+ obj
+ end
+ }
end
def initialize(vec_name)
@id = vec_name
- TkVar_ID_TBL[@id] = self
@def_default = false
@default_val = nil
diff --git a/ext/tk/lib/tkextlib/blt/watch.rb b/ext/tk/lib/tkextlib/blt/watch.rb
index ae5e50f126..2daf417e0b 100644
--- a/ext/tk/lib/tkextlib/blt/watch.rb
+++ b/ext/tk/lib/tkextlib/blt/watch.rb
@@ -13,11 +13,23 @@ module Tk::BLT
TkCommandNames = ['::blt::watch'.freeze].freeze
WATCH_ID_TBL = TkCore::INTERP.create_table
- BLT_WATCH_ID = ['blt_watch_id'.freeze, '00000'.taint].freeze
+
+ (BLT_WATCH_ID = ['blt_watch_id'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ WATCH_ID_TBL.mutex.synchronize{ WATCH_ID_TBL.clear }
+ }
def self.names(state = None)
- tk_split_list(tk_call('::blt::watch', 'names', state)).collect{|name|
- WATCH_ID_TBL[name] || name
+ lst = tk_split_list(tk_call('::blt::watch', 'names', state))
+ WATCH_ID_TBL.mutex.synchronize{
+ lst.collect{|name|
+ WATCH_ID_TBL[name] || name
+ }
}
end
@@ -45,13 +57,17 @@ module Tk::BLT
if name
@id = name.to_s
else
- @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
- BLT_WATCH_ID[1].succ!
+ BLT_WATCH_ID.mutex.synchronize{
+ @id = BLT_WATCH_ID.join(TkCore::INTERP._ip_id_)
+ BLT_WATCH_ID[1].succ!
+ }
end
@path = @id
- WATCH_ID_TBL[@id] = self
+ WATCH_ID_TBL.mutex.synchronize{
+ WATCH_ID_TBL[@id] = self
+ }
tk_call('::blt::watch', 'create', @id, *hash_kv(keys))
end
diff --git a/ext/tk/lib/tkextlib/bwidget/button.rb b/ext/tk/lib/tkextlib/bwidget/button.rb
index 4a9d4a7948..8f3087d098 100644
--- a/ext/tk/lib/tkextlib/bwidget/button.rb
+++ b/ext/tk/lib/tkextlib/bwidget/button.rb
@@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb'
module Tk
module BWidget
- class Button < TkButton
+ class Button < Tk::Button
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
index ef999239f9..8d6d212189 100644
--- a/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/buttonbox.rb
@@ -31,7 +31,7 @@ class Tk::BWidget::ButtonBox
name = tagOrId[:name]
return index(name) unless name.empty?
end
- if tagOrId.kind_of?(TkButton)
+ if tagOrId.kind_of?(Tk::Button)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
@@ -40,7 +40,13 @@ class Tk::BWidget::ButtonBox
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -54,7 +60,7 @@ class Tk::BWidget::ButtonBox
name = idx[:name]
idx = name unless name.empty?
end
- if idx.kind_of?(TkButton)
+ if idx.kind_of?(Tk::Button)
idx = idx[:text]
end
number(tk_send('index', idx.to_s))
@@ -62,7 +68,13 @@ class Tk::BWidget::ButtonBox
def insert(idx, keys={}, &b)
win = window(tk_send('insert', tagid(idx), *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/combobox.rb b/ext/tk/lib/tkextlib/bwidget/combobox.rb
index 31f71c3aaf..1c58a4ccb0 100644
--- a/ext/tk/lib/tkextlib/bwidget/combobox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/combobox.rb
@@ -25,7 +25,13 @@ class Tk::BWidget::ComboBox
def get_listbox(&b)
win = window(tk_send_without_enc('getlistbox'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/dialog.rb b/ext/tk/lib/tkextlib/bwidget/dialog.rb
index 2790d88d24..0ddee21d05 100644
--- a/ext/tk/lib/tkextlib/bwidget/dialog.rb
+++ b/ext/tk/lib/tkextlib/bwidget/dialog.rb
@@ -103,7 +103,7 @@ class Tk::BWidget::Dialog
name = tagOrId[:name]
return index(name) unless name.empty?
end
- if tagOrId.kind_of?(TkButton)
+ if tagOrId.kind_of?(Tk::Button)
return index(tagOrId[:text])
end
# index(tagOrId.to_s)
@@ -112,19 +112,37 @@ class Tk::BWidget::Dialog
def add(keys={}, &b)
win = window(tk_send('add', *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_buttonbox(&b)
win = window(@path + '.bbox')
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/entry.rb b/ext/tk/lib/tkextlib/bwidget/entry.rb
index aafb4aa7ff..a56890f4e3 100644
--- a/ext/tk/lib/tkextlib/bwidget/entry.rb
+++ b/ext/tk/lib/tkextlib/bwidget/entry.rb
@@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb'
module Tk
module BWidget
- class Entry < TkEntry
+ class Entry < Tk::Entry
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/label.rb b/ext/tk/lib/tkextlib/bwidget/label.rb
index ce10ecaf8b..88a504aa50 100644
--- a/ext/tk/lib/tkextlib/bwidget/label.rb
+++ b/ext/tk/lib/tkextlib/bwidget/label.rb
@@ -9,7 +9,7 @@ require 'tkextlib/bwidget.rb'
module Tk
module BWidget
- class Label < TkLabel
+ class Label < Tk::Label
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/labelentry.rb b/ext/tk/lib/tkextlib/bwidget/labelentry.rb
index 931feb9b48..95b40946a6 100644
--- a/ext/tk/lib/tkextlib/bwidget/labelentry.rb
+++ b/ext/tk/lib/tkextlib/bwidget/labelentry.rb
@@ -11,7 +11,7 @@ require 'tkextlib/bwidget/entry'
module Tk
module BWidget
- class LabelEntry < TkEntry
+ class LabelEntry < Tk::Entry
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/labelframe.rb b/ext/tk/lib/tkextlib/bwidget/labelframe.rb
index f7b267eebb..dc221806e4 100644
--- a/ext/tk/lib/tkextlib/bwidget/labelframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/labelframe.rb
@@ -40,7 +40,13 @@ class Tk::BWidget::LabelFrame
end
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/listbox.rb b/ext/tk/lib/tkextlib/bwidget/listbox.rb
index 1267500661..d8cd72fec2 100644
--- a/ext/tk/lib/tkextlib/bwidget/listbox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/listbox.rb
@@ -211,14 +211,26 @@ class Tk::BWidget::ListBox::Item
include TkTreatTagFont
ListItem_TBL = TkCore::INTERP.create_table
- ListItem_ID = ['bw:item'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ ListItem_TBL.clear }
+ (ListItem_ID = ['bw:item'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ListItem_TBL.mutex.synchronize{ ListItem_TBL.clear }
+ }
def self.id2obj(lbox, id)
lpath = lbox.path
- return id unless ListItem_TBL[lpath]
- ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
+ ListItem_TBL.mutex.synchronize{
+ if ListItem_TBL[lpath]
+ ListItem_TBL[lpath][id]? ListItem_TBL[lpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(lbox, *args)
@@ -250,13 +262,17 @@ class Tk::BWidget::ListBox::Item
if keys.key?('itemname')
@path = @id = keys.delete('itemname')
else
- @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
- ListItem_ID[1].succ!
+ ListItem_ID.mutex.synchronize{
+ @path = @id = ListItem_ID.join(TkCore::INTERP._ip_id_)
+ ListItem_ID[1].succ!
+ }
end
- ListItem_TBL[@id] = self
- ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
- ListItem_TBL[@lpath][@id] = self
+ ListItem_TBL.mutex.synchronize{
+ ListItem_TBL[@id] = self
+ ListItem_TBL[@lpath] = {} unless ListItem_TBL[@lpath]
+ ListItem_TBL[@lpath][@id] = self
+ }
@listbox.insert(index, @id, keys)
end
diff --git a/ext/tk/lib/tkextlib/bwidget/mainframe.rb b/ext/tk/lib/tkextlib/bwidget/mainframe.rb
index c54e878557..de66eaf81e 100644
--- a/ext/tk/lib/tkextlib/bwidget/mainframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/mainframe.rb
@@ -41,37 +41,73 @@ class Tk::BWidget::MainFrame
def add_indicator(keys={}, &b)
win = window(tk_send('addindicator', *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def add_toolbar(&b)
win = window(tk_send('addtoolbar'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_frame(&b)
win = window(tk_send('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_indicator(idx, &b)
win = window(tk_send('getindicator', idx))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_menu(menu_id, &b)
win = window(tk_send('getmenu', menu_id))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
def get_toolbar(idx, &b)
win = window(tk_send('gettoolbar', idx))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
index 9c946d0630..cc8a996f46 100644
--- a/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
+++ b/ext/tk/lib/tkextlib/bwidget/messagedlg.rb
@@ -173,6 +173,9 @@ class Tk::BWidget::MessageDlg
end
def create
- num_or_str(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
+ # return the index of the pressed button, or nil if it is destroyed
+ ret = num_or_str(tk_call(self.class::TkCommandNames[0],
+ @path, *hash_kv(@keys)))
+ (ret < 0)? nil: ret
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/notebook.rb b/ext/tk/lib/tkextlib/bwidget/notebook.rb
index 5146d4915d..423943619c 100644
--- a/ext/tk/lib/tkextlib/bwidget/notebook.rb
+++ b/ext/tk/lib/tkextlib/bwidget/notebook.rb
@@ -89,7 +89,13 @@ class Tk::BWidget::NoteBook
def add(page, &b)
win = window(tk_send('add', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -105,7 +111,13 @@ class Tk::BWidget::NoteBook
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -115,7 +127,13 @@ class Tk::BWidget::NoteBook
def insert(index, page, keys={}, &b)
win = window(tk_send('insert', index, tagid(page), *hash_kv(keys)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
index fc01284be6..fbc2c11255 100644
--- a/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
+++ b/ext/tk/lib/tkextlib/bwidget/pagesmanager.rb
@@ -26,7 +26,13 @@ class Tk::BWidget::PagesManager
def add(page, &b)
win = window(tk_send('add', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
@@ -42,7 +48,13 @@ class Tk::BWidget::PagesManager
def get_frame(page, &b)
win = window(tk_send('getframe', tagid(page)))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/panedwindow.rb b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
index 19982c6095..4d979fd523 100644
--- a/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
+++ b/ext/tk/lib/tkextlib/bwidget/panedwindow.rb
@@ -25,7 +25,13 @@ class Tk::BWidget::PanedWindow
def get_frame(idx, &b)
win = window(tk_send_without_enc('getframe', idx))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/panelframe.rb b/ext/tk/lib/tkextlib/bwidget/panelframe.rb
index 13f8817d74..84bae0768b 100644
--- a/ext/tk/lib/tkextlib/bwidget/panelframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/panelframe.rb
@@ -36,7 +36,13 @@ class Tk::BWidget::PanelFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/progressdlg.rb b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
index fbf00f3b00..32600255d5 100644
--- a/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
+++ b/ext/tk/lib/tkextlib/bwidget/progressdlg.rb
@@ -51,4 +51,8 @@ class Tk::BWidget::ProgressDlg
def value= (val)
@keys['variable'].value = val
end
+
+ def create
+ window(tk_call(self.class::TkCommandNames[0], @path, *hash_kv(@keys)))
+ end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
index a3986681a5..010c960ec5 100644
--- a/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/scrollableframe.rb
@@ -23,7 +23,13 @@ class Tk::BWidget::ScrollableFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
index e9e53235b7..3599fd8459 100644
--- a/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
+++ b/ext/tk/lib/tkextlib/bwidget/scrolledwindow.rb
@@ -21,7 +21,13 @@ class Tk::BWidget::ScrolledWindow
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/selectcolor.rb b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
index 742a84cd84..0f9014f8de 100644
--- a/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
+++ b/ext/tk/lib/tkextlib/bwidget/selectcolor.rb
@@ -10,6 +10,11 @@ require 'tkextlib/bwidget/messagedlg'
module Tk
module BWidget
class SelectColor < Tk::BWidget::MessageDlg
+ class Dialog < Tk::BWidget::SelectColor
+ end
+ class Menubutton < Tk::Menubutton
+ end
+ MenuButton = Menubutton
end
end
end
@@ -43,3 +48,26 @@ class Tk::BWidget::SelectColor
tk_call('SelectColor::setcolor', idx, color)
end
end
+
+class Tk::BWidget::SelectColor::Dialog
+ def create_self(keys)
+ super(keys)
+ @keys['type'] = 'dialog'
+ end
+
+ def create
+ @keys['type'] = 'dialog' # 'dialog' type returns color
+ tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(@keys))
+ end
+end
+
+class Tk::BWidget::SelectColor::Menubutton
+ def create_self(keys)
+ keys = {} unless keys
+ keys = _symbolkey2str(keys)
+ keys['type'] = 'menubutton' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectColor::TkCommandNames[0],
+ @path, *hash_kv(keys)))
+ end
+end
diff --git a/ext/tk/lib/tkextlib/bwidget/selectfont.rb b/ext/tk/lib/tkextlib/bwidget/selectfont.rb
index 478787602a..e53eb3b5bc 100644
--- a/ext/tk/lib/tkextlib/bwidget/selectfont.rb
+++ b/ext/tk/lib/tkextlib/bwidget/selectfont.rb
@@ -66,7 +66,7 @@ class Tk::BWidget::SelectFont::Dialog
end
def create
- @keys['type'] = 'dialog'
+ @keys['type'] = 'dialog' # 'dialog' type returns font name
tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(@keys))
end
end
@@ -79,7 +79,8 @@ class Tk::BWidget::SelectFont::Toolbar
def create_self(keys)
keys = {} unless keys
keys = _symbolkey2str(keys)
- keys['type'] = 'toolbar'
- tk_call(Tk::BWidget::SelectFont::TkCommandNames[0], @path, *hash_kv(keys))
+ keys['type'] = 'toolbar' # 'toolbar' type returns widget path
+ window(tk_call(Tk::BWidget::SelectFont::TkCommandNames[0],
+ @path, *hash_kv(keys)))
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/spinbox.rb b/ext/tk/lib/tkextlib/bwidget/spinbox.rb
index ca4c046e5c..48358baa5c 100644
--- a/ext/tk/lib/tkextlib/bwidget/spinbox.rb
+++ b/ext/tk/lib/tkextlib/bwidget/spinbox.rb
@@ -10,7 +10,7 @@ require 'tkextlib/bwidget/entry'
module Tk
module BWidget
- class SpinBox < TkEntry
+ class SpinBox < Tk::Entry
end
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/statusbar.rb b/ext/tk/lib/tkextlib/bwidget/statusbar.rb
index df16e4c0b7..39c678d37e 100644
--- a/ext/tk/lib/tkextlib/bwidget/statusbar.rb
+++ b/ext/tk/lib/tkextlib/bwidget/statusbar.rb
@@ -36,7 +36,13 @@ class Tk::BWidget::StatusBar
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/bwidget/titleframe.rb b/ext/tk/lib/tkextlib/bwidget/titleframe.rb
index f519490430..68534e66e9 100644
--- a/ext/tk/lib/tkextlib/bwidget/titleframe.rb
+++ b/ext/tk/lib/tkextlib/bwidget/titleframe.rb
@@ -21,7 +21,13 @@ class Tk::BWidget::TitleFrame
def get_frame(&b)
win = window(tk_send_without_enc('getframe'))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
end
diff --git a/ext/tk/lib/tkextlib/bwidget/tree.rb b/ext/tk/lib/tkextlib/bwidget/tree.rb
index e7178debe2..7a46db575e 100644
--- a/ext/tk/lib/tkextlib/bwidget/tree.rb
+++ b/ext/tk/lib/tkextlib/bwidget/tree.rb
@@ -263,14 +263,26 @@ class Tk::BWidget::Tree::Node
include TkTreatTagFont
TreeNode_TBL = TkCore::INTERP.create_table
- TreeNode_ID = ['bw:node'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ TreeNode_TBL.clear }
+ (TreeNode_ID = ['bw:node'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ TreeNode_TBL.mutex.synchronize{ TreeNode_TBL.clear }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless TreeNode_TBL[tpath]
- TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
+ TreeNode_TBL.mutex.synchronize{
+ if TreeNode_TBL[tpath]
+ TreeNode_TBL[tpath][id]? TreeNode_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(tree, *args)
@@ -311,13 +323,17 @@ class Tk::BWidget::Tree::Node
if keys.key?('nodename')
@path = @id = keys.delete('nodename')
else
- @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
- TreeNode_ID[1].succ!
+ TreeNode_ID.mutex.synchronize{
+ @path = @id = TreeNode_ID.join(TkCore::INTERP._ip_id_)
+ TreeNode_ID[1].succ!
+ }
end
- TreeNode_TBL[@id] = self
- TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
- TreeNode_TBL[@tpath][@id] = self
+ TreeNode_TBL.mutex.synchronize{
+ TreeNode_TBL[@id] = self
+ TreeNode_TBL[@tpath] = {} unless TreeNode_TBL[@tpath]
+ TreeNode_TBL[@tpath][@id] = self
+ }
@tree.insert(index, parent, @id, keys)
end
diff --git a/ext/tk/lib/tkextlib/bwidget/widget.rb b/ext/tk/lib/tkextlib/bwidget/widget.rb
index 568e503a8b..34e51308a5 100644
--- a/ext/tk/lib/tkextlib/bwidget/widget.rb
+++ b/ext/tk/lib/tkextlib/bwidget/widget.rb
@@ -43,7 +43,13 @@ module Tk::BWidget::Widget
def self.create(klass, path, rename=None, &b)
win = window(tk_call('Widget::create', klass, path, rename))
- win.instance_eval(&b) if b
+ if b
+ if TkCore::WITH_RUBY_VM ### Ruby 1.9 !!!!
+ win.instance_exec(self, &b)
+ else
+ win.instance_eval(&b)
+ end
+ end
win
end
diff --git a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
index 07abf3a7bf..2b75d62eb9 100644
--- a/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
+++ b/ext/tk/lib/tkextlib/itcl/incr_tcl.rb
@@ -40,16 +40,22 @@ module Tk
class ItclObject < TkObject
ITCL_CLASSNAME = ''.freeze
- ITCL_OBJ_ID = ['itclobj'.freeze, '00000'.taint].freeze
+ (ITCL_OBJ_ID = ['itclobj'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
ITCL_OBJ_TBL = {}.taint
def initialize(*args)
if (@klass = self.class::ITCL_CLASSNAME).empty?
fail RuntimeError, 'unknown itcl class (abstract class?)'
end
- @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID.mutex.synchronize{
+ @id = Tk::Itcl::ItclObject::TCL_OBJ_ID.join(TkCore::INTERP._ip_id_)
+ Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
+ }
@path = @id
- Tk::Itcl::ItclObject::ITCL_OBJ_ID[1].succ!
end
def self.call_proc(name, *args)
diff --git a/ext/tk/lib/tkextlib/itk/incr_tk.rb b/ext/tk/lib/tkextlib/itk/incr_tk.rb
index 0626536e36..e06deb552c 100644
--- a/ext/tk/lib/tkextlib/itk/incr_tk.rb
+++ b/ext/tk/lib/tkextlib/itk/incr_tk.rb
@@ -145,9 +145,16 @@ module Tk
private :__config_cmd
ComponentID_TBL = TkCore::INTERP.create_table
- Itk_Component_ID = ['itk:component'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ ComponentID_TBL.clear }
+ (Itk_Component_ID = ['itk:component'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ ComponentID_TBL.mutex.synchronize{ ComponentID_TBL.clear }
+ }
def self.id2obj(master, id)
if master.kind_of?(TkObject)
@@ -155,8 +162,13 @@ module Tk
else
master = master.to_s
end
- return id unless ComponentID_TBL.key?(master)
- (ComponentID_TBL.key?(id))? ComponentID_TBL[master][id]: id
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ (ComponentID_TBL[master].key?(id))? ComponentID_TBL[master][id]: id
+ else
+ id
+ end
+ }
end
def self.new(master, component=nil)
@@ -171,17 +183,21 @@ module Tk
elsif component
component = component.to_s
else
- component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
- Itk_Component_ID[1].succ!
+ Itk_Component_ID.mutex.synchronize{
+ component = Itk_Component_ID.join(TkCore::INTERP._ip_id_)
+ Itk_Component_ID[1].succ!
+ }
end
- if ComponentID_TBL.key?(master)
- if ComponentID_TBL[master].key?(component)
- return ComponentID_TBL[master][component]
+ ComponentID_TBL.mutex.synchronize{
+ if ComponentID_TBL.key?(master)
+ if ComponentID_TBL[master].key?(component)
+ return ComponentID_TBL[master][component]
+ end
+ else
+ ComponentID_TBL[master] = {}
end
- else
- ComponentID_TBL[master] = {}
- end
+ }
super(master, component)
end
@@ -190,7 +206,9 @@ module Tk
@master = master
@component = component
- ComponentID_TBL[@master][@component] = self
+ ComponentID_TBL.mutex.synchronize{
+ ComponentID_TBL[@master][@component] = self
+ }
begin
@widget = window(tk_call(@master, 'component', @component))
diff --git a/ext/tk/lib/tkextlib/iwidgets/calendar.rb b/ext/tk/lib/tkextlib/iwidgets/calendar.rb
index 0152f8593a..236ca96f00 100644
--- a/ext/tk/lib/tkextlib/iwidgets/calendar.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/calendar.rb
@@ -45,6 +45,23 @@ class Tk::Iwidgets::Calendar
class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ [?d, ?s, :date], nil ]
PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
diff --git a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
index 46ca389db2..7d2b41f806 100644
--- a/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/checkbox.rb
@@ -85,12 +85,24 @@ class Tk::Iwidgets::Checkbox
self
end
- def get(idx)
- simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
+ def get_tags
+ simplelist(tk_call_without_enc(@path, 'get'))
+ end
+
+ def get_objs
+ simplelist(tk_call_without_enc(@path, 'get')).collect{|id|
Tk::Itk::Component.id2obj(self, id)
}
end
+ def get(idx=nil)
+ if idx
+ bool(tk_call_without_enc(@path, 'get', index(idx)))
+ else
+ get_tags
+ end
+ end
+
def index(idx)
number(tk_call(@path, 'index', tagid(idx)))
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
index 6aa933ce06..1f9effb46e 100644
--- a/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/entryfield.rb
@@ -42,6 +42,23 @@ class Tk::Iwidgets::Entryfield
[ ?w, TkComm.method(:window) ],
nil
]
+
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
index 4cc6aeecbd..4e7d8f8579 100644
--- a/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/hierarchy.rb
@@ -30,6 +30,23 @@ class Tk::Iwidgets::Hierarchy
class ValidateArgs < TkUtil::CallbackSubst
KEY_TBL = [ [?n, ?s, :node], nil ]
PROC_TBL = [ [?s, TkComm.method(:string) ], nil ]
+
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -57,6 +74,22 @@ class Tk::Iwidgets::Hierarchy
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -78,6 +111,23 @@ class Tk::Iwidgets::Hierarchy
nil
]
PROC_TBL = [ [ ?s, TkComm.method(:string) ], nil ]
+
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -207,7 +257,7 @@ class Tk::Iwidgets::Hierarchy
self
end
- # based on TkText widget
+ # based on Tk::Text widget
def bbox(index)
list(tk_send_without_enc('bbox', _get_eval_enc_str(index)))
diff --git a/ext/tk/lib/tkextlib/iwidgets/notebook.rb b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
index 0f9d713ea1..268452afec 100644
--- a/ext/tk/lib/tkextlib/iwidgets/notebook.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/notebook.rb
@@ -146,7 +146,12 @@ class Tk::Iwidgets::Notebook
def view(*idxs)
if idxs.size == 0
- window(tk_send_without_enc('view'))
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
else
tk_send_without_enc('view', *idxs)
self
@@ -160,8 +165,8 @@ class Tk::Iwidgets::Notebook
end
alias xview_moveto view_moveto
alias yview_moveto view_moveto
- def view_scroll(*idxs)
- view('scroll', *idxs)
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
end
alias xview_scroll view_scroll
alias yview_scroll view_scroll
diff --git a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
index 1a2821bd6a..cfcbca1aad 100644
--- a/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/radiobox.rb
@@ -85,10 +85,13 @@ class Tk::Iwidgets::Radiobox
self
end
- def get(idx)
- simplelist(tk_call(@path, 'get', index(idx))).collect{|id|
- Tk::Itk::Component.id2obj(self, id)
- }
+ def get_tag
+ ((tag = tk_call_without_enc(@path, 'get')).empty?)? nil: tag
+ end
+ alias get get_tag
+
+ def get_obj
+ (tag = get_tag)? Tk::Itk::Component.id2obj(self, tag): nil
end
def index(idx)
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
index 407c8f2aad..b07602e340 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledcanvas.rb
@@ -171,10 +171,16 @@ class Tk::Iwidgets::Scrolledcanvas
end
def delete(*args)
- if TkcItem::CItemID_TBL[self.path]
+ tbl = nil
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl = TkcItem::CItemID_TBL[self.path]
+ }
+ if tbl
find('withtag', *args).each{|item|
if item.kind_of?(TkcItem)
- TkcItem::CItemID_TBL[self.path].delete(item.id)
+ TkcItem::CItemID_TBL.mutex.synchronize{
+ tbl.delete(item.id)
+ }
end
}
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
index fdafc8dc7f..2887b60815 100644
--- a/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/scrolledtext.rb
@@ -322,6 +322,11 @@ class Tk::Iwidgets::Scrolledtext
def _ktext_length(txt)
+ if TkCore::WITH_ENCODING ### Ruby 1.9 !!!!!!!!!!!!!
+ return txt.length
+ end
+ ###########################
+
if $KCODE !~ /n/i
return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
index bb81fcca5e..bf9b5ec30a 100644
--- a/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/selectionbox.rb
@@ -59,7 +59,7 @@ class Tk::Iwidgets::Selectionbox
self
end
- # based on TkListbox ( and TkTextWin )
+ # based on Tk::Listbox ( and TkTextWin )
def curselection
list(tk_send_without_enc('curselection'))
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
index ab790e97a6..f772ecf8c2 100644
--- a/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/selectiondialog.rb
@@ -49,7 +49,7 @@ class Tk::Iwidgets::Selectiondialog
self
end
- # based on TkListbox ( and TkTextWin )
+ # based on Tk::Listbox ( and TkTextWin )
def curselection
list(tk_send_without_enc('curselection'))
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/spinner.rb b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
index 174b9bd506..126cfe7c95 100644
--- a/ext/tk/lib/tkextlib/iwidgets/spinner.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/spinner.rb
@@ -37,6 +37,23 @@ class Tk::Iwidgets::Spinner
[ ?w, TkComm.method(:window) ],
nil
]
+
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
end
diff --git a/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
index 0d9715f87b..382604102e 100644
--- a/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/tabnotebook.rb
@@ -116,6 +116,11 @@ class Tk::Iwidgets::Tabnotebook
self
end
+ def show_tab(idx)
+ @tabset.show_tab(idx)
+ self
+ end
+
def scrollcommand(cmd=Proc.new)
configure_cmd 'scrollcommand', cmd
self
@@ -147,7 +152,12 @@ class Tk::Iwidgets::Tabnotebook
def view(*index)
if index.size == 0
- window(tk_send_without_enc('view'))
+ idx = num_or_str(tk_send_without_enc('view'))
+ if idx.kind_of?(Fixnum) && idx < 0
+ nil
+ else
+ idx
+ end
else
tk_send_without_enc('view', *index)
self
@@ -161,8 +171,8 @@ class Tk::Iwidgets::Tabnotebook
end
alias xview_moveto view_moveto
alias yview_moveto view_moveto
- def view_scroll(*index)
- view('scroll', *index)
+ def view_scroll(index, what='pages')
+ view('scroll', index, what)
end
alias xview_scroll view_scroll
alias yview_scroll view_scroll
diff --git a/ext/tk/lib/tkextlib/iwidgets/tabset.rb b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
index 54e56d0514..618260e8e3 100644
--- a/ext/tk/lib/tkextlib/iwidgets/tabset.rb
+++ b/ext/tk/lib/tkextlib/iwidgets/tabset.rb
@@ -96,4 +96,48 @@ class Tk::Iwidgets::Tabset
tk_call(@path, 'select', index(idx))
self
end
+
+ def show_tab(idx)
+ if index(idx) == 0
+ self.start = 0
+ return
+ end
+
+ reutrn unless @canvas ||= self.winfo_children[0]
+
+ delta = 1 if (delta = cget(:gap)) == 'overlap' ||
+ (delta = self.winfo_pixels(delta) + 1) <= 0
+
+ case cget(:tabpos)
+ when 's', 'n'
+ if (head = tabcget(idx, :left)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_width
+ tab_start, tab_end = @canvas .
+ find_overlapping(head, 0, head + delta, @canvas.winfo_height) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[0], bbox[2]]} . max
+
+ when 'e', 'w'
+ if (head = tabcget(idx, :top)) < 0
+ self.start -= head
+ return
+ end
+ tabs_size = @canvas.winfo_height
+ tab_start, tab_end = @canvas .
+ find_overlapping(0, head, @canvas.winfo_width, head + delta) .
+ find_all{|id| @canvas.itemtype(id) == TkcPolygon} .
+ map!{|id| bbox = @canvas.bbox(id); [bbox[1], bbox[3]]} . max
+ end
+
+ if (size = tab_end - tab_start + 1) > tabs_size
+ self.start -= tab_start
+ elsif head + size > tabs_size
+ self.start -= head + size - tabs_size
+ end
+
+ self
+ end
end
diff --git a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
index 6940a9174c..7db3c2e2b7 100644
--- a/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
+++ b/ext/tk/lib/tkextlib/tcllib/autoscroll.rb
@@ -108,7 +108,7 @@ module Tk
end
end
-class TkScrollbar
+class Tk::Scrollbar
def autoscroll
# Arranges for the already existing scrollbar to be mapped
# and unmapped as needed.
diff --git a/ext/tk/lib/tkextlib/tcllib/ctext.rb b/ext/tk/lib/tkextlib/tcllib/ctext.rb
index 70a45dd8e7..9014037f3d 100644
--- a/ext/tk/lib/tkextlib/tcllib/ctext.rb
+++ b/ext/tk/lib/tkextlib/tcllib/ctext.rb
@@ -15,7 +15,7 @@ TkPackage.require('ctext')
module Tk
module Tcllib
- class CText < TkText
+ class CText < Tk::Text
PACKAGE_NAME = 'ctext'.freeze
def self.package_name
PACKAGE_NAME
diff --git a/ext/tk/lib/tkextlib/tcllib/datefield.rb b/ext/tk/lib/tkextlib/tcllib/datefield.rb
index bd84488101..2244dd7a9a 100644
--- a/ext/tk/lib/tkextlib/tcllib/datefield.rb
+++ b/ext/tk/lib/tkextlib/tcllib/datefield.rb
@@ -24,7 +24,7 @@ TkPackage.require('datefield')
module Tk
module Tcllib
- class Datefield < TkEntry
+ class Datefield < Tk::Entry
PACKAGE_NAME = 'datefield'.freeze
def self.package_name
PACKAGE_NAME
diff --git a/ext/tk/lib/tkextlib/tcllib/ico.rb b/ext/tk/lib/tkextlib/tcllib/ico.rb
index 3beeb11a4d..8c92926a4c 100644
--- a/ext/tk/lib/tkextlib/tcllib/ico.rb
+++ b/ext/tk/lib/tkextlib/tcllib/ico.rb
@@ -94,8 +94,10 @@ class Tk::Tcllib::ICO
if keys.key?('name')
@path = keys['name'].to_s
else
- @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
- Tk_Image_ID[1].succ!
+ Tk_Image_ID.mutex.synchronize{
+ @path = Tk_Image_ID.join(TkCore::INTERP._ip_id_)
+ Tk_Image_ID[1].succ!
+ }
end
tk_call_without_enc('::ico::getIcon', file, index, '-name', @path,
'-format', 'image', *hash_kv(keys, true))
diff --git a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
index 8c9e0bd683..c4b8240c04 100644
--- a/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
+++ b/ext/tk/lib/tkextlib/tcllib/ip_entry.rb
@@ -18,7 +18,7 @@ TkPackage.require('ipentry')
module Tk
module Tcllib
- class IP_Entry < TkEntry
+ class IP_Entry < Tk::Entry
PACKAGE_NAME = 'ipentry'.freeze
def self.package_name
PACKAGE_NAME
diff --git a/ext/tk/lib/tkextlib/tcllib/plotchart.rb b/ext/tk/lib/tkextlib/tcllib/plotchart.rb
index f5f344ceb3..06ab20f3e6 100644
--- a/ext/tk/lib/tkextlib/tcllib/plotchart.rb
+++ b/ext/tk/lib/tkextlib/tcllib/plotchart.rb
@@ -225,7 +225,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class XYPlot < TkCanvas
+ class XYPlot < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -247,7 +247,7 @@ module Tk::Tcllib::Plotchart
@xaxis = args.shift
@yaxis = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -265,7 +265,9 @@ module Tk::Tcllib::Plotchart
private :_create_chart
def __destroy_hook__
- Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
end
def plot(series, x, y)
@@ -337,7 +339,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class PolarPlot < TkCanvas
+ class PolarPlot < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -356,7 +358,7 @@ module Tk::Tcllib::Plotchart
@radius_data = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -374,7 +376,9 @@ module Tk::Tcllib::Plotchart
private :_create_chart
def __destroy_hook__
- Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
end
def plot(series, radius, angle)
@@ -395,7 +399,7 @@ module Tk::Tcllib::Plotchart
Polarplot = PolarPlot
############################
- class IsometricPlot < TkCanvas
+ class IsometricPlot < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -430,7 +434,7 @@ module Tk::Tcllib::Plotchart
@stepsize = args.shift
end
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -475,7 +479,7 @@ module Tk::Tcllib::Plotchart
Isometricplot = IsometricPlot
############################
- class Plot3D < TkCanvas
+ class Plot3D < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -500,7 +504,7 @@ module Tk::Tcllib::Plotchart
@yaxis = args.shift
@zaxis = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -557,7 +561,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Piechart < TkCanvas
+ class Piechart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -566,7 +570,7 @@ module Tk::Tcllib::Plotchart
].freeze
def initialize(*args) # args := ([parent] [, keys])
- if args[0].kind_of?(TkCanvas)
+ if args[0].kind_of?(Tk::Canvas)
parent = args.shift
@path = parent.path
else
@@ -588,7 +592,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Barchart < TkCanvas
+ class Barchart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -626,7 +630,7 @@ module Tk::Tcllib::Plotchart
@series_size = args.shift
end
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -645,7 +649,9 @@ module Tk::Tcllib::Plotchart
private :_create_chart
def __destroy_hook__
- Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.mutex.synchronize{
+ Tk::Tcllib::Plotchart::PlotSeries::SeriesID_TBL.delete(@path)
+ }
end
def plot(series, dat, col=None)
@@ -672,7 +678,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Timechart < TkCanvas
+ class Timechart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -699,7 +705,7 @@ module Tk::Tcllib::Plotchart
@time_end = args.shift
@items = args.shift
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -733,7 +739,7 @@ module Tk::Tcllib::Plotchart
end
############################
- class Gnattchart < TkCanvas
+ class Gnattchart < Tk::Canvas
include ChartMethod
TkCommandNames = [
@@ -772,7 +778,7 @@ module Tk::Tcllib::Plotchart
@text_width = None
end
- if parent.kind_of?(TkCanvas)
+ if parent.kind_of?(Tk::Canvas)
@path = parent.path
else
super(parent, *args) # create canvas widget
@@ -834,23 +840,38 @@ module Tk::Tcllib::Plotchart
############################
class PlotSeries < TkObject
SeriesID_TBL = TkCore::INTERP.create_table
- Series_ID = ['series'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ SeriesID_TBL.clear }
+
+ (Series_ID = ['series'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+ TkCore::INTERP.init_ip_env{
+ SeriesID_TBL.mutex.synchronize{ SeriesID_TBL.clear }
+ }
def self.id2obj(chart, id)
path = chart.path
- return id unless SeriesID_TBL[path]
- SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ SeriesID_TBL.mutex.synchronize{
+ if SeriesID_TBL[path]
+ SeriesID_TBL[path][id]? SeriesID_TBL[path][id]: id
+ else
+ id
+ end
+ }
end
def initialize(chart, keys=nil)
@parent = @chart_obj = chart
@ppath = @chart_obj.path
- @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
- # SeriesID_TBL[@id] = self
- SeriesID_TBL[@ppath] = {} unless SeriesID_TBL[@ppath]
- SeriesID_TBL[@ppath][@id] = self
- Series_ID[1].succ!
+ Series_ID.mutex.synchronize{
+ @path = @series = @id = Series_ID.join(TkCore::INTERP._ip_id_)
+ Series_ID[1].succ!
+ }
+ SeriesID_TBL.mutex.synchronize{
+ SeriesID_TBL[@ppath] ||= {}
+ SeriesID_TBL[@ppath][@id] = self
+ }
dataconfig(keys) if keys.kind_of?(Hash)
end
diff --git a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
index 92dde65ce7..b366e0198b 100644
--- a/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
+++ b/ext/tk/lib/tkextlib/tcllib/tkpiechart.rb
@@ -125,7 +125,9 @@ module Tk::Tcllib::Tkpiechart
def delete
tk_call_without_enc('::stooop::delete', @tag_key)
- CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
self
end
@@ -184,8 +186,10 @@ module Tk::Tcllib::Tkpiechart
@id = "slices(#{@tag_key})"
@tag = TkcNamedTag.new(@pie.canvas, @id)
- CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
- CItemID_TBL[@path][@id] = self
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path] = {} unless CItemID_TBL[@path]
+ CItemID_TBL[@path][@id] = self
+ }
end
def tag_key
@@ -200,7 +204,9 @@ module Tk::Tcllib::Tkpiechart
def delete
tk_call_without_enc('pie::deleteSlice', @pie.tag_key, @tag_key)
- CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ CItemID_TBL.mutex.synchronize{
+ CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path]
+ }
@pie._delete_slice(self)
self
end
diff --git a/ext/tk/lib/tkextlib/tile.rb b/ext/tk/lib/tkextlib/tile.rb
index acc7bebe4e..02473d57a1 100644
--- a/ext/tk/lib/tkextlib/tile.rb
+++ b/ext/tk/lib/tkextlib/tile.rb
@@ -4,6 +4,7 @@
#
require 'tk'
+require 'tk/ttk_selector'
# call setup script for general 'tkextlib' libraries
require 'tkextlib/setup.rb'
@@ -15,33 +16,66 @@ require 'tkextlib/tile/setup.rb'
# TkPackage.require('tile', '0.4')
# TkPackage.require('tile', '0.6')
# TkPackage.require('tile', '0.7')
-verstr = TkPackage.require('tile')
+if Tk::TK_MAJOR_VERSION > 8 ||
+ (Tk::TK_MAJOR_VERSION == 8 && Tk::TK_MINOR_VERSION >= 5)
+ TkPackage.require('tile') # for compatibility (version check of 'tile')
+ verstr = TkPackage.require('Ttk')
+else
+ verstr = TkPackage.require('tile')
+end
+
ver = verstr.split('.')
-if ver[0].to_i == 0 && ver[1].to_i <= 4
- # version 0.4 or former
- module Tk
- module Tile
- USE_TILE_NAMESPACE = true
- USE_TTK_NAMESPACE = false
- TILE_SPEC_VERSION_ID = 0
+if ver[0].to_i == 0
+ # Tile extension package
+ if ver[1].to_i <= 4
+ # version 0.4 or former
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = true
+ USE_TTK_NAMESPACE = false
+ TILE_SPEC_VERSION_ID = 0
+ end
end
- end
-elsif ver[0].to_i == 0 && ver[1].to_i <= 6
- # version 0.5 -- version 0.6
- module Tk
- module Tile
- USE_TILE_NAMESPACE = true
- USE_TTK_NAMESPACE = true
- TILE_SPEC_VERSION_ID = 5
+ elsif ver[1].to_i <= 6
+ # version 0.5 -- version 0.6
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = true
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 5
+ end
+ end
+ elsif ver[1].to_i <= 7
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 7
+ end
+ end
+ else
+ # version 0.8 or later
+ module Tk
+ module Tile
+ USE_TILE_NAMESPACE = false
+ USE_TTK_NAMESPACE = true
+ TILE_SPEC_VERSION_ID = 8
+ end
end
end
+
+ module Tk::Tile
+ PACKAGE_NAME = 'tile'.freeze
+ end
else
- # version 0.7 or later
+ # Ttk package merged Tcl/Tk core (Tcl/Tk 8.5+)
module Tk
module Tile
USE_TILE_NAMESPACE = false
USE_TTK_NAMESPACE = true
- TILE_SPEC_VERSION_ID = 7
+ TILE_SPEC_VERSION_ID = 8
+
+ PACKAGE_NAME = 'Ttk'.freeze
end
end
end
@@ -51,30 +85,110 @@ module Tk
module Tile
TkComm::TkExtlibAutoloadModule.unshift(self)
- PACKAGE_NAME = 'tile'.freeze
def self.package_name
PACKAGE_NAME
end
def self.package_version
begin
- TkPackage.require('tile')
+ TkPackage.require(PACKAGE_NAME)
rescue
''
end
end
def self.__Import_Tile_Widgets__!
+ warn 'Warning: "Tk::Tile::__Import_Tile_Widgets__!" is obsolete.' <<
+ ' To control default widget set, use "Tk.default_widget_set = :Ttk"'
Tk.tk_call('namespace', 'import', '-force', 'ttk::*')
end
- def self.load_images(imgdir, pat=TkComm::None)
- images = Hash[*TkComm.simplelist(Tk.tk_call('::tile::LoadImages',
- imgdir, pat))]
- images.keys.each{|k|
- images[k] = TkPhotoImage.new(:imagename=>images[k],
- :without_creating=>true)
+ def self.__define_LoadImages_proc_for_compatibility__!
+ # Ttk 8.5 (Tile 0.8) lost 'LoadImages' utility procedure.
+ # So, some old scripts doen't work, because those scripts use the
+ # procedure to define local styles.
+ # Of course, rewriting such Tcl/Tk scripts isn't difficult for
+ # Tcl/Tk users. However, it may be troublesome for Ruby/Tk users
+ # who use such Tcl/Tk scripts as it is.
+ # This method may help Ruby/Tk users who don't want to modify old
+ # Tcl/Tk scripts for the latest version of Ttk (Tile) extension.
+ # This method defines a comaptible 'LoadImages' procedure on the
+ # Tcl/Tk interpreter working under Ruby/Tk.
+ # Please give attention to use this method. It may conflict with
+ # some definitions on Tcl/Tk scripts.
+ klass_name = self.name
+ proc_name = 'LoadImages'
+ if Tk::Tile::USE_TTK_NAMESPACE
+ ns_list = ['::tile']
+ if Tk.info(:commands, "::ttk::#{proc_name}").empty?
+ ns_list << '::ttk'
+ end
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ ns_list = ['::ttk']
+ if Tk.info(:commands, "::tile::#{proc_name}").empty?
+ ns_list << '::tile'
+ end
+ end
+
+ ns_list.each{|ns|
+ cmd = "#{ns}::#{proc_name}"
+ unless Tk.info(:commands, cmd).empty?
+ fail RuntimeError, "can't define '#{cmd}' command (already exist)"
+ end
+ TkNamespace.eval(ns){
+ TkCore::INTERP.add_tk_procs(proc_name, 'imgdir {patterns {*.gif}}',
+ <<-'EOS')
+ foreach pattern $patterns {
+ foreach file [glob -directory $imgdir $pattern] {
+ set img [file tail [file rootname $file]]
+ if {![info exists images($img)]} {
+ set images($img) [image create photo -file $file]
+ }
+ }
+ }
+ return [array get images]
+ EOS
+ }
}
+ end
+
+ def self.load_images(imgdir, pat=nil)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ if Tk::Tile::USE_TTK_NAMESPACE
+ cmd = '::ttk::LoadImages'
+ else # Tk::Tile::USE_TILE_NAMESPACE
+ cmd = '::tile::LoadImages'
+ end
+ pat ||= TkComm::None
+ images = Hash[*TkComm.simplelist(Tk.tk_call(cmd, imgdir, pat))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ else ## TILE_SPEC_VERSION_ID >= 8
+ pat ||= '*.gif'
+ if pat.kind_of?(Array)
+ pat_list = pat
+ else
+ pat_list = [ pat ]
+ end
+ Dir.chdir(imgdir){
+ pat_list.each{|pat|
+ Dir.glob(pat).each{|f|
+ img = File.basename(f, '.*')
+ unless TkComm.bool(Tk.info('exists', "images(#{img})"))
+ Tk.tk_call('set', "images(#{img})",
+ Tk.tk_call('image', 'create', 'photo', '-file', f))
+ end
+ }
+ }
+ }
+ images = Hash[*TkComm.simplelist(Tk.tk_call('array', 'get', 'images'))]
+ images.keys.each{|k|
+ images[k] = TkPhotoImage.new(:imagename=>images[k],
+ :without_creating=>true)
+ }
+ end
images
end
@@ -84,11 +198,20 @@ module Tk
end
module KeyNav
- def self.enableMnemonics(w)
- Tk.tk_call('::keynav::enableMnemonics', w)
- end
- def self.defaultButton(w)
- Tk.tk_call('::keynav::defaultButton', w)
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ def self.enableMnemonics(w)
+ Tk.tk_call('::keynav::enableMnemonics', w)
+ end
+ def self.defaultButton(w)
+ Tk.tk_call('::keynav::defaultButton', w)
+ end
+ else # dummy
+ def self.enableMnemonics(w)
+ ""
+ end
+ def self.defaultButton(w)
+ ""
+ end
end
end
@@ -103,6 +226,12 @@ module Tk
Menu = 'TkMenuFont'
SmallCaption = 'TkSmallCaptionFont'
Icon = 'TkIconFont'
+
+ TkFont::SYSTEM_FONT_NAMES.add [
+ 'TkDefaultFont', 'TkTextFont', 'TkHeadingFont',
+ 'TkCaptionFont', 'TkTooltipFont', 'TkFixedFont',
+ 'TkMenuFont', 'TkSmallCaptionFont', 'TkIconFont'
+ ]
end
module ParseStyleLayout
@@ -141,7 +270,7 @@ module Tk
end
private :__val2ruby_optkeys
- def instate(state, script=nil, &b)
+ def ttk_instate(state, script=nil, &b)
if script
tk_send('instate', state, script)
elsif b
@@ -150,19 +279,30 @@ module Tk
bool(tk_send('instate', state))
end
end
+ alias tile_instate ttk_instate
- def state(state=nil)
+ def ttk_state(state=nil)
if state
tk_send('state', state)
else
list(tk_send('state'))
end
end
+ alias tile_state ttk_state
- def identify(x, y)
+ def ttk_identify(x, y)
ret = tk_send_without_enc('identify', x, y)
(ret.empty?)? nil: ret
end
+ alias tile_identify ttk_identify
+
+ # remove instate/state/identify method
+ # to avoid the conflict with widget options
+ if Tk.const_defined?(:USE_OBSOLETE_TILE_STATE_METHOD) && Tk::USE_OBSOLETE_TILE_STATE_METHOD
+ alias instate ttk_instate
+ alias state ttk_state
+ alias identify ttk_identify
+ end
end
######################################
@@ -200,6 +340,8 @@ module Tk
autoload :TPaned, 'tkextlib/tile/tpaned'
autoload :Paned, 'tkextlib/tile/tpaned'
+ autoload :PanedWindow, 'tkextlib/tile/tpaned'
+ autoload :Panedwindow, 'tkextlib/tile/tpaned'
autoload :TProgressbar, 'tkextlib/tile/tprogressbar'
autoload :Progressbar, 'tkextlib/tile/tprogressbar'
@@ -216,6 +358,8 @@ module Tk
autoload :TScrollbar, 'tkextlib/tile/tscrollbar'
autoload :Scrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :XScrollbar, 'tkextlib/tile/tscrollbar'
+ autoload :YScrollbar, 'tkextlib/tile/tscrollbar'
autoload :TSeparator, 'tkextlib/tile/tseparator'
autoload :Separator, 'tkextlib/tile/tseparator'
@@ -223,8 +367,13 @@ module Tk
autoload :TSquare, 'tkextlib/tile/tsquare'
autoload :Square, 'tkextlib/tile/tsquare'
+ autoload :SizeGrip, 'tkextlib/tile/sizegrip'
+ autoload :Sizegrip, 'tkextlib/tile/sizegrip'
+
autoload :Treeview, 'tkextlib/tile/treeview'
autoload :Style, 'tkextlib/tile/style'
end
end
+
+Ttk = Tk::Tile
diff --git a/ext/tk/lib/tkextlib/tile/sizegrip.rb b/ext/tk/lib/tkextlib/tile/sizegrip.rb
index ea796583b0..c5068919a4 100644
--- a/ext/tk/lib/tkextlib/tile/sizegrip.rb
+++ b/ext/tk/lib/tkextlib/tile/sizegrip.rb
@@ -9,9 +9,13 @@ module Tk
module Tile
class SizeGrip < TkWindow
end
+ Sizegrip = SizeGrip
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Sizegrip, :TkSizegrip, :TkSizeGrip)
+
+
class Tk::Tile::SizeGrip < TkWindow
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/style.rb b/ext/tk/lib/tkextlib/tile/style.rb
index 59bc4b0d78..bf8acb34b0 100644
--- a/ext/tk/lib/tkextlib/tile/style.rb
+++ b/ext/tk/lib/tkextlib/tile/style.rb
@@ -17,6 +17,97 @@ module Tk::Tile::Style
end
class << Tk::Tile::Style
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ TkCommandNames = ['style'.freeze].freeze
+
+ # --- Tk::Tile::Style.__define_wrapper_proc_for_compatibility__! ---
+ # On Ttk (Tile) extension, 'style' command has imcompatible changes
+ # depend on the version of the extention. It requires modifying the
+ # Tcl/Tk scripts to define local styles. The rule for modification
+ # is a simple one. But, if users want to keep compatibility between
+ # versions of the extension, they will have to contrive to do that.
+ # It may be troublesome, especially for Ruby/Tk users.
+ # This method may help such work. This method make some definitions
+ # on the Tcl/Tk interpreter to work with different version of style
+ # command format. Please give attention to use this method. It may
+ # conflict with some definitions on Tcl/Tk scripts.
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 7
+ def __define_wrapper_proc_for_compatibility__!
+ unless Tk.info(:commands, '::ttk::style').empty?
+ fail RuntimeError,
+ "can't define ':ttk::style' command (already exist)"
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]
+ }
+ }
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ else ### TILE_SPEC_VERSION_ID == 7
+ def __define_wrapper_proc_for_compatibility__!
+ unless Tk.info(:commands, '::ttk::style').empty?
+ fail RuntimeError,
+ "can't define ':ttk::style' command (already exist)"
+ end
+ TkCore::INTERP.add_tk_procs('::ttk::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set spec [lindex $args 4]
+ set map [lrange $spec 1 end]
+ if [llength $map] {
+ # return [eval [concat [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ return [uplevel 1 [list ::style element create [lindex $args 2] image [lindex $spec 0] -map $map] [lrange $args 5 end]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::style $args"]
+ return [uplevel 1 ::style $args]
+ EOS
+ #########################
+ end
+ end
+ else ### TILE_SPEC_VERSION_ID >= 8
+ TkCommandNames = ['::ttk::style'.freeze].freeze
+
+ def __define_wrapper_proc_for_compatibility__!
+ unless Tk.info(:commands, '::style').empty?
+ fail RuntimeError, "can't define '::style' command (already exist)"
+ end
+ TkCore::INTERP.add_tk_procs('::style', 'args', <<-'EOS')
+ if [string equal [lrange $args 0 1] {element create}] {
+ if [string equal [lindex $args 3] image] {
+ set name [lindex $args 4]
+ set opts [lrange $args 5 end]
+ set idx [lsearch $opts -map]
+ if {$idx >= 0 && [expr $idx % 2 == 0]} {
+ # return [eval [concat [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]]
+ return [uplevel 1 [list ::ttk::style element create [lindex $args 2] image [concat $name [lindex $opts [expr $idx + 1]]]] [lreplace $opts $idx [expr $idx + 1]]]
+ }
+ }
+ } elseif [string equal [lindex $args 0] default] {
+ # return [eval "::ttk::style [lreplace $args 0 0 configure]"]
+ return [uplevel 1 ::ttk::style [lreplace $args 0 0 configure]]
+ }
+ # return [eval "::ttk::style $args"]
+ return [uplevel 1 ::ttk::style $args]
+ EOS
+ #########################
+ end
+ end
+
def configure(style=nil, keys=nil)
if style.kind_of?(Hash)
keys = style
@@ -31,9 +122,9 @@ class << Tk::Tile::Style
end
if keys && keys != None
- tk_call('style', sub_cmd, style, *hash_kv(keys))
+ tk_call(TkCommandNames[0], sub_cmd, style, *hash_kv(keys))
else
- tk_call('style', sub_cmd, style)
+ tk_call(TkCommandNames[0], sub_cmd, style)
end
end
alias default configure
@@ -46,14 +137,33 @@ class << Tk::Tile::Style
style = '.' unless style
if keys && keys != None
- tk_call('style', 'map', style, *hash_kv(keys))
+ if keys.kind_of?(Hash)
+ tk_call(TkCommandNames[0], 'map', style, *hash_kv(keys))
+ else
+ simplelist(tk_call(TkCommandNames[0], 'map', style, '-' << keys.to_s))
+ end
else
- tk_call('style', 'map', style)
+ ret = {}
+ Hash[*(simplelist(tk_call(TkCommandNames[0], 'map', style)))].each{|k, v|
+ ret[k[1..-1]] = list(v)
+ }
+ ret
end
end
+ alias map_configure map
+
+ def map_configinfo(style=nil, key=None)
+ style = '.' unless style
+ map(style, key)
+ end
+
+ def map_default_configinfo(key=None)
+ map('.', key)
+ end
def lookup(style, opt, state=None, fallback_value=None)
- tk_call('style', 'lookup', style, '-' << opt.to_s, state, fallback_value)
+ tk_call(TkCommandNames[0], 'lookup', style,
+ '-' << opt.to_s, state, fallback_value)
end
include Tk::Tile::ParseStyleLayout
@@ -66,42 +176,93 @@ class << Tk::Tile::Style
style = '.' unless style
if spec
- tk_call('style', 'layout', style, spec)
+ tk_call(TkCommandNames[0], 'layout', style, spec)
else
- _style_layout(list(tk_call('style', 'layout', style)))
+ _style_layout(list(tk_call(TkCommandNames[0], 'layout', style)))
end
end
def element_create(name, type, *args)
- tk_call('style', 'element', 'create', name, type, *args)
+ if type == 'image' || type == :image
+ element_create_image(name, *args)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, type, *args)
+ end
+ end
+
+ def element_create_image(name, *args)
+ fail ArgumentError, 'Must supply a base image' unless (spec = args.shift)
+ if (opts = args.shift)
+ if opts.kind_of?(Hash)
+ opts = _symbolkey2str(opts)
+ else
+ fail ArgumentError, 'bad option'
+ end
+ end
+ fail ArgumentError, 'too many arguments' unless args.empty?
+
+ if spec.kind_of?(Array)
+ # probably, command format is tile 0.8+ (Tcl/Tk8.5+) style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ else
+ fail ArgumentError, 'illegal arguments' if opts.key?('map')
+ base = spec.shift
+ opts['map'] = spec
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', base, opts)
+ end
+ else
+ # probably, command format is tile 0.7.8 or older style
+ if Tk::Tile::TILE_SPEC_VERSION_ID >= 8
+ spec = [spec, *(opts.delete('map'))] if opts.key?('map')
+ end
+ if opts
+ tk_call(TkCommandNames[0],
+ 'element', 'create', name, 'image', spec, opts)
+ else
+ tk_call(TkCommandNames[0], 'element', 'create', name, 'image', spec)
+ end
+ end
end
def element_names()
- list(tk_call('style', 'element', 'names'))
+ list(tk_call(TkCommandNames[0], 'element', 'names'))
end
def element_options(elem)
- simplelist(tk_call('style', 'element', 'options', elem))
+ simplelist(tk_call(TkCommandNames[0], 'element', 'options', elem))
end
def theme_create(name, keys=nil)
+ name = name.to_s
if keys && keys != None
- tk_call('style', 'theme', 'create', name, *hash_kv(keys))
+ tk_call(TkCommandNames[0], 'theme', 'create', name, *hash_kv(keys))
else
- tk_call('style', 'theme', 'create', name)
+ tk_call(TkCommandNames[0], 'theme', 'create', name)
end
+ name
end
def theme_settings(name, cmd=nil, &b)
+ name = name.to_s
cmd = Proc.new(&b) if !cmd && b
- tk_call('style', 'theme', 'settings', name, cmd)
+ tk_call(TkCommandNames[0], 'theme', 'settings', name, cmd)
+ name
end
def theme_names()
- list(tk_call('style', 'theme', 'names'))
+ list(tk_call(TkCommandNames[0], 'theme', 'names'))
end
def theme_use(name)
- tk_call('style', 'theme', 'use', name)
+ name = name.to_s
+ tk_call(TkCommandNames[0], 'theme', 'use', name)
+ name
end
end
diff --git a/ext/tk/lib/tkextlib/tile/tbutton.rb b/ext/tk/lib/tkextlib/tile/tbutton.rb
index 1142a27100..5d7db10fe9 100644
--- a/ext/tk/lib/tkextlib/tile/tbutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tbutton.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TButton < TkButton
+ class TButton < Tk::Button
end
Button = TButton
end
end
-class Tk::Tile::TButton < TkButton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Button, :TkButton)
+
+
+class Tk::Tile::TButton < Tk::Button
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
index fce799683d..172225fcec 100644
--- a/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tcheckbutton.rb
@@ -7,7 +7,7 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TCheckButton < TkCheckButton
+ class TCheckButton < Tk::CheckButton
end
TCheckbutton = TCheckButton
CheckButton = TCheckButton
@@ -15,7 +15,11 @@ module Tk
end
end
-class Tk::Tile::TCheckButton < TkCheckButton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Checkbutton,
+ :TkCheckbutton, :TkCheckButton)
+
+
+class Tk::Tile::TCheckButton < Tk::CheckButton
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tcombobox.rb b/ext/tk/lib/tkextlib/tile/tcombobox.rb
index e8e042fbd9..b64372f1c9 100644
--- a/ext/tk/lib/tkextlib/tile/tcombobox.rb
+++ b/ext/tk/lib/tkextlib/tile/tcombobox.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Combobox, :TkCombobox)
+
+
class Tk::Tile::TCombobox < Tk::Tile::TEntry
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/tentry.rb b/ext/tk/lib/tkextlib/tile/tentry.rb
index 4d57ce7756..4b221fcb88 100644
--- a/ext/tk/lib/tkextlib/tile/tentry.rb
+++ b/ext/tk/lib/tkextlib/tile/tentry.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TEntry < TkEntry
+ class TEntry < Tk::Entry
end
Entry = TEntry
end
end
-class Tk::Tile::TEntry < TkEntry
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Entry, :TkEntry)
+
+
+class Tk::Tile::TEntry < Tk::Entry
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tframe.rb b/ext/tk/lib/tkextlib/tile/tframe.rb
index 691c9c42af..3b5f98bb6e 100644
--- a/ext/tk/lib/tkextlib/tile/tframe.rb
+++ b/ext/tk/lib/tkextlib/tile/tframe.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TFrame < TkFrame
+ class TFrame < Tk::Frame
end
Frame = TFrame
end
end
-class Tk::Tile::TFrame < TkFrame
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Frame, :TkFrame)
+
+
+class Tk::Tile::TFrame < Tk::Frame
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tlabel.rb b/ext/tk/lib/tkextlib/tile/tlabel.rb
index 4111d1906a..7d074d3842 100644
--- a/ext/tk/lib/tkextlib/tile/tlabel.rb
+++ b/ext/tk/lib/tkextlib/tile/tlabel.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TLabel < TkLabel
+ class TLabel < Tk::Label
end
Label = TLabel
end
end
-class Tk::Tile::TLabel < TkLabel
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Label, :TkLabel)
+
+
+class Tk::Tile::TLabel < Tk::Label
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tlabelframe.rb b/ext/tk/lib/tkextlib/tile/tlabelframe.rb
index 8981232b25..cff66d8658 100644
--- a/ext/tk/lib/tkextlib/tile/tlabelframe.rb
+++ b/ext/tk/lib/tkextlib/tile/tlabelframe.rb
@@ -9,10 +9,16 @@ module Tk
module Tile
class TLabelframe < Tk::Tile::TFrame
end
- Labelframe = TLabelframe
+ TLabelFrame = TLabelframe
+ Labelframe = TLabelframe
+ LabelFrame = TLabelframe
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Labelframe,
+ :TkLabelframe, :TkLabelFrame)
+
+
class Tk::Tile::TLabelframe < Tk::Tile::TFrame
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/tmenubutton.rb b/ext/tk/lib/tkextlib/tile/tmenubutton.rb
index 4b81fa1c81..7c6ab28e52 100644
--- a/ext/tk/lib/tkextlib/tile/tmenubutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tmenubutton.rb
@@ -7,13 +7,19 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TMenubutton < TkMenubutton
+ class TMenubutton < Tk::Menubutton
end
- Menubutton = TMenubutton
+ TMenuButton = TMenubutton
+ Menubutton = TMenubutton
+ MenuButton = TMenubutton
end
end
-class Tk::Tile::TMenubutton < TkMenubutton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Menubutton,
+ :TkMenubutton, :TkMenuButton)
+
+
+class Tk::Tile::TMenubutton < Tk::Menubutton
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tnotebook.rb b/ext/tk/lib/tkextlib/tile/tnotebook.rb
index a928e64b61..76f225c579 100644
--- a/ext/tk/lib/tkextlib/tile/tnotebook.rb
+++ b/ext/tk/lib/tkextlib/tile/tnotebook.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Notebook, :TkNotebook)
+
+
class Tk::Tile::TNotebook < TkWindow
################################
include TkItemConfigMethod
diff --git a/ext/tk/lib/tkextlib/tile/tpaned.rb b/ext/tk/lib/tkextlib/tile/tpaned.rb
index 11178b19d3..342b54d253 100644
--- a/ext/tk/lib/tkextlib/tile/tpaned.rb
+++ b/ext/tk/lib/tkextlib/tile/tpaned.rb
@@ -9,15 +9,23 @@ module Tk
module Tile
class TPaned < TkWindow
end
- Paned = TPaned
+ PanedWindow = Panedwindow = Paned = TPaned
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Panedwindow,
+ :TkPanedwindow, :TkPanedWindow)
+
+
class Tk::Tile::TPaned < TkWindow
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
- TkCommandNames = ['::ttk::paned'.freeze].freeze
+ if Tk::Tile::TILE_SPEC_VERSION_ID < 8
+ TkCommandNames = ['::ttk::paned'.freeze].freeze
+ else
+ TkCommandNames = ['::ttk::panedwindow'.freeze].freeze
+ end
else
TkCommandNames = ['::tpaned'.freeze].freeze
end
diff --git a/ext/tk/lib/tkextlib/tile/tprogressbar.rb b/ext/tk/lib/tkextlib/tile/tprogressbar.rb
index 36c1c75c23..f786d370dd 100644
--- a/ext/tk/lib/tkextlib/tile/tprogressbar.rb
+++ b/ext/tk/lib/tkextlib/tile/tprogressbar.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Progressbar, :TkProgressbar)
+
+
class Tk::Tile::TProgressbar
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tile/tradiobutton.rb b/ext/tk/lib/tkextlib/tile/tradiobutton.rb
index e2f614cb97..d653a6d256 100644
--- a/ext/tk/lib/tkextlib/tile/tradiobutton.rb
+++ b/ext/tk/lib/tkextlib/tile/tradiobutton.rb
@@ -7,7 +7,7 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TRadioButton < TkRadioButton
+ class TRadioButton < Tk::RadioButton
end
TRadiobutton = TRadioButton
RadioButton = TRadioButton
@@ -15,7 +15,11 @@ module Tk
end
end
-class Tk::Tile::TRadioButton < TkRadioButton
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Radiobutton,
+ :TkRadiobutton, :TkRadioButton)
+
+
+class Tk::Tile::TRadioButton < Tk::RadioButton
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/treeview.rb b/ext/tk/lib/tkextlib/tile/treeview.rb
index 68e478896c..7f31b9c233 100644
--- a/ext/tk/lib/tkextlib/tile/treeview.rb
+++ b/ext/tk/lib/tkextlib/tile/treeview.rb
@@ -12,6 +12,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Treeview, :TkTreeview)
+
+
module Tk::Tile::TreeviewConfig
include TkItemConfigMethod
@@ -378,7 +381,7 @@ module Tk::Tile::TreeviewConfig
when :item, 'item'
['width']
when :column, 'column'
- super(id[1])
+ super(id[1]) + ['minwidth']
when :tag, 'tag'
super(id[1])
when :heading, 'heading'
@@ -410,7 +413,7 @@ module Tk::Tile::TreeviewConfig
when :item, 'item'
['open']
when :column, 'column'
- super(id[1])
+ super(id[1]) + ['stretch']
when :tag, 'tag'
super(id[1])
when :heading, 'heading'
@@ -614,30 +617,43 @@ end
class Tk::Tile::Treeview::Item < TkObject
ItemID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ Tk::Tile::Treeview::Item::ItemID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::Tile::Treeview::Item::ItemID_TBL[tpath]
- (Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id])? \
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]: id
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath]
+ (Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def self.assign(tree, id)
tpath = tree.path
- if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
- return Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
- end
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ return Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id]
+ end
- obj = self.allocate
- obj.instance_eval{
- @parent = @t = tree
- @tpath = tpath
- @path = @id = id
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @t = tree
+ @tpath = tpath
+ @path = @id = id
+ }
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id] = obj
}
- ItemID_TBL[tpath] = {} unless ItemID_TBL[tpath]
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath][id] = obj
obj
end
@@ -666,8 +682,10 @@ class Tk::Tile::Treeview::Item < TkObject
@parent = @t = tree
@tpath = tree.path
@path = @id = _insert_item(@t, parent_item, idx, keys)
- ItemID_TBL[@tpath] = {} unless ItemID_TBL[@tpath]
- ItemID_TBL[@tpath][@id] = self
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ ItemID_TBL[@tpath] = {} unless ItemID_TBL[@tpath]
+ ItemID_TBL[@tpath][@id] = self
+ }
end
def id
@id
@@ -801,22 +819,35 @@ end
class Tk::Tile::Treeview::Root < Tk::Tile::Treeview::Item
def self.new(tree, keys = {})
tpath = tree.path
- if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
- Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
- else
- super(tree, keys)
- end
+ obj = nil
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Item::ItemID_TBL[tpath] &&
+ Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ obj = Tk::Tile::Treeview::Item::ItemID_TBL[tpath]['']
+ else
+ #super(tree, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = tree
+ @tpath = tree.path
+ @path = @id = ''
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
end
def initialize(tree, keys = {})
+ # dummy:: not called by 'new' method
@parent = @t = tree
@tpath = tree.path
@path = @id = ''
- unless Tk::Tile::Treeview::Item::ItemID_TBL[@tpath]
- Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] = {}
- end
- Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath] ||= {}
+ Tk::Tile::Treeview::Item::ItemID_TBL[@tpath][@id] = self
+ }
end
end
@@ -826,24 +857,42 @@ class Tk::Tile::Treeview::Tag < TkObject
include TkTreatTagFont
TagID_TBL = TkCore::INTERP.create_table
- Tag_ID = ['tile_treeview_tag'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ Tk::Tile::Treeview::Tag::TagID_TBL.clear }
+ (Tag_ID = ['tile_treeview_tag'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::TagID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::Tile::Treeview::Tag::TagID_TBL[tpath]
- (Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id])? \
- Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id]: id
+ Tk::Tile::Treeview::Tag::TagID_TBL.mutex.synchronize{
+ if Tk::Tile::Treeview::Tag::TagID_TBL[tpath]
+ (Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id])? \
+ Tk::Tile::Treeview::Tag::TagID_TBL[tpath][id]: id
+ else
+ id
+ end
+ }
end
def initialize(tree, keys=nil)
@parent = @t = tree
@tpath = tree.path
- @path = @id = Tag_ID.join(TkCore::INTERP._ip_id_)
- TagID_TBL[@tpath] = {} unless TagID_TBL[@tpath]
- TagID_TBL[@tpath][@id] = self
- Tag_ID[1].succ!
+ Tag_ID.mutex.synchronize{
+ @path = @id = Tag_ID.join(TkCore::INTERP._ip_id_)
+ Tag_ID[1].succ!
+ }
+ TagID_TBL.mutex.synchronize{
+ TagID_TBL[@tpath] = {} unless TagID_TBL[@tpath]
+ TagID_TBL[@tpath][@id] = self
+ }
if keys && keys != None
tk_call_without_enc(@tpath, 'tag', 'configure', *hash_kv(keys, true))
end
@@ -916,8 +965,12 @@ class Tk::Tile::Treeview < TkWindow
WidgetClassNames[WidgetClassName] = self
def __destroy_hook__
- Tk::Tile::Treeview::Item::ItemID_TBL.delete(@path)
- Tk::Tile::Treeview::Tag::ItemID_TBL.delete(@path)
+ Tk::Tile::Treeview::Item::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Item::ItemID_TBL.delete(@path)
+ }
+ Tk::Tile::Treeview::Tag::ItemID_TBL.mutex.synchronize{
+ Tk::Tile::Treeview::Tag::ItemID_TBL.delete(@path)
+ }
end
def self.style(*args)
diff --git a/ext/tk/lib/tkextlib/tile/tscale.rb b/ext/tk/lib/tkextlib/tile/tscale.rb
index 7ec72e3515..2c46fd9bd4 100644
--- a/ext/tk/lib/tkextlib/tile/tscale.rb
+++ b/ext/tk/lib/tkextlib/tile/tscale.rb
@@ -7,7 +7,7 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TScale < TkScale
+ class TScale < Tk::Scale
end
Scale = TScale
@@ -17,7 +17,10 @@ module Tk
end
end
-class Tk::Tile::TScale < TkScale
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scale, :TkScale)
+
+
+class Tk::Tile::TScale < Tk::Scale
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
diff --git a/ext/tk/lib/tkextlib/tile/tscrollbar.rb b/ext/tk/lib/tkextlib/tile/tscrollbar.rb
index bd49ae18e3..163b8f4713 100644
--- a/ext/tk/lib/tkextlib/tile/tscrollbar.rb
+++ b/ext/tk/lib/tkextlib/tile/tscrollbar.rb
@@ -7,13 +7,16 @@ require 'tkextlib/tile.rb'
module Tk
module Tile
- class TScrollbar < TkScrollbar
+ class TScrollbar < Tk::Scrollbar
end
Scrollbar = TScrollbar
end
end
-class Tk::Tile::TScrollbar < TkScrollbar
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Scrollbar, :TkScrollbar)
+
+
+class Tk::Tile::TScrollbar < Tk::Scrollbar
include Tk::Tile::TileWidget
if Tk::Tile::USE_TTK_NAMESPACE
@@ -28,3 +31,24 @@ class Tk::Tile::TScrollbar < TkScrollbar
[self::WidgetClassName, *(args.map!{|a| _get_eval_string(a)})].join('.')
end
end
+
+class Tk::Tile::XScrollbar < Tk::Tile::TScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'horizontal'
+ super(keys)
+ end
+ private :create_self
+end
+
+class Tk::Tile::YScrollbar < Tk::Tile::TScrollbar
+ def create_self(keys)
+ keys = {} unless keys
+ keys['orient'] = 'vertical'
+ super(keys)
+ end
+ private :create_self
+end
+
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::XScrollbar, :TkXScrollbar)
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::YScrollbar, :TkYScrollbar)
diff --git a/ext/tk/lib/tkextlib/tile/tseparator.rb b/ext/tk/lib/tkextlib/tile/tseparator.rb
index ca731d4e5b..30fae2c525 100644
--- a/ext/tk/lib/tkextlib/tile/tseparator.rb
+++ b/ext/tk/lib/tkextlib/tile/tseparator.rb
@@ -13,6 +13,9 @@ module Tk
end
end
+Tk.__set_toplevel_aliases__(:Ttk, Tk::Tile::Separator, :TkSeparator)
+
+
class Tk::Tile::TSeparator < TkWindow
include Tk::Tile::TileWidget
diff --git a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
index a040532eb6..ea91d3d1f4 100644
--- a/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
+++ b/ext/tk/lib/tkextlib/tkDND/tkdnd.rb
@@ -57,6 +57,22 @@ module Tk
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
# setup tables
_setup_subst_table(KEY_TBL, PROC_TBL);
end
diff --git a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
index 8527f61df1..d893a83cf2 100644
--- a/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
+++ b/ext/tk/lib/tkextlib/tkHTML/htmlwidget.rb
@@ -39,7 +39,10 @@ class Tk::HTML_Widget::ClippingWindow
WidgetClassNames[WidgetClassName] = self
HtmlClip_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ HtmlClip_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ HtmlClip_TBL.mutex.synchronize{ HtmlClip_TBL.clear }
+ }
def self.new(parent, keys={})
if parent.kind_of?(Hash)
@@ -54,7 +57,9 @@ class Tk::HTML_Widget::ClippingWindow
else
ppath = ''
end
- return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath]
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath] if HtmlClip_TBL[ppath]
+ }
widgetname = keys.delete('widgetname')
if widgetname =~ /^(.*)\.[^.]+$/
@@ -62,7 +67,9 @@ class Tk::HTML_Widget::ClippingWindow
if ppath2[0] != ?.
ppath2 = ppath + '.' + ppath2
end
- return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
+ HtmlClip_TBL.mutex.synchronize{
+ return HtmlClip_TBL[ppath2] if HtmlClip_TBL[ppath2]
+ }
ppath = ppath2
end
@@ -79,7 +86,9 @@ class Tk::HTML_Widget::ClippingWindow
@parent = parent
@ppath = parent.path
@path = @id = @ppath + '.x'
- HtmlClip_TBL[@ppath] = self
+ HtmlClip_TBL.mutex.synchronize{
+ HtmlClip_TBL[@ppath] = self
+ }
end
def method_missing(m, *args, &b)
diff --git a/ext/tk/lib/tkextlib/tktable/tktable.rb b/ext/tk/lib/tkextlib/tktable/tktable.rb
index 4edaabc847..fb8a8b0f72 100644
--- a/ext/tk/lib/tkextlib/tktable/tktable.rb
+++ b/ext/tk/lib/tkextlib/tktable/tktable.rb
@@ -118,23 +118,39 @@ class Tk::TkTable::CellTag
include TkTreatTagFont
CellTagID_TBL = TkCore::INTERP.create_table
- CellTag_ID = ['tktbl:celltag'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ CellTagID_TBL.clear }
+ (CellTag_ID = ['tktbl:celltag'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ CellTagID_TBL.mutex.synchronize{ CellTagID_TBL.clear }
+ }
def self.id2obj(table, id)
tpath = table.path
- return id unless CellTagID_TBL[tpath]
- CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[tpath]
+ CellTagID_TBL[tpath][id]? CellTagID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys=nil)
@parent = @t = parent
@tpath - parent.path
- @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
- CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
- CellTagID_TBL[@tpath][@id] = self
- CellTag_ID[1].succ!
+ CellTag_ID.mutex.synchronize{
+ @path = @id = CellTag_ID.join(TkCore::INTERP._ip_id_)
+ CellTag_ID[1].succ!
+ }
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
configure(keys) if keys
end
@@ -144,7 +160,9 @@ class Tk::TkTable::CellTag
def destroy
tk_call(@tpath, 'tag', 'delete', @id)
- CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath].delete(@id) if CellTagID_TBL[@tpath]
+ }
self
end
alias delete destroy
@@ -189,22 +207,35 @@ end
class Tk::TkTable::NamedCellTag < Tk::TkTable::CellTag
def self.new(parent, name, keys=nil)
- if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
- cell = CellTagID_TBL[parent.path][name]
- cell.configure(keys) if keys
- return cell
- else
- super(parent, name, keys)
- end
+ obj = nil
+ CellTagID_TBL.mutex.synchronize{
+ if CellTagID_TBL[parent.path] && CellTagID_TBL[parent.path][name]
+ obj = CellTagID_TBL[parent.path][name]
+ else
+ #super(parent, name, keys)
+ (obj = self.allocate).instance_eval{
+ @parent = @t = parent
+ @tpath = parent.path
+ @path = @id = name
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ end
+ }
+ obj.configure(keys) if keys && ! keys.empty?
+ obj
end
def initialize(parent, name, keys=nil)
+ # dummy:: not called by 'new' method
@parent = @t = parent
- @tpath - parent.path
+ @tpath = parent.path
@path = @id = name
- CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
- CellTagID_TBL[@tpath][@id] = self
- configure(keys) if keys
+ CellTagID_TBL.mutex.synchronize{
+ CellTagID_TBL[@tpath] = {} unless CellTagID_TBL[@tpath]
+ CellTagID_TBL[@tpath][@id] = self
+ }
+ configure(keys) if keys && ! keys.empty?
end
end
@@ -220,7 +251,9 @@ class Tk::TkTable
include Tk::ValidateConfigure
def __destroy_hook__
- Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
+ Tk::TkTable::CelTag::CellTagID_TBL.mutex.synchronize{
+ Tk::TkTable::CelTag::CellTagID_TBL.delete(@path)
+ }
end
def __boolval_optkeys
@@ -258,6 +291,22 @@ class Tk::TkTable
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -291,6 +340,22 @@ class Tk::TkTable
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -322,6 +387,22 @@ class Tk::TkTable
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)
@@ -356,6 +437,22 @@ class Tk::TkTable
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
end
@@ -746,15 +843,17 @@ class Tk::TkTable
end
def tagid2obj(tagid)
- if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
- if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
- Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL.key?(@path)
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path].key?(tagid)
+ Tk::TkTable::CellTag::CellTagID_TBL[@path][tagid]
+ else
+ tagid
+ end
else
tagid
end
- else
- tagid
- end
+ }
end
def tag_cell(tag, *cells)
@@ -775,13 +874,15 @@ class Tk::TkTable
end
def tag_delete(tag)
tk_send('tag', 'delete', tagid(tag))
- if Tk::TkTable::CellTag::CellTagID_TBL[@path]
- if tag.kind_of? Tk::TkTable::CellTag
- Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
- else
- Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
+ Tk::TkTable::CellTag::CellTagID_TBL.mutex.synchronize{
+ if Tk::TkTable::CellTag::CellTagID_TBL[@path]
+ if tag.kind_of? Tk::TkTable::CellTag
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag.id)
+ else
+ Tk::TkTable::CellTag::CellTagID_TBL[@path].delete(tag)
+ end
end
- end
+ }
self
end
def tag_exist?(tag)
diff --git a/ext/tk/lib/tkextlib/tktrans/tktrans.rb b/ext/tk/lib/tkextlib/tktrans/tktrans.rb
index 665c57af0c..e051c09211 100644
--- a/ext/tk/lib/tkextlib/tktrans/tktrans.rb
+++ b/ext/tk/lib/tkextlib/tktrans/tktrans.rb
@@ -39,7 +39,7 @@ class TkWindow
end
end
-class TkRoot
+class Tk::Root
undef tktrans_set_image, tktrans_get_image
def tktrans_set_image(img)
@@ -51,7 +51,7 @@ class TkRoot
end
end
-class TkToplevel
+class Tk::Toplevel
undef tktrans_set_image, tktrans_get_image
def tktrans_set_image(img)
diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
index 12f7cffabf..b72b157dcd 100644
--- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
+++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb
@@ -137,6 +137,22 @@ class Tk::TreeCtrl::NotifyEvent
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
# setup tables to be used by scan_args, _get_subst_key, _get_all_subst_keys
#
# _get_subst_key() and _get_all_subst_keys() generates key-string
@@ -544,10 +560,18 @@ class Tk::TreeCtrl
#########################
def __destroy_hook__
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.delete(@path)
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path)
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path)
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.delete(@path)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.delete(@path)
+ }
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.delete(@path)
+ }
end
#########################
@@ -638,9 +662,11 @@ class Tk::TreeCtrl
end
def column_delete(idx)
- if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path]
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path].delete(idx)
- end
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[self.path].delete(idx)
+ end
+ }
tk_send('column', 'delete', idx)
self
end
@@ -750,11 +776,13 @@ class Tk::TreeCtrl
end
def element_delete(*elems)
- if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path]
- elems.each{|elem|
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path].delete(elem)
- }
- end
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path]
+ elems.each{|elem|
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[self.path].delete(elem)
+ }
+ end
+ }
tk_send('element', 'delete', *elems)
self
end
@@ -885,22 +913,25 @@ class Tk::TreeCtrl
def _erase_children(item)
item_children(item).each{|i| _erase_children(i)}
+ # table is already locked
Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].delete(item)
end
private :_erase_children
def item_delete(first, last=None)
- if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path]
- if first == 'all' || first == :all || last == 'all' || last == :all
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].clear
- elsif last == None
- _erase_children(first)
- else
- self.range(first, last).each{|id|
- _erase_children(id)
- }
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path]
+ if first == 'all' || first == :all || last == 'all' || last == :all
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[self.path].clear
+ elsif last == None
+ _erase_children(first)
+ else
+ self.range(first, last).each{|id|
+ _erase_children(id)
+ }
+ end
end
- end
+ }
tk_send('item', 'delete', first, last)
self
end
@@ -1520,11 +1551,13 @@ class Tk::TreeCtrl
end
def style_delete(*args)
- if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path]
- args.each{|sty|
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path].delete(sty)
- }
- end
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path]
+ args.each{|sty|
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[self.path].delete(sty)
+ }
+ end
+ }
tk_send('style', 'delete', *args)
self
end
@@ -1608,15 +1641,29 @@ end
class Tk::TreeCtrl::Column < TkObject
TreeCtrlColumnID_TBL = TkCore::INTERP.create_table
- TreeCtrlColumnID = ['treectrl_column'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear}
+ (TreeCtrlColumnID = ['treectrl_column'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath]
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath]
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys={})
@@ -1625,17 +1672,19 @@ class Tk::TreeCtrl::Column < TkObject
keys = _symbolkey2str(keys)
- @path = @id =
- keys.delete('tag') ||
- Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.mutex.synchronize{
+ @path = @id =
+ keys.delete('tag') ||
+ Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ!
+ }
keys['tag'] = @id
- unless Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath]
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self
- Tk::TreeCtrl::Column::TreeCtrlColumnID[1].succ!
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Column::TreeCtrlColumnID_TBL[@tpath][@id] = self
+ }
@tree.column_create(keys)
end
@@ -1692,11 +1741,18 @@ end
class Tk::TreeCtrl::Element < TkObject
TreeCtrlElementID_TBL = TkCore::INTERP.create_table
- TreeCtrlElementID = ['treectrl_element'.freeze, '00000'.taint].freeze
+
+ (TreeCtrlElementID = ['treectrl_element'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
TreeCtrlElemTypeToClass = {}
TkCore::INTERP.init_ip_env{
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear
+ }
}
def self.type2class(type)
@@ -1705,22 +1761,30 @@ class Tk::TreeCtrl::Element < TkObject
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath]
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath]
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id]? \
Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, type, keys=nil)
@tree = parent
@tpath = parent.path
@type = type.to_s
- @path = @id =
- Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_)
- unless Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath]
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self
- Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ!
+ Tk::TreeCtrl::Element::TreeCtrlElementID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Element::TreeCtrlElementID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Element::TreeCtrlElementID[1].succ!
+ }
+
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Element::TreeCtrlElementID_TBL[@tpath][@id] = self
+ }
@tree.element_create(@id, @type, keys)
end
@@ -1800,13 +1864,22 @@ end
class Tk::TreeCtrl::Item < TkObject
TreeCtrlItemID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.clear}
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath]
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath]
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys={})
@@ -1814,10 +1887,10 @@ class Tk::TreeCtrl::Item < TkObject
@tpath = parent.path
@path = @id = @tree.item_create(keys)
- unless Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath]
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath][@id] = self
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Item::TreeCtrlItemID_TBL[@tpath][@id] = self
+ }
end
def id
@@ -2088,27 +2161,45 @@ end
class Tk::TreeCtrl::Style < TkObject
TreeCtrlStyleID_TBL = TkCore::INTERP.create_table
- TreeCtrlStyleID = ['treectrl_style'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear }
+ (TreeCtrlStyleID = ['treectrl_style'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.clear
+ }
+ }
def self.id2obj(tree, id)
tpath = tree.path
- return id unless Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath]
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ if Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath]
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id]? \
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[tpath][id] : id
+ else
+ id
+ end
+ }
end
def initialize(parent, keys=nil)
@tree = parent
@tpath = parent.path
- @path = @id =
- Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_)
- unless Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath]
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] = {}
- end
- Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self
- Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ!
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.mutex.synchronize{
+ @path = @id =
+ Tk::TreeCtrl::Style::TreeCtrlStyleID.join(TkCore::INTERP._ip_id_)
+ Tk::TreeCtrl::Style::TreeCtrlStyleID[1].succ!
+ }
+
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL.mutex.synchronize{
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath] ||= {}
+ Tk::TreeCtrl::Style::TreeCtrlStyleID_TBL[@tpath][@id] = self
+ }
@tree.style_create(@id, keys)
end
diff --git a/ext/tk/lib/tkextlib/version.rb b/ext/tk/lib/tkextlib/version.rb
index c7816fd4a5..3542c79dbe 100644
--- a/ext/tk/lib/tkextlib/version.rb
+++ b/ext/tk/lib/tkextlib/version.rb
@@ -2,5 +2,5 @@
# release date of tkextlib
#
module Tk
- Tkextlib_RELEASE_DATE = '2007-05-26'.freeze
+ Tkextlib_RELEASE_DATE = '2008-03-29'.freeze
end
diff --git a/ext/tk/lib/tkextlib/vu/pie.rb b/ext/tk/lib/tkextlib/vu/pie.rb
index 78f3fa54da..1975803db1 100644
--- a/ext/tk/lib/tkextlib/vu/pie.rb
+++ b/ext/tk/lib/tkextlib/vu/pie.rb
@@ -116,13 +116,26 @@ end
class Tk::Vu::PieSlice
SliceID_TBL = TkCore::INTERP.create_table
- Pie_Slice_ID = ['vu:pie'.freeze, '00000'.taint].freeze
- TkCore::INTERP.init_ip_env{ SliceID_TBL.clear }
+
+ (Pie_Slice_ID = ['vu:pie'.freeze, '00000'.taint]).instance_eval{
+ @mutex = Mutex.new
+ def mutex; @mutex; end
+ freeze
+ }
+
+ TkCore::INTERP.init_ip_env{
+ SliceID_TBL.mutex.synchronize{ SliceID_TBL.clear }
+ }
def self.id2obj(pie, id)
pie_path = pie.path
- return id unless SliceID_TBL[pie_path]
- SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[pie_path]
+ SliceID_TBL[pie_path][id]? SliceID_TBL[pie_path][id]: id
+ else
+ id
+ end
+ }
end
def initialize(parent, *args)
@@ -131,10 +144,14 @@ class Tk::Vu::PieSlice
end
@parent = @pie = parent
@ppath = parent.path
- @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_)
- SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
- SliceID_TBL[@ppath][@id] = self
- Pie_Slice_ID[1].succ!
+ Pie_Slice_ID.mutex.synchronize{
+ @path = @id = Pie_Slice_ID.join(TkCore::INTERP._ip_id_)
+ Pie_Slice_ID[1].succ!
+ }
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
if args[-1].kind_of?(Hash)
keys = args.unshift
@@ -209,22 +226,48 @@ end
class Tk::Vu::NamedPieSlice
def self.new(parent, name, *args)
- if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name]
- return SliceID_TBL[parent.path][name]
- else
- super(parent, name, *args)
- end
+ obj = nil
+ SliceID_TBL.mutex.synchronize{
+ if SliceID_TBL[parent.path] && SliceID_TBL[parent.path][name]
+ obj = SliceID_TBL[parent.path][name]
+ else
+ #super(parent, name, *args)
+ unless parent.kind_of?(Tk::Vu::Pie)
+ fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
+ end
+ obj = self.allocate
+ obj.instance_eval{
+ @parent = @pie = parent
+ @ppath = parent.path
+ @path = @id = name.to_s
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
+ end
+ }
+ obj.instance_eval{
+ if args[-1].kind_of?(Hash)
+ keys = args.unshift
+ end
+ @pie.set(@id, *args)
+ configure(keys)
+ }
+
+ obj
end
def initialize(parent, name, *args)
+ # dummy:: not called by 'new' method
unless parent.kind_of?(Tk::Vu::Pie)
fail ArgumentError, "expect a Tk::Vu::Pie instance for 1st argument"
end
@parent = @pie = parent
@ppath = parent.path
@path = @id = name.to_s
- SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
- SliceID_TBL[@ppath][@id] = self
+ SliceID_TBL.mutex.synchronize{
+ SliceID_TBL[@ppath] = {} unless SliceID_TBL[@ppath]
+ SliceID_TBL[@ppath][@id] = self
+ }
if args[-1].kind_of?(Hash)
keys = args.unshift
diff --git a/ext/tk/lib/tkextlib/vu/spinbox.rb b/ext/tk/lib/tkextlib/vu/spinbox.rb
index b6499645a3..a7e40ea319 100644
--- a/ext/tk/lib/tkextlib/vu/spinbox.rb
+++ b/ext/tk/lib/tkextlib/vu/spinbox.rb
@@ -17,6 +17,6 @@ end
module Tk
module Vu
- Spinbox = TkSpinbox
+ Spinbox = Tk::Spinbox
end
end
diff --git a/ext/tk/lib/tkextlib/winico/winico.rb b/ext/tk/lib/tkextlib/winico/winico.rb
index c53a3ff48c..30fb9682d5 100644
--- a/ext/tk/lib/tkextlib/winico/winico.rb
+++ b/ext/tk/lib/tkextlib/winico/winico.rb
@@ -34,10 +34,15 @@ end
class Tk::Winico
WinicoID_TBL = TkCore::INTERP.create_table
- TkCore::INTERP.init_ip_env{ WinicoID_TBL.clear }
+
+ TkCore::INTERP.init_ip_env{
+ WinicoID_TBL.mutex.synchronize{ WinicoID_TBL.clear }
+ }
def self.id2obj(id)
- (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id
+ WinicoID_TBL.mutex.synchronize{
+ (WinicoID_TBL.key?(id))? WinicoID_TBL[id] : id
+ }
end
def self.info
@@ -81,7 +86,9 @@ class Tk::Winico
"must be given proper information from where loading icons"
end
@path = @id
- WinicoID_TBL[@id] = self
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL[@id] = self
+ }
end
def id
@@ -96,7 +103,9 @@ class Tk::Winico
def delete
tk_call('winico', 'delete', @id)
- WinicoID_TBL.delete(@id)
+ WinicoID_TBL.mutex.synchronize{
+ WinicoID_TBL.delete(@id)
+ }
self
end
alias destroy delete
@@ -126,15 +135,37 @@ class Tk::Winico
[ ?n, TkComm.method(:number) ],
[ ?s, TkComm.method(:string) ],
[ ?x, proc{|id|
- if Tk::Winico::WinicoID_TBL.key?(id)
- Tk::Winico::WinicoID_TBL[id]
- else
- Tk::Winico.new(nil, nil, id)
- end
+ Tk::Winico::WinicoID_TBL.mutex.synchronize{
+ if Tk::Winico::WinicoID_TBL.key?(id)
+ obj = Tk::Winico::WinicoID_TBL[id]
+ else
+ # Tk::Winico.new(nil, nil, id)
+ obj = Tk::Winico.allocate
+ obj.instance_eval{ @path = @id = id }
+ Tk::Winico::WinicoID_TBL[id] = obj
+ end
+ obj
+ }
} ],
nil
]
+ # for Ruby m17n :: ?x --> String --> char-code ( getbyte(0) )
+ KEY_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ inf[1] = inf[1].getbyte(0) if inf[1].kind_of?(String)
+ end
+ inf
+ }
+
+ PROC_TBL.map!{|inf|
+ if inf.kind_of?(Array)
+ inf[0] = inf[0].getbyte(0) if inf[0].kind_of?(String)
+ end
+ inf
+ }
+
_setup_subst_table(KEY_TBL, PROC_TBL);
def self.ret_val(val)