From 21cce8dc191d640846bf473c0b9576d6cf3844da Mon Sep 17 00:00:00 2001 From: nagai Date: Fri, 18 Nov 2005 22:37:53 +0000 Subject: * ext/tk/lib/tk/font.rb: remove dependency on Ruby's version (1.8 or 1.9). * ext/tk/lib/tkextlib/ICONS/icons.rb: ditto. * ext/tk/sample/tkextlib/treectrl/demo.rb: ditto. * ext/tk/lib/tk.rb: update RELEASE_DATE git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@9564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/tk/lib/tk.rb | 2 +- ext/tk/lib/tk/font.rb | 27 ++++++++++++++------------- ext/tk/lib/tkextlib/ICONS/icons.rb | 22 +++++++++++++++++----- 3 files changed, 32 insertions(+), 19 deletions(-) (limited to 'ext/tk/lib') diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 3e6c0c0a0..0d18882d8 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -4499,7 +4499,7 @@ end #Tk.freeze module Tk - RELEASE_DATE = '2005-11-18'.freeze + RELEASE_DATE = '2005-11-19'.freeze autoload :AUTO_PATH, 'tk/variable' autoload :TCL_PACKAGE_PATH, 'tk/variable' diff --git a/ext/tk/lib/tk/font.rb b/ext/tk/lib/tk/font.rb index 8e63558ca..f7ea973a7 100644 --- a/ext/tk/lib/tk/font.rb +++ b/ext/tk/lib/tk/font.rb @@ -488,6 +488,19 @@ class TkFont create_compoundfont(ltn, knj, keys) end + def initialize_copy(font) + unless font.kind_of?(TkFont) + fail TypeError, '"initialize_copy should take same class object' + end + if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY + keys = {} + font.configinfo.each{|key,value| keys[key] = value } + initialize(font.latin_font_id, font.kanji_font_id, keys) + else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY + initialize(font.latin_font_id, font.kanji_font_id, font.configinfo) + end + end + def _get_font_info_from_hash(font) font = _symbolkey2str(font) foundry = (info = font['foundry'] .to_s)? info: '*' @@ -1183,25 +1196,13 @@ class TkFont ################################### =begin - 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 dup TkFont.new(self) end def clone TkFont.new(self) end +=end end module TkFont::CoreMethods diff --git a/ext/tk/lib/tkextlib/ICONS/icons.rb b/ext/tk/lib/tkextlib/ICONS/icons.rb index 8a37e35eb..b430bae55 100644 --- a/ext/tk/lib/tkextlib/ICONS/icons.rb +++ b/ext/tk/lib/tkextlib/ICONS/icons.rb @@ -75,14 +75,26 @@ module Tk ########################################## - def self.new(name, keys=nil) - unless obj = Tk_IMGTBL["::icon::#{name}"] - obj = allocate() - obj.instance_eval{initialize(name, keys)} + class << self + alias _new new + + def new(name, keys=nil) + if obj = Tk_IMGTBL["::icon::#{name}"] + if keys + keys = _symbolkey2str(keys) + unless keys.delete('without_creating') + tk_call('::icons::icons', 'create', *(hash_kv(keys) << obj.name)) + end + end + else + obj = _new(name, keys) + end + obj end - obj end + ########################################## + def initialize(name, keys=nil) if name.kind_of?(String) && name =~ /^::icon::(.+)$/ @name = $1 -- cgit