diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-25 15:13:14 +0000 |
commit | d0233291bc8a5068e52c69c210e5979e5324b5bc (patch) | |
tree | 7d9459449c33792c63eeb7baa071e76352e0baab /trunk/ext/tk/lib/tkextlib/ICONS/icons.rb | |
parent | 0dc342de848a642ecce8db697b8fecd83a63e117 (diff) | |
parent | 72eaacaa15256ab95c3b52ea386f88586fb9da40 (diff) |
re-adding tag v1_9_0_4 as an alias of trunk@18848v1_9_0_4
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_0_4@18849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'trunk/ext/tk/lib/tkextlib/ICONS/icons.rb')
-rw-r--r-- | trunk/ext/tk/lib/tkextlib/ICONS/icons.rb | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/trunk/ext/tk/lib/tkextlib/ICONS/icons.rb b/trunk/ext/tk/lib/tkextlib/ICONS/icons.rb deleted file mode 100644 index b430bae55d..0000000000 --- a/trunk/ext/tk/lib/tkextlib/ICONS/icons.rb +++ /dev/null @@ -1,129 +0,0 @@ -# -# tkextlib/ICONS/icons.rb -# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) -# - -require 'tk' - -# call setup script for general 'tkextlib' libraries -require 'tkextlib/setup.rb' - -# call setup script -require 'tkextlib/ICONS/setup.rb' - -# TkPackage.require('icons', '1.0') -TkPackage.require('icons') - -module Tk - class ICONS < TkImage - extend Tk - - PACKAGE_NAME = 'icons'.freeze - def self.package_name - PACKAGE_NAME - end - - def self.package_version - begin - TkPackage.require('icons') - rescue - '' - end - end - - def self.create(*args) # icon, icon, ..., ?option=>value, ...? - if args[-1].kind_of?(Hash) - keys = args.pop - icons = simplelist(tk_call('::icons::icons', 'create', - *(hash_kv(keys) << (args.flatten)))) - else - icons = simplelist(tk_call('::icons::icons', 'create', - args.flatten)) - end - - icons.collect{|icon| self.new(icon, :without_creating=>true)} - end - - def self.delete(*icons) # icon, icon, ... - icons = icons.flatten - return if icons.empty? - icons.map!{|icon| - if icon.kind_of?(Tk::ICONS) - Tk_IMGTBL.delete(icon.path) - icon.name - elsif icon.to_s =~ /^::icon::(.*)/ - name = $1 - Tk_IMGTBL.delete(icon) - name - else - Tk_IMGTBL.delete("::icon::#{icon}") - icon - end - } - tk_call('::icons::icons', 'delete', icons) - end - - def self.query(*args) # icon, icon, ..., ?option=>value, ...? - if args[-1].kind_of?(Hash) - keys = args.pop - simplelist(tk_call('::icons::icons', 'query', - *(hash_kv(keys) << (args.flatten)))) - else - simplelist(tk_call('::icons::icons', 'query', args.flatten)) - end . map{|inf| list(inf) } - end - - ########################################## - - 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 - end - - ########################################## - - def initialize(name, keys=nil) - if name.kind_of?(String) && name =~ /^::icon::(.+)$/ - @name = $1 - @path = name - else - @name = name.to_s - @path = "::icon::#{@name}" - end - keys = _symbolkey2str(keys) - unless keys.delete('without_creating') - tk_call('::icons::icons', 'create', *(hash_kv(keys) << @name)) - end - Tk_IMGTBL[@path] = self - end - - def name - @name - end - - def delete - Tk_IMGTBL.delete(@path) - tk_call('::icons::icons', 'delete', @name) - self - end - - def query(keys={}) - list(simplelist(tk_call('::icons::icons', 'query', - *(hash_kv(keys) << @name)) - )[0]) - end - end -end |