diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-30 09:22:56 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-11-30 09:22:56 +0000 |
| commit | eb3c43d0830eec497618fcf66c260d0fcb556e0b (patch) | |
| tree | 10201990b7207e17e644aa4c410573beb0ba904e /ext/tk/lib/tkextlib/blt/tabnotebook.rb | |
| parent | 55a5557f3256596ace71613564a4704f259c75f2 (diff) | |
merges r20349 from trunk into ruby_1_9_1.
* ext/tk/lib/tkextlib/blt/tabset.rb, ext/tk/lib/tkextlib/blt/tabnotebook.rb:
fix many bugs. Now, those work properly.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@20410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/lib/tkextlib/blt/tabnotebook.rb')
| -rw-r--r-- | ext/tk/lib/tkextlib/blt/tabnotebook.rb | 91 |
1 files changed, 90 insertions, 1 deletions
diff --git a/ext/tk/lib/tkextlib/blt/tabnotebook.rb b/ext/tk/lib/tkextlib/blt/tabnotebook.rb index 508fa2b82..510352ba4 100644 --- a/ext/tk/lib/tkextlib/blt/tabnotebook.rb +++ b/ext/tk/lib/tkextlib/blt/tabnotebook.rb @@ -13,9 +13,98 @@ module Tk::BLT 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) - 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 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 |
