From 54ec1c4fe81672ca66f327ef6ae170f458cd79e5 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Wed, 15 Aug 2007 20:57:30 +0000 Subject: sorry. I made wrong tags. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_8_5_54@13009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby_1_8_5/ext/tk/lib/tk/menu.rb | 632 --------------------------------------- 1 file changed, 632 deletions(-) delete mode 100644 ruby_1_8_5/ext/tk/lib/tk/menu.rb (limited to 'ruby_1_8_5/ext/tk/lib/tk/menu.rb') diff --git a/ruby_1_8_5/ext/tk/lib/tk/menu.rb b/ruby_1_8_5/ext/tk/lib/tk/menu.rb deleted file mode 100644 index ddddc8e53e..0000000000 --- a/ruby_1_8_5/ext/tk/lib/tk/menu.rb +++ /dev/null @@ -1,632 +0,0 @@ -# -# tk/menu.rb : treat menu and menubutton -# -require 'tk' -require 'tk/itemconfig' -require 'tk/menuspec' - -module TkMenuEntryConfig - include TkItemConfigMethod - - def __item_cget_cmd(id) - [self.path, 'entrycget', id] - end - private :__item_cget_cmd - - def __item_config_cmd(id) - [self.path, 'entryconfigure', id] - end - private :__item_config_cmd - - def __item_strval_optkeys(id) - super(id) << 'selectcolor' - end - private :__item_strval_optkeys - - def __item_listval_optkeys(id) - [] - end - private :__item_listval_optkeys - - def __item_val2ruby_optkeys(id) # { key=>proc, ... } - super(id).update('menu'=>proc{|i, v| window(v)}) - end - private :__item_val2ruby_optkeys - - alias entrycget itemcget - alias entryconfigure itemconfigure - alias entryconfiginfo itemconfiginfo - alias current_entryconfiginfo current_itemconfiginfo - - private :itemcget, :itemconfigure - private :itemconfiginfo, :current_itemconfiginfo -end - -class TkMenuval}) - end - else - tk_call('entryconfigure', index, "-#{key}", val) - end - end - self - end - - def entryconfiginfo(index, key=nil) - if TkComm::GET_CONFIGINFO_AS_ARRAY - if key - case key.to_s - when 'text', 'label', 'show' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) - when 'font', 'kanjifont' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) - conf[4] = tagfont_configinfo(index, conf[4]) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) - end - conf[0] = conf[0][1..-1] - conf - else - ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] - when 'text', 'label', 'show' - else - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - if conf[4] - if conf[4].index('{') - conf[4] = tk_split_list(conf[4]) - else - conf[4] = tk_tcl2ruby(conf[4]) - end - end - end - conf[1] = conf[1][1..-1] if conf.size == 2 # alias info - conf - } - if fontconf - ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'} - fontconf[4] = tagfont_configinfo(index, fontconf[4]) - ret.push(fontconf) - else - ret - end - end - else # ! TkComm::GET_CONFIGINFO_AS_ARRAY - if key - case key.to_s - when 'text', 'label', 'show' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) - when 'font', 'kanjifont' - conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) - conf[4] = tagfont_configinfo(index, conf[4]) - else - conf = tk_split_list(_fromUTF8(tk_send_without_enc('entryconfigure',_get_eval_enc_str(index),"-#{key}"))) - end - key = conf.shift[1..-1] - { key => conf } - else - ret = {} - tk_split_simplelist(_fromUTF8(tk_send_without_enc('entryconfigure', _get_eval_enc_str(index)))).each{|conflist| - conf = tk_split_simplelist(conflist) - key = conf.shift[1..-1] - case key - when 'text', 'label', 'show' - else - if conf[2] - if conf[2].index('{') - conf[2] = tk_split_list(conf[2]) - else - conf[2] = tk_tcl2ruby(conf[2]) - end - end - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) - end - end - end - if conf.size == 1 - ret[key] = conf[0][1..-1] # alias info - else - ret[key] = conf - end - } - fontconf = ret['font'] - if fontconf - ret.delete('font') - ret.delete('kanjifont') - fontconf[3] = tagfont_configinfo(index, fontconf[3]) - ret['font'] = fontconf - end - ret - end - end - end - - def current_entryconfiginfo(index, key=nil) - if TkComm::GET_CONFIGINFO_AS_ARRAY - if key - conf = entryconfiginfo(index, key) - {conf[0] => conf[4]} - else - ret = {} - entryconfiginfo(index).each{|conf| - ret[conf[0]] = conf[4] if conf.size > 2 - } - ret - end - else # ! TkComm::GET_CONFIGINFO_AS_ARRAY - ret = {} - entryconfiginfo(index, key).each{|k, conf| - ret[k] = conf[-1] if conf.kind_of?(Array) - } - ret - end - end -=end -end - - -class TkMenuClone return value of tk_optionMenu - @path = path - #TkComm::Tk_WINDOWS[@path] = self - TkCore::INTERP.tk_windows[@path] = self - end - end - - def initialize(*args) - # args :: [parent,] [var,] [value[, ...],] [keys] - # parent --> TkWindow or nil - # var --> TkVariable or nil - # keys --> Hash - # keys[:parent] or keys['parent'] --> parent - # keys[:variable] or keys['variable'] --> var - # keys[:values] or keys['values'] --> value, ... - # other Hash keys are menubutton options - keys = {} - keys = args.pop if args[-1].kind_of?(Hash) - keys = _symbolkey2str(keys) - - parent = nil - if args[0].kind_of?(TkWindow) || args[0] == nil - keys.delete('parent') # ignore - parent = args.shift - else - parent = keys.delete('parent') - end - - @variable = nil - if args[0].kind_of?(TkVariable) || args[0] == nil - keys.delete('variable') # ignore - @variable = args.shift - else - @variable = keys.delete('variable') - end - @variable = TkVariable.new unless @variable - - (args = keys.delete('values') || []) if args.empty? - if args.empty? - args << @variable.value - else - @variable.value = args[0] - end - - install_win(if parent then parent.path end) - @menu = OptionMenu.new(tk_call('tk_optionMenu', - @path, @variable.id, *args)) - - configure(keys) if keys - end - - def value - @variable.value - end - - def value=(val) - @variable.value = val - end - - def activate(index) - @menu.activate(index) - self - end - def add(value) - @menu.add('radiobutton', 'variable'=>@variable, - 'label'=>value, 'value'=>value) - self - end - def index(index) - @menu.index(index) - end - def invoke(index) - @menu.invoke(index) - end - def insert(index, value) - @menu.insert(index, 'radiobutton', 'variable'=>@variable, - 'label'=>value, 'value'=>value) - self - end - def delete(index, last=None) - @menu.delete(index, last) - self - end - def yposition(index) - @menu.yposition(index) - end - def menu - @menu - end - def menucget(key) - @menu.cget(key) - end - def menuconfigure(key, val=None) - @menu.configure(key, val) - self - end - def menuconfiginfo(key=nil) - @menu.configinfo(key) - end - def current_menuconfiginfo(key=nil) - @menu.current_configinfo(key) - end - def entrycget(index, key) - @menu.entrycget(index, key) - end - def entryconfigure(index, key, val=None) - @menu.entryconfigure(index, key, val) - self - end - def entryconfiginfo(index, key=nil) - @menu.entryconfiginfo(index, key) - end - def current_entryconfiginfo(index, key=nil) - @menu.current_entryconfiginfo(index, key) - end -end -TkOptionMenuButton = TkOptionMenubutton -- cgit v1.2.3