* ext/tk/lib/tkextlib/blt/tabset.rb, ext/tk/lib/tkextlib/blt/tabnotebook.rb:

fix many bugs. Now, those work properly.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nagai 2008-11-24 18:49:43 +00:00
Родитель 012fee9476
Коммит 9a206a8039
5 изменённых файлов: 189 добавлений и 18 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Tue Nov 25 03:37:42 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/blt/tabset.rb,
ext/tk/lib/tkextlib/blt/tabnotebook.rb:
fix many bugs. Now, those work properly.
Tue Nov 25 03:26:04 2008 Yukihiro Matsumoto <matz@ruby-lang.org> Tue Nov 25 03:26:04 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (num_step): treat infinite step specially. * numeric.c (num_step): treat infinite step specially.

Просмотреть файл

@ -1,3 +1,9 @@
Tue Nov 25 03:37:42 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/blt/tabset.rb,
ext/tk/lib/tkextlib/blt/tabnotebook.rb:
fix many bugs. Now, those work properly.
Sat Nov 22 10:31:25 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> Sat Nov 22 10:31:25 2008 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/lib/tkextlib/blt.rb, ext/tk/lib/tkextlib/blt/vector.rb: * ext/tk/lib/tkextlib/blt.rb, ext/tk/lib/tkextlib/blt/vector.rb:

Просмотреть файл

@ -13,9 +13,98 @@ module Tk::BLT
WidgetClassName = 'Tabnotebook'.freeze WidgetClassName = 'Tabnotebook'.freeze
WidgetClassNames[WidgetClassName] = self WidgetClassNames[WidgetClassName] = self
class Tab < Tk::BLT::Tabset::Tab
def self.new(parent, pos=nil, name=nil, keys={})
if pos.kind_of?(Hash)
keys = pos
name = nil
pos = nil
end
if name.kind_of?(Hash)
keys = name
name = nil
end
obj = nil
TabID_TBL.mutex.synchronize{
if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
obj = TabID_TBL[parent.path][name]
if pos
if pos.to_s == 'end'
obj.move_after('end')
else
obj.move_before(pos)
end
end
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)
@t = parent
@tpath = parent.path
if name
@path = @id = name
unless (list(tk_call(@tpath, 'tab', 'names', @id)).empty?)
if pos
idx = tk_call(@tpath, 'index', @id)
if pos.to_s == 'end'
tk_call(@tpath, 'move', idx, 'after', 'end')
else
tk_call(@tpath, 'move', idx, 'before', pos)
end
end
tk_call(@tpath, 'tab', 'configure', @id, keys)
else
fail ArgumentError, "can't find tab \"#{@id}\" in #{@t}"
end
else
pos = 'end' unless pos
@path = @id = tk_call(@tpath, 'insert', pos, keys)
end
end
end
#######################################
def get_tab(index) def get_tab(index)
Tk::BLT::Tabset::Tab.id2obj(tk_send_without_enc('id', tagindex(index))) if (idx = tk_send_without_enc('id', tagindex(index))).empty?
nil
else
Tk::BLT::Tabset::Tab.id2obj(self, idx)
end
end end
alias get_id get_tab alias get_id get_tab
def get_tabobj(index)
if (idx = tk_send_without_enc('id', tagindex(index))).empty?
nil
else
Tk::BLT::Tabnotebook::Tab.new(self, nil, idx)
end
end
alias index_name index
def insert(pos=nil, keys={})
if pos.kind_of?(Hash)
keys = pos
pos = nil
end
pos = 'end' if pos.nil?
Tk::BLT::Tabnotebook::Tab.new(self, nil,
tk_send('insert', tagindex(pos), keys))
end
undef :insert_tabs
undef :tab_pageheight, :tab_pagewidth
end end
end end

Просмотреть файл

@ -27,7 +27,7 @@ module Tk::BLT
tpath = tabset.path tpath = tabset.path
TabID_TBL.mutex.synchronize{ TabID_TBL.mutex.synchronize{
if TabID_TBL[tpath] if TabID_TBL[tpath]
TabID_TBL[tpath][id]? TabID_TBL[tpath]: id TabID_TBL[tpath][id]? TabID_TBL[tpath][id]: id
else else
id id
end end
@ -48,6 +48,13 @@ module Tk::BLT
TabID_TBL.mutex.synchronize{ TabID_TBL.mutex.synchronize{
if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name] if name && TabID_TBL[parent.path] && TabID_TBL[parent.path][name]
obj = TabID_TBL[parent.path][name] obj = TabID_TBL[parent.path][name]
if pos
if pos.to_s == 'end'
obj.move_after('end')
else
obj.move_before(pos)
end
end
obj.configure if keys && ! keys.empty? obj.configure if keys && ! keys.empty?
else else
(obj = self.allocate).instance_eval{ (obj = self.allocate).instance_eval{
@ -69,9 +76,9 @@ module Tk::BLT
if pos if pos
idx = tk_call(@tpath, 'index', '-name', @id) idx = tk_call(@tpath, 'index', '-name', @id)
if pos.to_s == 'end' if pos.to_s == 'end'
tk_call(@tpath, idx, 'moveto', 'after', 'end') tk_call(@tpath, 'move', idx, 'after', 'end')
else else
tk_call(@tpath, idx, 'moveto', 'before', pos) tk_call(@tpath, 'move', idx, 'before', pos)
end end
end end
tk_call(@tpath, 'tab', 'configure', @id, keys) tk_call(@tpath, 'tab', 'configure', @id, keys)
@ -80,11 +87,11 @@ module Tk::BLT
tk_call(@tpath, 'insert', pos, @id, keys) tk_call(@tpath, 'insert', pos, @id, keys)
end end
else else
pos = 'end' unless pos
TabsetTab_ID.mutex.synchronize{ TabsetTab_ID.mutex.synchronize{
@path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_) @path = @id = TabsetTab_ID.join(TkCore::INTERP._ip_id_)
TabsetTab_ID[1].succ! TabsetTab_ID[1].succ!
} }
pos = 'end' unless pos
tk_call(@tpath, 'insert', pos, @id, keys) tk_call(@tpath, 'insert', pos, @id, keys)
end end
end end
@ -173,10 +180,10 @@ module Tk::BLT
end end
def perforation_highlight(mode) def perforation_highlight(mode)
@t.perforation.highlight(self.index, mode) @t.perforation_highlight(self.index, mode)
end end
def perforation_invoke() def perforation_invoke()
@t.perforation.invoke(self.index) @t.perforation_invoke(self.index)
end end
def see() def see()
@ -335,19 +342,43 @@ module Tk::BLT
end end
def get_tab(index) def get_tab(index)
Tk::BLT::Tabset::Tab.id2obj(tk_send_without_enc('get', tagindex(index))) if (idx = tk_send_without_enc('get', tagindex(index))).empty?
nil
else
Tk::BLT::Tabset::Tab.id2obj(self, idx)
end
end
def get_tabobj(index)
if (idx = tk_send_without_enc('get', tagindex(index))).empty?
nil
else
Tk::BLT::Tabset::Tab.new(self, nil, name, {})
end
end end
def index(str) def index(str)
num_or_str(tk_send('index', str)) num_or_str(tk_send('index', str))
end end
def index_name(tab) def index_name(tab)
num_or_str(tk_send('index', '-mame', tagid(tab))) num_or_str(tk_send('index', '-name', tagid(tab)))
end end
def insert(pos, tab, keys={}) def insert(pos, tab, keys={})
pos = 'end' if pos.nil?
Tk::BLT::Tabset::Tab.new(self, tagindex(pos), tagid(tab), keys) Tk::BLT::Tabset::Tab.new(self, tagindex(pos), tagid(tab), keys)
end end
def insert_tabs(pos, *tabs)
pos = 'end' if pos.nil?
if tabs[-1].kind_of?(Hash)
keys = tabs.pop
else
keys = {}
end
fail ArgumentError, 'no tabs is given' if tabs.empty?
tabs.map!{|tab| tagid(tab)}
tk_send('insert', tagindex(pos), *(tabs + [keys]))
tabs.collect{|tab| Tk::BLT::Tabset::Tab.new(self, nil, tagid(tab))}
end
def invoke(index) def invoke(index)
tk_send('invoke', tagindex(index)) tk_send('invoke', tagindex(index))
@ -363,15 +394,31 @@ module Tk::BLT
end end
def nearest(x, y) def nearest(x, y)
Tk::BLT::Tabset::Tab.id2obj(num_or_str(tk_send_without_enc('nearest', x, y))) Tk::BLT::Tabset::Tab.id2obj(self, num_or_str(tk_send_without_enc('nearest', x, y)))
end end
def perforation_highlight(index, mode) def perforation_activate(mode)
tk_send('perforation', 'highlight', tagindex(index), mode) tk_send('perforation', 'activate', mode)
self self
end end
def perforation_invoke(index) def perforation_highlight(index, *args)
tk_send('perforation', 'invoke', tagindex(index)) if args.empty?
# index --> mode
tk_send('perforation', 'highlight', index)
elsif args.size == 1
# args[0] --> mode
tk_send('perforation', 'highlight', tagindex(index), args[0])
else # Error: call to get Tcl's error message
tk_send('perforation', 'highlight', tagindex(index), *args)
end
self
end
def perforation_invoke(index=nil)
if index
tk_send('perforation', 'invoke', tagindex(index))
else
tk_send('perforation', 'invoke')
end
end end
def scan_mark(x, y) def scan_mark(x, y)
@ -397,14 +444,37 @@ module Tk::BLT
self self
end end
def tab_dockall
tk_send('tab', 'dockall')
self
end
def tab_names(pat=None) def tab_names(pat=None)
simplelist(tk_send('tab', 'names', pat)).collect{|name| simplelist(tk_send('tab', 'names', pat)).collect{|name|
Tk::BLT::Tabset::Tab.id2obj(name) Tk::BLT::Tabset::Tab.id2obj(self, name)
} }
end end
def tab_tearoff(index, name=None) def tab_objs(pat=None)
window(tk_send('tab', 'tearoff', tagindex(index), name)) simplelist(tk_send('tab', 'names', pat)).collect{|name|
Tk::BLT::Tabset::Tab.new(self, nil, name, {})
}
end
def tab_ids(pat=None)
simplelist(tk_send('tab', 'names', pat))
end
def tab_pageheight
number(tk_send('tab', 'pageheight'))
end
def tab_pagewidth
number(tk_send('tab', 'pagewidth'))
end
def tab_tearoff(index, parent=None)
window(tk_send('tab', 'tearoff', tagindex(index), parent))
end end
def xscrollcommand(cmd=Proc.new) def xscrollcommand(cmd=Proc.new)

Просмотреть файл

@ -2,5 +2,5 @@
# release date of tkextlib # release date of tkextlib
# #
module Tk module Tk
Tkextlib_RELEASE_DATE = '2008-11-22'.freeze Tkextlib_RELEASE_DATE = '2008-11-25'.freeze
end end