From e88d2cec1f896a5f23550dcdd5d1f7994e687b79 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 28 Feb 2002 06:53:33 +0000 Subject: * eval.c (rb_mod_include): load modules in argument order. * st.c (st_init_table_with_size): num_bins should be prime numbers (no decrement). * st.c (rehash): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tk.rb | 471 ++++++++++++++++++++++++++++++++----------------- ext/tk/lib/tkcanvas.rb | 148 ++++------------ ext/tk/lib/tkentry.rb | 16 +- ext/tk/lib/tkfont.rb | 2 +- ext/tk/lib/tktext.rb | 125 ++----------- 5 files changed, 376 insertions(+), 386 deletions(-) (limited to 'ext') diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 066864a237..a16694bf76 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -2174,6 +2174,123 @@ module TkTreatFont end end +module TkTreatItemFont + def __conf_cmd(idx) + raise NotImplementError, "need to define `__conf_cmd'" + end + def __item_pathname(tagOrId) + raise NotImplementError, "need to define `__item_pathname'" + end + private :__conf_cmd, :__item_pathname + + def tagfont_configinfo(tagOrId) + pathname = __item_pathname(tagOrId) + ret = TkFont.used_on(pathname) + if ret == nil + ret = TkFont.init_widget_font(pathname, self.path, + __conf_cmd(0), __conf_cmd(1), tagOrId) + end + ret + end + alias tagfontobj tagfont_configinfo + + def tagfont_configure(tagOrId, slot) + pathname = __item_pathname(tagOrId) + if (fnt = slot.delete('font')) + if fnt.kind_of? TkFont + return fnt.call_font_configure(pathname, self.path, + __conf_cmd(0), __conf_cmd(1), + tagOrId, slot) + else + latintagfont_configure(tagOrId, fnt) if fnt + end + end + if (ltn = slot.delete('latinfont')) + latintagfont_configure(tagOrId, ltn) if ltn + end + if (ltn = slot.delete('asciifont')) + latintagfont_configure(tagOrId, ltn) if ltn + end + if (knj = slot.delete('kanjifont')) + kanjitagfont_configure(tagOrId, knj) if knj + end + + tk_call(self.path, __conf_cmd(0), __conf_cmd(1), + tagOrId, *hash_kv(slot)) if slot != {} + self + end + + def latintagfont_configure(tagOrId, ltn, keys=nil) + fobj = tagfontobj(tagOrId) + if ltn.kind_of? TkFont + conf = {} + ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []} + if conf == {} + fobj.latin_replace(ltn) + fobj.latin_configure(keys) if keys + elsif keys + fobj.latin_configure(conf.update(keys)) + else + fobj.latin_configure(conf) + end + else + fobj.latin_replace(ltn) + end + end + alias asciitagfont_configure latintagfont_configure + + def kanjitagfont_configure(tagOrId, knj, keys=nil) + fobj = tagfontobj(tagOrId) + if knj.kind_of? TkFont + conf = {} + knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []} + if conf == {} + fobj.kanji_replace(knj) + fobj.kanji_configure(keys) if keys + elsif keys + fobj.kanji_configure(conf.update(keys)) + else + fobj.kanji_configure(conf) + end + else + fobj.kanji_replace(knj) + end + end + + def tagfont_copy(tagOrId, window, wintag=nil) + if wintag + window.tagfontobj(wintag).configinfo.each{|key,value| + tagfontobj(tagOrId).configure(key,value) + } + tagfontobj(tagOrId).replace(window.tagfontobj(wintag).latin_font, + window.tagfontobj(wintag).kanji_font) + else + window.tagfont(wintag).configinfo.each{|key,value| + tagfontobj(tagOrId).configure(key,value) + } + tagfontobj(tagOrId).replace(window.fontobj.latin_font, + window.fontobj.kanji_font) + end + end + + def latintagfont_copy(tagOrId, window, wintag=nil) + if wintag + tagfontobj(tagOrId).latin_replace(window.tagfontobj(wintag).latin_font) + else + tagfontobj(tagOrId).latin_replace(window.fontobj.latin_font) + end + end + alias asciitagfont_copy latintagfont_copy + + def kanjitagfont_copy(tagOrId, window, wintag=nil) + if wintag + tagfontobj(tagOrId).kanji_replace(window.tagfontobj(wintag).kanji_font) + else + tagfontobj(tagOrId).kanji_replace(window.fontobj.kanji_font) + end + end +end + class TkObjectval}) + tagfont_configure(index, {key=>val}) else tk_call 'itemconfigure', index, "-#{key}", val end @@ -2995,109 +3228,15 @@ class TkListbox @@ -9,116 +9,18 @@ require "tk" require 'tkfont' module TkTreatCItemFont - def tagfont_configinfo(tagOrId) - if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag) - pathname = self.path + ';' + tagOrId.id.to_s - else - pathname = self.path + ';' + tagOrId.to_s - end - ret = TkFont.used_on(pathname) - if ret == nil - ret = TkFont.init_widget_font(pathname, - self.path, 'itemconfigure', tagOrId) - end - ret - end - alias tagfontobj tagfont_configinfo + include TkTreatItemFont - def tagfont_configure(tagOrId, slot) - if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag) - pathname = self.path + ';' + tagOrId.id.to_s - else - pathname = self.path + ';' + tagOrId.to_s - end - if (fnt = slot.delete('font')) - if fnt.kind_of? TkFont - return fnt.call_font_configure(pathname, - self.path,'itemconfigure',tagOrId,slot) - else - latintagfont_configure(tagOrId, fnt) if fnt - end - end - if (ltn = slot.delete('latinfont')) - latintagfont_configure(tagOrId, ltn) if ltn - end - if (ltn = slot.delete('asciifont')) - latintagfont_configure(tagOrId, ltn) if ltn - end - if (knj = slot.delete('kanjifont')) - kanjitagfont_configure(tagOrId, knj) if knj - end - - tk_call(self.path, 'itemconfigure', tagOrId, *hash_kv(slot)) if slot != {} - self + ItemCMD = ['itemconfigure', TkComm::None] + def __conf_cmd(idx) + ItemCMD[idx] end - def latintagfont_configure(tagOrId, ltn, keys=nil) - fobj = tagfontobj(tagOrId) - if ltn.kind_of? TkFont - conf = {} - ltn.latin_configinfo.each{|key,val| conf[key] = val if val != []} - if conf == {} - fobj.latin_replace(ltn) - fobj.latin_configure(keys) if keys - elsif keys - fobj.latin_configure(conf.update(keys)) - else - fobj.latin_configure(conf) - end - else - fobj.latin_replace(ltn) - end - end - alias asciitagfont_configure latintagfont_configure - - def kanjitagfont_configure(tagOrId, knj, keys=nil) - fobj = tagfontobj(tagOrId) - if knj.kind_of? TkFont - conf = {} - knj.kanji_configinfo.each{|key,val| conf[key] = val if val != []} - if conf == {} - fobj.kanji_replace(knj) - fobj.kanji_configure(keys) if keys - elsif keys - fobj.kanji_configure(conf.update(keys)) - else - fobj.kanji_configure(conf) - end - else - fobj.kanji_replace(knj) - end - end - - def tagfont_copy(tagOrId, window, wintag=nil) - if wintag - window.tagfontobj(wintag).configinfo.each{|key,value| - tagfontobj(tagOrId).configure(key,value) - } - tagfontobj(tagOrId).replace(window.tagfontobj(wintag).latin_font, - window.tagfontobj(wintag).kanji_font) - else - window.tagfont(tagOrId).configinfo.each{|key,value| - tagfontobj(tagOrId).configure(key,value) - } - tagfontobj(tagOrId).replace(window.fontobj.latin_font, - window.fontobj.kanji_font) - end - end - - def latintagfont_copy(tagOrId, window, wintag=nil) - if wintag - tagfontobj(tagOrId).latin_replace(window.tagfontobj(wintag).latin_font) - else - tagfontobj(tagOrId).latin_replace(window.fontobj.latin_font) - end - end - alias asciitagfont_copy latintagfont_copy - - def kanjitagfont_copy(tagOrId, window, wintag=nil) - if wintag - tagfontobj(tagOrId).kanji_replace(window.tagfontobj(wintag).kanji_font) + def __item_pathname(tagOrId) + if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag) + self.path + ';' + tagOrId.id.to_s else - tagfontobj(tagOrId).kanji_replace(window.fontobj.kanji_font) + self.path + ';' + tagOrId.to_s end end end @@ -133,8 +35,12 @@ class TkCanvasval}) + tagfont_configure(tag, {key=>val}) else tk_send 'tag', 'configure', tag, "-#{key}", val end -- cgit v1.2.3