From: Hidetoshi NAGAI [email protected]
Subject: Re: BLT::Tabnotebook - tabnotebook.tcl not found
Date: Mon, 24 Nov 2008 08:19:44 +0900
Message-ID: [email protected]
I’ll rewrite tabnotebook.rb. Please give me a few days.
Please try the following patch.
And now, please use Tk::BLT::Tabnotebook::Tab for Tabnotebook objects.
^^^^^^^^^^^
Index: ext/tk/lib/tkextlib/blt/tabset.rb
— ext/tk/lib/tkextlib/blt/tabset.rb (revision 20347)
+++ ext/tk/lib/tkextlib/blt/tabset.rb (working copy)
@@ -27,7 +27,7 @@
tpath = tabset.path
TabID_TBL.mutex.synchronize{
if TabID_TBL[tpath]
@@ -48,6 +48,13 @@
TabID_TBL.mutex.synchronize{
if name && TabID_TBL[parent.path] &&
TabID_TBL[parent.path][name]
obj = TabID_TBL[parent.path][name]
@@ -69,9 +76,9 @@
if pos
idx = tk_call(@tpath, ‘index’, ‘-name’, @id)
if pos.to_s == ‘end’
-
tk_call(@tpath, idx, 'moveto', 'after', 'end')
-
tk_call(@tpath, 'move', idx, 'after', 'end')
else
-
tk_call(@tpath, idx, 'moveto', 'before', pos)
-
tk_call(@tpath, 'move', idx, 'before', pos)
end
end
tk_call(@tpath, 'tab', 'configure', @id, keys)
@@ -80,11 +87,11 @@
tk_call(@tpath, ‘insert’, pos, @id, keys)
end
else
-
pos = 'end' unless pos
tk_call(@tpath, 'insert', pos, @id, keys)
end
end
@@ -173,10 +180,10 @@
end
def perforation_highlight(mode)
@@ -335,19 +342,43 @@
end
def get_tab(index)
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
def index(str)
num_or_str(tk_send(‘index’, str))
end
def index_name(tab)
-
num_or_str(tk_send('index', '-name', tagid(tab)))
end
def insert(pos, tab, keys={})
-
pos = 'end' if pos.nil?
Tk::BLT::Tabset::Tab.new(self, tagindex(pos), tagid(tab), keys)
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))}
Tk::BLT::Tabset::Tab.id2obj(num_or_str(tk_send_without_enc(‘nearest’, x,
y)))
num_or_str(tk_send_without_enc(‘nearest’, x, y)))
end
-
def perforation_highlight(index, *args)
-
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
def scan_mark(x, y)
tk_send_without_enc(‘scan’, ‘mark’, x, y)
@@ -397,16 +444,39 @@
self
end
-
def tab_dockall
-
tk_send('tab', 'dockall')
-
self
-
end
-
def tab_names(pat=None)
simplelist(tk_send(‘tab’, ‘names’, pat)).collect{|name|
-
def tab_objs(pat=None)
-
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
-
def xscrollcommand(cmd=Proc.new)
configure_cmd ‘scrollcommand’, cmd
self
Index: ext/tk/lib/tkextlib/blt/tabnotebook.rb
===================================================================
— ext/tk/lib/tkextlib/blt/tabnotebook.rb (revision 20347)
+++ ext/tk/lib/tkextlib/blt/tabnotebook.rb (working copy)
@@ -13,9 +13,98 @@
WidgetClassName = ‘Tabnotebook’.freeze
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)
tagindex(index)))
-
if (idx = tk_send_without_enc('id', tagindex(index))).empty?
-
nil
-
else
-
Tk::BLT::Tabset::Tab.id2obj(self, idx)
-
end
end
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