summaryrefslogtreecommitdiff
path: root/ext/tk/lib/tkextlib/tile
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tk/lib/tkextlib/tile')
-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
18 files changed, 374 insertions, 77 deletions
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