From 58bc7420de33ca276e5ab455754d1b1798d518de Mon Sep 17 00:00:00 2001 From: nagai Date: Fri, 18 Mar 2005 15:43:42 +0000 Subject: * ext/tk/lib/tk/font.rb: add some TkFont class methods to get font information without creating a TkFont object. * ext/tk/lib/tkextlib/treectrl/tktreectrl.rb: bug fix and define some classes for components of Tk::TreeCtrl git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/ChangeLog.tkextlib | 7 +- ext/tk/lib/tk/font.rb | 1518 +++++++++++++++------------- ext/tk/lib/tk/menuspec.rb | 12 +- ext/tk/lib/tkextlib/treectrl/tktreectrl.rb | 859 ++++++++++++++-- 4 files changed, 1624 insertions(+), 772 deletions(-) (limited to 'ext/tk') diff --git a/ext/tk/ChangeLog.tkextlib b/ext/tk/ChangeLog.tkextlib index 2e76d523f0..c27ada6d01 100644 --- a/ext/tk/ChangeLog.tkextlib +++ b/ext/tk/ChangeLog.tkextlib @@ -1,7 +1,12 @@ +2005-03-18 Hidetoshi NAGAI + + * lib/tkextlib/treectrl/tktreectrl.rb: bug fix and define some + classes for components of Tk::TreeCtrl + 2005-03-17 Hidetoshi NAGAI * lib/tkextlib/treectrl/tktreectrl.rb: call wrong method in - Tk::TreeCtrl#*_configinfo and current_*_configinfo method + Tk::TreeCtrl#*_configinfo and current_*_configinfo method 2005-03-16 Hidetoshi NAGAI diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb index 92f3a82434..389f001f44 100644 --- a/ext/tk/lib/tk/font.rb +++ b/ext/tk/lib/tk/font.rb @@ -163,6 +163,82 @@ class TkFont ################################### # class methods ################################### + def TkFont.actual(fnt, option=nil) + if fnt.kind_of?(TkFont) + fnt.actual(option) + else + actual_core(fnt, nil, option) + end + end + + def TkFont.actual_displayof(fnt, win, option=nil) + if fnt.kind_of?(TkFont) + fnt.actual_displayof(win, option) + else + win = '.' unless win + actual_core(fnt, win, option) + end + end + + def TkFont.configure(fnt, slot, value=None) + if fnt.kind_of?(TkFont) + fnt.configure(fnt, slot, value) + else + configure_core(fnt, slot, value) + end + fnt + end + + def TkFont.configinfo(fnt, slot=nil) + if fnt.kind_of?(TkFont) + fnt.configinfo(fnt, slot) + else + configinfo_core(fnt, slot) + end + end + + def TkFont.current_configinfo(fnt, slot=nil) + if fnt.kind_of?(TkFont) + fnt.current_configinfo(fnt, slot) + else + current_configinfo_core(fnt, slot) + end + end + + def TkFont.measure(fnt, text) + if fnt.kind_of?(TkFont) + fnt.measure(text) + else + measure_core(fnt, nil, text) + end + end + + def TkFont.measure_displayof(fnt, win, text) + if fnt.kind_of?(TkFont) + fnt.measure_displayof(win, text) + else + win = '.' unless win + measure_core(fnt, win, text) + end + end + + def TkFont.metrics(fnt, option=nil) + if fnt.kind_of?(TkFont) + fnt.metrics(option) + else + metrics_core(fnt, nil, option) + end + end + + def TkFont.metrics_displayof(fnt, win, option=nil) + if fnt.kind_of?(TkFont) + font.metrics_displayof(win, option=nil) + else + win = '.' unless win + metrics_core(fnt, win, option) + end + end + def TkFont.families(win=nil) case (Tk::TK_VERSION) when /^4\.*/ @@ -675,497 +751,317 @@ class TkFont end end - def actual_core_tk4x(font, win=nil, option=nil) - # dummy - if option == 'pointadjust' || option == :pointadjust - 1.0 - elsif option - case OptionType[option.to_s] - when ?n - 0 - when ?b - false - else - '' + ################################### + public + ################################### + def method_missing(id, *args) + name = id.id2name + case args.length + when 1 + configure name, args[0] + when 0 + begin + configinfo name + rescue + fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at end else - [['family',''], ['size',0], ['weight',''], ['slant',''], - ['underline',false], ['overstrike',false], ['charset',''], - ['pointadjust',0]] + fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at end end - def actual_core_tk8x(font, win=nil, option=nil) - if option == 'compound' || option == :compound - "" - elsif option - if win - val = tk_call('font', 'actual', font, - "-displayof", win, "-#{option}") - else - val = tk_call('font', 'actual', font, "-#{option}") - end - case OptionType[option.to_s] - when ?n - num_or_str(val) - when ?b - bool(val) - else - val - end + def call_font_configure(path, *args) + if path.kind_of?(Array) + # [path, optkey] + win, tag = path[0].split(';') + optkey = path[1].to_s else - l = tk_split_simplelist(if win - tk_call('font', 'actual', font, - "-displayof", win) - else - tk_call('font', 'actual', font) - end) - r = [] - while key=l.shift - if key == '-compound' - l.shift - else - key = key[1..-1] - val = l.shift - case OptionType[key] - when ?n - r.push [key, num_or_str(val)] - when ?b - r.push [key, bool(val)] - else - r.push [key, val] - end - end - end - r + win, tag, optkey = path.split(';') end - end - def configure_core_tk4x(font, slot, value=None) - #"" + fontslot = _symbolkey2str(@fontslot) + if optkey && optkey != "" + ltn = fontslot.delete('font') + knj = fontslot.delete('kanjifont') + fontslot[optkey] = ltn if ltn + fontslot["kanji#{optkey}"] = knj if knj + end + + keys = _symbolkey2str(args.pop).update(fontslot) + args.concat(hash_kv(keys)) + tk_call(*args) + Tk_FontUseTBL[[win, tag, optkey].join(';')] = self self end - def configinfo_core_tk4x(font, option=nil) - # dummy - if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY - if option == 'pointadjust' || option == :pointadjust - 1.0 - elsif option - case OptionType[option.to_s] - when ?n - 0 - when ?b - false + def used + ret = [] + Tk_FontUseTBL.each{|key,value| + next unless self == value + if key.include?(';') + win, tag, optkey = key.split(';') + winobj = tk_tcl2ruby(win) + if winobj.kind_of? TkText + if optkey + ret.push([winobj, winobj.tagid2obj(tag), optkey]) + else + ret.push([winobj, winobj.tagid2obj(tag)]) + end + elsif winobj.kind_of? TkCanvas + if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag + if optkey + ret.push([winobj, tagobj, optkey]) + else + ret.push([winobj, tagobj]) + end + elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem + if optkey + ret.push([winobj, tagobj, optkey]) + else + ret.push([winobj, tagobj]) + end + else + if optkey + ret.push([winobj, tag, optkey]) + else + ret.push([winobj, tag]) + end + end + elsif winobj.kind_of? TkMenu + if optkey + ret.push([winobj, tag, optkey]) + else + ret.push([winobj, tag]) + end else - '' + if optkey + ret.push([win, tag, optkey]) + else + ret.push([win, tag]) + end end else - [['family',''], ['size',0], ['weight',''], ['slant',''], - ['underline',false], ['overstrike',false], ['charset',''], - ['pointadjust',1.0]] + ret.push(tk_tcl2ruby(key)) end - else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY - current_configinfo_core_tk4x(font, option) - end + } + ret end - def current_configinfo_core_tk4x(font, option=nil) - if option - case OptionType[option.to_s] - when ?n - 0 - when ?b - false - else - '' - end + def id + @id + end + + def to_eval + font + end + + def font + @compoundfont + end + alias font_id font + + def latin_font_id + @latinfont + end + + def latin_font + # @latinfont + if @latin_descendant + @latin_descendant else - {'family'=>'', 'size'=>0, 'weight'=>'', 'slant'=>'', - 'underline'=>false, 'overstrike'=>false, - 'charset'=>false, 'pointadjust'=>1.0} + @latin_descendant = DescendantFont.new(self, 'latin') end end + alias latinfont latin_font - def configure_core_tk8x(font, slot, value=None) - if JAPANIZED_TK - begin - padjust = tk_call('font', 'configure', font, '-pointadjust') - rescue - padjust = nil - end + def kanji_font_id + @kanjifont + end + + def kanji_font + # @kanjifont + if @kanji_descendant + @kanji_descendant else - padjust = nil + @kanji_descendant = DescendantFont.new(self, 'kanji') end - if slot.kind_of? Hash - if JAPANIZED_TK && (slot.key?('family') || slot.key?(:family)) - slot = _symbolkey2str(slot) - configure_core_tk8x(font, 'family', slot.delete('family')) - end + end + alias kanjifont kanji_font - if ((slot.key?('size') || slot.key?(:size)) && - padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust)) - tk_call('font', 'configure', font, - '-pointadjust', padjust, *hash_kv(slot)) - else - tk_call('font', 'configure', font, *hash_kv(slot)) - end - elsif (slot == 'size' || slot == :size) && padjust != nil - tk_call('font', 'configure', font, - "-#{slot}", value, '-pointadjust', padjust) - elsif JAPANIZED_TK && (slot == 'family' || slot == :family) - # coumpund font? - begin - compound = tk_split_simplelist(tk_call('font', 'configure', - font, '-compound')) - rescue - tk_call('font', 'configure', font, '-family', value) - return self - end - if compound == [] - tk_call('font', 'configure', font, '-family', value) - return self - end - ltn, knj = compound + def actual(option=nil) + actual_core(@compoundfont, nil, option) + end - lfnt = tk_call('font', 'create', '-copy', ltn) - begin - tk_call('font', 'configure', lfnt, '-family', value) - latin_replace_core_tk8x(lfnt) - rescue RuntimeError => e - fail e if $DEBUG - ensure - tk_call('font', 'delete', lfnt) if lfnt != '' - end + def actual_displayof(win, option=nil) + win = '.' unless win + actual_core(@compoundfont, win, option) + end - kfnt = tk_call('font', 'create', '-copy', knj) - begin - tk_call('font', 'configure', kfnt, '-family', value) - kanji_replace_core_tk8x(lfnt) - rescue RuntimeError => e - fail e if $DEBUG - ensure - tk_call('font', 'delete', kfnt) if kfnt != '' - end - - else - tk_call('font', 'configure', font, "-#{slot}", value) - end - self + def latin_actual(option=nil) + actual_core(@latinfont, nil, option) end - def configinfo_core_tk8x(font, option=nil) - if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY - if option == 'compound' || option == :compound - "" - elsif option - val = tk_call('font', 'configure', font, "-#{option}") - case OptionType[option.to_s] - when ?n - num_or_str(val) - when ?b - bool(val) - else - val - end - else - l = tk_split_simplelist(tk_call('font', 'configure', font)) - r = [] - while key=l.shift - if key == '-compound' - l.shift - else - key = key[1..-1] - val = l.shift - case OptionType[key] - when ?n - r.push [key, num_or_str(val)] - when ?b - r.push [key, bool(val)] - else - r.push [key, val] - end - end - end - r - end - else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY - current_configinfo_core_tk8x(font, option) + def latin_actual_displayof(win, option=nil) + win = '.' unless win + actual_core(@latinfont, win, option) + end + + def kanji_actual(option=nil) + #if JAPANIZED_TK + if @kanjifont != "" + actual_core(@kanjifont, nil, option) + else + actual_core_tk4x(nil, nil, option) end end - def current_configinfo_core_tk8x(font, option=nil) - if option == 'compound' - "" - elsif option - val = tk_call('font', 'configure', font, "-#{option}") - case OptionType[option.to_s] - when ?n - num_or_str(val) - when ?b - bool(val) - else - val - end + def kanji_actual_displayof(win, option=nil) + #if JAPANIZED_TK + if @kanjifont != "" + win = '.' unless win + actual_core(@kanjifont, win, option) else - l = tk_split_simplelist(tk_call('font', 'configure', font)) - r = {} - while key=l.shift - if key == '-compound' - l.shift - else - key = key[1..-1] - val = l.shift - case OptionType[key] - when ?n - r.push [key, num_or_str(val)] - when ?b - r.push [key, bool(val)] - else - r.push [key, val] - end - end - end - r + actual_core_tk4x(nil, win, option) end end - def delete_core_tk4x - Tk_FontNameTBL.delete(@id) - Tk_FontUseTBL.delete_if{|key,value| value == self} + def [](slot) + configinfo slot end - def delete_core_tk8x - begin - tk_call('font', 'delete', @latinfont) - rescue - end - begin - tk_call('font', 'delete', @kanjifont) - rescue - end - begin - tk_call('font', 'delete', @compoundfont) - rescue - end - Tk_FontNameTBL.delete(@id) - Tk_FontUseTBL.delete_if{|key,value| value == self} + def []=(slot, val) + configure slot, val + val end - def latin_replace_core_tk4x(ltn) - create_latinfont_tk4x(ltn) - @compoundfont[0] = [@latinfont] if JAPANIZED_TK - @fontslot['font'] = @latinfont - Tk_FontUseTBL.dup.each{|w, fobj| - if self == fobj - begin - if w.include?(';') - win, tag, optkey = w.split(';') - optkey = 'font' if optkey == nil || optkey == '' - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'font'=>@latinfont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) - else - raise RuntimeError, "unknown widget type" - end - else -# tk_tcl2ruby(w).font_configure('font'=>@latinfont) - tk_call(w, 'configure', '-font', @latinfont) - end - rescue - Tk_FontUseTBL.delete(w) - end - end - } + def configure(slot, value=None) + configure_core(@compoundfont, slot, value) self end - def kanji_replace_core_tk4x(knj) - return self unless JAPANIZED_TK + def configinfo(slot=nil) + configinfo_core(@compoundfont, slot) + end - create_kanjifont_tk4x(knj) - @compoundfont[1] = [@kanjifont] - @fontslot['kanjifont'] = @kanjifont - Tk_FontUseTBL.dup.each{|w, fobj| - if self == fobj - begin - if w.include?(';') - win, tag, optkey = w.split(';') - optkey = 'kanjifont' unless optkey - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) - else - raise RuntimeError, "unknown widget type" - end - else -# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont) - tk_call(w, 'configure', '-kanjifont', @kanjifont) - end - rescue - Tk_FontUseTBL.delete(w) - end - end - } - self + def current_configinfo(slot=nil) + current_configinfo_core(@compoundfont, slot) end - def latin_replace_core_tk8x(ltn) - if JAPANIZED_TK - begin - tk_call('font', 'delete', '@font_tmp') - rescue - end - begin - fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont) - rescue - #fnt_bup = '' - fnt_bup = DEFAULT_LATIN_FONT_NAME - end - end + def delete + delete_core + end - begin - tk_call('font', 'delete', @latinfont) - rescue + def latin_configure(slot, value=None) + if JAPANIZED_TK + configure_core(@latinfont, slot, value) + else + configure(slot, value) end - create_latinfont(ltn) + self + end + def latin_configinfo(slot=nil) if JAPANIZED_TK - keys = self.configinfo - tk_call('font', 'delete', @compoundfont) - begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) -=begin - latinkeys = {} - begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} - rescue - latinkeys = {} - end - if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) - end -=end - rescue RuntimeError => e - tk_call('font', 'delete', @latinfont) - if fnt_bup && fnt_bup != '' - tk_call('font', 'create', @latinfont, '-copy', fnt_bup) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - tk_call('font', 'delete', fnt_bup) - else - fail e - end - end + configinfo_core(@latinfont, slot) + else + configinfo(slot) + end + end + def kanji_configure(slot, value=None) + #if JAPANIZED_TK + if @kanjifont != "" + configure_core(@kanjifont, slot, value) + configure('size'=>configinfo('size')) # to reflect new configuration else - latinkeys = {} - begin - actual_core(@latinfont).each{|key,val| latinkeys[key] = val} - rescue - latinkeys = {} - end - if latinkeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) - end - end + #"" + configure(slot, value) + end self end - def kanji_replace_core_tk8x(knj) - if JAPANIZED_TK - begin - tk_call('font', 'delete', '@font_tmp') - rescue - end - begin - fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont) - rescue - #fnt_bup = '' - fnt_bup = DEFAULT_KANJI_FONT_NAME - end + def kanji_configinfo(slot=nil) + #if JAPANIZED_TK + if @kanjifont != "" + configinfo_core(@kanjifont, slot) + else + #[] + configinfo(slot) end + end - begin - tk_call('font', 'delete', @kanjifont) - rescue - end - create_kanjifont(knj) + def replace(ltn, knj=None) + knj = ltn if knj == None + latin_replace(ltn) + kanji_replace(knj) + self + end - if JAPANIZED_TK - keys = self.configinfo - tk_call('font', 'delete', @compoundfont) - begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - rescue RuntimeError => e - tk_call('font', 'delete', @kanjifont) - if fnt_bup && fnt_bup != '' - tk_call('font', 'create', @kanjifont, '-copy', fnt_bup) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - tk_call('font', 'delete', fnt_bup) - else - fail e - end - end - end + def latin_replace(ltn) + latin_replace_core(ltn) + reset_pointadjust self end - def measure_core_tk4x(win, text) - 0 + def kanji_replace(knj) + kanji_replace_core(knj) + reset_pointadjust + self end - def measure_core_tk8x(win, text) - if win - number(tk_call('font', 'measure', @compoundfont, - '-displayof', win, text)) - else - number(tk_call('font', 'measure', @compoundfont, text)) - end + def measure(text) + measure_core(@compoundfont, nil, text) end - def metrics_core_tk4x(font, win, option=nil) - # dummy - if option - "" - else - [['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]]] - end + def measure_displayof(win, text) + win = '.' unless win + measure_core(@compoundfont, win, text) end - def metrics_core_tk8x(font, win, option=nil) - if option - if win - number(tk_call('font', 'metrics', font, - "-displayof", win, "-#{option}")) - else - number(tk_call('font', 'metrics', font, "-#{option}")) - end + def metrics(option=nil) + metrics_core(@compoundfont, nil, option) + end + + def metrics_displayof(win, option=nil) + win = '.' unless win + metrics_core(@compoundfont, win, option) + end + + def latin_metrics(option=nil) + metrics_core(@latinfont, nil, option) + end + + def latin_metrics_displayof(win, option=nil) + win = '.' unless win + metrics_core(@latinfont, win, option) + end + + def kanji_metrics(option=nil) + if JAPANIZED_TK + metrics_core(@kanjifont, nil, option) else - l = tk_split_list(if win - tk_call('font','metrics',font,"-displayof",win) - else - tk_call('font','metrics',font) - end) - r = [] - while key=l.shift - r.push [key[1..-1], l.shift.to_i] + metrics_core_tk4x(nil, nil, option) + end + end + + def kanji_metrics_displayof(win, option=nil) + if JAPANIZED_TK + win = '.' unless win + metrics_core(@kanjifont, win, option) + else + metrics_core_tk4x(nil, win, option) + end + end + + def reset_pointadjust + begin + if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK + configure('pointadjust' => latin_actual.assoc('size')[1].to_f / + kanji_actual.assoc('size')[1].to_f ) end - r + rescue end + self end ################################### @@ -1176,383 +1072,587 @@ class TkFont alias create_latinfont create_latinfont_tk4x alias create_kanjifont create_kanjifont_tk4x alias create_compoundfont create_compoundfont_tk4x - alias actual_core actual_core_tk4x - alias configure_core configure_core_tk4x - alias configinfo_core configinfo_core_tk4x - alias current_configinfo_core current_configinfo_core_tk4x - alias delete_core delete_core_tk4x - alias latin_replace_core latin_replace_core_tk4x - alias kanji_replace_core kanji_replace_core_tk4x - alias measure_core measure_core_tk4x - alias metrics_core metrics_core_tk4x when /^8\.[0-5]/ alias create_latinfont create_latinfont_tk8x alias create_kanjifont create_kanjifont_tk8x alias create_compoundfont create_compoundfont_tk8x - alias actual_core actual_core_tk8x - alias configure_core configure_core_tk8x - alias configinfo_core configinfo_core_tk8x - alias current_configinfo_core current_configinfo_core_tk8x - alias delete_core delete_core_tk8x - alias latin_replace_core latin_replace_core_tk8x - alias kanji_replace_core kanji_replace_core_tk8x - alias measure_core measure_core_tk8x - alias metrics_core metrics_core_tk8x else alias create_latinfont create_latinfont_tk8x alias create_kanjifont create_kanjifont_tk8x alias create_compoundfont create_compoundfont_tk8x - alias actual_core actual_core_tk8x - alias configure_core configure_core_tk8x - alias configinfo_core configinfo_core_tk8x - alias current_configinfo_core current_configinfo_core_tk8x - alias delete_core delete_core_tk8x - alias latin_replace_core latin_replace_core_tk8x - alias kanji_replace_core kanji_replace_core_tk8x - alias measure_core measure_core_tk8x - alias metrics_core metrics_core_tk8x end ################################### - public + # public alias ################################### - def method_missing(id, *args) - name = id.id2name - case args.length - when 1 - configure name, args[0] - when 0 - begin - configinfo name - rescue - fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at - end - else - fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at - end + alias ascii_font latin_font + alias asciifont latinfont + alias create_asciifont create_latinfont + alias ascii_actual latin_actual + alias ascii_actual_displayof latin_actual_displayof + alias ascii_configure latin_configure + alias ascii_configinfo latin_configinfo + alias ascii_replace latin_replace + alias ascii_metrics latin_metrics + + ################################### + def dup + src = self + obj = super() + obj.instance_eval{ initialize(src) } + obj + end + def clone + src = self + obj = super() + obj.instance_eval{ initialize(src) } + obj end +end - def call_font_configure(path, *args) - if path.kind_of?(Array) - # [path, optkey] - win, tag = path[0].split(';') - optkey = path[1].to_s - else - win, tag, optkey = path.split(';') - end +module TkFont::CoreMethods + include Tk + extend TkCore - fontslot = _symbolkey2str(@fontslot) - if optkey && optkey != "" - ltn = fontslot.delete('font') - knj = fontslot.delete('kanjifont') - fontslot[optkey] = ltn if ltn - fontslot["kanji#{optkey}"] = knj if knj - end + private - keys = _symbolkey2str(args.pop).update(fontslot) - args.concat(hash_kv(keys)) - tk_call(*args) - Tk_FontUseTBL[[win, tag, optkey].join(';')] = self - self + def actual_core_tk4x(font, win=nil, option=nil) + # dummy + if option == 'pointadjust' || option == :pointadjust + 1.0 + elsif option + case TkFont::OptionType[option.to_s] + when ?n + 0 + when ?b + false + else + '' + end + else + [['family',''], ['size',0], ['weight',''], ['slant',''], + ['underline',false], ['overstrike',false], ['charset',''], + ['pointadjust',0]] + end end - def used - ret = [] - Tk_FontUseTBL.each{|key,value| - next unless self == value - if key.include?(';') - win, tag, optkey = key.split(';') - winobj = tk_tcl2ruby(win) - if winobj.kind_of? TkText - if optkey - ret.push([winobj, winobj.tagid2obj(tag), optkey]) - else - ret.push([winobj, winobj.tagid2obj(tag)]) - end - elsif winobj.kind_of? TkCanvas - if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag - if optkey - ret.push([winobj, tagobj, optkey]) - else - ret.push([winobj, tagobj]) - end - elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem - if optkey - ret.push([winobj, tagobj, optkey]) - else - ret.push([winobj, tagobj]) - end - else - if optkey - ret.push([winobj, tag, optkey]) - else - ret.push([winobj, tag]) - end - end - elsif winobj.kind_of? TkMenu - if optkey - ret.push([winobj, tag, optkey]) - else - ret.push([winobj, tag]) - end + def actual_core_tk8x(font, win=nil, option=nil) + if option == 'compound' || option == :compound + "" + elsif option + if win + val = tk_call('font', 'actual', font, + "-displayof", win, "-#{option}") + else + val = tk_call('font', 'actual', font, "-#{option}") + end + case TkFont::OptionType[option.to_s] + when ?n + num_or_str(val) + when ?b + bool(val) + else + val + end + else + l = tk_split_simplelist(if win + tk_call('font', 'actual', font, + "-displayof", win) + else + tk_call('font', 'actual', font) + end) + r = [] + while key=l.shift + if key == '-compound' + l.shift else - if optkey - ret.push([win, tag, optkey]) + key = key[1..-1] + val = l.shift + case TkFont::OptionType[key] + when ?n + r.push [key, num_or_str(val)] + when ?b + r.push [key, bool(val)] else - ret.push([win, tag]) + r.push [key, val] end end - else - ret.push(tk_tcl2ruby(key)) end - } - ret - end - - def id - @id - end - - def to_eval - font - end - - def font - @compoundfont + r + end end - alias font_id font - def latin_font_id - @latinfont + def configure_core_tk4x(font, slot, value=None) + #"" + self end - def latin_font - # @latinfont - if @latin_descendant - @latin_descendant - else - @latin_descendant = DescendantFont.new(self, 'latin') + def configinfo_core_tk4x(font, option=nil) + # dummy + if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY + if option == 'pointadjust' || option == :pointadjust + 1.0 + elsif option + case TkFont::OptionType[option.to_s] + when ?n + 0 + when ?b + false + else + '' + end + else + [['family',''], ['size',0], ['weight',''], ['slant',''], + ['underline',false], ['overstrike',false], ['charset',''], + ['pointadjust',1.0]] + end + else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY + current_configinfo_core_tk4x(font, option) end end - alias latinfont latin_font - - def kanji_font_id - @kanjifont - end - def kanji_font - # @kanjifont - if @kanji_descendant - @kanji_descendant + def current_configinfo_core_tk4x(font, option=nil) + if option + case TkFont::OptionType[option.to_s] + when ?n + 0 + when ?b + false + else + '' + end else - @kanji_descendant = DescendantFont.new(self, 'kanji') + {'family'=>'', 'size'=>0, 'weight'=>'', 'slant'=>'', + 'underline'=>false, 'overstrike'=>false, + 'charset'=>false, 'pointadjust'=>1.0} end end - alias kanjifont kanji_font - def actual(option=nil) - actual_core(@compoundfont, nil, option) - end + def configure_core_tk8x(font, slot, value=None) + if JAPANIZED_TK + begin + padjust = tk_call('font', 'configure', font, '-pointadjust') + rescue + padjust = nil + end + else + padjust = nil + end + if slot.kind_of? Hash + if JAPANIZED_TK && (slot.key?('family') || slot.key?(:family)) + slot = _symbolkey2str(slot) + configure_core_tk8x(font, 'family', slot.delete('family')) + end - def actual_displayof(win, option=nil) - win = '.' unless win - actual_core(@compoundfont, win, option) - end + if ((slot.key?('size') || slot.key?(:size)) && + padjust && !slot.key?('pointadjust') && !slot.key?(:pointadjust)) + tk_call('font', 'configure', font, + '-pointadjust', padjust, *hash_kv(slot)) + else + tk_call('font', 'configure', font, *hash_kv(slot)) + end + elsif (slot == 'size' || slot == :size) && padjust != nil + tk_call('font', 'configure', font, + "-#{slot}", value, '-pointadjust', padjust) + elsif JAPANIZED_TK && (slot == 'family' || slot == :family) + # coumpund font? + begin + compound = tk_split_simplelist(tk_call('font', 'configure', + font, '-compound')) + rescue + tk_call('font', 'configure', font, '-family', value) + return self + end + if compound == [] + tk_call('font', 'configure', font, '-family', value) + return self + end + ltn, knj = compound - def latin_actual(option=nil) - actual_core(@latinfont, nil, option) - end + lfnt = tk_call('font', 'create', '-copy', ltn) + begin + tk_call('font', 'configure', lfnt, '-family', value) + latin_replace_core_tk8x(lfnt) + rescue RuntimeError => e + fail e if $DEBUG + ensure + tk_call('font', 'delete', lfnt) if lfnt != '' + end - def latin_actual_displayof(win, option=nil) - win = '.' unless win - actual_core(@latinfont, win, option) + kfnt = tk_call('font', 'create', '-copy', knj) + begin + tk_call('font', 'configure', kfnt, '-family', value) + kanji_replace_core_tk8x(lfnt) + rescue RuntimeError => e + fail e if $DEBUG + ensure + tk_call('font', 'delete', kfnt) if kfnt != '' + end + + else + tk_call('font', 'configure', font, "-#{slot}", value) + end + self end - def kanji_actual(option=nil) - #if JAPANIZED_TK - if @kanjifont != "" - actual_core(@kanjifont, nil, option) - else - actual_core_tk4x(nil, nil, option) + def configinfo_core_tk8x(font, option=nil) + if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY + if option == 'compound' || option == :compound + "" + elsif option + val = tk_call('font', 'configure', font, "-#{option}") + case TkFont::OptionType[option.to_s] + when ?n + num_or_str(val) + when ?b + bool(val) + else + val + end + else + l = tk_split_simplelist(tk_call('font', 'configure', font)) + r = [] + while key=l.shift + if key == '-compound' + l.shift + else + key = key[1..-1] + val = l.shift + case TkFont::OptionType[key] + when ?n + r.push [key, num_or_str(val)] + when ?b + r.push [key, bool(val)] + else + r.push [key, val] + end + end + end + r + end + else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY + current_configinfo_core_tk8x(font, option) end end - def kanji_actual_displayof(win, option=nil) - #if JAPANIZED_TK - if @kanjifont != "" - win = '.' unless win - actual_core(@kanjifont, win, option) + def current_configinfo_core_tk8x(font, option=nil) + if option == 'compound' + "" + elsif option + val = tk_call('font', 'configure', font, "-#{option}") + case TkFont::OptionType[option.to_s] + when ?n + num_or_str(val) + when ?b + bool(val) + else + val + end else - actual_core_tk4x(nil, win, option) + l = tk_split_simplelist(tk_call('font', 'configure', font)) + r = {} + while key=l.shift + if key == '-compound' + l.shift + else + key = key[1..-1] + val = l.shift + case TkFont::OptionType[key] + when ?n + r.push [key, num_or_str(val)] + when ?b + r.push [key, bool(val)] + else + r.push [key, val] + end + end + end + r end end - def [](slot) - configinfo slot + def delete_core_tk4x + TkFont::Tk_FontNameTBL.delete(@id) + TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self} end - def []=(slot, val) - configure slot, val - val + def delete_core_tk8x + begin + tk_call('font', 'delete', @latinfont) + rescue + end + begin + tk_call('font', 'delete', @kanjifont) + rescue + end + begin + tk_call('font', 'delete', @compoundfont) + rescue + end + TkFont::Tk_FontNameTBL.delete(@id) + TkFont::Tk_FontUseTBL.delete_if{|key,value| value == self} end - def configure(slot, value=None) - configure_core(@compoundfont, slot, value) + def latin_replace_core_tk4x(ltn) + create_latinfont_tk4x(ltn) + @compoundfont[0] = [@latinfont] if JAPANIZED_TK + @fontslot['font'] = @latinfont + TkFont::Tk_FontUseTBL.dup.each{|w, fobj| + if self == fobj + begin + if w.include?(';') + win, tag, optkey = w.split(';') + optkey = 'font' if optkey == nil || optkey == '' + winobj = tk_tcl2ruby(win) +# winobj.tagfont_configure(tag, {'font'=>@latinfont}) + if winobj.kind_of? TkText + tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @latinfont) + elsif winobj.kind_of? TkCanvas + tk_call(win, 'itemconfigure', tag, "-#{optkey}", @latinfont) + elsif winobj.kind_of? TkMenu + tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) + else + raise RuntimeError, "unknown widget type" + end + else +# tk_tcl2ruby(w).font_configure('font'=>@latinfont) + tk_call(w, 'configure', '-font', @latinfont) + end + rescue + TkFont::Tk_FontUseTBL.delete(w) + end + end + } self end - def configinfo(slot=nil) - configinfo_core(@compoundfont, slot) - end - - def current_configinfo(slot=nil) - current_configinfo_core(@compoundfont, slot) - end + def kanji_replace_core_tk4x(knj) + return self unless JAPANIZED_TK - def delete - delete_core + create_kanjifont_tk4x(knj) + @compoundfont[1] = [@kanjifont] + @fontslot['kanjifont'] = @kanjifont + TkFont::Tk_FontUseTBL.dup.each{|w, fobj| + if self == fobj + begin + if w.include?(';') + win, tag, optkey = w.split(';') + optkey = 'kanjifont' unless optkey + winobj = tk_tcl2ruby(win) +# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont}) + if winobj.kind_of? TkText + tk_call(win, 'tag', 'configure', tag, "-#{optkey}", @kanjifont) + elsif winobj.kind_of? TkCanvas + tk_call(win, 'itemconfigure', tag, "-#{optkey}", @kanjifont) + elsif winobj.kind_of? TkMenu + tk_call(win, 'entryconfigure', tag, "-#{optkey}", @latinfont) + else + raise RuntimeError, "unknown widget type" + end + else +# tk_tcl2ruby(w).font_configure('kanjifont'=>@kanjifont) + tk_call(w, 'configure', '-kanjifont', @kanjifont) + end + rescue + TkFont::Tk_FontUseTBL.delete(w) + end + end + } + self end - def latin_configure(slot, value=None) + def latin_replace_core_tk8x(ltn) if JAPANIZED_TK - configure_core(@latinfont, slot, value) - else - configure(slot, value) + begin + tk_call('font', 'delete', '@font_tmp') + rescue + end + begin + fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @latinfont) + rescue + #fnt_bup = '' + fnt_bup = TkFont::DEFAULT_LATIN_FONT_NAME + end end - self - end - def latin_configinfo(slot=nil) - if JAPANIZED_TK - configinfo_core(@latinfont, slot) - else - configinfo(slot) + begin + tk_call('font', 'delete', @latinfont) + rescue end - end + create_latinfont(ltn) + + if JAPANIZED_TK + keys = self.configinfo + tk_call('font', 'delete', @compoundfont) + begin + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) +=begin + latinkeys = {} + begin + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + rescue + latinkeys = {} + end + if latinkeys != {} + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + end +=end + rescue RuntimeError => e + tk_call('font', 'delete', @latinfont) + if fnt_bup && fnt_bup != '' + tk_call('font', 'create', @latinfont, '-copy', fnt_bup) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'delete', fnt_bup) + else + fail e + end + end - def kanji_configure(slot, value=None) - #if JAPANIZED_TK - if @kanjifont != "" - configure_core(@kanjifont, slot, value) - configure('size'=>configinfo('size')) # to reflect new configuration else - #"" - configure(slot, value) - end + latinkeys = {} + begin + actual_core(@latinfont).each{|key,val| latinkeys[key] = val} + rescue + latinkeys = {} + end + if latinkeys != {} + tk_call('font', 'configure', @compoundfont, *hash_kv(latinkeys)) + end + end self end - def kanji_configinfo(slot=nil) - #if JAPANIZED_TK - if @kanjifont != "" - configinfo_core(@kanjifont, slot) - else - #[] - configinfo(slot) + def kanji_replace_core_tk8x(knj) + if JAPANIZED_TK + begin + tk_call('font', 'delete', '@font_tmp') + rescue + end + begin + fnt_bup = tk_call('font', 'create', '@font_tmp', '-copy', @kanjifont) + rescue + #fnt_bup = '' + fnt_bup = TkFont::DEFAULT_KANJI_FONT_NAME + end end - end - - def replace(ltn, knj=None) - knj = ltn if knj == None - latin_replace(ltn) - kanji_replace(knj) - self - end - def latin_replace(ltn) - latin_replace_core(ltn) - reset_pointadjust - self - end + begin + tk_call('font', 'delete', @kanjifont) + rescue + end + create_kanjifont(knj) - def kanji_replace(knj) - kanji_replace_core(knj) - reset_pointadjust + if JAPANIZED_TK + keys = self.configinfo + tk_call('font', 'delete', @compoundfont) + begin + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + rescue RuntimeError => e + tk_call('font', 'delete', @kanjifont) + if fnt_bup && fnt_bup != '' + tk_call('font', 'create', @kanjifont, '-copy', fnt_bup) + tk_call('font', 'create', @compoundfont, + '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) + tk_call('font', 'delete', fnt_bup) + else + fail e + end + end + end self end - def measure(text) - measure_core(nil, text) - end - - def measure_displayof(win, text) - win = '.' unless win - measure_core(win, text) - end - - def metrics(option=nil) - metrics_core(@compoundfont, nil, option) - end - - def metrics_displayof(win, option=nil) - win = '.' unless win - metrics_core(@compoundfont, win, option) - end - - def latin_metrics(option=nil) - metrics_core(@latinfont, nil, option) - end - - def latin_metrics_displayof(win, option=nil) - win = '.' unless win - metrics_core(@latinfont, win, option) + def measure_core_tk4x(font, win, text) + 0 end - def kanji_metrics(option=nil) - if JAPANIZED_TK - metrics_core(@kanjifont, nil, option) + def measure_core_tk8x(font, win, text) + if win + number(tk_call('font', 'measure', font, + '-displayof', win, text)) else - metrics_core_tk4x(nil, nil, option) + number(tk_call('font', 'measure', font, text)) end end - def kanji_metrics_displayof(win, option=nil) - if JAPANIZED_TK - win = '.' unless win - metrics_core(@kanjifont, win, option) + def metrics_core_tk4x(font, win, option=nil) + # dummy + if option + "" else - metrics_core_tk4x(nil, win, option) + [['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]]] end end - def reset_pointadjust - begin - if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK - configure('pointadjust' => latin_actual.assoc('size')[1].to_f / - kanji_actual.assoc('size')[1].to_f ) + def metrics_core_tk8x(font, win, option=nil) + if option + if win + number(tk_call('font', 'metrics', font, + "-displayof", win, "-#{option}")) + else + number(tk_call('font', 'metrics', font, "-#{option}")) end - rescue + else + l = tk_split_list(if win + tk_call('font','metrics',font,"-displayof",win) + else + tk_call('font','metrics',font) + end) + r = [] + while key=l.shift + r.push [key[1..-1], l.shift.to_i] + end + r end - self end ################################### - # public alias + # private alias ################################### - alias ascii_font latin_font - alias asciifont latinfont - alias create_asciifont create_latinfont - alias ascii_actual latin_actual - alias ascii_actual_displayof latin_actual_displayof - alias ascii_configure latin_configure - alias ascii_configinfo latin_configinfo - alias ascii_replace latin_replace - alias ascii_metrics latin_metrics + case (Tk::TK_VERSION) + when /^4\.*/ + alias actual_core actual_core_tk4x + alias configure_core configure_core_tk4x + alias configinfo_core configinfo_core_tk4x + alias current_configinfo_core current_configinfo_core_tk4x + alias delete_core delete_core_tk4x + alias latin_replace_core latin_replace_core_tk4x + alias kanji_replace_core kanji_replace_core_tk4x + alias measure_core measure_core_tk4x + alias metrics_core metrics_core_tk4x + + when /^8\.[0-5]/ + alias actual_core actual_core_tk8x + alias configure_core configure_core_tk8x + alias configinfo_core configinfo_core_tk8x + alias current_configinfo_core current_configinfo_core_tk8x + alias delete_core delete_core_tk8x + alias latin_replace_core latin_replace_core_tk8x + alias kanji_replace_core kanji_replace_core_tk8x + alias measure_core measure_core_tk8x + alias metrics_core metrics_core_tk8x + + else + alias actual_core actual_core_tk8x + alias configure_core configure_core_tk8x + alias configinfo_core configinfo_core_tk8x + alias current_configinfo_core current_configinfo_core_tk8x + alias delete_core delete_core_tk8x + alias latin_replace_core latin_replace_core_tk8x + alias kanji_replace_core kanji_replace_core_tk8x + alias measure_core measure_core_tk8x + alias metrics_core metrics_core_tk8x - ################################### - def dup - src = self - obj = super() - obj.instance_eval{ initialize(src) } - obj - end - def clone - src = self - obj = super() - obj.instance_eval{ initialize(src) } - obj end end + +class TkFont + include TkFont::CoreMethods + extend TkFont::CoreMethods +end diff --git a/ext/tk/lib/tk/menuspec.rb b/ext/tk/lib/tk/menuspec.rb index c8819f8e41..118a4f42b1 100644 --- a/ext/tk/lib/tk/menuspec.rb +++ b/ext/tk/lib/tk/menuspec.rb @@ -12,12 +12,12 @@ # And the format of the menu_info is: # [ # [text, underline, configs], # menu button/entry (*1) -# [label, command, underline, accelerator, configs], # command entry -# [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry +# [label, command, underline, accelerator, configs], # command entry +# [label, TkVar_obj, underline, accelerator, configs], # checkbutton entry # [label, [TkVar_obj, value], -# underline, accelerator, configs], # radiobutton entry +# underline, accelerator, configs], # radiobutton entry # [label, [[...menu_info...], [...menu_info...], ...], -# underline, accelerator, configs], # cascade entry +# underline, accelerator, configs], # cascade entry (*2) # '---', # separator # ... # ] @@ -33,6 +33,10 @@ # and *.apple for Mac), append 'menu_name'=>name (name is 'help' for UNIX, # 'system' for Win, and 'apple' for Mac) option to the configs hash of # menu button/entry information. +# +# NOTE: (*2) +# If you want to configure a cascade menu, add :menu_config=>{...configs..} +# to the configs of the cascade entry. module TkMenuSpec def _create_menu(parent, menu_info, menu_name = nil, diff --git a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb index 98d66a7225..0e8fd86c0f 100644 --- a/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb +++ b/ext/tk/lib/tkextlib/treectrl/tktreectrl.rb @@ -99,7 +99,7 @@ class Tk::TreeCtrl::NotifyEvent } ], - [ ?o, proc{|val| tk_tcl2ruby(val)} ], + [ ?o, proc{|val| TkComm.tk_tcl2ruby(val)} ], nil ] @@ -131,12 +131,19 @@ module Tk::TreeCtrl::ConfigMethod key = key.to_s end + if (obj.kind_of?(Tk::TreeCtrl::Column) || + obj.kind_of?(Tk::TreeCtrl::Element) || + obj.kind_of?(Tk::TreeCtrl::Item) || + obj.kind_of?(Tk::TreeCtrl::Style)) + obj = obj.id + end + case key when 'column' obj when 'debug' - obj + None when 'dragimage' obj @@ -162,12 +169,13 @@ module Tk::TreeCtrl::ConfigMethod end def tagid(mixed_id) - if mixed_id.kind_of?(Array) + if mixed_id == 'debug' + ['debug', None] + elsif mixed_id.kind_of?(Array) [mixed_id[0], treectrl_tagid(*mixed_id)] else tagid(mixed_id.split(':')) end - fail ArgumentError, "unknown id format" end def __item_cget_cmd(mixed_id) @@ -346,17 +354,30 @@ module Tk::TreeCtrl::ConfigMethod current_itemconfiginfo(['element', tagOrId], slot) end - def item_element_cget(tagOrId, option) - itemcget([['item', 'element'], tagOrId], option) + def item_cget(tagOrId, option) + itemcget(['item', tagOrId], option) end - def item_element_configure(tagOrId, slot, value=None) - itemconfigure([['item', 'element'], tagOrId], slot, value) + def item_configure(tagOrId, slot, value=None) + itemconfigure(['item', tagOrId], slot, value) end - def item_element_configinfo(tagOrId, slot=nil) - itemconfiginfo([['item', 'element'], tagOrId], slot) + def item_configinfo(tagOrId, slot=nil) + itemconfiginfo(['item', tagOrId], slot) end - def current_item_element_configinfo(tagOrId, slot=nil) - current_itemconfiginfo([['item', 'element'], tagOrId], slot) + def current_item_configinfo(tagOrId, slot=nil) + current_itemconfiginfo(['item', tagOrId], slot) + end + + def item_element_cget(item, column, elem, option) + itemcget([['item', 'element'], [item, column, elem]], option) + end + def item_element_configure(item, column, elem, slot, value=None) + itemconfigure([['item', 'element'], [item, column, elem]], slot, value) + end + def item_element_configinfo(item, column, elem, slot=nil) + itemconfiginfo([['item', 'element'], [item, column, elem]], slot) + end + def current_item_element_configinfo(item, column, elem, slot=nil) + current_itemconfiginfo([['item', 'element'], [item, column, elem]], slot) end def marquee_cget(tagOrId, option) @@ -407,11 +428,20 @@ class Tk::TreeCtrl include Scrollable TkCommandNames = ['treectrl'.freeze].freeze - WidgetClassName = ''.freeze + WidgetClassName = 'TreeCtrl'.freeze WidgetClassNames[WidgetClassName] = self ######################### + 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) + end + + ######################### + def __boolval_optkeys [ 'showbuttons', 'showheader', 'showlines', 'showroot', @@ -480,6 +510,9 @@ 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_send('column', 'delete', idx) self end @@ -488,8 +521,8 @@ class Tk::TreeCtrl num_or_str(tk_send('column', 'index', idx)) end - def column_move(idx, to) - tk_send('column', 'move', idx, to) + def column_move(idx, before) + tk_send('column', 'move', idx, before) self end @@ -503,7 +536,7 @@ class Tk::TreeCtrl end def compare(item1, op, item2) - number(tk_send('compare', item1, op, item2)) + bool(tk_send('compare', item1, op, item2)) end def contentbox() @@ -563,18 +596,29 @@ 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_send('element', 'delete', *elems) self end def element_names() - list(tk_send('element', 'names')) + list(tk_send('element', 'names')).collect!{|elem| + Tk::TreeCtrl::Element.id2obj(self, elem) + } end def element_type(elem) tk_send('element', 'type', elem) end + def element_class(elem) + Tk::TreeCtrl::Element.type2class(element_type(elem)) + end + def expand(*dsc) tk_send('expand', *dsc) self @@ -586,7 +630,37 @@ class Tk::TreeCtrl end def identify(x, y) - list(tk_send('identify', x, y)) + lst = list(tk_send('identify', x, y)) + + if lst[0] == 'item' + lst[1] = Tk::TreeCtrl::Item.id2obj(self, lst[1]) + size = lst.size + i = 2 + while i < size + case lst[i] + when 'line' + i += 1 + lst[i] = Tk::TreeCtrl::Item.id2obj(self, lst[i]) + i += 1 + + when 'button' + i += 1 + + when 'column' + i += 2 + + when 'elem' + i += 1 + lst[i] = Tk::TreeCtrl::Element.id2obj(self, lst[i]) + i += 1 + + else + i += 1 + end + end + end + + lst end def index(idx) @@ -594,7 +668,9 @@ class Tk::TreeCtrl end def item_ancestors(item) - list(tk_send('item', 'ancestors', item)) + list(tk_send('item', 'ancestors', item)).collect!{|id| + Tk::TreeCtrl::Item.id2obj(self, id) + } end def item_bbox(item, *args) @@ -602,7 +678,9 @@ class Tk::TreeCtrl end def item_children(item) - list(tk_send('item', 'children', item)) + list(tk_send('item', 'children', item)).collect!{|id| + Tk::TreeCtrl::Item.id2obj(self, id) + } end def item_collapse(item) @@ -624,7 +702,24 @@ class Tk::TreeCtrl num_or_str(tk_send('item', 'create', keys)) end + def _erase_children(item) + item_children(item).each{|i| _erase_children(i)} + 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) + } + end + end tk_send('item', 'delete', first, last) self end @@ -633,6 +728,10 @@ class Tk::TreeCtrl list(tk_send('item', 'dump', item)) end + def item_dump_hash(item) + Hash[*list(tk_send('item', 'dump', item))] + end + def item_element_actual(item, column, elem, key) tk_send('item', 'element', 'actual', item, column, elem, "-#{key}") end @@ -652,7 +751,8 @@ class Tk::TreeCtrl tk_send('item', 'firstchild', parent, child) self else - num_or_str(tk_send('item', 'firstchild', parent)) + id = num_or_str(tk_send('item', 'firstchild', parent)) + Tk::TreeCtrl::Item.id2obj(self, id) end end alias item_first_child item_firstchild @@ -694,7 +794,8 @@ class Tk::TreeCtrl tk_send('item', 'lastchild', parent, child) self else - num_or_str(tk_send('item', 'lastchild', parent)) + id = num_or_str(tk_send('item', 'lastchild', parent)) + Tk::TreeCtrl::Item.id2obj(self, id) end end alias item_last_child item_lastchild @@ -704,7 +805,8 @@ class Tk::TreeCtrl tk_send('item', 'nextsibling', sibling, nxt) self else - num_or_str(tk_send('item', 'nextsibling', sibling)) + id = num_or_str(tk_send('item', 'nextsibling', sibling)) + Tk::TreeCtrl::Item.id2obj(self, id) end end alias item_next_sibling item_nextsibling @@ -716,7 +818,8 @@ class Tk::TreeCtrl alias item_children_size item_numchildren def item_parent(item) - num_or_str(tk_send('item', 'parent', item)) + id = num_or_str(tk_send('item', 'parent', item)) + Tk::TreeCtrl::Item.id2obj(self, id) end def item_prevsibling(sibling, prev=nil) @@ -724,44 +827,84 @@ class Tk::TreeCtrl tk_send('item', 'prevsibling', sibling, prev) self else - num_or_str(tk_send('item', 'prevsibling', sibling)) + id = num_or_str(tk_send('item', 'prevsibling', sibling)) + Tk::TreeCtrl::Item.id2obj(self, id) end end alias item_prev_sibling item_prevsibling def item_remove(item) - list(tk_send('item', 'remove', item)) + tk_send('item', 'remove', item) + self end def item_rnc(item) list(tk_send('item', 'rnc', item)) end - def item_sort(item, *opts) - flag = false - if opts[-1].kind_of?(Hash) - opts[-1,1] = __conv_item_keyonly_opts(item, opts[-1]).to_a - end + def _item_sort_core(real_sort, item, *opts) + # opts ::= sort_param [, sort_param, ... ] + # sort_param ::= {key=>val, ...} + # [type, desc, {key=>val, ...}] + # param + opts = opts.collect{|param| + if param.kind_of?(Hash) + param = _symbolkey2str(param) + if param.key('column') + key = '-column' + desc = param.delete('column') + elsif param.key('element') + key = '-element' + desc = param.delete('element') + else + key = nil + end + + if param.empty? + param = None + else + param = __conv_item_keyonly_opts(item, param).to_a + end + + if key + [key, desc].concat(param) + else + param + end + + elsif param.kind_of?(Array) + if param[2].kind_of?(Hash) + param[2] = __conv_item_keyonly_opts(item, param[2]).to_a + end + param + + elsif param.kind_of?(String) && param =~ /\A[a-z]+\Z/ + '-' << param + + elsif param.kind_of?(Symbol) + '-' << param.to_s - opts = opts.collect{|opt| - if opt.kind_of?(Array) - key = "-#{opt[0]}" - flag = true if key == '-notreally' - ["-#{opt[0]}", opt[1]] else - key = "-#{opt}" - flag = true if key == '-notreally' - key + param end }.flatten - ret = tk_send('item', 'sort', item, *opts) - if flag - list(ret) + if real_sort + tk_send('item', 'sort', item, *opts) + self else - ret + list(tk_send('item', 'sort', item, '-notreally', *opts)) end end + private :_item_sort_core + + def item_sort_not_really(item, *opts) + _item_sort_core(false, item, *opts) + end + + def item_sort(item, *opts) + _item_sort_core(true, item, *opts) + end def item_state_forcolumn(item, column, *args) tk_send('item', 'state', 'forcolumn', item, column, *args) @@ -783,7 +926,9 @@ class Tk::TreeCtrl end def item_style_elements(item, column) - list(tk_send('item', 'style', 'elements', item, column)) + list(tk_send('item', 'style', 'elements', item, column)).collect!{|id| + Tk::TreeCtrl::Style.id2obj(self, id) + } end def item_style_map(item, column, style, map) @@ -794,12 +939,15 @@ class Tk::TreeCtrl def item_style_set(item, column=nil, *args) if args.empty? if column - tk_send('item', 'style', 'set', item, column) + id = tk_send('item', 'style', 'set', item, column) + Tk::TreeCtrl::Style.id2obj(self, id) else - list(tk_send('item', 'style', 'set', item)) + list(tk_send('item', 'style', 'set', item)).collect!{|id| + Tk::TreeCtrl::Style.id2obj(self, id) + } end else - tk_send('item', 'style', 'set', item, *(args.flatten)) + tk_send('item', 'style', 'set', item, column, *(args.flatten)) self end end @@ -813,7 +961,7 @@ class Tk::TreeCtrl tk_send('item', 'text', item, column) end else - tk_send('item', 'text', item, txt, *args) + tk_send('item', 'text', item, column, txt, *args) self end end @@ -868,7 +1016,9 @@ class Tk::TreeCtrl end def marquee_identify() - list(tk_send('marquee', 'identify')) + list(tk_send('marquee', 'identify')).collect!{|id| + Tk::TreeCtrl::Item.id2obj(self, id) + } end def marquee_visible(st=None) @@ -913,7 +1063,7 @@ class Tk::TreeCtrl self end - def notify_bindremove(obj, event) + def notify_bind_remove(obj, event) _bind_remove([@path, 'notify', 'bind', obj], event) self end @@ -970,17 +1120,25 @@ class Tk::TreeCtrl def numcolumns() num_or_str(tk_send('numcolumns')) end + alias num_columns numcolumns + alias columns_size numcolumns def numitems() num_or_str(tk_send('numitems')) end + alias num_items numitems + alias items_size numitems def orphans() - list(tk_send('orphans')) + list(tk_send('orphans')).collect!{|id| + Tk::TreeCtrl::Item.id2obj(self, id) + } end def range(first, last) - list(tk_send('range', first, last)) + list(tk_send('range', first, last)).collect!{|id| + Tk::TreeCtrl::Item.id2obj(self, id) + } end def state_define(name) @@ -1012,7 +1170,8 @@ class Tk::TreeCtrl end def selection_anchor(item=None) - num_or_str(tk_send('selection', 'anchor', item)) + id = num_or_str(tk_send('selection', 'anchor', item)) + Tk::TreeCtrl::Item.id2obj(self, id) end def selection_clear(*args) # first, last @@ -1025,7 +1184,9 @@ class Tk::TreeCtrl end def selection_get() - list(tk_send('selection', 'get')) + list(tk_send('selection', 'get')).collect!{|id| + Tk::TreeCtrl::Item.id2obj(self, id) + } end def selection_includes(item) @@ -1046,34 +1207,65 @@ 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_send('style', 'delete', *args) self end def style_elements(style, *elems) if elems.empty? - list(tk_send('style', 'elements', style)) + list(tk_send('style', 'elements', style)).collect!{|id| + Tk::TreeCtrl::Element.id2obj(self, id) + } else tk_send('style', 'elements', style, elems.flatten) self end end + def _conv_style_layout_val(sty, val) + case sty.to_s + when 'padx', 'pady', 'ipadx', 'ipady' + number(val) + when 'detach' + bool(val) + when 'union' + simplelist(val).collect!{|elem| + Tk::TreeCtrl::Element.id2obj(self, elem) + } + else + val + end + end + private :_conv_style_layout_val + def style_layout(style, elem, keys=None) if keys && keys != None if keys.kind_of?(Hash) tk_send('style', 'layout', style, elem, *hash_kv(keys)) self else - tk_send('style', 'layout', style, elem, "-#{keys}") + _conv_style_layout_val(keys, + tk_send('style', 'layout', + style, elem, "-#{keys}")) end else - list(tk_send('style', 'layout', style, elem)) + ret = Hash.new + Hash[*simplelist(tk_send('style', 'layout', style, elem))].each{|k, v| + ret[k] = _conv_style_layout_val(k, v) + } + ret end end def style_names() - list(tk_send('style', 'names')) + list(tk_send('style', 'names')).collect!{|id| + Tk::TreeCtrl::Style.id2obj(self, id) + } end def toggle(*items) @@ -1086,3 +1278,554 @@ class Tk::TreeCtrl self end 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} + + 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 + end + + def initialize(parent, keys={}) + @tree = parent + @tpath = parent.path + + keys = _symbolkey2str(keys) + + @path = @id = + keys.delete('tag') || + Tk::TreeCtrl::Column::TreeCtrlColumnID.join(TkCore::INTERP._ip_id_) + + 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! + + @tree.column_create(keys) + end + + def id + @id + end + + def to_s + @id.to_s.dup + end + + def cget(opt) + @tree.column_cget(@tree.column_index(@id), opt) + end + + def configure(*args) + @tree.column_configure(@tree.column_index(@id), *args) + end + + def configinfo(*args) + @tree.column_configinfo(@tree.column_index(@id), *args) + end + + def current_configinfo(*args) + @tree.current_column_configinfo(@tree.column_index(@id), *args) + end + + def delete + @tree.column_delete(@tree.column_index(@id)) + self + end + + def index + @tree.column_index(@id) + end + + def move(before) + @tree.column_move(@tree.column_index(@id), before) + self + end + + def needed_width + @tree.column_needed_width(@tree.column_index(@id)) + end + alias neededwidth needed_width + + def current_width + @tree.column_width(@tree.column_index(@id)) + end +end + +##################### + +class Tk::TreeCtrl::Element < TkObject + TreeCtrlElementID_TBL = TkCore::INTERP.create_table + TreeCtrlElementID = ['treectrl_element'.freeze, '00000'.taint].freeze + TreeCtrlElemTypeToClass = {} + + TkCore::INTERP.init_ip_env{ + Tk::TreeCtrl::Element::TreeCtrlElementID_TBL.clear + } + + def self.type2class(type) + TreeCtrlElemTypeToClass[type] || type + end + + 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[tpath][id] : id + 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! + + @tree.element_create(@id, @type, keys) + end + + def id + @id + end + + def to_s + @id.dup + end + + def cget(opt) + @tree.element_cget(@id, opt) + end + + def configure(*args) + @tree.element_configure(@id, *args) + end + + def configinfo(*args) + @tree.element_configinfo(@id, *args) + end + + def current_configinfo(*args) + @tree.current_element_configinfo(@id, *args) + end + + def delete + @tree.element_delete(@id) + self + end + + def element_type + @tree.element_type(@id) + end + + def element_class + @tree.element_class(@id) + end +end + +class Tk::TreeCtrl::BitmapElement < Tk::TreeCtrl::Element + TreeCtrlElemTypeToClass['bitmap'] = self + + def initialize(parent, keys=nil) + super(parent, 'bitmap', keys) + end +end + +class Tk::TreeCtrl::BorderElement < Tk::TreeCtrl::Element + TreeCtrlElemTypeToClass['border'] = self + + def initialize(parent, keys=nil) + super(parent, 'border', keys) + end +end + +class Tk::TreeCtrl::ImageElement < Tk::TreeCtrl::Element + TreeCtrlElemTypeToClass['image'] = self + + def initialize(parent, keys=nil) + super(parent, 'image', keys) + end +end + +class Tk::TreeCtrl::RectangleElement < Tk::TreeCtrl::Element + TreeCtrlElemTypeToClass['rect'] = self + + def initialize(parent, keys=nil) + super(parent, 'rect', keys) + end +end + +##################### + +class Tk::TreeCtrl::Item < TkObject + TreeCtrlItemID_TBL = TkCore::INTERP.create_table + + TkCore::INTERP.init_ip_env{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 + end + + def initialize(parent, keys={}) + @tree = parent + @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 + end + + def id + @id + end + + def to_s + @id.to_s.dup + end + + def ancestors + @tree.item_ancestors(@id) + end + + def bbox(*args) + @tree.item_bbox(@id, *args) + end + + def children + @tree.item_children(@id) + end + + def collapse + @tree.item_collapse(@id) + self + end + + def collapse_recurse + @tree.item_collapse_recurse(@id) + self + end + + def complex(*args) + @tree.item_complex(@id, *args) + self + end + + def cget(opt) + @tree.item_cget(@id, opt) + end + + def configure(*args) + @tree.item_configure(@id, *args) + end + + def configinfo(*args) + @tree.item_configinfo(@id, *args) + end + + def current_configinfo(*args) + @tree.current_item_configinfo(@id, *args) + end + + def delete + @tree.item_delete(@id) + self + end + + def element_dump + @tree.item_dump(@id) + end + + def element_dump_hash + @tree.item_dump_hash(@id) + end + + def element_actual(column, elem, key) + @tree.item_element_actual(@id, column, elem, key) + end + + def element_cget(opt) + @tree.item_element_cget(@id, opt) + end + + def element_configure(*args) + @tree.item_element_configure(@id, *args) + end + + def element_configinfo(*args) + @tree.item_element_configinfo(@id, *args) + end + + def current_element_configinfo(*args) + @tree.current_item_element_configinfo(@id, *args) + end + + def expand + @tree.item_expand(@id) + self + end + + def expand_recurse + @tree.item_expand_recurse(@id) + self + end + + def firstchild(child=nil) + if child + @tree.item_firstchild(@id, child) + self + else + @tree.item_firstchild(@id) + end + end + alias first_child firstchild + + def hashbutton(st=None) + if st == None + @tree.item_hashbutton(@id) + else + @tree.item_hashbutton(@id, st) + self + end + end + + def hashbutton? + @tree.item_hashbutton(@id) + end + + def index + @tree.item_index(@id) + end + + def isancestor(des) + @tree.item_isancestor(@id, des) + end + alias is_ancestor isancestor + alias isancestor? isancestor + alias is_ancestor? isancestor + alias ancestor? isancestor + + def isopen + @tree.item_isopen(@id) + end + alias is_open isopen + alias isopen? isopen + alias is_open? isopen + alias isopened? isopen + alias is_opened? isopen + alias open? isopen + + def lastchild(child=nil) + if child + @tree.item_lastchild(@id, child) + self + else + @tree.item_lastchild(@id) + end + end + alias last_child lastchild + + def nextsibling(nxt=nil) + if nxt + @tree.item_nextsibling(@id, nxt) + self + else + @tree.item_nextsibling(@id) + end + end + alias next_sibling nextsibling + + def numchildren + @tree.item_numchildren(@id) + end + alias num_children numchildren + alias children_size numchildren + + def parent_index + @tree.item_parent(@id) + end + + def prevsibling(nxt=nil) + if nxt + @tree.item_prevsibling(@id, nxt) + self + else + @tree.item_prevsibling(@id) + end + end + alias prev_sibling prevsibling + + def remove + @tree.item_remove(@id) + end + + def rnc + @tree.item_rnc(@id) + end + + def sort(*opts) + @tree.item_sort(@id, *opts) + end + + def state_forcolumn(column, *args) + @tree.item_state_forcolumn(@id, column, *args) + self + end + alias state_for_column state_forcolumn + + def state_get(*args) + @tree.item_state_get(@id, *args) + end + + def state_set(*args) + @tree.item_state_set(@id, *args) + self + end + + def style_elements(column) + @tree.item_style_elements(@id, column) + end + + def style_map(column, style, map) + @tree.item_style_map(@id, column, style, map) + self + end + + def style_set(column=nil, *args) + if args.empty? + @tree.item_style_set(@id, column) + else + @tree.item_style_set(@id, column, *args) + self + end + end + + def item_text(column, txt=nil, *args) + if args.empty? + if txt + @tree.item_text(@id, column, txt) + self + else + @tree.item_text(@id, column) + end + else + @tree.item_text(@id, column, txt, *args) + self + end + end + + def toggle + @tree.item_toggle(@id) + self + end + + def toggle_recurse + @tree.item_toggle_recurse(@id) + self + end + + def visible(st=None) + if st == None + @tree.item_visible(@id) + else + @tree.item_visible(@id, st) + self + end + end +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 } + + 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 + 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! + + @tree.style_create(@id, keys) + end + + def id + @id + end + + def to_s + @id.dup + end + + def cget(opt) + @tree.style_cget(@id, opt) + end + + def configure(*args) + @tree.style_configure(@id, *args) + end + + def configinfo(*args) + @tree.style_configinfo(@id, *args) + end + + def current_configinfo(*args) + @tree.current_style_configinfo(@id, *args) + end + + def delete + @tree.style_delete(@id) + self + end + + def elements(*elems) + if elems.empty? + @tree.style_elements(@id) + else + @tree.style_elements(@id, *elems) + self + end + end + + def layout(elem, keys=None) + if keys && keys != None && keys.kind_of?(Hash) + @tree.style_layout(@id, elem, keys) + self + else + @tree.style_layout(@id, elem, keys) + end + end +end -- cgit v1.2.3