diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-01 16:09:54 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-05-01 16:09:54 +0000 |
commit | f1c3638777c89f9b085ba0aa3863e3f5691154e3 (patch) | |
tree | 795f5cae59103ce5b7fc91cfd3d706ee7a746ba2 /ext/tk | |
parent | 9857d6c5462ce5a0a9194b85937d977fc042323a (diff) |
* renewal Ruby/Tk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk')
123 files changed, 3848 insertions, 10742 deletions
diff --git a/ext/tk/MANIFEST b/ext/tk/MANIFEST index 503adaabb7..32d8029de1 100644 --- a/ext/tk/MANIFEST +++ b/ext/tk/MANIFEST @@ -1,5 +1,6 @@ MANIFEST README.1st +README.fork extconf.rb depend tkutil.c @@ -22,6 +23,77 @@ lib/tkscrollbox.rb lib/tktext.rb lib/tkvirtevent.rb lib/tkwinpkg.rb +lib/tk/after.rb +lib/tk/autoload.rb +lib/tk/bgerror.rb +lib/tk/bindtag.rb +lib/tk/button.rb +lib/tk/canvas.rb +lib/tk/canvastag.rb +lib/tk/checkbutton.rb +lib/tk/clipboard.rb +lib/tk/clock.rb +lib/tk/composite.rb +lib/tk/console.rb +lib/tk/dialog.rb +lib/tk/encodedstr.rb +lib/tk/entry.rb +lib/tk/event.rb +lib/tk/font.rb +lib/tk/frame.rb +lib/tk/grid.rb +lib/tk/image.rb +lib/tk/itemfont.rb +lib/tk/kinput.rb +lib/tk/label.rb +lib/tk/labelframe.rb +lib/tk/listbox.rb +lib/tk/macpkg.rb +lib/tk/menu.rb +lib/tk/menubar.rb +lib/tk/message.rb +lib/tk/mngfocus.rb +lib/tk/msgcat.rb +lib/tk/namespace.rb +lib/tk/optiondb.rb +lib/tk/pack.rb +lib/tk/package.rb +lib/tk/palette.rb +lib/tk/panedwindow.rb +lib/tk/place.rb +lib/tk/radiobutton.rb +lib/tk/root.rb +lib/tk/scale.rb +lib/tk/scrollable.rb +lib/tk/scrollbar.rb +lib/tk/scrollbox.rb +lib/tk/selection.rb +lib/tk/spinbox.rb +lib/tk/tagfont.rb +lib/tk/text.rb +lib/tk/textimage.rb +lib/tk/textmark.rb +lib/tk/texttag.rb +lib/tk/textwindow.rb +lib/tk/timer.rb +lib/tk/toplevel.rb +lib/tk/txtwin_abst.rb +lib/tk/validation.rb +lib/tk/variable.rb +lib/tk/virtevent.rb +lib/tk/winfo.rb +lib/tk/winpkg.rb +lib/tk/wm.rb +lib/tk/xim.rb +sample/binding_sample.rb +sample/bindtag_sample.rb +sample/binstr_usage.rb +sample/btn_with_frame.rb +sample/encstr_usage.rb +sample/iso2022-kr.txt +sample/propagate.rb +sample/resource.en +sample/resource.ja sample/safe-tk.rb sample/tkalignbox.rb sample/tkballoonhelp.rb @@ -33,20 +105,22 @@ sample/tkfrom.rb sample/tkhello.rb sample/tkline.rb sample/tkmenubutton.rb +sample/tkmsgcat-load_rb.rb +sample/tkmsgcat-load_rb2.rb +sample/tkmsgcat-load_tk.rb sample/tkmulticolumnlist.rb sample/tkmultilistbox.rb sample/tkmultilistframe.rb sample/tkoptdb-safeTk.rb sample/tkoptdb.rb sample/tktextframe.rb -sample/resource.ja -sample/resource.en sample/tktimer.rb sample/tktimer2.rb sample/tktimer3.rb sample/demos-en/ChangeLog sample/demos-en/ChangeLog.prev sample/demos-en/README +sample/demos-en/README.1st sample/demos-en/README.tkencoding sample/demos-en/arrow.rb sample/demos-en/bind.rb @@ -55,6 +129,7 @@ sample/demos-en/browse1 sample/demos-en/browse2 sample/demos-en/button.rb sample/demos-en/check.rb +sample/demos-en/check2.rb sample/demos-en/clrpick.rb sample/demos-en/colors.rb sample/demos-en/cscroll.rb @@ -71,6 +146,7 @@ sample/demos-en/entry2.rb sample/demos-en/entry3.rb sample/demos-en/filebox.rb sample/demos-en/floor.rb +sample/demos-en/floor2.rb sample/demos-en/form.rb sample/demos-en/hello sample/demos-en/hscale.rb @@ -78,19 +154,6 @@ sample/demos-en/icon.rb sample/demos-en/image1.rb sample/demos-en/image2.rb sample/demos-en/image3.rb -sample/demos-en/images/earth.gif -sample/demos-en/images/earthris.gif -sample/demos-en/images/face.xbm -sample/demos-en/images/flagdown.xbm -sample/demos-en/images/flagup.xbm -sample/demos-en/images/gray25.xbm -sample/demos-en/images/grey.25 -sample/demos-en/images/grey.5 -sample/demos-en/images/letters.xbm -sample/demos-en/images/noletter.xbm -sample/demos-en/images/pattern.xbm -sample/demos-en/images/tcllogo.gif -sample/demos-en/images/teapot.ppm sample/demos-en/items.rb sample/demos-en/ixset sample/demos-en/ixset2 @@ -107,6 +170,7 @@ sample/demos-en/plot.rb sample/demos-en/puzzle.rb sample/demos-en/radio.rb sample/demos-en/radio2.rb +sample/demos-en/radio3.rb sample/demos-en/rmt sample/demos-en/rolodex sample/demos-en/rolodex-j @@ -123,6 +187,7 @@ sample/demos-en/text.rb sample/demos-en/timer sample/demos-en/tkencoding.rb sample/demos-en/twind.rb +sample/demos-en/twind2.rb sample/demos-en/unicodeout.rb sample/demos-en/vscale.rb sample/demos-en/widget @@ -134,6 +199,7 @@ sample/demos-jp/browse1 sample/demos-jp/browse2 sample/demos-jp/button.rb sample/demos-jp/check.rb +sample/demos-jp/check2.rb sample/demos-jp/clrpick.rb sample/demos-jp/colors.rb sample/demos-jp/cscroll.rb @@ -150,6 +216,7 @@ sample/demos-jp/entry2.rb sample/demos-jp/entry3.rb sample/demos-jp/filebox.rb sample/demos-jp/floor.rb +sample/demos-jp/floor2.rb sample/demos-jp/form.rb sample/demos-jp/hello sample/demos-jp/hscale.rb @@ -157,19 +224,6 @@ sample/demos-jp/icon.rb sample/demos-jp/image1.rb sample/demos-jp/image2.rb sample/demos-jp/image3.rb -sample/demos-jp/images/earth.gif -sample/demos-jp/images/earthris.gif -sample/demos-jp/images/face.bmp -sample/demos-jp/images/flagdown.bmp -sample/demos-jp/images/flagup.bmp -sample/demos-jp/images/gray25.bmp -sample/demos-jp/images/grey.25 -sample/demos-jp/images/grey.5 -sample/demos-jp/images/letters.bmp -sample/demos-jp/images/noletter.bmp -sample/demos-jp/images/pattern.bmp -sample/demos-jp/images/tcllogo.gif -sample/demos-jp/images/teapot.ppm sample/demos-jp/items.rb sample/demos-jp/ixset sample/demos-jp/ixset2 @@ -186,6 +240,7 @@ sample/demos-jp/plot.rb sample/demos-jp/puzzle.rb sample/demos-jp/radio.rb sample/demos-jp/radio2.rb +sample/demos-jp/radio3.rb sample/demos-jp/rmt sample/demos-jp/rolodex sample/demos-jp/rolodex-j @@ -200,6 +255,51 @@ sample/demos-jp/tcolor sample/demos-jp/text.rb sample/demos-jp/timer sample/demos-jp/twind.rb +sample/demos-jp/twind2.rb sample/demos-jp/unicodeout.rb sample/demos-jp/vscale.rb sample/demos-jp/widget +sample/images/earth.gif +sample/images/earthris.gif +sample/images/face.xbm +sample/images/flagdown.xbm +sample/images/flagup.xbm +sample/images/gray25.xbm +sample/images/grey.25 +sample/images/grey.5 +sample/images/letters.xbm +sample/images/noletter.xbm +sample/images/pattern.xbm +sample/images/tcllogo.gif +sample/images/teapot.ppm +sample/msgs_rb/README +sample/msgs_rb/cs.msg +sample/msgs_rb/de.msg +sample/msgs_rb/el.msg +sample/msgs_rb/en.msg +sample/msgs_rb/en_gb.msg +sample/msgs_rb/eo.msg +sample/msgs_rb/es.msg +sample/msgs_rb/fr.msg +sample/msgs_rb/it.msg +sample/msgs_rb/ja.msg +sample/msgs_rb/nl.msg +sample/msgs_rb/pl.msg +sample/msgs_rb/ru.msg +sample/msgs_rb2/README +sample/msgs_rb2/de.msg +sample/msgs_rb2/ja.msg +sample/msgs_tk/README +sample/msgs_tk/cs.msg +sample/msgs_tk/de.msg +sample/msgs_tk/el.msg +sample/msgs_tk/en.msg +sample/msgs_tk/en_gb.msg +sample/msgs_tk/eo.msg +sample/msgs_tk/es.msg +sample/msgs_tk/fr.msg +sample/msgs_tk/it.msg +sample/msgs_tk/ja.msg +sample/msgs_tk/nl.msg +sample/msgs_tk/pl.msg +sample/msgs_tk/ru.msg diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb index f769b06e30..4f87d527ae 100644 --- a/ext/tk/extconf.rb +++ b/ext/tk/extconf.rb @@ -1,2 +1,3 @@ require 'mkmf' +$preload = ["tcltklib"] create_makefile("tkutil") diff --git a/ext/tk/lib/multi-tk.rb b/ext/tk/lib/multi-tk.rb index c2dcb4f971..a3cd3857a0 100644 --- a/ext/tk/lib/multi-tk.rb +++ b/ext/tk/lib/multi-tk.rb @@ -3,6 +3,7 @@ # by Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> require 'tcltklib' +require 'tkutil' require 'thread' ################################################ @@ -13,7 +14,6 @@ TclTkLib.mainloop_abort_on_exception = true # TclTkLib.mainloop_abort_on_exception = nil - ################################################ # exceptiopn to treat the return value from IP class MultiTkIp_OK < Exception @@ -48,12 +48,15 @@ class MultiTkIp ###################################### - @@CB_ENTRY_CLASS = Class.new{|c| + @@CB_ENTRY_CLASS = Class.new(TkCallbackEntry){|c| def initialize(ip, cmd) @ip = ip @cmd = cmd end attr_reader :ip, :cmd + def inspect + cmd.inspect + end def call(*args) begin unless @ip.deleted? @@ -68,8 +71,11 @@ class MultiTkIp ###################################### - def _keys2opts(keys) - keys.collect{|k,v| "-#{k} #{v}"}.join(' ') + def _keys2opts(src_keys) + return nil if src_keys == nil + keys = {}; src_keys.each{|k, v| keys[k.to_s] = v} + #keys.collect{|k,v| "-#{k} #{v}"}.join(' ') + keys.collect{|k,v| "-#{k} #{TclTkLib._conv_listelement(TkComm::_get_eval_string(v))}"}.join(' ') end private :_keys2opts @@ -136,10 +142,11 @@ class MultiTkIp rescue SystemExit # delete IP unless @interp.deleted? - if @interp._invoke('info', 'command', '.') != "" - @interp._invoke('destroy', '.') - end - @interp.delete + # if @interp._invoke('info', 'command', '.') != "" + # @interp._invoke('destroy', '.') + # end + # @interp.delete + @interp._eval_without_enc('exit') end _check_and_return(thread, MultiTkIp_OK.new(nil)) break @@ -200,14 +207,14 @@ class MultiTkIp @@DEFAULT_MASTER = self.allocate @@DEFAULT_MASTER.instance_eval{ - @encoding = [].taint - @tk_windows = {}.taint @tk_table_list = [].taint @slave_ip_tbl = {}.taint + @slave_ip_top = {}.taint + unless keys.kind_of? Hash fail ArgumentError, "expecting a Hash object for the 2nd argument" end @@ -274,23 +281,28 @@ class MultiTkIp tk_opts = {} keys.each{|k,v| - if k.to_s == 'name' + k_str = k.to_s + if k_str == 'name' name = v - elsif k.to_s == 'safe' + elsif k_str == 'safe' safe = v - elsif SAFE_OPT_LIST.member?(k.to_s) - safe_opts[k] = v + elsif SAFE_OPT_LIST.member?(k_str) + safe_opts[k_str] = v else - tk_opts[k] = v + tk_opts[k_str] = v end } - [name, safe, safe_opts, tk_opts] + if keys['without_tk'] || keys[:without_tk] + [name, safe, safe_opts, nil] + else + [name, safe, safe_opts, tk_opts] + end end private :_parse_slaveopts def _create_slave_ip_name - name = SLAVE_IP_ID.join + name = SLAVE_IP_ID.join('') SLAVE_IP_ID[1].succ! name end @@ -388,14 +400,18 @@ class MultiTkIp # procedure to delete slave interpreter slave_delete_proc = proc{ unless slave_ip.deleted? - if slave_ip._invoke('info', 'command', '.') != "" - slave_ip._invoke('destroy', '.') - end - slave_ip.delete + #if slave_ip._invoke('info', 'command', '.') != "" + # slave_ip._invoke('destroy', '.') + #end + #slave_ip.delete + slave_ip._eval_without_enc('exit') end + top.destroy if top.winfo_exist? } tag = TkBindTag.new.bind('Destroy', slave_delete_proc) + top.bindtags = top.bindtags.unshift(tag) + # create control frame TkFrame.new(top, :bg=>'red', :borderwidth=>3, :relief=>'ridge') {|fc| fc.bindtags = fc.bindtags.unshift(tag) @@ -421,23 +437,45 @@ class MultiTkIp # return keys loadTk_keys['use'] = TkWinfo.id(c) - loadTk_keys + [loadTk_keys, top.path] end private :__create_safetk_frame def __create_safe_slave_obj(safe_opts, app_name, tk_opts) # safe interpreter - # at present, not enough support for '-deleteHook' option ip_name = _create_slave_ip_name slave_ip = @interp.create_slave(ip_name, true) - @interp._eval("::safe::interpInit #{ip_name} "+_keys2opts(safe_opts)) - tk_opts = __check_safetk_optkeys(tk_opts) - unless tk_opts.key?('use') - tk_opts = __create_safetk_frame(slave_ip, ip_name, app_name, tk_opts) - end - slave_ip._invoke('set', 'argv0', app_name) if app_name.kind_of?(String) - @interp._eval("::safe::loadTk #{ip_name} #{_keys2opts(tk_opts)}") @slave_ip_tbl[ip_name] = slave_ip + + @interp._eval("::safe::interpInit #{ip_name}") + + slave_ip._invoke('set', 'argv0', app_name) if app_name.kind_of?(String) + + if tk_opts + tk_opts = __check_safetk_optkeys(tk_opts) + if tk_opts.key?('use') + @slave_ip_top[ip_name] = '' + else + tk_opts, top_path = __create_safetk_frame(slave_ip, ip_name, app_name, + tk_opts) + @slave_ip_top[ip_name] = top_path + end + @interp._eval("::safe::loadTk #{ip_name} #{_keys2opts(tk_opts)}") + else + @slave_ip_top[ip_name] = nil + end + + if safe_opts.key?('deleteHook') || safe_opts.key?(:deleteHook) + @interp._eval("::safe::interpConfigure #{ip_name} " + + _keys2opts(safe_opts)) + else + @interp._eval("::safe::interpConfigure #{ip_name} " + + _keys2opts(safe_opts) + '-deleteHook {' + + TkComm._get_eval_string(proc{|slave| + self._default_delete_hook(slave) + }) + '}') + end + [slave_ip, ip_name] end @@ -481,15 +519,15 @@ class MultiTkIp fail ArgumentError, "expecting a Hash object for the 2nd argument" end - @encoding = [] @tk_windows = {} @tk_table_list = [] @slave_ip_tbl = {} + @slave_ip_top = {} - @encoding.taint unless @encoding.tainted? @tk_windows.taint unless @tk_windows.tainted? @tk_table_list.taint unless @tk_table_list.tainted? @slave_ip_tbl.taint unless @slave_ip_tbl.tainted? + @slave_ip_top.taint unless @slave_ip_top.tainted? name, safe, safe_opts, tk_opts = _parse_slaveopts(keys) @@ -532,6 +570,34 @@ class MultiTkIp self.freeze # defend against modification end + + ###################################### + + def _default_delete_hook(slave) + if @slave_ip_top[slave].kind_of?(String) + # call default hook of safetk.tcl (ignore exceptions) + if @slave_ip_top[slave] == '' + begin + @interp._eval("::safe::disallowTk #{slave}") + rescue + warn("Waring: fail to call '::safe::disallowTk'") if $DEBUG + end + else # toplevel path + begin + @interp._eval("::safe::tkDelete {} #{@slave_ip_top[slave]} #{slave}") + rescue + warn("Waring: fail to call '::safe::tkDelete'") if $DEBUG + begin + @interp._eval("destroy #{@slave_ip_top[slave]}") + rescue + warn("Waring: fail to destroy toplevel") if $DEBUG + end + end + end + end + @slave_ip_tbl.delete(slave) + @slave_ip_top.delete(slave) + end end @@ -796,6 +862,10 @@ class MultiTkIp rescue SystemExit # exit IP warn("Warning: "+ $! + " on " + self.inspect) if $DEBUG + begin + self._eval_without_enc('exit') + rescue Exception + end self.delete ret = nil rescue Exception => e @@ -823,6 +893,10 @@ class MultiTkIp rescue SystemExit # exit IP warn("Warning: " + $! + " on " + self.inspect) if $DEBUG + begin + self._eval_without_enc('exit') + rescue Exception + end self.delete rescue Exception => e # others --> warning @@ -868,10 +942,12 @@ class << MultiTkIp __getip.do_one_event(flag) end def mainloop_abort_on_exception - __getip.mainloop_abort_on_exception + # __getip.mainloop_abort_on_exception + TclTkLib.mainloop_abort_on_exception end def mainloop_abort_on_exception=(mode) - __getip.mainloop_abort_on_exception=(mode) + # __getip.mainloop_abort_on_exception=(mode) + TclTkLib.mainloop_abort_on_exception=(mode) end def set_eventloop_tick(tick) __getip.set_eventloop_tick(tick) @@ -919,6 +995,22 @@ class << MultiTkIp __getip._invoke(*args) end + def _eval_without_enc(str) + __getip._eval_without_enc(str) + end + + def _invoke_without_enc(*args) + __getip._invoke_without_enc(*args) + end + + def _eval_with_enc(str) + __getip._eval_with_enc(str) + end + + def _invoke_with_enc(*args) + __getip._invoke_with_enc(*args) + end + def _toUTF8(str, encoding) __getip._toUTF8(str, encoding) end @@ -938,6 +1030,54 @@ class << MultiTkIp def _return_value __getip._return_value end + + def _get_variable(var, flag) + __getip._get_variable(var, flag) + end + def _get_variable2(var, idx, flag) + __getip._get_variable2(var, idx, flag) + end + def _set_variable(var, value, flag) + __getip._set_variable(var, value, flag) + end + def _set_variable2(var, idx, value, flag) + __getip._set_variable2(var, idx, value, flag) + end + def _unset_variable(var, flag) + __getip._unset_variable(var, flag) + end + def _unset_variable2(var, idx, flag) + __getip._unset_variable2(var, idx, flag) + end + + def _get_global_var(var) + __getip._get_global_var(var) + end + def _get_global_var2(var, idx) + __getip._get_global_var2(var, idx) + end + def _set_global_var(var, value) + __getip._set_global_var(var, value) + end + def _set_global_var2(var, idx, value) + __getip._set_global_var2(var, idx, value) + end + def _unset_global_var(var) + __getip._unset_global_var(var) + end + def _unset_global_var2(var, idx) + __getip._unset_global_var2(var, idx) + end + + def _split_tklist(str) + __getip._split_tklist(str) + end + def _merge_tklist(*args) + __getip._merge_tklist(*args) + end + def _conv_listelement(arg) + __getip._conv_listelement(arg) + end end @@ -952,12 +1092,12 @@ class << TclTkLib def do_one_event(flag = TclTkLib::EventFlag::ALL) MultiTkIp.do_one_event(flag) end - def mainloop_abort_on_exception - MultiTkIp.mainloop_abort_on_exception - end - def mainloop_abort_on_exception=(mode) - MultiTkIp.mainloop_abort_on_exception=(mode) - end + #def mainloop_abort_on_exception + # MultiTkIp.mainloop_abort_on_exception + #end + #def mainloop_abort_on_exception=(mode) + # MultiTkIp.mainloop_abort_on_exception=(mode) + #end def set_eventloop_tick(tick) MultiTkIp.set_eventloop_tick(tick) end @@ -979,12 +1119,19 @@ class << TclTkLib def restart MultiTkIp.restart end + + def _merge_tklist(*args) + MultiTkIp._merge_tklist(*args) + end + def _conv_listelement(arg) + MultiTkIp._conv_listelement(arg) + end end # depend on TclTkIp class MultiTkIp - def mainloop(check_root = true, restart_on_dead = true) + def mainloop(check_root = true, restart_on_dead = false) return self if self.slave? unless restart_on_dead @interp.mainloop(check_root) @@ -1022,6 +1169,10 @@ class MultiTkIp end def delete + if safe? + # do 'exit' to call the delete_hook procedure + @interp._eval_without_enc('exit') + end @interp.delete end @@ -1041,6 +1192,22 @@ class MultiTkIp @interp._invoke(*args) end + def _eval_without_enc(str) + @interp._eval_without_enc(str) + end + + def _invoke_without_enc(*args) + @interp._invoke_without_enc(*args) + end + + def _eval_with_enc(str) + @interp._eval_with_enc(str) + end + + def _invoke_with_enc(*args) + @interp._invoke_with_enc(*args) + end + def _toUTF8(str, encoding) @interp._toUTF8(str, encoding) end @@ -1060,6 +1227,54 @@ class MultiTkIp def _return_value @interp._return_value end + + def _get_variable(var, flag) + @interp._get_variable(var, flag) + end + def _get_variable2(var, idx, flag) + @interp._get_variable2(var, idx, flag) + end + def _set_variable(var, value, flag) + @interp._set_variable(var, value, flag) + end + def _set_variable2(var, idx, value, flag) + @interp._set_variable2(var, idx, value, flag) + end + def _unset_variable(var, flag) + @interp._unset_variable(var, flag) + end + def _unset_variable2(var, idx, flag) + @interp._unset_variable2(var, idx, flag) + end + + def _get_global_var(var) + @interp._get_global_var(var) + end + def _get_global_var2(var, idx) + @interp._get_global_var2(var, idx) + end + def _set_global_var(var, value) + @interp._set_global_var(var, value) + end + def _set_global_var2(var, idx, value) + @interp._set_global_var2(var, idx, value) + end + def _unset_global_var(var) + @interp._unset_global_var(var) + end + def _unset_global_var2(var, idx) + @interp._unset_global_var2(var, idx) + end + + def _split_tklist(str) + @interp._split_tklist(str) + end + def _merge_tklist(*args) + @interp._merge_tklist(*args) + end + def _conv_listelement(arg) + @interp._conv_listelement(arg) + end end @@ -1090,7 +1305,7 @@ class MultiTkIp else list.push str[0..i-1] end - list += tk_split_simplelist(str[i+1..-1]) + list += _lst2ary(str[i+1..-1]) list end private :_lst2ary @@ -1224,6 +1439,14 @@ class MultiTkIp self end + def recursion_limit(slave = '', limit = None) + number(@interp._invoke('interp', 'recursionlimit', + _slavearg(slave), limit)) + end + def self.recursion_limit(slave = '', limit = None) + __getip.recursion_limit(slave) + end + def alias_target(aliascmd, slave = '') @interp._invoke('interp', 'target', _slavearg(slave), aliascmd) end @@ -1309,35 +1532,94 @@ class MultiTkIp end -# encoding convert +# Safe Base :: manipulating safe interpreter class MultiTkIp - # from tkencoding.rb by ttate@jaist.ac.jp - alias __eval _eval - alias __invoke _invoke + def safeip_configure(slave, slot, value=None) + # use for '-noStatics' option ==> {statics=>false} + # for '-nestedLoadOk' option ==> {nested=>true} + if slot.kind_of?(Hash) + ip = MultiTkIp.__getip + ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + + hash_kv(slot).join(' ')) + else + ip._eval('::safe::interpConfigure ' + @ip_name + ' ' + + "-#{slot} #{_get_eval_string(value)}") + end + self + end + + def safeip_configinfo(slot = nil) + ip = MultiTkIp.__getip + ret = {} + if slot + conf = _lst2ary(ip._eval("::safe::interpConfigure " + + @ip_name + " -#{slot}")) + if conf[0] == '-deleteHook' + if conf[1] =~ /^rb_out (c\d+)/ + ret[conf[0][1..-1]] = MultiTkIp._tk_cmd_tbl[$1] + else + ret[conf[0][1..-1]] = conf[1] + end + else + ret[conf[0][1..-1]] = conf[1] + end + else + Hash[*_lst2ary(ip._eval("::safe::interpConfigure " + + @ip_name))].each{|k, v| + if k == '-deleteHook' + if v =~ /^rb_out (c\d+)/ + ret[k[1..-1]] = MultiTkIp._tk_cmd_tbl[$1] + else + ret[k[1..-1]] = v + end + else + ret[k[1..-1]] = v + end + } + end + ret + end + def safeip_delete(slave) + ip = MultiTkIp.__getip + ip._eval("::safe::interpDelete " + @ip_name) + end + + def safeip_add_to_access_path(slave, dir) + ip = MultiTkIp.__getip + ip._eval("::safe::interpAddToAccessPath #{@ip_name} #{dir}") + end + + def safeip_find_in_access_path(slave, dir) + ip = MultiTkIp.__getip + ip._eval("::safe::interpFindInAccessPath #{@ip_name} #{dir}") + end + + def safeip_set_log_cmd(slave, cmd = Proc.new) + ip = MultiTkIp.__getip + ip._eval("::safe::setLogCmd #{@ip_name} #{_get_eval_string(cmd)}") + end +end + + +# encoding convert +class MultiTkIp def encoding - @encoding[0] + @interp.encoding end def encoding=(enc) - @encoding[0] = enc + @interp.encoding = enc end - - def _eval(cmd) - if @encoding[0] != nil - _fromUTF8(__eval(_toUTF8(cmd, @encoding[0])), @encoding[0]) - else - __eval(cmd) - end + + def encoding_convertfrom(str, enc=None) + @interp.encoding_convertfrom(str, enc) end + alias encoding_convert_from encoding_convertfrom - def _invoke(*cmds) - if defined?(@encoding[0]) && @encoding[0] != nil - cmds = cmds.collect{|cmd| _toUTF8(cmd, @encoding[0])} - _fromUTF8(__invoke(*cmds), @encoding[0]) - else - __invoke(*cmds) - end + def encoding_convertto(str, enc=None) + @interp.encoding_convertto(str, enc) end + alias encoding_convert_to encoding_convertto end diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb index 6bae4d8f42..36a9e54f2e 100644 --- a/ext/tk/lib/tk.rb +++ b/ext/tk/lib/tk.rb @@ -4,17 +4,30 @@ # by Yukihiro Matsumoto <matz@netlab.jp> # use Shigehiro's tcltklib -require "tcltklib" -require "tkutil" +require 'tcltklib' +require 'tkutil' +# autoload +require 'tk/autoload' + +class TclTkIp + # backup original (without encoding) _eval and _invoke + alias _eval_without_enc _eval + alias _invoke_without_enc _invoke +end + +# define TkComm module (step 1: basic functions) module TkComm + include TkUtil + extend TkUtil + WidgetClassNames = {}.taint - None = Object.new - def None.to_s - 'None' - end - None.freeze + # None = Object.new ### --> definition is moved to TkUtil module + # def None.to_s + # 'None' + # end + # None.freeze #Tk_CMDTBL = {} #Tk_WINDOWS = {} @@ -36,6 +49,21 @@ module TkComm @cmdtbl = [].taint } + unless const_defined?(:GET_CONFIGINFO_AS_ARRAY) + # GET_CONFIGINFO_AS_ARRAY = false => returns a Hash { opt =>val, ... } + # true => returns an Array [[opt,val], ... ] + # val is a list which includes resource info. + GET_CONFIGINFO_AS_ARRAY = true + end + unless const_defined?(:GET_CONFIGINFOwoRES_AS_ARRAY) + # for configinfo without resource info; list of [opt, value] pair + # false => returns a Hash { opt=>val, ... } + # true => returns an Array [[opt,val], ... ] + GET_CONFIGINFOwoRES_AS_ARRAY = true + end + # *** ATTENTION *** + # 'current_configinfo' method always returns a Hash under all cases of above. + def error_at frames = caller() frames.delete_if do |c| @@ -50,7 +78,7 @@ module TkComm begin #tk_class = TkCore::INTERP._invoke('winfo', 'class', path) - tk_class = Tk.ip_invoke('winfo', 'class', path) + tk_class = Tk.ip_invoke_without_enc('winfo', 'class', path) rescue return path end @@ -82,14 +110,20 @@ module TkComm private :_genobj_for_tkwidget module_function :_genobj_for_tkwidget - def tk_tcl2ruby(val) + def tk_tcl2ruby(val, enc_mode = nil) if val =~ /^rb_out (c\d+)/ #return Tk_CMDTBL[$1] return TkCore::INTERP.tk_cmd_tbl[$1] - end - if val.include? ?\s - return val.split.collect{|v| tk_tcl2ruby(v)} - end + #cmd_obj = TkCore::INTERP.tk_cmd_tbl[$1] + #if cmd_obj.kind_of?(Proc) || cmd_obj.kind_of?(Method) + # cmd_obj + #else + # cmd_obj.cmd + #end + end + #if val.include? ?\s + # return val.split.collect{|v| tk_tcl2ruby(v)} + #end case val when /^@font/ TkFont.get_obj(val) @@ -101,19 +135,124 @@ module TkComm TkCore::INTERP.tk_windows[val] : _genobj_for_tkwidget(val) when /^i\d+$/ TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val - when / / - val.split.collect{|elt| - tk_tcl2ruby(elt) - } when /^-?\d+\.?\d*(e[-+]?\d+)?$/ val.to_f + when /[^\\] / + tk_split_escstr(val).collect{|elt| + tk_tcl2ruby(elt) + } + when /\\ / + val.gsub(/\\ /, ' ') else - val + if enc_mode + _fromUTF8(val) + else + val + end + end + end + + private :tk_tcl2ruby + +unless const_defined?(:USE_TCLs_LIST_FUNCTIONS) + USE_TCLs_LIST_FUNCTIONS = true +end + +if USE_TCLs_LIST_FUNCTIONS + ########################################################################### + # use Tcl function version of split_list + ########################################################################### + + def tk_split_escstr(str) + TkCore::INTERP._split_tklist(str) + end + + def tk_split_sublist(str) + return [] if str == "" + list = TkCore::INTERP._split_tklist(str) + if list.size == 1 + tk_tcl2ruby(list[0]) + else + list.collect{|token| tk_split_sublist(token)} end end def tk_split_list(str) return [] if str == "" + TkCore::INTERP._split_tklist(str).collect{|token| tk_split_sublist(token)} + end + + def tk_split_simplelist(str) + #lst = TkCore::INTERP._split_tklist(str) + #if (lst.size == 1 && lst =~ /^\{.*\}$/) + # TkCore::INTERP._split_tklist(str[1..-2]) + #else + # lst + #end + TkCore::INTERP._split_tklist(str) + end + + def array2tk_list(ary) + return "" if ary.size == 0 + + dst = ary.collect{|e| + if e.kind_of? Array + array2tk_list(e) + elsif e.kind_of? Hash + tmp_ary = [] + e.each{|k,v| tmp_ary << k << v } + array2tk_list(tmp_ary) + else + _get_eval_string(e) + end + } + TkCore::INTERP._merge_tklist(*dst) + end + +else + ########################################################################### + # use Ruby script version of split_list (traditional methods) + ########################################################################### + + def tk_split_escstr(str) + return [] if str == "" + list = [] + token = nil + escape = false + brace = 0 + str.split('').each {|c| + brace += 1 if c == '{' && !escape + brace -= 1 if c == '}' && !escape + if brace == 0 && c == ' ' && !escape + list << token.gsub(/^\{(.*)\}$/, '\1') if token + token = nil + else + token = (token || "") << c + end + escape = (c == '\\' && !escape) + } + list << token.gsub(/^\{(.*)\}$/, '\1') if token + list + end + + def tk_split_sublist(str) + return [] if str == "" + return [tk_split_sublist(str[1..-2])] if str =~ /^\{.*\}$/ + list = tk_split_escstr(str) + if list.size == 1 + tk_tcl2ruby(list[0]) + else + list.collect{|token| tk_split_sublist(token)} + end + end + + def tk_split_list(str) + return [] if str == "" + tk_split_escstr(str).collect{|token| tk_split_sublist(token)} + end +=begin + def tk_split_list(str) + return [] if str == "" idx = str.index('{') while idx and idx > 0 and str[idx-1] == ?\\ idx = str.index('{', idx+1) @@ -130,11 +269,13 @@ module TkComm list = [] if list == "" str = str[idx+1..-1] i = -1 + escape = false brace = 1 str.each_byte {|c| i += 1 - brace += 1 if c == ?{ - brace -= 1 if c == ?} + brace += 1 if c == ?{ && !escape + brace -= 1 if c == ?} && !escape + escape = (c == ?\\) break if brace == 0 } if str.size == i + 1 @@ -148,56 +289,33 @@ module TkComm list += tk_split_list(str[i+1..-1]) list end +=end def tk_split_simplelist(str) return [] if str == "" - idx = str.index('{') - while idx and idx > 0 and str[idx-1] == ?\\ - idx = str.index('{', idx+1) - end - return str.split unless idx - - list = str[0,idx].split - str = str[idx+1..-1] - i = -1 - brace = 1 - str.each_byte {|c| - i += 1 - brace += 1 if c == ?{ - brace -= 1 if c == ?} - break if brace == 0 + list = [] + token = nil + escape = false + brace = 0 + str.split('').each {|c| + if c == '\\' && !escape + escape = true + token = (token || "") << c if brace > 0 + next + end + brace += 1 if c == '{' && !escape + brace -= 1 if c == '}' && !escape + if brace == 0 && c == ' ' && !escape + list << token.gsub(/^\{(.*)\}$/, '\1') if token + token = nil + else + token = (token || "") << c + end + escape = false } - if i == 0 - list.push '' - elsif str[0, i] == ' ' - list.push ' ' - else - list.push str[0..i-1] - end - list += tk_split_simplelist(str[i+1..-1]) + list << token.gsub(/^\{(.*)\}$/, '\1') if token list end - private :tk_tcl2ruby, :tk_split_list, :tk_split_simplelist - - def _symbolkey2str(keys) - h = {} - keys.each{|key,value| h[key.to_s] = value} - h - end - private :_symbolkey2str - - def hash_kv(keys) - conf = [] - if keys and keys != None - for k, v in keys - conf.push("-#{k}") - conf.push(v) - end - end - conf - end - private :hash_kv - module_function :hash_kv def array2tk_list(ary) ary.collect{|e| @@ -211,9 +329,61 @@ module TkComm end }.join(" ") end +end + + private :tk_split_escstr, :tk_split_sublist + private :tk_split_list, :tk_split_simplelist private :array2tk_list + + module_function :tk_split_escstr, :tk_split_sublist + module_function :tk_split_list, :tk_split_simplelist module_function :array2tk_list + private_class_method :tk_split_escstr, :tk_split_sublist + private_class_method :tk_split_list, :tk_split_simplelist + private_class_method :array2tk_list + +=begin + ### --> definition is moved to TkUtil module + def _symbolkey2str(keys) + h = {} + keys.each{|key,value| h[key.to_s] = value} + h + end + private :_symbolkey2str + module_function :_symbolkey2str +=end + +=begin + ### --> definition is moved to TkUtil module + # def hash_kv(keys, enc_mode = nil, conf = [], flat = false) + def hash_kv(keys, enc_mode = nil, conf = nil) + # Hash {key=>val, key=>val, ... } or Array [ [key, val], [key, val], ... ] + # ==> Array ['-key', val, '-key', val, ... ] + dst = [] + if keys and keys != None + keys.each{|k, v| + #dst.push("-#{k}") + dst.push('-' + k.to_s) + if v != None + # v = _get_eval_string(v, enc_mode) if (enc_mode || flat) + v = _get_eval_string(v, enc_mode) if enc_mode + dst.push(v) + end + } + end + if conf + conf + dst + else + dst + end + end + private :hash_kv + module_function :hash_kv +=end + +=begin + ### --> definition is moved to TkUtil module def bool(val) case val when "1", 1, 'yes', 'true' @@ -222,6 +392,7 @@ module TkComm false end end + def number(val) case val when /^-?\d+$/ @@ -229,19 +400,27 @@ module TkComm when /^-?\d+\.?\d*(e[-+]?\d+)?$/ val.to_f else - fail(ArgumentError, - Kernel.format('invalid value for Number:"%s"', val.to_s)) + fail(ArgumentError, "invalid value for Number:'#{val}'") end end def string(val) if val == "{}" '' - elsif val[0] == ?{ + elsif val[0] == ?{ && val[-1] == ?} val[1..-2] else val end end + def num_or_str(val) + begin + number(val) + rescue ArgumentError + string(val) + end + end +=end + def list(val) tk_split_list(val) end @@ -257,6 +436,13 @@ module TkComm nil end end + def image_obj(val) + if val =~ /^i\d+$/ + TkImage::Tk_IMGTBL[val]? TkImage::Tk_IMGTBL[val] : val + else + val + end + end def procedure(val) if val =~ /^rb_out (c\d+)/ #Tk_CMDTBL[$1] @@ -268,19 +454,34 @@ module TkComm end end private :bool, :number, :string, :list, :simplelist, :window, :procedure - module_function :bool, :number, :string, :list, :simplelist - module_function :window, :procedure + module_function :bool, :number, :num_or_str, :string, :list, :simplelist + module_function :window, :image_obj, :procedure - def _get_eval_string(str) + def _toUTF8(str, encoding = nil) + TkCore::INTERP._toUTF8(str, encoding) + end + def _fromUTF8(str, encoding = nil) + TkCore::INTERP._fromUTF8(str, encoding) + end + private :_toUTF8, :_fromUTF8 + module_function :_toUTF8, :_fromUTF8 + +=begin + ### --> definition is moved to TkUtil module + def _get_eval_string(str, enc_mode = nil) return nil if str == None - if str.kind_of?(String) - # do nothing + if str.kind_of?(TkObject) + str = str.path + elsif str.kind_of?(String) + str = _toUTF8(str) if enc_mode elsif str.kind_of?(Symbol) str = str.id2name + str = _toUTF8(str) if enc_mode elsif str.kind_of?(Hash) - str = hash_kv(str).join(" ") + str = hash_kv(str, enc_mode).join(" ") elsif str.kind_of?(Array) str = array2tk_list(str) + str = _toUTF8(str) if enc_mode elsif str.kind_of?(Proc) str = install_cmd(str) elsif str == nil @@ -291,28 +492,102 @@ module TkComm str = "1" elsif (str.respond_to?(:to_eval)) str = str.to_eval() + str = _toUTF8(str) if enc_mode else str = str.to_s() || '' unless str.kind_of? String fail RuntimeError, "fail to convert the object to a string" end - str + str = _toUTF8(str) if enc_mode end return str end +=end +=begin + def _get_eval_string(obj, enc_mode = nil) + case obj + when Numeric + obj.to_s + when String + (enc_mode)? _toUTF8(obj): obj + when Symbol + (enc_mode)? _toUTF8(obj.id2name): obj.id2name + when TkObject + obj.path + when Hash + hash_kv(obj, enc_mode).join(' ') + when Array + (enc_mode)? _toUTF8(array2tk_list(obj)): array2tk_list(obj) + when Proc, Method, TkCallbackEntry + install_cmd(obj) + when false + '0' + when true + '1' + when nil + '' + when None + nil + else + if (obj.respond_to?(:to_eval)) + (enc_mode)? _toUTF8(obj.to_eval): obj.to_eval + else + begin + obj = obj.to_s || '' + rescue + fail RuntimeError, "fail to convert object '#{obj}' to string" + end + (enc_mode)? _toUTF8(obj): obj + end + end + end private :_get_eval_string module_function :_get_eval_string +=end + +=begin + ### --> definition is moved to TkUtil module + def _get_eval_enc_str(obj) + return obj if obj == None + _get_eval_string(obj, true) + end + private :_get_eval_enc_str + module_function :_get_eval_enc_str +=end - def ruby2tcl(v) +=begin + ### --> obsolete + def ruby2tcl(v, enc_mode = nil) if v.kind_of?(Hash) v = hash_kv(v) v.flatten! - v.collect{|e|ruby2tcl(e)} + v.collect{|e|ruby2tcl(e, enc_mode)} else - _get_eval_string(v) + _get_eval_string(v, enc_mode) end end private :ruby2tcl +=end + +=begin + ### --> definition is moved to TkUtil module + def _conv_args(args, enc_mode, *src_args) + conv_args = [] + src_args.each{|arg| + conv_args << _get_eval_string(arg, enc_mode) unless arg == None + # if arg.kind_of?(Hash) + # arg.each{|k, v| + # args << '-' + k.to_s + # args << _get_eval_string(v, enc_mode) + # } + # elsif arg != None + # args << _get_eval_string(arg, enc_mode) + # end + } + args + conv_args + end + private :_conv_args +=end def _curr_cmd_id #id = format("c%.4d", Tk_IDs[0]) @@ -331,20 +606,26 @@ module TkComm return '' if cmd == '' id = _next_cmd_id #Tk_CMDTBL[id] = cmd - TkCore::INTERP.tk_cmd_tbl[id] = TkCore::INTERP.get_cb_entry(cmd) + if cmd.kind_of?(TkCallbackEntry) + TkCore::INTERP.tk_cmd_tbl[id] = cmd + else + TkCore::INTERP.tk_cmd_tbl[id] = TkCore::INTERP.get_cb_entry(cmd) + end @cmdtbl = [] unless defined? @cmdtbl @cmdtbl.taint unless @cmdtbl.tainted? @cmdtbl.push id - return Kernel.format("rb_out %s", id); + #return Kernel.format("rb_out %s", id); + return 'rb_out ' + id end def uninstall_cmd(id) id = $1 if /rb_out (c\d+)/ =~ id #Tk_CMDTBL.delete(id) TkCore::INTERP.tk_cmd_tbl.delete(id) end - private :install_cmd, :uninstall_cmd - module_function :install_cmd + # private :install_cmd, :uninstall_cmd + module_function :install_cmd, :uninstall_cmd +=begin def install_win(ppath,name=nil) if !name or name == '' #name = format("w%.4d", Tk_IDs[1]) @@ -362,6 +643,29 @@ module TkComm #Tk_WINDOWS[@path] = self TkCore::INTERP.tk_windows[@path] = self end +=end + def install_win(ppath,name=nil) + if name + if name == '' + raise ArgumentError, "invalid wiget-name '#{name}'" + end + if name[0] == ?. + @path = '' + name + @path.freeze + return TkCore::INTERP.tk_windows[@path] = self + end + else + name = "w" + Tk_IDs[1] + Tk_IDs[1].succ! + end + if !ppath or ppath == '.' + @path = '.' + name + else + @path = ppath + '.' + name + end + @path.freeze + TkCore::INTERP.tk_windows[@path] = self + end def uninstall_win() #Tk_WINDOWS.delete(@path) @@ -369,163 +673,22 @@ module TkComm end private :install_win, :uninstall_win - class Event - module TypeNum - KeyPress = 2 - KeyRelease = 3 - ButtonPress = 4 - ButtonRelease = 5 - MotionNotify = 6 - EnterNotify = 7 - LeaveNotify = 8 - FocusIn = 9 - FocusOut = 10 - KeymapNotify = 11 - Expose = 12 - GraphicsExpose = 13 - NoExpose = 14 - VisibilityNotify = 15 - CreateNotify = 16 - DestroyNotify = 17 - UnmapNotify = 18 - MapNotify = 19 - MapRequest = 20 - ReparentNotify = 21 - ConfigureNotify = 22 - ConfigureRequest = 23 - GravityNotify = 24 - ResizeRequest = 25 - CirculateNotify = 26 - CirculateRequest = 27 - PropertyNotify = 28 - SelectionClear = 29 - SelectionRequest = 30 - SelectionNotify = 31 - ColormapNotify = 32 - ClientMessage = 33 - MappingNotify = 34 - end - - EV_KEY = '#abcdfhikmopstwxyABDEKNRSTWXY' - EV_TYPE = 'nsnnsbnsnsbsxnnnnsnnbsnssnwnn' - - def self.scan_args(arg_str, arg_val) - arg_cnv = [] - arg_str.strip.split(/\s+/).each_with_index{|kwd,idx| - if kwd =~ /^%(.)$/ - if num = EV_KEY.index($1) - case EV_TYPE[num] - when ?n - begin - val = TkComm::number(arg_val[idx]) - rescue ArgumentError - # ignore --> no convert - val = TkComm::string(arg_val[idx]) - end - arg_cnv << val - when ?s - arg_cnv << TkComm::string(arg_val[idx]) - when ?b - arg_cnv << TkComm::bool(arg_val[idx]) - when ?w - arg_cnv << TkComm::window(arg_val[idx]) - when ?x - begin - arg_cnv << TkComm::number(arg_val[idx]) - rescue ArgumentError - arg_cnv << arg_val[idx] - end - else - arg_cnv << arg_val[idx] - end - else - arg_cnv << arg_val[idx] - end - else - arg_cnv << arg_val[idx] - end - } - arg_cnv - end - - def initialize(seq,a,b,c,d,f,h,i,k,m,o,p,s,t,w,x,y, - aa,bb,dd,ee,kk,nn,rr,ss,tt,ww,xx,yy) - @serial = seq - @above = a - @num = b - @count = c - @detail = d - @focus = f - @height = h - @win_hex = i - @keycode = k - @mode = m - @override = o - @place = p - @state = s - @time = t - @width = w - @x = x - @y = y - @char = aa - @borderwidth = bb - @wheel_delta = dd - @send_event = ee - @keysym = kk - @keysym_num = nn - @rootwin_id = rr - @subwindow = ss - @type = tt - @widget = ww - @x_root = xx - @y_root = yy - end - attr :serial - attr :above - attr :num - attr :count - attr :detail - attr :focus - attr :height - attr :win_hex - attr :keycode - attr :mode - attr :override - attr :place - attr :state - attr :time - attr :width - attr :x - attr :y - attr :char - attr :borderwidth - attr :wheel_delta - attr :send_event - attr :keysym - attr :keysym_num - attr :rootwin_id - attr :subwindow - attr :type - attr :widget - attr :x_root - attr :y_root - end - - def install_bind(cmd, args=nil) - if args - id = install_cmd(proc{|*arg| - TkUtil.eval_cmd(cmd, *Event.scan_args(args, arg)) - }) - id + " " + args + def _epath(win) + if win.kind_of?(TkObject) + win.epath + elsif win.respond_to?(:epath) + win.epath else - args = ' %# %a %b %c %d %f %h %i %k %m %o %p %s %t %w %x %y' + - ' %A %B %D %E %K %N %R %S %T %W %X %Y' - id = install_cmd(proc{|*arg| - TkUtil.eval_cmd(cmd, Event.new(*Event.scan_args(args, arg))) - }) - id + args + win end end + private :_epath +end + +# define TkComm module (step 2: event binding) +module TkComm + include TkEvent + extend TkEvent def tk_event_sequence(context) if context.kind_of? TkVirtualEvent @@ -550,7 +713,8 @@ module TkComm def _bind_core(mode, what, context, cmd, args=nil) id = install_bind(cmd, args) if cmd begin - tk_call(*(what + ["<#{tk_event_sequence(context)}>", mode + id])) + tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", + mode + id])) rescue uninstall_cmd(id) if cmd fail @@ -566,12 +730,12 @@ module TkComm end def _bind_remove(what, context) - tk_call(*(what + ["<#{tk_event_sequence(context)}>", ''])) + tk_call_without_enc(*(what + ["<#{tk_event_sequence(context)}>", ''])) end def _bindinfo(what, context=nil) if context - tk_call(*what+["<#{tk_event_sequence(context)}>"]).collect {|cmdline| + tk_call_without_enc(*what+["<#{tk_event_sequence(context)}>"]) .collect {|cmdline| if cmdline =~ /^rb_out (c\d+)\s+(.*)$/ #[Tk_CMDTBL[$1], $2] [TkCore::INTERP.tk_cmd_tbl[$1], $2] @@ -580,7 +744,7 @@ module TkComm end } else - tk_split_simplelist(tk_call(*what)).collect!{|seq| + tk_split_simplelist(tk_call_without_enc(*what)).collect!{|seq| l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| case (subseq) when /^<<[^<>]+>>$/ @@ -635,25 +799,9 @@ module TkComm def bindinfo_all(context=nil) _bindinfo(['bind', 'all'], context) end - - def pack(*args) - TkPack.configure(*args) - end - - def grid(*args) - TkGrid.configure(*args) - end - - def update(idle=nil) - if idle - tk_call 'update', 'idletasks' - else - tk_call 'update' - end - end - end + module TkCore include TkComm extend TkComm @@ -662,7 +810,8 @@ module TkCore if self.const_defined? :IP_NAME name = IP_NAME.to_s else - name = nil + #name = nil + name = $0 end if self.const_defined? :IP_OPTS if IP_OPTS.kind_of?(Hash) @@ -689,7 +838,14 @@ module TkCore @init_ip_env = [].taint # table of Procs @add_tk_procs = [].taint # table of [name, args, body] - @cb_entry_class = Class.new{|c| + @cb_entry_class = Class.new(TkCallbackEntry){|c| + class << c + def inspect + sprintf("#<Class(TkCallbackEntry):%0x>", self.__id__) + end + alias to_s inspect + end + def initialize(ip, cmd) @ip = ip @cmd = cmd @@ -698,9 +854,16 @@ module TkCore def call(*args) @ip.cb_eval(@cmd, *args) end - } + def inspect + sprintf("#<cb_entry:%0x>", self.__id__) + end + alias to_s inspect + }.freeze } + def INTERP.cb_entry_class + @cb_entry_class + end def INTERP.tk_cmd_tbl @tk_cmd_tbl end @@ -708,6 +871,15 @@ module TkCore @tk_windows end + class Tk_OBJECT_TABLE + def initialize(id) + @id = id + end + def method_missing(m, *args, &b) + TkCore::INTERP.tk_object_table(@id).send(m, *args, &b) + end + end + def INTERP.tk_object_table(id) @tk_table_list[id] end @@ -715,20 +887,21 @@ module TkCore id = @tk_table_list.size (tbl = {}).tainted? || tbl.taint @tk_table_list << tbl - obj = Object.new - obj.instance_eval <<-EOD - def self.method_missing(m, *args) - TkCore::INTERP.tk_object_table(#{id}).send(m, *args) - end - EOD - return obj +# obj = Object.new +# obj.instance_eval <<-EOD +# def self.method_missing(m, *args) +# TkCore::INTERP.tk_object_table(#{id}).send(m, *args) +# end +# EOD +# return obj + Tk_OBJECT_TABLE.new(id) end def INTERP.get_cb_entry(cmd) @cb_entry_class.new(__getip, cmd).freeze end def INTERP.cb_eval(cmd, *args) - TkComm._get_eval_string(TkUtil.eval_cmd(cmd, *args)) + TkUtil._get_eval_string(TkUtil.eval_cmd(cmd, *args)) end def INTERP.init_ip_env(script = Proc.new) @@ -746,15 +919,64 @@ module TkCore end end + WIDGET_DESTROY_HOOK = '<WIDGET_DESTROY_HOOK>' + INTERP._invoke_without_enc('event', 'add', + "<#{WIDGET_DESTROY_HOOK}>", 'Destroy') + INTERP._invoke_without_enc('bind', 'all', "<#{WIDGET_DESTROY_HOOK}>", + install_bind(proc{|xpath| + path = xpath[1..-1] + unless TkCore::INTERP.deleted? + if (widget = TkCore::INTERP.tk_windows[path]) + if widget.respond_to?(:__destroy_hook__) + begin + widget.__destroy_hook__ + rescue Exception + end + end + end + end + }, 'x%W')) + INTERP.add_tk_procs(TclTkLib::FINALIZE_PROC_NAME, '', + "bind all <#{WIDGET_DESTROY_HOOK}> {}") + + INTERP.add_tk_procs('rb_out', 'args', <<-'EOL') + if {[set st [catch {eval {ruby_cmd TkCore callback} $args} ret]] != 0} { + #return -code $st $ret + set idx [string first "\n\n" $ret] + if {$idx > 0} { + return -code $st \ + -errorinfo [string range $ret [expr $idx + 2] \ + [string length $ret]] \ + [string range $ret 0 [expr $idx - 1]] + } else { + return -code $st $ret + } + } else { + return $ret + } + EOL +=begin INTERP.add_tk_procs('rb_out', 'args', <<-'EOL') - regsub -all {!} $args {\\!} args - regsub -all "{" $args "\\{" args + #regsub -all {\\} $args {\\\\} args + #regsub -all {!} $args {\\!} args + #regsub -all "{" $args "\\{" args + regsub -all {(\\|!|\{|\})} $args {\\\1} args if {[set st [catch {ruby [format "TkCore.callback %%Q!%s!" $args]} ret]] != 0} { - return -code $st $ret - } { + #return -code $st $ret + set idx [string first "\n\n" $ret] + if {$idx > 0} { + return -code $st \ + -errorinfo [string range $ret [expr $idx + 2] \ + [string length $ret]] \ + [string range $ret 0 [expr $idx - 1]] + } else { + return -code $st $ret + } + } else { return $ret } EOL +=end EventFlag = TclTkLib::EventFlag @@ -766,31 +988,64 @@ module TkCore fail TkCallbackContinue, "Tk callback returns 'continue' status" end - def TkCore.callback(arg) - # arg = tk_split_list(arg) - arg = tk_split_simplelist(arg) - #_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg)) - #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift], - # *arg)) - cb_obj = TkCore::INTERP.tk_cmd_tbl[arg.shift] - unless $DEBUG - cb_obj.call(*arg) - else - begin - raise 'check backtrace' - rescue - # ignore backtrace before 'callback' - pos = -($!.backtrace.size) - end + def TkCore.callback(*arg) + begin + TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) + rescue Exception => e begin - cb_obj.call(*arg) - rescue - trace = $!.backtrace - raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + - "\tfrom #{trace[1..pos].join("\n\tfrom ")}" + msg = _toUTF8(e.class.inspect) + ': ' + + _toUTF8(e.message) + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + _toUTF8(e.backtrace.join("\n")) + + "\n---< backtrace of Tk side >-------" + msg.instance_variable_set(:@encoding, 'utf-8') + rescue Exception + msg = e.class.inspect + ': ' + e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + + "\n---< backtrace of Tk side >-------" end + fail(e, msg) end end +=begin + def TkCore.callback(arg_str) + # arg = tk_split_list(arg_str) + arg = tk_split_simplelist(arg_str) + #_get_eval_string(TkUtil.eval_cmd(Tk_CMDTBL[arg.shift], *arg)) + #_get_eval_string(TkUtil.eval_cmd(TkCore::INTERP.tk_cmd_tbl[arg.shift], + # *arg)) + # TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) + begin + TkCore::INTERP.tk_cmd_tbl[arg.shift].call(*arg) + rescue Exception => e + raise(e, e.class.inspect + ': ' + e.message + "\n" + + "\n---< backtrace of Ruby side >-----\n" + + e.backtrace.join("\n") + + "\n---< backtrace of Tk side >-------") + end +#=begin +# cb_obj = TkCore::INTERP.tk_cmd_tbl[arg.shift] +# unless $DEBUG +# cb_obj.call(*arg) +# else +# begin +# raise 'check backtrace' +# rescue +# # ignore backtrace before 'callback' +# pos = -($!.backtrace.size) +# end +# begin +# cb_obj.call(*arg) +# rescue +# trace = $!.backtrace +# raise $!, "\n#{trace[0]}: #{$!.message} (#{$!.class})\n" + +# "\tfrom #{trace[1..pos].join("\n\tfrom ")}" +# end +# end +#=end + end +=end def load_cmd_on_ip(tk_cmd) bool(tk_call('auto_load', tk_cmd)) @@ -799,7 +1054,7 @@ module TkCore def after(ms, cmd=Proc.new) myid = _curr_cmd_id cmdid = install_cmd(cmd) - tk_call("after",ms,cmdid) + tk_call_without_enc("after",ms,cmdid) # return id # return # if false #defined? Thread # Thread.start do @@ -817,69 +1072,25 @@ module TkCore def after_idle(cmd=Proc.new) myid = _curr_cmd_id cmdid = install_cmd(cmd) - tk_call('after','idle',cmdid) - end - - def clock_clicks(ms=nil) - if ms - tk_call('clock','clicks','-milliseconds').to_i - else - tk_call('clock','clicks').to_i - end - end - - def clock_format(clk, form=nil) - if form - tk_call('clock','format',clk,'-format',form).to_i - else - tk_call('clock','format',clk).to_i - end - end - - def clock_formatGMT(clk, form=nil) - if form - tk_call('clock','format',clk,'-format',form,'-gmt','1').to_i - else - tk_call('clock','format',clk,'-gmt','1').to_i - end - end - - def clock_scan(str, base=nil) - if base - tk_call('clock','scan',str,'-base',base).to_i - else - tk_call('clock','scan',str).to_i - end - end - - def clock_scanGMT(str, base=nil) - if base - tk_call('clock','scan',str,'-base',base,'-gmt','1').to_i - else - tk_call('clock','scan',str,'-gmt','1').to_i - end - end - - def clock_seconds - tk_call('clock','seconds').to_i + tk_call_without_enc('after','idle',cmdid) end def windowingsystem - tk_call('tk', 'windowingsystem') + tk_call_without_enc('tk', 'windowingsystem') end def scaling(scale=nil) if scale - tk_call('tk', 'scaling', scale) + tk_call_without_enc('tk', 'scaling', scale) else - Float(number(tk_call('tk', 'scaling'))) + Float(number(tk_call_without_enc('tk', 'scaling'))) end end def scaling_displayof(win, scale=nil) if scale - tk_call('tk', 'scaling', '-displayof', win, scale) + tk_call_without_enc('tk', 'scaling', '-displayof', win, scale) else - Float(number(tk_call('tk', '-displayof', win, 'scaling'))) + Float(number(tk_call_without_enc('tk', '-displayof', win, 'scaling'))) end end @@ -896,7 +1107,8 @@ module TkCore end def rb_appsend(interp, async, *args) - args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')} + #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')} + args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')} args.push(').to_s"') appsend(interp, async, 'ruby "(', *args) end @@ -911,7 +1123,8 @@ module TkCore end def rb_appsend_displayof(interp, win, async, *args) - args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')} + #args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"]/, '\\\\\&')} + args = args.collect!{|c| _get_eval_string(c).gsub(/[\[\]$"\\]/, '\\\\\&')} args.push(').to_s"') appsend_displayof(interp, win, async, 'ruby "(', *args) end @@ -971,147 +1184,154 @@ module TkCore end def event_generate(window, context, keys=nil) - window = window.path if window.kind_of? TkObject + #window = window.path if window.kind_of?(TkObject) if keys - tk_call('event', 'generate', window, - "<#{tk_event_sequence(context)}>", *hash_kv(keys)) + tk_call_without_enc('event', 'generate', window, + "<#{tk_event_sequence(context)}>", + *hash_kv(keys, true)) else - tk_call('event', 'generate', window, "<#{tk_event_sequence(context)}>") + tk_call_without_enc('event', 'generate', window, + "<#{tk_event_sequence(context)}>") end + nil end def messageBox(keys) - tk_call 'tk_messageBox', *hash_kv(keys) + tk_call('tk_messageBox', *hash_kv(keys)) end def getOpenFile(keys = nil) - tk_call 'tk_getOpenFile', *hash_kv(keys) + tk_call('tk_getOpenFile', *hash_kv(keys)) end def getSaveFile(keys = nil) - tk_call 'tk_getSaveFile', *hash_kv(keys) + tk_call('tk_getSaveFile', *hash_kv(keys)) end def chooseColor(keys = nil) - tk_call 'tk_chooseColor', *hash_kv(keys) + tk_call('tk_chooseColor', *hash_kv(keys)) end def chooseDirectory(keys = nil) - tk_call 'tk_chooseDirectory', *hash_kv(keys) + tk_call('tk_chooseDirectory', *hash_kv(keys)) end - def ip_eval(cmd_string) - res = INTERP._eval(cmd_string) + def _ip_eval_core(enc_mode, cmd_string) + case enc_mode + when nil + res = INTERP._eval(cmd_string) + when false + res = INTERP._eval_without_enc(cmd_string) + when true + res = INTERP._eval_with_enc(cmd_string) + end if INTERP._return_value() != 0 fail RuntimeError, res, error_at end return res end + private :_ip_eval_core - def ip_invoke(*args) - res = INTERP._invoke(*args) + def ip_eval(cmd_string) + _ip_eval_core(nil, cmd_string) + end + + def ip_eval_without_enc(cmd_string) + _ip_eval_core(false, cmd_string) + end + + def ip_eval_with_enc(cmd_string) + _ip_eval_core(true, cmd_string) + end + + def _ip_invoke_core(enc_mode, *args) + case enc_mode + when false + res = INTERP._invoke_without_enc(*args) + when nil + res = INTERP._invoke(*args) + when true + res = INTERP._invoke_with_enc(*args) + end if INTERP._return_value() != 0 fail RuntimeError, res, error_at end return res end + private :_ip_invoke_core - def tk_call(*args) - puts args.inspect if $DEBUG - args.collect! {|x|ruby2tcl(x)} - args.compact! - args.flatten! - print "=> ", args.join(" ").inspect, "\n" if $DEBUG + def ip_invoke(*args) + _ip_invoke_core(nil, *args) + end + + def ip_invoke_without_enc(*args) + _ip_invoke_core(false, *args) + end + + def ip_invoke_with_enc(*args) + _ip_invoke_core(true, *args) + end + + def _tk_call_core(enc_mode, *args) + ### puts args.inspect if $DEBUG + #args.collect! {|x|ruby2tcl(x, enc_mode)} + #args.compact! + #args.flatten! + args = _conv_args([], enc_mode, *args) + puts 'invoke args => ' + args.inspect if $DEBUG + ### print "=> ", args.join(" ").inspect, "\n" if $DEBUG begin # res = INTERP._invoke(*args).taint - res = INTERP._invoke(*args) # _invoke returns a TAINTED string + # res = INTERP._invoke(enc_mode, *args) + res = _ip_invoke_core(enc_mode, *args) + # >>>>> _invoke returns a TAINTED string <<<<< rescue NameError => err -# err = $! + # err = $! begin args.unshift "unknown" #res = INTERP._invoke(*args).taint - res = INTERP._invoke(*args) # _invoke returns a TAINTED string + #res = INTERP._invoke(enc_mode, *args) + res = _ip_invoke_core(enc_mode, *args) + # >>>>> _invoke returns a TAINTED string <<<<< rescue StandardError => err2 - fail err2 unless /^invalid command/ =~ err2 + fail err2 unless /^invalid command/ =~ err2.message fail err end end if INTERP._return_value() != 0 fail RuntimeError, res, error_at end - print "==> ", res.inspect, "\n" if $DEBUG + ### print "==> ", res.inspect, "\n" if $DEBUG return res end -end - -module TkPackage - include TkCore - extend TkPackage - - TkCommandNames = ['package'.freeze].freeze - - def add_path(path) - Tk::AUTO_PATH.value = Tk::AUTO_PATH.to_a << path - end + private :_tk_call_core - def forget(package) - tk_call('package', 'forget', package) - nil - end - - def names - tk_split_simplelist(tk_call('package', 'names')) - end - - def provide(package, version=nil) - if version - tk_call('package', 'provide', package, version) - nil - else - tk_call('package', 'provide', package) - end - end - - def present(package, version=None) - tk_call('package', 'present', package, version) - end - - def present_exact(package, version) - tk_call('package', 'present', '-exact', package, version) - end - - def require(package, version=None) - tk_call('package', 'require', package, version) - end - - def require_exact(package, version) - tk_call('package', 'require', '-exact', package, version) - end - - def versions(package) - tk_split_simplelist(tk_call('package', 'versions', package)) + def tk_call(*args) + _tk_call_core(nil, *args) end - def vcompare(version1, version2) - Integer(tk_call('package', 'vcompare', version1, version2)) + def tk_call_without_enc(*args) + _tk_call_core(false, *args) end - def vsatisfies(version1, version2) - bool(tk_call('package', 'vsatisfies', version1, version2)) + def tk_call_with_enc(*args) + _tk_call_core(true, *args) end end + module Tk include TkCore extend Tk - TCL_VERSION = INTERP._invoke("info", "tclversion").freeze - TCL_PATCHLEVEL = INTERP._invoke("info", "patchlevel").freeze + TCL_VERSION = INTERP._invoke_without_enc("info", "tclversion").freeze + TCL_PATCHLEVEL = INTERP._invoke_without_enc("info", "patchlevel").freeze - TK_VERSION = INTERP._invoke("set", "tk_version").freeze - TK_PATCHLEVEL = INTERP._invoke("set", "tk_patchLevel").freeze + TK_VERSION = INTERP._invoke_without_enc("set", "tk_version").freeze + TK_PATCHLEVEL = INTERP._invoke_without_enc("set", "tk_patchLevel").freeze - JAPANIZED_TK = (INTERP._invoke("info", "commands", "kanji") != "").freeze + JAPANIZED_TK = (INTERP._invoke_without_enc("info", "commands", + "kanji") != "").freeze def Tk.const_missing(sym) case(sym) @@ -1131,8 +1351,11 @@ module Tk # tk_split_simplelist(INTERP._invoke('set', 'tcl_libPath')) when :PLATFORM, :TCL_PLATFORM - Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', - 'tcl_platform'))] + if $SAFE >= 4 + fail SecurityError, "can't get #{sym} when $SAFE >= 4" + end + Hash[*tk_split_simplelist(INTERP._invoke_without_enc('array', 'get', + 'tcl_platform'))] when :ENV Hash[*tk_split_simplelist(INTERP._invoke('array', 'get', 'env'))] @@ -1148,7 +1371,7 @@ module Tk when :PRIV, :PRIVATE, :TK_PRIV priv = {} - if INTERP._invoke('info', 'vars', 'tk::Priv') != "" + if INTERP._invoke_without_enc('info', 'vars', 'tk::Priv') != "" var_nam = 'tk::Priv' else var_nam = 'tkPriv' @@ -1176,44 +1399,116 @@ module Tk TkRoot.new end + def Tk.load_tclscript(file, enc=nil) + if enc + # TCL_VERSION >= 8.5 + tk_call('source', '-encoding', enc, file) + else + tk_call('source', file) + end + end + + def Tk.load_tcllibrary(file, pkg_name=None, interp=None) + tk_call('load', file, pkg_name, interp) + end + + def Tk.unload_tcllibrary(*args) + if args[-1].kind_of?(Hash) + keys = _symbolkey2str(args.pop) + nocomp = (keys['nocomplain'])? '-nocomplain': None + keeplib = (keys['keeplibrary'])? '-keeplibrary': None + tk_call('unload', nocomp, keeplib, '--', *args) + else + tk_call('unload', *args) + end + end + def Tk.bell(nice = false) if nice - tk_call 'bell', '-nice' + tk_call_without_enc('bell', '-nice') else - tk_call 'bell' + tk_call_without_enc('bell') end + nil end def Tk.bell_on_display(win, nice = false) if nice - tk_call('bell', '-displayof', win, '-nice') + tk_call_without_enc('bell', '-displayof', win, '-nice') else - tk_call('bell', '-displayof', win) + tk_call_without_enc('bell', '-displayof', win) end + nil end def Tk.destroy(*wins) - tk_call('destroy', *wins) + tk_call_without_enc('destroy', *wins) end def Tk.exit - tk_call('destroy', '.') + tk_call_without_enc('destroy', '.') + end + + def Tk.pack(*args) + #TkPack.configure(*args) + TkPack(*args) + end + + def Tk.grid(*args) + TkGrid.configure(*args) + end + + def Tk.update(idle=nil) + if idle + tk_call_without_enc('update', 'idletasks') + else + tk_call_without_enc('update') + end + end + def Tk.update_idletasks + update(true) + end + +=begin + # See tcltklib.c for the reason of why the following methods are disabled. + def Tk.thread_update(idle=nil) + if idle + tk_call_without_enc('thread_update', 'idletasks') + else + tk_call_without_enc('thread_update') + end + end + def Tk.thread_update_idletasks + thread_update(true) end +=end - def Tk.current_grabs - tk_split_list(tk_call('grab', 'current')) + def Tk.current_grabs(win = nil) + if win + window(tk_call_without_enc('grab', 'current', win)) + else + tk_split_list(tk_call_without_enc('grab', 'current')) + end end def Tk.focus(display=nil) if display == nil - window(tk_call('focus')) + window(tk_call_without_enc('focus')) else - window(tk_call('focus', '-displayof', display)) + window(tk_call_without_enc('focus', '-displayof', display)) + end + end + + def Tk.focus_to(win, force=false) + if force + tk_call_without_enc('focus', '-force', win) + else + tk_call_without_enc('focus', win) end end def Tk.focus_lastfor(win) - window(tk_call('focus', '-lastfor', win)) + window(tk_call_without_enc('focus', '-lastfor', win)) end def Tk.focus_next(win) @@ -1225,7 +1520,7 @@ module Tk end def Tk.strictMotif(bool=None) - bool(tk_call('set', 'tk_strictMotif', bool)) + bool(tk_call_without_enc('set', 'tk_strictMotif', bool)) end def Tk.show_kinsoku(mode='both') @@ -1258,286 +1553,12 @@ module Tk end end - def Tk.toUTF8(str,encoding) - INTERP._toUTF8(str,encoding) + def Tk.toUTF8(str, encoding = nil) + _toUTF8(str, encoding) end - def Tk.fromUTF8(str,encoding) - INTERP._fromUTF8(str,encoding) - end - - module Scrollable - def xscrollcommand(cmd=Proc.new) - configure_cmd 'xscrollcommand', cmd - end - def yscrollcommand(cmd=Proc.new) - configure_cmd 'yscrollcommand', cmd - end - def xview(*index) - v = tk_send('xview', *index) - list(v) if index.size == 0 - end - def yview(*index) - v = tk_send('yview', *index) - list(v) if index.size == 0 - end - def xscrollbar(bar=nil) - if bar - @xscrollbar = bar - @xscrollbar.orient 'horizontal' - self.xscrollcommand {|*arg| @xscrollbar.set(*arg)} - @xscrollbar.command {|*arg| self.xview(*arg)} - end - @xscrollbar - end - def yscrollbar(bar=nil) - if bar - @yscrollbar = bar - @yscrollbar.orient 'vertical' - self.yscrollcommand {|*arg| @yscrollbar.set(*arg)} - @yscrollbar.command {|*arg| self.yview(*arg)} - end - @yscrollbar - end - end - - module Wm - include TkComm - - TkCommandNames = ['wm'.freeze].freeze - - def aspect(*args) - w = tk_call('wm', 'aspect', path, *args) - if args.length == 0 - list(w) - else - self - end - end - def attributes(slot=nil,value=None) - if slot == nil - lst = tk_split_list(tk_call('wm', 'attributes', path)) - info = {} - while key = lst.shift - info[key[1..-1]] = lst.shift - end - info - elsif slot.kind_of? Hash - tk_call('wm', 'attributes', path, *hash_kv(slot)) - self - elsif value == None - tk_call('wm', 'attributes', path, "-#{slot}") - else - tk_call('wm', 'attributes', path, "-#{slot}", value) - self - end - end - def client(name=None) - if name == None - tk_call 'wm', 'client', path - else - name = '' if name == nil - tk_call 'wm', 'client', path, name - self - end - end - def colormapwindows(*args) - r = tk_call('wm', 'colormapwindows', path, *args) - if args.size == 0 - list(r) - else - self - end - end - def wm_command(value=nil) - if value - tk_call('wm', 'command', path, value) - self - else - procedure(tk_call('wm', 'command', path)) - end - end - def deiconify(ex = true) - tk_call('wm', 'deiconify', path) if ex - self - end - def focusmodel(mode = nil) - if mode - tk_call 'wm', 'focusmodel', path, mode - self - else - tk_call 'wm', 'focusmodel', path - end - end - def frame - tk_call('wm', 'frame', path) - end - def geometry(geom=nil) - if geom - tk_call('wm', 'geometry', path, geom) - self - else - tk_call('wm', 'geometry', path) - end - end - def grid(*args) - w = tk_call('wm', 'grid', path, *args) - if args.size == 0 - list(w) - else - self - end - end - def group(*args) - w = tk_call('wm', 'group', path, *args) - if args.size == 0 - window(w) - else - self - end - end - def iconbitmap(bmp=nil) - if bmp - tk_call 'wm', 'iconbitmap', path, bmp - self - else - tk_call 'wm', 'iconbitmap', path - end - end - def iconify(ex = true) - tk_call('wm', 'iconify', path) if ex - self - end - def iconmask(bmp=nil) - if bmp - tk_call 'wm', 'iconmask', path, bmp - self - else - tk_call 'wm', 'iconmask', path - end - end - def iconname(name=nil) - if name - tk_call 'wm', 'iconname', path, name - self - else - tk_call 'wm', 'iconname', path - end - end - def iconposition(*args) - w = tk_call('wm', 'iconposition', path, *args) - if args.size == 0 - list(w) - else - self - end - end - def iconwindow(*args) - w = tk_call('wm', 'iconwindow', path, *args) - if args.size == 0 - window(w) - else - self - end - end - def maxsize(*args) - w = tk_call('wm', 'maxsize', path, *args) - if args.size == 0 - list(w) - else - self - end - end - def minsize(*args) - w = tk_call('wm', 'minsize', path, *args) - if args.size == 0 - list(w) - else - self - end - end - def overrideredirect(bool=None) - if bool == None - bool(tk_call('wm', 'overrideredirect', path)) - else - tk_call 'wm', 'overrideredirect', path, bool - self - end - end - def positionfrom(who=None) - if who == None - r = tk_call('wm', 'positionfrom', path) - (r == "")? nil: r - else - tk_call('wm', 'positionfrom', path, who) - self - end - end - def protocol(name=nil, cmd=nil) - if cmd - tk_call('wm', 'protocol', path, name, cmd) - self - elsif name - result = tk_call('wm', 'protocol', path, name) - (result == "")? nil : tk_tcl2ruby(result) - else - tk_split_simplelist(tk_call('wm', 'protocol', path)) - end - end - def resizable(*args) - w = tk_call('wm', 'resizable', path, *args) - if args.length == 0 - list(w).collect{|e| bool(e)} - else - self - end - end - def sizefrom(who=None) - if who == None - r = tk_call('wm', 'sizefrom', path) - (r == "")? nil: r - else - tk_call('wm', 'sizefrom', path, who) - self - end - end - def stackorder - list(tk_call('wm', 'stackorder', path)) - end - def stackorder_isabove(win) - bool(tk_call('wm', 'stackorder', path, 'isabove', win)) - end - def stackorder_isbelow(win) - bool(tk_call('wm', 'stackorder', path, 'isbelow', win)) - end - def state(state=nil) - if state - tk_call 'wm', 'state', path, state - self - else - tk_call 'wm', 'state', path - end - end - def title(str=nil) - if str - tk_call('wm', 'title', path, str) - self - else - tk_call('wm', 'title', path) - end - end - def transient(master=nil) - if master - tk_call('wm', 'transient', path, master) - self - else - window(tk_call('wm', 'transient', path, master)) - end - end - def withdraw(ex = true) - tk_call('wm', 'withdraw', path) if ex - self - end + def Tk.fromUTF8(str, encoding = nil) + _fromUTF8(str, encoding) end end @@ -1545,45 +1566,20 @@ end # string with Tcl's encoding ########################################### module Tk - class EncodedString < String - @@enc_buf = '__rb_encoding_buffer__' - - def self.tk_escape(str) - s = '"' + str.gsub(/[\[\]$"]/, '\\\\\&') + '"' - TkCore::INTERP.__eval(Kernel.format('global %s; set %s %s', - @@enc_buf, @@enc_buf, s)) - end - - def self.new(str, enc = Tk.encoding_system) - obj = super(self.tk_escape(str)) - obj.instance_eval{@enc = enc} - obj - end - - def self.new_without_escape(str, enc = Tk.encoding_system) - obj = super(str) - obj.instance_eval{@enc = enc} - obj - end - - def encoding - @enc - end + def Tk.subst_utf_backslash(str) + Tk::EncodedString.subst_utf_backslash(str) end - def Tk.EncodedString(str, enc = Tk.encoding_system) - Tk::EncodedString.new(str, enc) + def Tk.subst_tk_backslash(str) + Tk::EncodedString.subst_tk_backslash(str) end - - class UTF8_String < EncodedString - def self.new(str) - super(str, 'utf-8') - end - def self.new_without_escape(str) - super(str, 'utf-8') - end + def Tk.utf_to_backslash_sequence(str) + Tk::EncodedString.utf_to_backslash_sequence(str) end - def Tk.UTF8_String(str) - Tk::UTF8_String.new(str) + def Tk.utf_to_backslash(str) + Tk::EncodedString.utf_to_backslash_sequence(str) + end + def Tk.to_backslash_sequence(str) + Tk::EncodedString.to_backslash_sequence(str) end end @@ -1591,20 +1587,96 @@ end ########################################### # convert kanji string to/from utf-8 ########################################### -if /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK +if (/^(8\.[1-9]|9\.|[1-9][0-9])/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK) class TclTkIp # from tkencoding.rb by ttate@jaist.ac.jp + attr_accessor :encoding + alias __eval _eval alias __invoke _invoke - - attr_accessor :encoding - + + alias __toUTF8 _toUTF8 + alias __fromUTF8 _fromUTF8 + +=begin + #### --> definition is moved to TclTkIp module + + def _toUTF8(str, encoding = nil) + # decide encoding + if encoding + encoding = encoding.to_s + elsif str.kind_of?(Tk::EncodedString) && str.encoding != nil + encoding = str.encoding.to_s + elsif str.instance_variable_get(:@encoding) + encoding = str.instance_variable_get(:@encoding).to_s + elsif defined?(@encoding) && @encoding != nil + encoding = @encoding.to_s + else + encoding = __invoke('encoding', 'system') + end + + # convert + case encoding + when 'utf-8', 'binary' + str + else + __toUTF8(str, encoding) + end + end + + def _fromUTF8(str, encoding = nil) + unless encoding + if defined?(@encoding) && @encoding != nil + encoding = @encoding.to_s + else + encoding = __invoke('encoding', 'system') + end + end + + if str.kind_of?(Tk::EncodedString) + if str.encoding == 'binary' + str + else + __fromUTF8(str, encoding) + end + elsif str.instance_variable_get(:@encoding).to_s == 'binary' + str + else + __fromUTF8(str, encoding) + end + end +=end + + def _eval(cmd) + _fromUTF8(__eval(_toUTF8(cmd))) + end + + def _invoke(*cmds) + _fromUTF8(__invoke(*(cmds.collect{|cmd| _toUTF8(cmd)}))) + end + + alias _eval_with_enc _eval + alias _invoke_with_enc _invoke + +=begin def _eval(cmd) - if defined? @encoding - if cmd.kind_of?(Tk::EncodedString) - _fromUTF8(__eval(_toUTF8(cmd, cmd.encoding)), @encoding) + if defined?(@encoding) && @encoding != 'utf-8' + ret = if cmd.kind_of?(Tk::EncodedString) + case cmd.encoding + when 'utf-8', 'binary' + __eval(cmd) + else + __eval(_toUTF8(cmd, cmd.encoding)) + end + elsif cmd.instance_variable_get(:@encoding) == 'binary' + __eval(cmd) + else + __eval(_toUTF8(cmd, @encoding)) + end + if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' + ret else - _fromUTF8(__eval(_toUTF8(cmd, @encoding)), @encoding) + _fromUTF8(ret, @encoding) end else __eval(cmd) @@ -1612,19 +1684,32 @@ if /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK end def _invoke(*cmds) - if defined? @encoding + if defined?(@encoding) && @encoding != 'utf-8' cmds = cmds.collect{|cmd| if cmd.kind_of?(Tk::EncodedString) - _toUTF8(cmd, cmd.encoding) + case cmd.encoding + when 'utf-8', 'binary' + cmd + else + _toUTF8(cmd, cmd.encoding) + end + elsif cmd.instance_variable_get(:@encoding) == 'binary' + cmd else _toUTF8(cmd, @encoding) end } - _fromUTF8(__invoke(*cmds), @encoding) + ret = __invoke(*cmds) + if ret.kind_of?(String) && ret.instance_variable_get(:@encoding) == 'binary' + ret + else + _fromUTF8(ret, @encoding) + end else __invoke(*cmds) end end +=end end module Tk @@ -1688,6 +1773,9 @@ else class TclTkIp alias __eval _eval alias __invoke _invoke + + alias _eval_with_enc _eval + alias _invoke_with_enc _invoke end module Tk @@ -1720,1709 +1808,9 @@ else end alias encoding_convert_to encoding_convertto end - - extend Encoding - end -end - -module TkBindCore - def bind(context, cmd=Proc.new, args=nil) - Tk.bind(self, context, cmd, args) - end - - def bind_append(context, cmd=Proc.new, args=nil) - Tk.bind_append(self, context, cmd, args) - end - - def bind_remove(context) - Tk.bind_remove(self, context) - end - - def bindinfo(context=nil) - Tk.bindinfo(self, context) - end -end - -class TkBindTag - include TkBindCore - - #BTagID_TBL = {} - BTagID_TBL = TkCore::INTERP.create_table - Tk_BINDTAG_ID = ["btag".freeze, "00000".taint].freeze - - TkCore::INTERP.init_ip_env{ BTagID_TBL.clear } - - def TkBindTag.id2obj(id) - BTagID_TBL[id]? BTagID_TBL[id]: id - end - - def TkBindTag.new_by_name(name, *args, &b) - return BTagID_TBL[name] if BTagID_TBL[name] - self.new(*args, &b).instance_eval{ - BTagID_TBL.delete @id - @id = name - BTagID_TBL[@id] = self - } - end - - def initialize(*args, &b) - @id = Tk_BINDTAG_ID.join - Tk_BINDTAG_ID[1].succ! - BTagID_TBL[@id] = self - bind(*args, &b) if args != [] - end - - ALL = self.new_by_name('all') - - def name - @id - end - - def to_eval - @id - end - - def inspect - Kernel.format "#<TkBindTag: %s>", @id - end -end - -class TkBindTagAll<TkBindTag - def TkBindTagAll.new(*args, &b) - $stderr.puts "Warning: TkBindTagALL is obsolete. Use TkBindTag::ALL\n" - - TkBindTag::ALL.bind(*args, &b) if args != [] - TkBindTag::ALL - end -end - -class TkDatabaseClass<TkBindTag - def self.new(name, *args, &b) - return BTagID_TBL[name] if BTagID_TBL[name] - super(name, *args, &b) - end - - def initialize(name, *args, &b) - @id = name - BTagID_TBL[@id] = self - bind(*args, &b) if args != [] - end - - def inspect - Kernel.format "#<TkDatabaseClass: %s>", @id - end -end - -class TkVariable - include Tk - extend TkCore - - include Comparable - - #TkCommandNames = ['tkwait'.freeze].freeze - TkCommandNames = ['vwait'.freeze].freeze - - #TkVar_CB_TBL = {} - #TkVar_ID_TBL = {} - TkVar_CB_TBL = TkCore::INTERP.create_table - TkVar_ID_TBL = TkCore::INTERP.create_table - Tk_VARIABLE_ID = ["v".freeze, "00000".taint].freeze - - TkCore::INTERP.add_tk_procs('rb_var', 'args', - "ruby [format \"TkVariable.callback %%Q!%s!\" $args]") - - def TkVariable.callback(args) - name1,name2,op = tk_split_list(args) - if TkVar_CB_TBL[name1] - _get_eval_string(TkVar_CB_TBL[name1].trace_callback(name2,op)) - else - '' - end - end - - def initialize(val="") - @id = Tk_VARIABLE_ID.join - Tk_VARIABLE_ID[1].succ! - TkVar_ID_TBL[@id] = self - - @trace_var = nil - @trace_elem = nil - @trace_opts = nil - -=begin - if val == [] - # INTERP._eval(format('global %s; set %s(0) 0; unset %s(0)', - # @id, @id, @id)) - elsif val.kind_of?(Array) - a = [] - # val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))} - # s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"' - val.each_with_index{|e,i| a.push(i); a.push(e)} - s = '"' + array2tk_list(a).gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(format('global %s; array set %s %s', @id, @id, s)) - elsif val.kind_of?(Hash) - s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ - .gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(format('global %s; array set %s %s', @id, @id, s)) - else - s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(format('global %s; set %s %s', @id, @id, s)) - end -=end - if val.kind_of?(Hash) - s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ - .gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(Kernel.format('global %s; array set %s %s', @id, @id, s)) - else - s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s)) - end - end - - def wait(on_thread = false, check_root = false) - if $SAFE >= 4 - fail SecurityError, "can't wait variable at $SAFE >= 4" - end - if on_thread - if check_root - INTERP._thread_tkwait('variable', @id) - else - INTERP._thread_vwait(@id) - end - else - if check_root - INTERP._invoke('tkwait', 'variable', @id) - else - INTERP._invoke('vwait', @id) - end - end - end - def eventloop_wait(check_root = false) - wait(false, check_root) - end - def thread_wait(check_root = false) - wait(true, check_root) - end - def tkwait(on_thread = true) - wait(on_thread, true) - end - def eventloop_tkwait - wait(false, true) - end - def thread_tkwait - wait(true, true) - end - - def id - @id - end - - def value - begin - INTERP._eval(Kernel.format('global %s; set %s', @id, @id)) - rescue - if INTERP._eval(Kernel.format('global %s; array exists %s', - @id, @id)) != "1" - fail - else - Hash[*tk_split_simplelist(INTERP._eval(Kernel.format('global %s; array get %s', @id, @id)))] - end - end - end - - def value=(val) - begin - s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s)) - rescue - if INTERP._eval(Kernel.format('global %s; array exists %s', - @id, @id)) != "1" - fail - else - if val == [] - INTERP._eval(Kernel.format('global %s; unset %s; set %s(0) 0; unset %s(0)', @id, @id, @id, @id)) - elsif val.kind_of?(Array) - a = [] - val.each_with_index{|e,i| a.push(i); a.push(array2tk_list(e))} - s = '"' + a.join(" ").gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', - @id, @id, @id, s)) - elsif val.kind_of?(Hash) - s = '"' + val.to_a.collect{|e| array2tk_list(e)}.join(" ")\ - .gsub(/[\[\]$"]/, '\\\\\&') + '"' - INTERP._eval(Kernel.format('global %s; unset %s; array set %s %s', - @id, @id, @id, s)) - else - fail - end - end - end - end - - def [](index) - INTERP._eval(Kernel.format('global %s; set %s(%s)', - @id, @id, _get_eval_string(index))) - end - - def []=(index,val) - INTERP._eval(Kernel.format('global %s; set %s(%s) %s', @id, @id, - _get_eval_string(index), _get_eval_string(val))) - end - - def numeric - number(value) - end - def numeric=(val) - case val - when Numeric - self.value=(val) - when TkVariable - self.value=(val.numeric) - else - raise ArgumentError, "Numeric is expected" - end - end - - def to_i - number(value).to_i - end - - def to_f - number(value).to_f - end - - def to_s - string(value).to_s - end - - def to_sym - value.intern - end - - def list - tk_split_list(value) - end - alias to_a list - - def list=(val) - case val - when Array - self.value=(val) - when TkVariable - self.value=(val.list) - else - raise ArgumentError, "Array is expected" - end - end - - def inspect - Kernel.format "#<TkVariable: %s>", @id - end - - def coerce(other) - case other - when TkVariable - [other.value, self.value] - when String - [other, self.to_s] - when Symbol - [other, self.to_sym] - when Integer - [other, self.to_i] - when Float - [other, self.to_f] - when Array - [other, self.to_a] - else - [other, self.value] - end - end - - def &(other) - if other.kind_of?(Array) - self.to_a & other.to_a - else - self.to_i & other.to_i - end - end - def |(other) - if other.kind_of?(Array) - self.to_a | other.to_a - else - self.to_i | other.to_i - end - end - def +(other) - case other - when Array - self.to_a + other - when String - self.value + other - else - begin - number(self.value) + other - rescue - self.value + other.to_s - end - end - end - def -(other) - if other.kind_of?(Array) - self.to_a - other - else - number(self.value) - other - end - end - def *(other) - begin - number(self.value) * other - rescue - self.value * other - end - end - def /(other) - number(self.value) / other - end - def %(other) - begin - number(self.value) % other - rescue - self.value % other - end - end - def **(other) - number(self.value) ** other - end - def =~(other) - self.value =~ other - end - - def ==(other) - case other - when TkVariable - self.equal?(other) - when String - self.to_s == other - when Symbol - self.to_sym == other - when Integer - self.to_i == other - when Float - self.to_f == other - when Array - self.to_a == other - when Hash - self.value == other - else - false - end - end - - def zero? - numeric.zero? - end - def nonzero? - !(numeric.zero?) - end - - def <=>(other) - if other.kind_of?(TkVariable) - begin - val = other.numeric - other = val - rescue - other = other.value - end - end - if other.kind_of?(Numeric) - begin - return self.numeric <=> other - rescue - return self.value <=> other.to_s - end - else - return self.value <=> other - end - end - - def to_eval - @id - end - - def unset(elem=nil) - if elem - INTERP._eval(Kernel.format('global %s; unset %s(%s)', - @id, @id, tk_tcl2ruby(elem))) - else - INTERP._eval(Kernel.format('global %s; unset %s', @id, @id)) - end - end - alias remove unset - - def trace_callback(elem, op) - if @trace_var.kind_of? Array - @trace_var.each{|m,e| e.call(self,elem,op) if m.index(op)} - end - if elem.kind_of? String - if @trace_elem[elem].kind_of? Array - @trace_elem[elem].each{|m,e| e.call(self,elem,op) if m.index(op)} - end - end - end - - def trace(opts, cmd) - @trace_var = [] if @trace_var == nil - opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('') - @trace_var.unshift([opts,cmd]) - if @trace_opts == nil - TkVar_CB_TBL[@id] = self - @trace_opts = opts - Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var') - else - newopts = @trace_opts.dup - opts.each_byte{|c| newopts += c.chr unless newopts.index(c)} - if newopts != @trace_opts - Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var') - end - end - end - - def trace_element(elem, opts, cmd) - @trace_elem = {} if @trace_elem == nil - @trace_elem[elem] = [] if @trace_elem[elem] == nil - opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('') - @trace_elem[elem].unshift([opts,cmd]) - if @trace_opts == nil - TkVar_CB_TBL[@id] = self - @trace_opts = opts - Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var') - else - newopts = @trace_opts.dup - opts.each_byte{|c| newopts += c.chr unless newopts.index(c)} - if newopts != @trace_opts - Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var') - end - end - end - - def trace_vinfo - return [] unless @trace_var - @trace_var.dup - end - def trace_vinfo_for_element(elem) - return [] unless @trace_elem - return [] unless @trace_elem[elem] - @trace_elem[elem].dup - end - - def trace_vdelete(opts,cmd) - return unless @trace_var.kind_of? Array - opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('') - idx = -1 - newopts = '' - @trace_var.each_with_index{|e,i| - if idx < 0 && e[0] == opts && e[1] == cmd - idx = i - next - end - e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} - } - if idx >= 0 - @trace_var.delete_at(idx) - else - return - end - - @trace_elem.each{|elem| - @trace_elem[elem].each{|e| - e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} - } - } - - newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('') - if newopts != @trace_opts - Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - if @trace_opts != '' - Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var') - end - end - end - - def trace_vdelete_for_element(elem,opts,cmd) - return unless @trace_elem.kind_of? Hash - return unless @trace_elem[elem].kind_of? Array - opts = ['r','w','u'].find_all{|c| opts.index(c)}.join('') - idx = -1 - @trace_elem[elem].each_with_index{|e,i| - if idx < 0 && e[0] == opts && e[1] == cmd - idx = i - next - end - } - if idx >= 0 - @trace_elem[elem].delete_at(idx) - else - return - end - - newopts = '' - @trace_var.each{|e| - e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} - } - @trace_elem.each{|elem| - @trace_elem[elem].each{|e| - e[0].each_byte{|c| newopts += c.chr unless newopts.index(c)} - } - } - - newopts = ['r','w','u'].find_all{|c| newopts.index(c)}.join('') - if newopts != @trace_opts - Tk.tk_call('trace', 'vdelete', @id, @trace_opts, 'rb_var') - @trace_opts.replace(newopts) - if @trace_opts != '' - Tk.tk_call('trace', 'variable', @id, @trace_opts, 'rb_var') - end - end - end -end - -class TkVarAccess<TkVariable - def self.new(name, *args) - return TkVar_ID_TBL[name] if TkVar_ID_TBL[name] - super(name, *args) - end - - def initialize(varname, val=nil) - @id = varname - TkVar_ID_TBL[@id] = self - if val - s = '"' + _get_eval_string(val).gsub(/[\[\]$"]/, '\\\\\&') + '"' #" - INTERP._eval(Kernel.format('global %s; set %s %s', @id, @id, s)) - end - end -end - -module Tk - begin - auto_path = INTERP._invoke('set', 'auto_path') - rescue - begin - auto_path = INTERP._invoke('set', 'env(TCLLIBPATH)') - rescue - auto_path = Tk::LIBRARY - end - end - - AUTO_PATH = TkVarAccess.new('auto_path', auto_path) - -=begin - AUTO_OLDPATH = tk_split_simplelist(INTERP._invoke('set', 'auto_oldpath')) - AUTO_OLDPATH.each{|s| s.freeze} - AUTO_OLDPATH.freeze -=end - - TCL_PACKAGE_PATH = TkVarAccess.new('tcl_pkgPath') - PACKAGE_PATH = TCL_PACKAGE_PATH - - TCL_LIBRARY_PATH = TkVarAccess.new('tcl_libPath') - LIBRARY_PATH = TCL_LIBRARY_PATH - - TCL_PRECISION = TkVarAccess.new('tcl_precision') -end - -module TkSelection - include Tk - extend Tk - - TkCommandNames = ['selection'.freeze].freeze - - def self.clear(sel=nil) - if sel - tk_call 'selection', 'clear', '-selection', sel - else - tk_call 'selection', 'clear' - end - end - def self.clear_on_display(win, sel=nil) - if sel - tk_call 'selection', 'clear', '-displayof', win, '-selection', sel - else - tk_call 'selection', 'clear', '-displayof', win - end - end - def clear(sel=nil) - TkSelection.clear_on_display(self, sel) - self - end - - def self.get(keys=nil) - tk_call 'selection', 'get', *hash_kv(keys) - end - def self.get_on_display(win, keys=nil) - tk_call 'selection', 'get', '-displayof', win, *hash_kv(keys) - end - def get(keys=nil) - TkSelection.get_on_display(self, sel) - end - - def self.handle(win, func=Proc.new, keys=nil, &b) - if func.kind_of?(Hash) && keys == nil - keys = func - func = Proc.new(&b) - end - args = ['selection', 'handle'] - args += hash_kv(keys) - args += [win, func] - tk_call(*args) - end - def handle(func=Proc.new, keys=nil, &b) - TkSelection.handle(self, func, keys, &b) - end - - def self.get_owner(sel=nil) - if sel - window(tk_call('selection', 'own', '-selection', sel)) - else - window(tk_call('selection', 'own')) - end - end - def self.get_owner_on_display(win, sel=nil) - if sel - window(tk_call('selection', 'own', '-displayof', win, '-selection', sel)) - else - window(tk_call('selection', 'own', '-displayof', win)) - end - end - def get_owner(sel=nil) - TkSelection.get_owner_on_display(self, sel) - self - end - - def self.set_owner(win, keys=nil) - tk_call('selection', 'own', *(hash_kv(keys) << win)) - end - def set_owner(keys=nil) - TkSelection.set_owner(self, keys) - self end end -module TkKinput - include Tk - extend Tk - - TkCommandNames = [ - 'kinput_start'.freeze, - 'kinput_send_spot'.freeze, - 'kanjiInput'.freeze - ].freeze - - def TkKinput.start(window, style=None) - tk_call 'kinput_start', window.path, style - end - def kinput_start(style=None) - TkKinput.start(self, style) - end - - def TkKinput.send_spot(window) - tk_call 'kinput_send_spot', window.path - end - def kinput_send_spot - TkKinput.send_spot(self) - end - - def TkKinput.input_start(window, keys=nil) - tk_call 'kanjiInput', 'start', window.path, *hash_kv(keys) - end - def kanji_input_start(keys=nil) - TkKinput.input_start(self, keys) - end - - def TkKinput.attribute_config(window, slot, value=None) - if slot.kind_of? Hash - tk_call 'kanjiInput', 'attribute', window.path, *hash_kv(slot) - else - tk_call 'kanjiInput', 'attribute', window.path, "-#{slot}", value - end - end - def kinput_attribute_config(slot, value=None) - TkKinput.attribute_config(self, slot, value) - end - - def TkKinput.attribute_info(window, slot=nil) - if slot - conf = tk_split_list(tk_call('kanjiInput', 'attribute', - window.path, "-#{slot}")) - conf[0] = conf[0][1..-1] - conf - else - tk_split_list(tk_call('kanjiInput', 'attribute', - window.path)).collect{|conf| - conf[0] = conf[0][1..-1] - conf - } - end - end - def kinput_attribute_info(slot=nil) - TkKinput.attribute_info(self, slot) - end - - def TkKinput.input_end(window) - tk_call 'kanjiInput', 'end', window.path - end - def kanji_input_end - TkKinput.input_end(self) - end -end - -module TkXIM - include Tk - extend Tk - - TkCommandNames = ['imconfigure'.freeze].freeze - - def TkXIM.useinputmethods(window=nil, value=nil) - if window - if value - tk_call 'tk', 'useinputmethods', '-displayof', window.path, value - else - tk_call 'tk', 'useinputmethods', '-displayof', window.path - end - else - if value - tk_call 'tk', 'useinputmethods', value - else - tk_call 'tk', 'useinputmethods' - end - end - end - - def TkXIM.caret(window, keys=nil) - if keys - tk_call('tk', 'caret', window, *hash_kv(keys)) - self - else - lst = tk_split_list(tk_call('tk', 'caret', window)) - info = {} - while key = lst.shift - info[key[1..-1]] = lst.shift - end - info - end - end - - def TkXIM.configure(window, slot, value=None) - begin - if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK - if slot.kind_of? Hash - tk_call 'imconfigure', window.path, *hash_kv(slot) - else - tk_call 'imconfigure', window.path, "-#{slot}", value - end - end - rescue - end - end - - def TkXIM.configinfo(window, slot=nil) - begin - if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK - if slot - conf = tk_split_list(tk_call('imconfigure', window.path, "-#{slot}")) - conf[0] = conf[0][1..-1] - conf - else - tk_split_list(tk_call('imconfigure', window.path)).collect{|conf| - conf[0] = conf[0][1..-1] - conf - } - end - else - [] - end - rescue - [] - end - end - - def useinputmethods(value=nil) - TkXIM.useinputmethods(self, value) - end - - def caret(keys=nil) - TkXIM.caret(self, keys=nil) - end - - def imconfigure(slot, value=None) - TkXIM.configinfo(self, slot, value) - end - - def imconfiginfo(slot=nil) - TkXIM.configinfo(self, slot) - end -end - -module TkWinfo - include Tk - extend Tk - - TkCommandNames = ['winfo'.freeze].freeze - - def TkWinfo.atom(name, win=nil) - if win - number(tk_call('winfo', 'atom', '-displayof', win, name)) - else - number(tk_call('winfo', 'atom', name)) - end - end - def winfo_atom(name) - TkWinfo.atom(name, self) - end - - def TkWinfo.atomname(id, win=nil) - if win - tk_call('winfo', 'atomname', '-displayof', win, id) - else - tk_call('winfo', 'atomname', id) - end - end - def winfo_atomname(id) - TkWinfo.atomname(id, self) - end - - def TkWinfo.cells(window) - number(tk_call('winfo', 'cells', window.path)) - end - def winfo_cells - TkWinfo.cells self - end - - def TkWinfo.children(window) - c = tk_call('winfo', 'children', window.path) - list(c) - end - def winfo_children - TkWinfo.children self - end - - def TkWinfo.classname(window) - tk_call 'winfo', 'class', window.path - end - def winfo_classname - TkWinfo.classname self - end - alias winfo_class winfo_classname - - def TkWinfo.colormapfull(window) - bool(tk_call('winfo', 'colormapfull', window.path)) - end - def winfo_colormapfull - TkWinfo.colormapfull self - end - - def TkWinfo.containing(rootX, rootY, win=nil) - if win - window(tk_call('winfo', 'containing', '-displayof', win, rootX, rootY)) - else - window(tk_call('winfo', 'containing', rootX, rootY)) - end - end - def winfo_containing(x, y) - TkWinfo.containing(x, y, self) - end - - def TkWinfo.depth(window) - number(tk_call('winfo', 'depth', window.path)) - end - def winfo_depth - TkWinfo.depth self - end - - def TkWinfo.exist?(window) - bool(tk_call('winfo', 'exists', window.path)) - end - def winfo_exist? - TkWinfo.exist? self - end - - def TkWinfo.fpixels(window, dist) - number(tk_call('winfo', 'fpixels', window.path, dist)) - end - def winfo_fpixels(dist) - TkWinfo.fpixels self, dist - end - - def TkWinfo.geometry(window) - tk_call('winfo', 'geometry', window.path) - end - def winfo_geometry - TkWinfo.geometry self - end - - def TkWinfo.height(window) - number(tk_call('winfo', 'height', window.path)) - end - def winfo_height - TkWinfo.height self - end - - def TkWinfo.id(window) - tk_call('winfo', 'id', window.path) - end - def winfo_id - TkWinfo.id self - end - - def TkWinfo.interps(window=nil) - if window - tk_split_simplelist(tk_call('winfo', 'interps', - '-displayof', window.path)) - else - tk_split_simplelist(tk_call('winfo', 'interps')) - end - end - def winfo_interps - TkWinfo.interps self - end - - def TkWinfo.mapped?(window) - bool(tk_call('winfo', 'ismapped', window.path)) - end - def winfo_mapped? - TkWinfo.mapped? self - end - - def TkWinfo.manager(window) - tk_call('winfo', 'manager', window.path) - end - def winfo_manager - TkWinfo.manager self - end - - def TkWinfo.appname(window) - tk_call('winfo', 'name', window.path) - end - def winfo_appname - TkWinfo.appname self - end - - def TkWinfo.parent(window) - window(tk_call('winfo', 'parent', window.path)) - end - def winfo_parent - TkWinfo.parent self - end - - def TkWinfo.widget(id, win=nil) - if win - window(tk_call('winfo', 'pathname', '-displayof', win, id)) - else - window(tk_call('winfo', 'pathname', id)) - end - end - def winfo_widget(id) - TkWinfo.widget id, self - end - - def TkWinfo.pixels(window, dist) - number(tk_call('winfo', 'pixels', window.path, dist)) - end - def winfo_pixels(dist) - TkWinfo.pixels self, dist - end - - def TkWinfo.reqheight(window) - number(tk_call('winfo', 'reqheight', window.path)) - end - def winfo_reqheight - TkWinfo.reqheight self - end - - def TkWinfo.reqwidth(window) - number(tk_call('winfo', 'reqwidth', window.path)) - end - def winfo_reqwidth - TkWinfo.reqwidth self - end - - def TkWinfo.rgb(window, color) - list(tk_call('winfo', 'rgb', window.path, color)) - end - def winfo_rgb(color) - TkWinfo.rgb self, color - end - - def TkWinfo.rootx(window) - number(tk_call('winfo', 'rootx', window.path)) - end - def winfo_rootx - TkWinfo.rootx self - end - - def TkWinfo.rooty(window) - number(tk_call('winfo', 'rooty', window.path)) - end - def winfo_rooty - TkWinfo.rooty self - end - - def TkWinfo.screen(window) - tk_call 'winfo', 'screen', window.path - end - def winfo_screen - TkWinfo.screen self - end - - def TkWinfo.screencells(window) - number(tk_call('winfo', 'screencells', window.path)) - end - def winfo_screencells - TkWinfo.screencells self - end - - def TkWinfo.screendepth(window) - number(tk_call('winfo', 'screendepth', window.path)) - end - def winfo_screendepth - TkWinfo.screendepth self - end - - def TkWinfo.screenheight (window) - number(tk_call('winfo', 'screenheight', window.path)) - end - def winfo_screenheight - TkWinfo.screenheight self - end - - def TkWinfo.screenmmheight(window) - number(tk_call('winfo', 'screenmmheight', window.path)) - end - def winfo_screenmmheight - TkWinfo.screenmmheight self - end - - def TkWinfo.screenmmwidth(window) - number(tk_call('winfo', 'screenmmwidth', window.path)) - end - def winfo_screenmmwidth - TkWinfo.screenmmwidth self - end - - def TkWinfo.screenvisual(window) - tk_call('winfo', 'screenvisual', window.path) - end - def winfo_screenvisual - TkWinfo.screenvisual self - end - - def TkWinfo.screenwidth(window) - number(tk_call('winfo', 'screenwidth', window.path)) - end - def winfo_screenwidth - TkWinfo.screenwidth self - end - - def TkWinfo.server(window) - tk_call 'winfo', 'server', window.path - end - def winfo_server - TkWinfo.server self - end - - def TkWinfo.toplevel(window) - window(tk_call('winfo', 'toplevel', window.path)) - end - def winfo_toplevel - TkWinfo.toplevel self - end - - def TkWinfo.visual(window) - tk_call('winfo', 'visual', window.path) - end - def winfo_visual - TkWinfo.visual self - end - - def TkWinfo.visualid(window) - tk_call('winfo', 'visualid', window.path) - end - def winfo_visualid - TkWinfo.visualid self - end - - def TkWinfo.visualsavailable(window, includeids=false) - if includeids - list(tk_call('winfo', 'visualsavailable', window.path, "includeids")) - else - list(tk_call('winfo', 'visualsavailable', window.path)) - end - end - def winfo_visualsavailable(includeids=false) - TkWinfo.visualsavailable self, includeids - end - - def TkWinfo.vrootheight(window) - number(tk_call('winfo', 'vrootheight', window.path)) - end - def winfo_vrootheight - TkWinfo.vrootheight self - end - - def TkWinfo.vrootwidth(window) - number(tk_call('winfo', 'vrootwidth', window.path)) - end - def winfo_vrootwidth - TkWinfo.vrootwidth self - end - - def TkWinfo.vrootx(window) - number(tk_call('winfo', 'vrootx', window.path)) - end - def winfo_vrootx - TkWinfo.vrootx self - end - - def TkWinfo.vrooty(window) - number(tk_call('winfo', 'vrooty', window.path)) - end - def winfo_vrooty - TkWinfo.vrooty self - end - - def TkWinfo.width(window) - number(tk_call('winfo', 'width', window.path)) - end - def winfo_width - TkWinfo.width self - end - - def TkWinfo.x(window) - number(tk_call('winfo', 'x', window.path)) - end - def winfo_x - TkWinfo.x self - end - - def TkWinfo.y(window) - number(tk_call('winfo', 'y', window.path)) - end - def winfo_y - TkWinfo.y self - end - - def TkWinfo.viewable(window) - bool(tk_call('winfo', 'viewable', window.path)) - end - def winfo_viewable - TkWinfo.viewable self - end - - def TkWinfo.pointerx(window) - number(tk_call('winfo', 'pointerx', window.path)) - end - def winfo_pointerx - TkWinfo.pointerx self - end - - def TkWinfo.pointery(window) - number(tk_call('winfo', 'pointery', window.path)) - end - def winfo_pointery - TkWinfo.pointery self - end - - def TkWinfo.pointerxy(window) - list(tk_call('winfo', 'pointerxy', window.path)) - end - def winfo_pointerxy - TkWinfo.pointerxy self - end -end - -module TkPack - include Tk - extend Tk - - TkCommandNames = ['pack'.freeze].freeze - - def configure(win, *args) - if args[-1].kind_of?(Hash) - keys = args.pop - end - wins = [win.epath] - for i in args - wins.push i.epath - end - tk_call "pack", 'configure', *(wins+hash_kv(keys)) - end - - def forget(*args) - tk_call 'pack', 'forget' *args - end - - def info(slave) - ilist = list(tk_call('pack', 'info', slave.epath)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - return info - end - - def propagate(master, bool=None) - if bool == None - bool(tk_call('pack', 'propagate', master.epath)) - else - tk_call('pack', 'propagate', master.epath, bool) - end - end - - def slaves(master) - list(tk_call('pack', 'slaves', master.epath)) - end - - module_function :configure, :forget, :info, :propagate, :slaves -end - -module TkGrid - include Tk - extend Tk - - TkCommandNames = ['grid'.freeze].freeze - - def bbox(*args) - list(tk_call('grid', 'bbox', *args)) - end - - def configure(widget, *args) - if args[-1].kind_of?(Hash) - keys = args.pop - end - wins = [] - args.unshift(widget) - for i in args - case i - when '-', 'x', '^' # RELATIVE PLACEMENT - wins.push(i) - else - wins.push(i.epath) - end - end - tk_call "grid", 'configure', *(wins+hash_kv(keys)) - end - - def columnconfigure(master, index, args) - tk_call "grid", 'columnconfigure', master, index, *hash_kv(args) - end - - def rowconfigure(master, index, args) - tk_call "grid", 'rowconfigure', master, index, *hash_kv(args) - end - - def columnconfiginfo(master, index, slot=nil) - if slot - tk_call('grid', 'columnconfigure', master, index, "-#{slot}").to_i - else - ilist = list(tk_call('grid', 'columnconfigure', master, index)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - info - end - end - - def rowconfiginfo(master, index, slot=nil) - if slot - tk_call('grid', 'rowconfigure', master, index, "-#{slot}").to_i - else - ilist = list(tk_call('grid', 'rowconfigure', master, index)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - info - end - end - - def add(widget, *args) - configure(widget, *args) - end - - def forget(*args) - tk_call 'grid', 'forget', *args - end - - def info(slave) - list(tk_call('grid', 'info', slave)) - end - - def location(master, x, y) - list(tk_call('grid', 'location', master, x, y)) - end - - def propagate(master, bool=None) - if bool == None - bool(tk_call('grid', 'propagate', master.epath)) - else - tk_call('grid', 'propagate', master.epath, bool) - end - end - - def remove(*args) - tk_call 'grid', 'remove', *args - end - - def size(master) - list(tk_call('grid', 'size', master)) - end - - def slaves(master, args) - list(tk_call('grid', 'slaves', master, *hash_kv(args))) - end - - module_function :bbox, :forget, :propagate, :info - module_function :remove, :size, :slaves, :location - module_function :configure, :columnconfigure, :rowconfigure - module_function :columnconfiginfo, :rowconfiginfo -end - -module TkPlace - include Tk - extend Tk - - TkCommandNames = ['place'.freeze].freeze - - def configure(win, slot, value=None) - if slot.kind_of? Hash - tk_call 'place', 'configure', win.epath, *hash_kv(slot) - else - tk_call 'place', 'configure', win.epath, "-#{slot}", value - end - end - - def configinfo(win, slot = nil) - # for >= Tk8.4a2 ? - if slot - conf = tk_split_list(tk_call('place', 'configure', - win.epath, "-#{slot}") ) - conf[0] = conf[0][1..-1] - conf - else - tk_split_simplelist(tk_call('place', 'configure', - win.epath)).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - conf - } - end - end - - def forget(win) - tk_call 'place', 'forget', win - end - - def info(win) - ilist = list(tk_call('place', 'info', win.epath)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - return info - end - - def slaves(master) - list(tk_call('place', 'slaves', master.epath)) - end - - module_function :configure, :configinfo, :forget, :info, :slaves -end - -module TkOptionDB - include Tk - extend Tk - - TkCommandNames = ['option'.freeze].freeze - - module Priority - WidgetDefault = 20 - StartupFile = 40 - UserDefault = 60 - Interactive = 80 - end - - def add(pat, value, pri=None) - if $SAFE >= 4 - fail SecurityError, "can't call 'TkOptionDB.add' at $SAFE >= 4" - end - tk_call 'option', 'add', pat, value, pri - end - def clear - if $SAFE >= 4 - fail SecurityError, "can't call 'TkOptionDB.crear' at $SAFE >= 4" - end - tk_call 'option', 'clear' - end - def get(win, name, klass) - tk_call('option', 'get', win ,name, klass) - end - def readfile(file, pri=None) - tk_call 'option', 'readfile', file, pri - end - module_function :add, :clear, :get, :readfile - - def read_entries(file, f_enc=nil) - if TkCore::INTERP.safe? - fail SecurityError, - "can't call 'TkOptionDB.read_entries' on a safe interpreter" - end - - i_enc = Tk.encoding() - - unless f_enc - f_enc = i_enc - end - - ent = [] - cline = '' - open(file, 'r') {|f| - while line = f.gets - cline += line.chomp! - case cline - when /\\$/ # continue - cline.chop! - next - when /^!/ # coment - cline = '' - next - when /^([^:]+):\s(.*)$/ - pat = $1 - val = $2 - p "ResourceDB: #{[pat, val].inspect}" if $DEBUG - pat = TkCore::INTERP._toUTF8(pat, f_enc) - pat = TkCore::INTERP._fromUTF8(pat, i_enc) - val = TkCore::INTERP._toUTF8(val, f_enc) - val = TkCore::INTERP._fromUTF8(val, i_enc) - ent << [pat, val] - cline = '' - else # unknown --> ignore - cline = '' - next - end - end - } - ent - end - module_function :read_entries - - def read_with_encoding(file, f_enc=nil, pri=None) - # try to read the file as an OptionDB file - readfile(file, pri).each{|pat, val| - add(pat, val, pri) - } - -=begin - i_enc = Tk.encoding() - - unless f_enc - f_enc = i_enc - end - - cline = '' - open(file, 'r') {|f| - while line = f.gets - cline += line.chomp! - case cline - when /\\$/ # continue - cline.chop! - next - when /^!/ # coment - cline = '' - next - when /^([^:]+):\s(.*)$/ - pat = $1 - val = $2 - p "ResourceDB: #{[pat, val].inspect}" if $DEBUG - pat = TkCore::INTERP._toUTF8(pat, f_enc) - pat = TkCore::INTERP._fromUTF8(pat, i_enc) - val = TkCore::INTERP._toUTF8(val, f_enc) - val = TkCore::INTERP._fromUTF8(val, i_enc) - add(pat, val, pri) - cline = '' - else # unknown --> ignore - cline = '' - next - end - end - } -=end - end - module_function :read_with_encoding - - # support procs on the resource database - @@resource_proc_class = Class.new - class << @@resource_proc_class - private :new - - CARRIER = '.'.freeze - METHOD_TBL = TkCore::INTERP.create_table - ADD_METHOD = false - SAFE_MODE = 4 - - def __closed_block_check__(str) - depth = 0 - str.scan(/[{}]/){|x| - if x == "{" - depth += 1 - elsif x == "}" - depth -= 1 - end - if depth <= 0 && !($' =~ /\A\s*\Z/) - fail RuntimeError, "bad string for procedure : #{str.inspect}" - end - } - str - end - - def __check_proc_string__(str) - # If you want to check the proc_string, do it in this method. - # Please define this in the block given to 'new_proc_class' method. - str - end - - def method_missing(id, *args) - res_proc = self::METHOD_TBL[id] - unless res_proc.kind_of? Proc - if id == :new || !(self::METHOD_TBL.has_key?(id) || self::ADD_METHOD) - raise NoMethodError, - "not support resource-proc '#{id.id2name}' for #{self.name}" - end - proc_str = TkOptionDB.get(self::CARRIER, id.id2name, '').strip - proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str - proc_str = __closed_block_check__(proc_str) - proc_str = __check_proc_string__(proc_str) - res_proc = eval('Proc.new' + proc_str) - self::METHOD_TBL[id] = res_proc - end - proc{ - $SAFE = self::SAFE_MODE - res_proc.call(*args) - }.call - end - - private :__closed_block_check__, :__check_proc_string__, :method_missing - end - @@resource_proc_class.freeze - - def __create_new_class(klass, func, safe = 4, add = false, parent = nil) - klass = klass.to_s if klass.kind_of? Symbol - unless (?A..?Z) === klass[0] - fail ArgumentError, "bad string '#{klass}' for class name" - end - unless func.kind_of? Array - fail ArgumentError, "method-list must be Array" - end - func_str = func.join(' ') - if parent == nil - install_win(parent) - elsif parent <= @@resource_proc_class - install_win(parent::CARRIER) - else - fail ArgumentError, "parent must be Resource-Proc class" - end - carrier = Tk.tk_call('frame', @path, '-class', klass) - - body = <<-"EOD" - class #{klass} < TkOptionDB.module_eval('@@resource_proc_class') - CARRIER = '#{carrier}'.freeze - METHOD_TBL = TkCore::INTERP.create_table - ADD_METHOD = #{add} - SAFE_MODE = #{safe} - %w(#{func_str}).each{|f| METHOD_TBL[f.intern] = nil } - end - EOD - - if parent.kind_of?(Class) && parent <= @@resource_proc_class - parent.class_eval(body) - eval(parent.name + '::' + klass) - else - eval(body) - eval('TkOptionDB::' + klass) - end - end - module_function :__create_new_class - private_class_method :__create_new_class - - def __remove_methods_of_proc_class(klass) - # for security, make these methods invalid - class << klass - attr_reader :class_eval, :name, :superclass, - :ancestors, :const_defined?, :const_get, :const_set, - :constants, :included_modules, :instance_methods, - :method_defined?, :module_eval, :private_instance_methods, - :protected_instance_methods, :public_instance_methods, - :remove_const, :remove_method, :undef_method, - :to_s, :inspect, :display, :method, :methods, - :instance_eval, :instance_variables, :kind_of?, :is_a?, - :private_methods, :protected_methods, :public_methods - end - end - module_function :__remove_methods_of_proc_class - private_class_method :__remove_methods_of_proc_class - - RAND_BASE_CNT = [0] - RAND_BASE_HEAD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' - RAND_BASE_CHAR = RAND_BASE_HEAD + 'abcdefghijklmnopqrstuvwxyz0123456789_' - def __get_random_basename - name = '%s%03d' % [RAND_BASE_HEAD[rand(RAND_BASE_HEAD.size),1], - RAND_BASE_CNT[0]] - len = RAND_BASE_CHAR.size - (6+rand(10)).times{ - name << RAND_BASE_CHAR[rand(len),1] - } - RAND_BASE_CNT[0] = RAND_BASE_CNT[0] + 1 - name - end - module_function :__get_random_basename - private_class_method :__get_random_basename - - # define new proc class : - # If you want to modify the new class or create a new subclass, - # you must do such operation in the block parameter. - # Because the created class is flozen after evaluating the block. - def new_proc_class(klass, func, safe = 4, add = false, parent = nil, &b) - new_klass = __create_new_class(klass, func, safe, add, parent) - new_klass.class_eval(&b) if block_given? - __remove_methods_of_proc_class(new_klass) - new_klass.freeze - new_klass - end - module_function :new_proc_class - - def eval_under_random_base(parent = nil, &b) - new_klass = __create_new_class(__get_random_basename(), - [], 4, false, parent) - ret = new_klass.class_eval(&b) if block_given? - __remove_methods_of_proc_class(new_klass) - new_klass.freeze - ret - end - module_function :eval_under_random_base - - def new_proc_class_random(klass, func, safe = 4, add = false, &b) - eval_under_random_base(){ - TkOption.new_proc_class(klass, func, safe, add, self, &b) - } - end - module_function :new_proc_class_random -end -TkOption = TkOptionDB -TkResourceDB = TkOptionDB module TkTreatFont def font_configinfo(name = nil) @@ -3573,198 +1961,37 @@ module TkTreatFont end end -module TkTreatItemFont - def __conf_cmd(idx) - raise NotImplementedError, "need to define `__conf_cmd'" - end - def __item_pathname(tagOrId) - raise NotImplementedError, "need to define `__item_pathname'" - end - private :__conf_cmd, :__item_pathname - - def tagfont_configinfo(tagOrId, name = nil) - pathname = __item_pathname(tagOrId) - ret = TkFont.used_on(pathname) - if ret == nil -=begin - if name - ret = name - else - ret = TkFont.init_widget_font(pathname, self.path, - __conf_cmd(0), __conf_cmd(1), tagOrId) - end -=end - 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) - slot = _symbolkey2str(slot) - - if slot.key?('font') - 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 - if fnt - if (slot.key?('kanjifont') || - slot.key?('latinfont') || - slot.key?('asciifont')) - fnt = TkFont.new(fnt) - - lfnt = slot.delete('latinfont') - lfnt = slot.delete('asciifont') if slot.key?('asciifont') - kfnt = slot.delete('kanjifont') - - fnt.latin_replace(lfnt) if lfnt - fnt.kanji_replace(kfnt) if kfnt - end - - slot['font'] = fnt - tk_call(self.path, __conf_cmd(0), __conf_cmd(1), - tagOrId, *hash_kv(slot)) - end - return self - end - end - - lfnt = slot.delete('latinfont') - lfnt = slot.delete('asciifont') if slot.key?('asciifont') - kfnt = slot.delete('kanjifont') - - if lfnt && kfnt - return TkFont.new(lfnt, kfnt).call_font_configure(pathname, self.path, - __conf_cmd(0), - __conf_cmd(1), - tagOrId, slot) - end - - latintagfont_configure(tagOrId, lfnt) if lfnt - kanjitagfont_configure(tagOrId, kfnt) if kfnt - - 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) - pathname = __item_pathname(tagOrId) - if (fobj = TkFont.used_on(pathname)) - fobj = TkFont.new(fobj) # create a new TkFont object - elsif Tk::JAPANIZED_TK - fobj = tagfontobj(tagOrId) # create a new TkFont object - else - tk_call(self.path, __conf_cmd(0), __conf_cmd(1), tagOrId, '-font', ltn) - return self - end - - if fobj.kind_of?(TkFont) - if ltn.kind_of? TkFont - conf = {} - ltn.latin_configinfo.each{|key,val| conf[key] = val} - if keys - fobj.latin_configure(conf.update(keys)) - else - fobj.latin_configure(conf) - end - else - fobj.latin_replace(ltn) - end - end - return fobj.call_font_configure(pathname, self.path, - __conf_cmd(0), __conf_cmd(1), tagOrId, {}) +module TkBindCore + def bind(context, cmd=Proc.new, args=nil) + Tk.bind(self, context, cmd, args) end - alias asciitagfont_configure latintagfont_configure - - def kanjitagfont_configure(tagOrId, knj, keys=nil) - pathname = __item_pathname(tagOrId) - if (fobj = TkFont.used_on(pathname)) - fobj = TkFont.new(fobj) # create a new TkFont object - elsif Tk::JAPANIZED_TK - fobj = tagfontobj(tagOrId) # create a new TkFont object - else - tk_call(self.path, __conf_cmd(0), __conf_cmd(1), tagOrId, '-font', knj) - return self - end - - if fobj.kind_of?(TkFont) - if knj.kind_of? TkFont - conf = {} - knj.kanji_configinfo.each{|key,val| conf[key] = val} - if keys - fobj.kanji_configure(conf.update(keys)) - else - fobj.kanji_configure(conf) - end - else - fobj.kanji_replace(knj) - end - end - return fobj.call_font_configure(pathname, self.path, - __conf_cmd(0), __conf_cmd(1), tagOrId, {}) + def bind_append(context, cmd=Proc.new, args=nil) + Tk.bind_append(self, context, cmd, args) end - def tagfont_copy(tagOrId, window, wintag=nil) - pathname = __item_pathname(tagOrId) - if wintag - fnt = window.tagfontobj(wintag).dup - else - fnt = window.fontobj.dup - end - fnt.call_font_configure(pathname, self.path, - __conf_cmd(0), __conf_cmd(1), tagOrId, {}) - return self - end - - def latintagfont_copy(tagOrId, window, wintag=nil) - pathname = __item_pathname(tagOrId) - tagfontobj(tagOrId).dup.call_font_configure(pathname, self.path, - __conf_cmd(0), __conf_cmd(1), - tagOrId, {}) - if wintag - tagfontobj(tagOrId). - latin_replace(window.tagfontobj(wintag).latin_font_id) - else - tagfontobj(tagOrId).latin_replace(window.fontobj.latin_font_id) - end - self + def bind_remove(context) + Tk.bind_remove(self, context) end - alias asciitagfont_copy latintagfont_copy - def kanjitagfont_copy(tagOrId, window, wintag=nil) - pathname = __item_pathname(tagOrId) - tagfontobj(tagOrId).dup.call_font_configure(pathname, self.path, - __conf_cmd(0), __conf_cmd(1), - tagOrId, {}) - if wintag - tagfontobj(tagOrId). - kanji_replace(window.tagfontobj(wintag).kanji_font_id) - else - tagfontobj(tagOrId).kanji_replace(window.fontobj.kanji_font_id) - end - self + def bindinfo(context=nil) + Tk.bindinfo(self, context) end end + class TkObject<TkKernel include Tk include TkTreatFont include TkBindCore def path - return @path + @path end def epath - return @path + @path end def to_eval @@ -3772,18 +1999,28 @@ class TkObject<TkKernel end def tk_send(cmd, *rest) - tk_call path, cmd, *rest + tk_call(path, cmd, *rest) + end + def tk_send_without_enc(cmd, *rest) + tk_call_without_enc(path, cmd, *rest) + end + def tk_send_with_enc(cmd, *rest) + tk_call_with_enc(path, cmd, *rest) end - private :tk_send + private :tk_send, :tk_send_without_enc, :tk_send_with_enc def method_missing(id, *args) name = id.id2name case args.length when 1 - configure name, args[0] + if name[-1] == ?= + configure name[0..-2], args[0] + else + configure name, args[0] + end when 0 begin - cget name + cget(name) rescue fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", @@ -3795,20 +2032,23 @@ class TkObject<TkKernel end def [](id) - cget id + cget(id) end def []=(id, val) - configure id, val + configure(id, val) + val end def cget(slot) case slot.to_s when 'text', 'label', 'show', 'data', 'file' - tk_call path, 'cget', "-#{slot}" + #tk_call(path, 'cget', "-#{slot}") + _fromUTF8(tk_call_without_enc(path, 'cget', "-#{slot}")) when 'font', 'kanjifont' #fnt = tk_tcl2ruby(tk_call(path, 'cget', "-#{slot}")) - fnt = tk_tcl2ruby(tk_call(path, 'cget', "-font")) + #fnt = tk_tcl2ruby(tk_call(path, 'cget', "-font")) + fnt = tk_tcl2ruby(tk_call_without_enc(path, 'cget', "-font"), true) unless fnt.kind_of?(TkFont) fnt = fontobj(fnt) end @@ -3819,7 +2059,7 @@ class TkObject<TkKernel fnt end else - tk_tcl2ruby tk_call(path, 'cget', "-#{slot}") + tk_tcl2ruby(tk_call_without_enc(path, 'cget', "-#{slot}"), true) end end @@ -3831,7 +2071,7 @@ class TkObject<TkKernel slot['asciifont'] || slot[:asciifont] ) font_configure(slot) elsif slot.size > 0 - tk_call path, 'configure', *hash_kv(slot) + tk_call(path, 'configure', *hash_kv(slot)) end else @@ -3845,93 +2085,177 @@ class TkObject<TkKernel font_configure({slot=>value}) end else - tk_call path, 'configure', "-#{slot}", value + tk_call(path, 'configure', "-#{slot}", value) end end self end def configure_cmd(slot, value) - configure slot, install_cmd(value) + configure(slot, install_cmd(value)) end def configinfo(slot = nil) - if slot == 'font' || slot == :font || - slot == 'kanjifont' || slot == :kanjifont - conf = tk_split_simplelist(tk_send('configure', "-#{slot}") ) - conf[0] = conf[0][1..-1] - conf[4] = fontobj(conf[4]) - conf - else - if slot - case slot.to_s - when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(tk_send('configure', "-#{slot}") ) - else - conf = tk_split_list(tk_send('configure', "-#{slot}") ) - end + if TkComm::GET_CONFIGINFO_AS_ARRAY + if slot == 'font' || slot == :font || + slot == 'kanjifont' || slot == :kanjifont + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}"))) conf[0] = conf[0][1..-1] + conf[4] = fontobj(conf[4]) conf else - ret = tk_split_simplelist(tk_send('configure') ).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] + if slot + case slot.to_s when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}"))) else - if conf[3] - if conf[3].index('{') - conf[3] = tk_split_list(conf[3]) - else - conf[3] = tk_tcl2ruby(conf[3]) + conf = tk_split_list(_fromUTF8(tk_send_without_enc('configure', "-#{slot}"))) + end + conf[0] = conf[0][1..-1] + conf + else + ret = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure'))).collect{|conflist| + conf = tk_split_simplelist(conflist) + conf[0] = conf[0][1..-1] + case conf[0] + when 'text', 'label', 'show', 'data', 'file' + else + 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[4] - if conf[4].index('{') - conf[4] = tk_split_list(conf[4]) - else - conf[4] = tk_tcl2ruby(conf[4]) + 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 + } + fontconf = ret.assoc('font') + if fontconf + ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'} + fontconf[4] = fontobj(fontconf[4]) + ret.push(fontconf) + else + ret end - conf - } - fontconf = ret.assoc('font') - if fontconf - ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'} - fontconf[4] = fontobj(fontconf[4]) - ret.push(fontconf) + end + end + else # ! TkComm::GET_CONFIGINFO_AS_ARRAY + if slot == 'font' || slot == :font || + slot == 'kanjifont' || slot == :kanjifont + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}"))) + key = conf.shift[1..-1] + conf[3] = fontobj(conf[3]) + { key => conf } + else + if slot + case slot.to_s + when 'text', 'label', 'show', 'data', 'file' + conf = tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure', "-#{slot}"))) + else + conf = tk_split_list(_fromUTF8(tk_send_without_enc('configure', "-#{slot}"))) + end + key = conf.shift[1..-1] + { key => conf } else + ret = {} + tk_split_simplelist(_fromUTF8(tk_send_without_enc('configure'))).each{|conflist| + conf = tk_split_simplelist(conflist) + key = conf.shift[1..-1] + case key + when 'text', 'label', 'show', 'data', 'file' + 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] = fontobj(fontconf[3]) + ret['font'] = fontconf + end ret end end end end + def current_configinfo(slot = nil) + if TkComm::GET_CONFIGINFO_AS_ARRAY + if slot + conf = configinfo(slot) + {conf[0] => conf[4]} + else + ret = {} + configinfo().each{|conf| + ret[conf[0]] = conf[4] if conf.size > 2 + } + ret + end + else # ! TkComm::GET_CONFIGINFO_AS_ARRAY + ret = {} + configinfo(slot).each{|key, conf| + ret[key] = conf[-1] if conf.kind_of?(Array) + } + ret + end + end + def event_generate(context, keys=nil) if keys - tk_call('event', 'generate', path, - "<#{tk_event_sequence(context)}>", *hash_kv(keys)) + #tk_call('event', 'generate', path, + # "<#{tk_event_sequence(context)}>", *hash_kv(keys)) + tk_call_without_enc('event', 'generate', path, + "<#{tk_event_sequence(context)}>", + *hash_kv(keys, true)) else - tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>") + #tk_call('event', 'generate', path, "<#{tk_event_sequence(context)}>") + tk_call_without_enc('event', 'generate', path, + "<#{tk_event_sequence(context)}>") end end def tk_trace_variable(v) unless v.kind_of?(TkVariable) - fail(ArgumentError, - Kernel.format("type error (%s); must be TkVariable object", - v.class)) + fail(ArgumentError, "type error (#{v.class}); must be TkVariable object") end v end private :tk_trace_variable def destroy - # tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id + tk_call 'trace', 'vdelete', @tk_vn, 'w', @var_id if @var_id end end + class TkWindow<TkObject include TkWinfo extend TkBindCore @@ -3993,6 +2317,10 @@ class TkWindow<TkObject end private :create_self + def exist? + TkWinfo.exist?(self) + end + def bind_class @db_class || self.class() end @@ -4016,7 +2344,12 @@ class TkWindow<TkObject end def pack(keys = nil) - tk_call 'pack', epath, *hash_kv(keys) + #tk_call_without_enc('pack', epath, *hash_kv(keys, true)) + if keys + TkPack.configure(self, keys) + else + TkPack.configure(self) + end self end @@ -4027,48 +2360,68 @@ class TkWindow<TkObject else keys = {'in'=>target} end - tk_call 'pack', epath, *hash_kv(keys) + #tk_call 'pack', epath, *hash_kv(keys) + TkPack.configure(self, keys) self end - def unpack - tk_call 'pack', 'forget', epath + def pack_forget + #tk_call_without_enc('pack', 'forget', epath) + TkPack.forget(self) self end - alias pack_forget unpack + alias unpack pack_forget def pack_config(slot, value=None) + #if slot.kind_of? Hash + # tk_call 'pack', 'configure', epath, *hash_kv(slot) + #else + # tk_call 'pack', 'configure', epath, "-#{slot}", value + #end if slot.kind_of? Hash - tk_call 'pack', 'configure', epath, *hash_kv(slot) + TkPack.configure(self, slot) else - tk_call 'pack', 'configure', epath, "-#{slot}", value + TkPack.configure(self, slot=>value) end end def pack_info() - ilist = list(tk_call('pack', 'info', epath)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - return info + #ilist = list(tk_call('pack', 'info', epath)) + #info = {} + #while key = ilist.shift + # info[key[1..-1]] = ilist.shift + #end + #return info + TkPack.info(self) end def pack_propagate(mode=None) + #if mode == None + # bool(tk_call('pack', 'propagate', epath)) + #else + # tk_call('pack', 'propagate', epath, mode) + # self + #end if mode == None - bool(tk_call('pack', 'propagate', epath)) + TkPack.propagate(self) else - tk_call('pack', 'propagate', epath, mode) + TkPack.propagate(self, mode) self end end def pack_slaves() - list(tk_call('pack', 'slaves', epath)) + #list(tk_call('pack', 'slaves', epath)) + TkPack.slaves(self) end def grid(keys = nil) - tk_call 'grid', epath, *hash_kv(keys) + #tk_call 'grid', epath, *hash_kv(keys) + if keys + TkGrid.configure(self, keys) + else + TkGrid.configure(self) + end self end @@ -4079,94 +2432,120 @@ class TkWindow<TkObject else keys = {'in'=>target} end - tk_call 'grid', epath, *hash_kv(keys) + #tk_call 'grid', epath, *hash_kv(keys) + TkGrid.configure(self, keys) self end - def ungrid - tk_call 'grid', 'forget', epath + def grid_forget + #tk_call('grid', 'forget', epath) + TkGrid.forget(self) self end - alias grid_forget ungrid + alias ungrid grid_forget def grid_bbox(*args) - list(tk_call('grid', 'bbox', epath, *args)) + #list(tk_call('grid', 'bbox', epath, *args)) + TkGrid.bbox(self, *args) end def grid_config(slot, value=None) + #if slot.kind_of? Hash + # tk_call 'grid', 'configure', epath, *hash_kv(slot) + #else + # tk_call 'grid', 'configure', epath, "-#{slot}", value + #end if slot.kind_of? Hash - tk_call 'grid', 'configure', epath, *hash_kv(slot) + TkGrid.configure(self, slot) else - tk_call 'grid', 'configure', epath, "-#{slot}", value + TkGrid.configure(self, slot=>value) end end def grid_columnconfig(index, keys) - tk_call('grid', 'columnconfigure', epath, index, *hash_kv(keys)) + #tk_call('grid', 'columnconfigure', epath, index, *hash_kv(keys)) + TkGrid.columnconfigure(self, index, keys) end + alias grid_columnconfigure grid_columnconfig def grid_rowconfig(index, keys) - tk_call('grid', 'rowconfigure', epath, index, *hash_kv(keys)) + #tk_call('grid', 'rowconfigure', epath, index, *hash_kv(keys)) + TkGrid.rowconfigure(self, index, keys) end + alias grid_rowconfigure grid_rowconfig def grid_columnconfiginfo(index, slot=nil) - if slot - tk_call('grid', 'columnconfigure', epath, index, "-#{slot}").to_i - else - ilist = list(tk_call('grid', 'columnconfigure', epath, index)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - info - end + #if slot + # tk_call('grid', 'columnconfigure', epath, index, "-#{slot}").to_i + #else + # ilist = list(tk_call('grid', 'columnconfigure', epath, index)) + # info = {} + # while key = ilist.shift + # info[key[1..-1]] = ilist.shift + # end + # info + #end + TkGrid.columnconfiginfo(self, index, slot) end def grid_rowconfiginfo(index, slot=nil) - if slot - tk_call('grid', 'rowconfigure', epath, index, "-#{slot}").to_i - else - ilist = list(tk_call('grid', 'rowconfigure', epath, index)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - info - end + #if slot + # tk_call('grid', 'rowconfigure', epath, index, "-#{slot}").to_i + #else + # ilist = list(tk_call('grid', 'rowconfigure', epath, index)) + # info = {} + # while key = ilist.shift + # info[key[1..-1]] = ilist.shift + # end + # info + #end + TkGrid.rowconfiginfo(self, index, slot) end def grid_info() - list(tk_call('grid', 'info', epath)) + #list(tk_call('grid', 'info', epath)) + TkGrid.info(self) end def grid_location(x, y) - list(tk_call('grid', 'location', epath, x, y)) + #list(tk_call('grid', 'location', epath, x, y)) + TkGrid.location(self, x, y) end def grid_propagate(mode=None) + #if mode == None + # bool(tk_call('grid', 'propagate', epath)) + #else + # tk_call('grid', 'propagate', epath, mode) + # self + #end if mode == None - bool(tk_call('grid', 'propagate', epath)) + TkGrid.propagete(self) else - tk_call('grid', 'propagate', epath, mode) + TkGrid.propagete(self, mode) self end end def grid_remove() - tk_call 'grid', 'remove', epath + #tk_call 'grid', 'remove', epath + TkGrid.remove(self) self end def grid_size() - list(tk_call('grid', 'size', epath)) + #list(tk_call('grid', 'size', epath)) + TkGrid.size(self) end def grid_slaves(args) - list(tk_call('grid', 'slaves', epath, *hash_kv(args))) + #list(tk_call('grid', 'slaves', epath, *hash_kv(args))) + TkGrid.slaves(self, args) end - def place(keys = nil) - tk_call 'place', epath, *hash_kv(keys) + def place(keys) + #tk_call 'place', epath, *hash_kv(keys) + TkPlace.configure(self, keys) self end @@ -4177,88 +2556,90 @@ class TkWindow<TkObject else keys = {'in'=>target} end - tk_call 'place', epath, *hash_kv(keys) + #tk_call 'place', epath, *hash_kv(keys) + TkPlace.configure(self, keys) self end - def unplace - tk_call 'place', 'forget', epath + def place_forget + #tk_call 'place', 'forget', epath + TkPlace.forget(self) self end - alias place_forget unplace + alias unplace place_forget def place_config(slot, value=None) - if slot.kind_of? Hash - tk_call 'place', 'configure', epath, *hash_kv(slot) - else - tk_call 'place', 'configure', epath, "-#{slot}", value - end + #if slot.kind_of? Hash + # tk_call 'place', 'configure', epath, *hash_kv(slot) + #else + # tk_call 'place', 'configure', epath, "-#{slot}", value + #end + TkPlace.configure(self, slot, value) end def place_configinfo(slot = nil) # for >= Tk8.4a2 ? - if slot - conf = tk_split_list(tk_call('place', 'configure', epath, "-#{slot}") ) - conf[0] = conf[0][1..-1] - conf - else - tk_split_simplelist(tk_call('place', - 'configure', epath)).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - conf - } - end + #if slot + # conf = tk_split_list(tk_call('place', 'configure', epath, "-#{slot}") ) + # conf[0] = conf[0][1..-1] + # conf + #else + # tk_split_simplelist(tk_call('place', + # 'configure', epath)).collect{|conflist| + # conf = tk_split_simplelist(conflist) + # conf[0] = conf[0][1..-1] + # conf + # } + #end + TkPlace.configinfo(slot) end def place_info() - ilist = list(tk_call('place', 'info', epath)) - info = {} - while key = ilist.shift - info[key[1..-1]] = ilist.shift - end - return info + #ilist = list(tk_call('place', 'info', epath)) + #info = {} + #while key = ilist.shift + # info[key[1..-1]] = ilist.shift + #end + #return info + TkPlace.info(self) end def place_slaves() - list(tk_call('place', 'slaves', epath)) + #list(tk_call('place', 'slaves', epath)) + TkPlace.slaves(self) end - def focus(force=false) + def set_focus(force=false) if force - tk_call 'focus', '-force', path + tk_call_without_enc('focus', '-force', path) else - tk_call 'focus', path + tk_call_without_enc('focus', path) end self end + alias focus set_focus - def grab(*args) - if !args or args.length == 0 - tk_call 'grab', 'set', path - self - elsif args.length == 1 - case args[0] - when 'global', :global - #return(tk_call('grab', 'set', '-global', path)) - tk_call('grab', 'set', '-global', path) - return self - when 'release', :release - #return tk_call('grab', 'release', path) - tk_call('grab', 'release', path) - return self - else - val = tk_call('grab', args[0], path) - end - case args[0] - when 'current', :current - return window(val) - when 'status', :status - return val - end - self + def grab(opt = nil) + unless opt + tk_call_without_enc('grab', 'set', path) + return self + end + + case opt + when 'global', :global + #return(tk_call('grab', 'set', '-global', path)) + tk_call_without_enc('grab', 'set', '-global', path) + return self + when 'release', :release + #return tk_call('grab', 'release', path) + tk_call_without_enc('grab', 'release', path) + return self + when 'current', :current + return window(tk_call_without_enc('grab', 'current', path)) + when 'status', :status + return tk_call_without_enc('grab', 'status', path) else - fail ArgumentError, 'wrong # of args' + return tk_call_without_enc('grab', args[0], path) end end @@ -4279,20 +2660,30 @@ class TkWindow<TkObject end def lower(below=None) + # below = below.epath if below.kind_of?(TkObject) + below = _epath(below) tk_call 'lower', epath, below self end def raise(above=None) + #above = above.epath if above.kind_of?(TkObject) + above = _epath(above) tk_call 'raise', epath, above self end - def command(cmd=Proc.new) - configure_cmd 'command', cmd + def command(cmd=nil, &b) + if cmd + configure_cmd('command', cmd) + elsif b + configure_cmd('command', Proc.new(&b)) + else + cget('command') + end end - def colormodel model=None - tk_call 'tk', 'colormodel', path, model + def colormodel(model=None) + tk_call('tk', 'colormodel', path, model) self end @@ -4323,7 +2714,7 @@ class TkWindow<TkObject } begin - tk_call 'destroy', epath + tk_call_without_enc('destroy', epath) rescue end uninstall_win @@ -4333,6 +2724,7 @@ class TkWindow<TkObject if $SAFE >= 4 fail SecurityError, "can't wait visibility at $SAFE >= 4" end + on_thread &= (Thread.list.size != 1) if on_thread INTERP._thread_tkwait('visibility', path) else @@ -4358,6 +2750,7 @@ class TkWindow<TkObject if $SAFE >= 4 fail SecurityError, "can't wait destroy at $SAFE >= 4" end + on_thread &= (Thread.list.size != 1) if on_thread INTERP._thread_tkwait('window', epath) else @@ -4398,6 +2791,7 @@ class TkWindow<TkObject def bindtags=(taglist) bindtags(taglist) + taglist end def bindtags_shift @@ -4412,1499 +2806,6 @@ class TkWindow<TkObject end end -class TkRoot<TkWindow - include Wm - -=begin - ROOT = [] - def TkRoot.new(keys=nil) - if ROOT[0] - Tk_WINDOWS["."] = ROOT[0] - return ROOT[0] - end - new = super(:without_creating=>true, :widgetname=>'.') - if keys # wm commands - keys.each{|k,v| - if v.kind_of? Array - new.send(k,*v) - else - new.send(k,v) - end - } - end - ROOT[0] = new - Tk_WINDOWS["."] = new - end -=end - def TkRoot.new(keys=nil, &b) - unless TkCore::INTERP.tk_windows['.'] - TkCore::INTERP.tk_windows['.'] = - super(:without_creating=>true, :widgetname=>'.') - end - root = TkCore::INTERP.tk_windows['.'] - if keys # wm commands - keys.each{|k,v| - if v.kind_of? Array - root.send(k,*v) - else - root.send(k,v) - end - } - end - root.instance_eval(&b) if block_given? - root - end - - WidgetClassName = 'Tk'.freeze - WidgetClassNames[WidgetClassName] = self - - def create_self - @path = '.' - end - private :create_self - - def path - "." - end - - def TkRoot.destroy - TkCore::INTERP._invoke('destroy', '.') - end -end - -class TkToplevel<TkWindow - include Wm - - TkCommandNames = ['toplevel'.freeze].freeze - WidgetClassName = 'Toplevel'.freeze - WidgetClassNames[WidgetClassName] = self - -################# old version -# def initialize(parent=nil, screen=nil, classname=nil, keys=nil) -# if screen.kind_of? Hash -# keys = screen.dup -# else -# @screen = screen -# end -# @classname = classname -# if keys.kind_of? Hash -# keys = keys.dup -# @classname = keys.delete('classname') if keys.key?('classname') -# @colormap = keys.delete('colormap') if keys.key?('colormap') -# @container = keys.delete('container') if keys.key?('container') -# @screen = keys.delete('screen') if keys.key?('screen') -# @use = keys.delete('use') if keys.key?('use') -# @visual = keys.delete('visual') if keys.key?('visual') -# end -# super(parent, keys) -# end -# -# def create_self -# s = [] -# s << "-class" << @classname if @classname -# s << "-colormap" << @colormap if @colormap -# s << "-container" << @container if @container -# s << "-screen" << @screen if @screen -# s << "-use" << @use if @use -# s << "-visual" << @visual if @visual -# tk_call 'toplevel', @path, *s -# end -################# - - def _wm_command_option_chk(keys) - keys = {} unless keys - new_keys = {} - wm_cmds = {} - keys.each{|k,v| - if Wm.method_defined?(k) - case k - when 'screen','class','colormap','container','use','visual' - new_keys[k] = v - else - case self.method(k).arity - when -1,1 - wm_cmds[k] = v - else - new_keys[k] = v - end - end - else - new_keys[k] = v - end - } - [new_keys, wm_cmds] - end - private :_wm_command_option_chk - - def initialize(parent=nil, screen=nil, classname=nil, keys=nil) - my_class_name = nil - if self.class < WidgetClassNames[WidgetClassName] - my_class_name = self.class.name - my_class_name = nil if my_class_name == '' - end - if parent.kind_of? Hash - keys = _symbolkey2str(parent) - if keys.key?('classname') - keys['class'] = keys.delete('classname') - end - @classname = keys['class'] - @colormap = keys['colormap'] - @container = keys['container'] - @screen = keys['screen'] - @use = keys['use'] - @visual = keys['visual'] - if !@classname && my_class_name - keys['class'] = @classname = my_class_name - end - if @classname.kind_of? TkBindTag - @db_class = @classname - @classname = @classname.id - elsif @classname - @db_class = TkDatabaseClass.new(@classname) - else - @db_class = self.class - @classname = @db_class::WidgetClassName - end - keys, cmds = _wm_command_option_chk(keys) - super(keys) - cmds.each{|k,v| - if v.kind_of? Array - self.send(k,*v) - else - self.send(k,v) - end - } - return - end - - if screen.kind_of? Hash - keys = screen - else - @screen = screen - if classname.kind_of? Hash - keys = classname - else - @classname = classname - end - end - if keys.kind_of? Hash - keys = _symbolkey2str(keys) - if keys.key?('classname') - keys['class'] = keys.delete('classname') - end - @classname = keys['class'] unless @classname - @colormap = keys['colormap'] - @container = keys['container'] - @screen = keys['screen'] unless @screen - @use = keys['use'] - @visual = keys['visual'] - else - keys = {} - end - if !@classname && my_class_name - keys['class'] = @classname = my_class_name - end - if @classname.kind_of? TkBindTag - @db_class = @classname - @classname = @classname.id - elsif @classname - @db_class = TkDatabaseClass.new(@classname) - else - @db_class = self.class - @classname = @db_class::WidgetClassName - end - keys, cmds = _wm_command_option_chk(keys) - super(parent, keys) - cmds.each{|k,v| - if v.kind_of? Array - self.send(k,*v) - else - self.send(k,v) - end - } - end - - def create_self(keys) - if keys and keys != None - tk_call 'toplevel', @path, *hash_kv(keys) - else - tk_call 'toplevel', @path - end - end - private :create_self - - def specific_class - @classname - end - - def self.database_class - if self == WidgetClassNames[WidgetClassName] || self.name == '' - self - else - TkDatabaseClass.new(self.name) - end - end - def self.database_classname - self.database_class.name - end - - def self.bind(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bind(*args) - end - end - def self.bind_append(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bind_append(*args) - end - end - def self.bind_remove(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bind_remove(*args) - end - end - def self.bindinfo(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bindinfo(*args) - end - end -end - -class TkFrame<TkWindow - TkCommandNames = ['frame'.freeze].freeze - WidgetClassName = 'Frame'.freeze - WidgetClassNames[WidgetClassName] = self - -################# old version -# def initialize(parent=nil, keys=nil) -# if keys.kind_of? Hash -# keys = keys.dup -# @classname = keys.delete('classname') if keys.key?('classname') -# @colormap = keys.delete('colormap') if keys.key?('colormap') -# @container = keys.delete('container') if keys.key?('container') -# @visual = keys.delete('visual') if keys.key?('visual') -# end -# super(parent, keys) -# end -# -# def create_self -# s = [] -# s << "-class" << @classname if @classname -# s << "-colormap" << @colormap if @colormap -# s << "-container" << @container if @container -# s << "-visual" << @visual if @visual -# tk_call 'frame', @path, *s -# end -################# - - def initialize(parent=nil, keys=nil) - my_class_name = nil - if self.class < WidgetClassNames[WidgetClassName] - my_class_name = self.class.name - my_class_name = nil if my_class_name == '' - end - if parent.kind_of? Hash - keys = _symbolkey2str(parent) - else - if keys - keys = _symbolkey2str(keys) - keys['parent'] = parent - else - keys = {'parent'=>parent} - end - end - if keys.key?('classname') - keys['class'] = keys.delete('classname') - end - @classname = keys['class'] - @colormap = keys['colormap'] - @container = keys['container'] - @visual = keys['visual'] - if !@classname && my_class_name - keys['class'] = @classname = my_class_name - end - if @classname.kind_of? TkBindTag - @db_class = @classname - @classname = @classname.id - elsif @classname - @db_class = TkDatabaseClass.new(@classname) - else - @db_class = self.class - @classname = @db_class::WidgetClassName - end - super(keys) - end - - def create_self(keys) - if keys and keys != None - tk_call 'frame', @path, *hash_kv(keys) - else - tk_call 'frame', @path - end - end - private :create_self - - def database_classname - @classname - end - - def self.database_class - if self == WidgetClassNames[WidgetClassName] || self.name == '' - self - else - TkDatabaseClass.new(self.name) - end - end - def self.database_classname - self.database_class.name - end - - def self.bind(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bind(*args) - end - end - def self.bind_append(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bind_append(*args) - end - end - def self.bind_remove(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bind_remove(*args) - end - end - def self.bindinfo(*args) - if self == WidgetClassNames[WidgetClassName] || self.name == '' - super(*args) - else - TkDatabaseClass.new(self.name).bindinfo(*args) - end - end -end - -class TkLabelFrame<TkFrame - TkCommandNames = ['labelframe'.freeze].freeze - WidgetClassName = 'Labelframe'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'labelframe', @path, *hash_kv(keys) - else - tk_call 'labelframe', @path - end - end - private :create_self -end -TkLabelframe = TkLabelFrame - -class TkPanedWindow<TkWindow - TkCommandNames = ['panedwindow'.freeze].freeze - WidgetClassName = 'Panedwindow'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'panedwindow', @path, *hash_kv(keys) - else - tk_call 'panedwindow', @path - end - end - private :create_self - - def add(*args) - keys = args.pop - fail ArgumentError, "no window in arguments" unless keys - if keys && keys.kind_of?(Hash) - fail ArgumentError, "no window in arguments" if args == [] - args = args.collect{|w| w.epath} - args.push(hash_kv(keys)) - else - args.push(keys) if keys - args = args.collect{|w| w.epath} - end - tk_send('add', *args) - self - end - - def forget(win, *wins) - tk_send('forget', win.epath, *(wins.collect{|w| w.epath})) - self - end - alias del forget - alias delete forget - alias remove forget - - def identify(x, y) - list(tk_send('identify', x, y)) - end - - def proxy_coord - list(tk_send('proxy', 'coord')) - end - def proxy_forget - tk_send('proxy', 'forget') - self - end - def proxy_place(x, y) - tk_send('proxy', 'place', x, y) - self - end - - def sash_coord(index) - list(tk_send('sash', 'coord', index)) - end - def sash_dragto(index) - tk_send('sash', 'dragto', index, x, y) - self - end - def sash_mark(index, x, y) - tk_send('sash', 'mark', index, x, y) - self - end - def sash_place(index, x, y) - tk_send('sash', 'place', index, x, y) - self - end - - def panecget(win, key) - tk_tcl2ruby(tk_send('panecget', win.epath, "-#{key}")) - end - - def paneconfigure(win, key, value=nil) - if key.kind_of? Hash - tk_send('paneconfigure', win.epath, *hash_kv(key)) - else - tk_send('paneconfigure', win.epath, "-#{key}", value) - end - self - end - alias pane_config paneconfigure - - def paneconfiginfo(win, key=nil) - if key - conf = tk_split_list(tk_send('paneconfigure', win.epath, "-#{key}")) - conf[0] = conf[0][1..-1] - conf - else - tk_split_simplelist(tk_send('paneconfigure', - win.epath)).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - 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 - conf - } - end - end - alias pane_configinfo paneconfiginfo - - def panes - list(tk_send('panes')) - end -end -TkPanedwindow = TkPanedWindow - -class TkLabel<TkWindow - TkCommandNames = ['label'.freeze].freeze - WidgetClassName = 'Label'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'label', @path, *hash_kv(keys) - else - tk_call 'label', @path - end - end - private :create_self - - def textvariable(v) - configure 'textvariable', tk_trace_variable(v) - end -end - -class TkButton<TkLabel - TkCommandNames = ['button'.freeze].freeze - WidgetClassName = 'Button'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'button', @path, *hash_kv(keys) - else - tk_call 'button', @path - end - end - private :create_self - - def invoke - tk_send 'invoke' - end - def flash - tk_send 'flash' - self - end -end - -class TkRadioButton<TkButton - TkCommandNames = ['radiobutton'.freeze].freeze - WidgetClassName = 'Radiobutton'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'radiobutton', @path, *hash_kv(keys) - else - tk_call 'radiobutton', @path - end - end - private :create_self - - def deselect - tk_send 'deselect' - self - end - def select - tk_send 'select' - self - end - def variable(v) - configure 'variable', tk_trace_variable(v) - end -end -TkRadiobutton = TkRadioButton - -class TkCheckButton<TkRadioButton - TkCommandNames = ['checkbutton'.freeze].freeze - WidgetClassName = 'Checkbutton'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'checkbutton', @path, *hash_kv(keys) - else - tk_call 'checkbutton', @path - end - end - private :create_self - - def toggle - tk_send 'toggle' - self - end -end -TkCheckbutton = TkCheckButton - -class TkMessage<TkLabel - TkCommandNames = ['message'.freeze].freeze - WidgetClassName = 'Message'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'message', @path, *hash_kv(keys) - else - tk_call 'message', @path - end - end - private :create_self -end - -class TkScale<TkWindow - TkCommandNames = ['scale'.freeze].freeze - WidgetClassName = 'Scale'.freeze - WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - if keys.key?('command') - cmd = keys.delete('command') - keys['command'] = proc{|val| cmd.call(val.to_f)} - end - tk_call 'scale', @path, *hash_kv(keys) - else - tk_call 'scale', @path - end - end - private :create_self - - def _wrap_command_arg(cmd) - proc{|val| - if val.kind_of?(String) - cmd.call(number(val)) - else - cmd.call(val) - end - } - end - private :_wrap_command_arg - - def configure_cmd(slot, value) - configure(slot=>value) - end - - def configure(slot, value=None) - if (slot == 'command' || slot == :command) - configure('command'=>value) - elsif slot.kind_of?(Hash) && - (slot.key?('command') || slot.key?(:command)) - slot = _symbolkey2str(slot) - slot['command'] = _wrap_command_arg(slot.delete('command')) - end - super(slot, value) - end - - def command(cmd=Proc.new) - configure('command'=>cmd) - end - - def get(x=None, y=None) - number(tk_send('get', x, y)) - end - - def coords(val=None) - tk_split_list(tk_send('coords', val)) - end - - def identify(x, y) - tk_send('identify', x, y) - end - - def set(val) - tk_send("set", val) - end - - def value - get - end - - def value= (val) - set(val) - end -end - -class TkScrollbar<TkWindow - TkCommandNames = ['scrollbar'.freeze].freeze - WidgetClassName = 'Scrollbar'.freeze - WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - @assigned = [] - @scroll_proc = proc{|*args| - if self.orient == 'horizontal' - @assigned.each{|w| w.xview(*args)} - else # 'vertical' - @assigned.each{|w| w.yview(*args)} - end - } - - if keys and keys != None - tk_call 'scrollbar', @path, *hash_kv(keys) - else - tk_call 'scrollbar', @path - end - end - private :create_self - - def assign(*wins) - begin - self.command(@scroll_proc) if self.cget('command').cmd != @scroll_proc - rescue Exception - self.command(@scroll_proc) - end - orient = self.orient - wins.each{|w| - @assigned << w unless @assigned.index(w) - if orient == 'horizontal' - w.xscrollcommand proc{|first, last| self.set(first, last)} - else # 'vertical' - w.yscrollcommand proc{|first, last| self.set(first, last)} - end - } - self - end - - def assigned_list - begin - return @assigned.dup if self.cget('command').cmd == @scroll_proc - rescue Exception - end - fail RuntimeError, "not depend on the assigned_list" - end - - def delta(deltax=None, deltay=None) - number(tk_send('delta', deltax, deltay)) - end - - def fraction(x=None, y=None) - number(tk_send('fraction', x, y)) - end - - def identify(x, y) - tk_send('identify', x, y) - end - - def get - ary1 = tk_send('get').split - ary2 = [] - for i in ary1 - ary2.push number(i) - end - ary2 - end - - def set(first, last) - tk_send "set", first, last - self - end - - def activate(element=None) - tk_send('activate', element) - end -end - -class TkXScrollbar<TkScrollbar - def create_self(keys) - keys = {} unless keys - keys['orient'] = 'horizontal' - super(keys) - end - private :create_self -end - -class TkYScrollbar<TkScrollbar - def create_self(keys) - keys = {} unless keys - keys['orient'] = 'vertical' - super(keys) - end - private :create_self -end - -class TkTextWin<TkWindow - def create_self - fail RuntimeError, "TkTextWin is an abstract class" - end - private :create_self - - def bbox(index) - list(tk_send('bbox', index)) - end - def delete(first, last=None) - tk_send 'delete', first, last - self - end - def get(*index) - tk_send 'get', *index - end - def insert(index, *args) - tk_send 'insert', index, *args - self - end - def scan_mark(x, y) - tk_send 'scan', 'mark', x, y - self - end - def scan_dragto(x, y) - tk_send 'scan', 'dragto', x, y - self - end - def see(index) - tk_send 'see', index - self - end -end - -module TkTreatListItemFont - include TkTreatItemFont - - ItemCMD = ['itemconfigure'.freeze, TkComm::None].freeze - def __conf_cmd(idx) - ItemCMD[idx] - end - - def __item_pathname(tagOrId) - self.path + ';' + tagOrId.to_s - end - - private :__conf_cmd, :__item_pathname -end - -class TkListbox<TkTextWin - include TkTreatListItemFont - include Scrollable - - TkCommandNames = ['listbox'.freeze].freeze - WidgetClassName = 'Listbox'.freeze - WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - tk_call 'listbox', @path, *hash_kv(keys) - else - tk_call 'listbox', @path - end - end - private :create_self - - def activate(y) - tk_send 'activate', y - self - end - def curselection - list(tk_send('curselection')) - end - def get(*index) - v = tk_send('get', *index) - if index.size == 1 - v - else - tk_split_simplelist(v) - end - end - def nearest(y) - tk_send('nearest', y).to_i - end - def size - tk_send('size').to_i - end - def selection_anchor(index) - tk_send 'selection', 'anchor', index - self - end - def selection_clear(first, last=None) - tk_send 'selection', 'clear', first, last - self - end - def selection_includes(index) - bool(tk_send('selection', 'includes', index)) - end - def selection_set(first, last=None) - tk_send 'selection', 'set', first, last - self - end - - def index(index) - tk_send('index', index).to_i - end - - def itemcget(index, key) - case key.to_s - when 'text', 'label', 'show' - tk_send('itemcget', index, "-#{key}") - when 'font', 'kanjifont' - #fnt = tk_tcl2ruby(tk_send('itemcget', index, "-#{key}")) - fnt = tk_tcl2ruby(tk_send('itemcget', index, '-font')) - unless fnt.kind_of?(TkFont) - fnt = tagfontobj(index, fnt) - end - if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font - else - fnt - end - else - tk_tcl2ruby(tk_send('itemcget', index, "-#{key}")) - end - end - def itemconfigure(index, key, val=None) - if key.kind_of? Hash - if (key['font'] || key[:font] || - key['kanjifont'] || key[:kanjifont] || - key['latinfont'] || key[:latinfont] || - key['asciifont'] || key[:asciifont] ) - tagfont_configure(index, _symbolkey2str(key)) - else - tk_send 'itemconfigure', index, *hash_kv(key) - end - - else - if (key == 'font' || key == :font || - key == 'kanjifont' || key == :kanjifont || - key == 'latinfont' || key == :latinfont || - key == 'asciifont' || key == :asciifont ) - if val == None - tagfontobj(index) - else - tagfont_configure(index, {key=>val}) - end - else - tk_call 'itemconfigure', index, "-#{key}", val - end - end - self - end - - def itemconfiginfo(index, key=nil) - if key - case key.to_s - when 'text', 'label', 'show' - conf = tk_split_simplelist(tk_send('itemconfigure',index,"-#{key}")) - when 'font', 'kanjifont' - conf = tk_split_simplelist(tk_send('itemconfigure',index,"-#{key}") ) - conf[4] = tagfont_configinfo(index, conf[4]) - else - conf = tk_split_list(tk_send('itemconfigure',index,"-#{key}")) - end - conf[0] = conf[0][1..-1] - conf - else - ret = tk_split_simplelist(tk_send('itemconfigure', - 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 - } - fontconf = ret.assoc('font') - 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 - end -end - -module TkTreatMenuEntryFont - include TkTreatItemFont - - ItemCMD = ['entryconfigure'.freeze, TkComm::None].freeze - def __conf_cmd(idx) - ItemCMD[idx] - end - - def __item_pathname(tagOrId) - self.path + ';' + tagOrId.to_s - end - - private :__conf_cmd, :__item_pathname -end - -class TkMenu<TkWindow - include TkTreatMenuEntryFont - - TkCommandNames = ['menu'.freeze].freeze - WidgetClassName = 'Menu'.freeze - WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - if keys and keys != None - tk_call 'menu', @path, *hash_kv(keys) - else - tk_call 'menu', @path - end - end - private :create_self - - def activate(index) - tk_send 'activate', index - self - end - def add(type, keys=nil) - tk_send 'add', type, *hash_kv(keys) - self - end - def add_cascade(keys=nil) - add('cascade', keys) - end - def add_checkbutton(keys=nil) - add('checkbutton', keys) - end - def add_command(keys=nil) - add('command', keys) - end - def add_radiobutton(keys=nil) - add('radiobutton', keys) - end - def add_separator(keys=nil) - add('separator', keys) - end - def index(index) - ret = tk_send('index', index) - (ret == 'none')? nil: number(ret) - end - def invoke(index) - tk_send 'invoke', index - end - def insert(index, type, keys=nil) - tk_send 'insert', index, type, *hash_kv(keys) - self - end - def delete(index, last=None) - tk_send 'delete', index, last - self - end - def popup(x, y, index=None) - tk_call('tk_popup', path, x, y, index) - self - end - def post(x, y) - tk_send 'post', x, y - self - end - def postcascade(index) - tk_send 'postcascade', index - self - end - def postcommand(cmd=Proc.new) - configure_cmd 'postcommand', cmd - self - end - def set_focus - tk_call('tk_menuSetFocus', path) - end - def tearoffcommand(cmd=Proc.new) - configure_cmd 'tearoffcommand', cmd - self - end - def menutype(index) - tk_send 'type', index - end - def unpost - tk_send 'unpost' - end - def yposition(index) - number(tk_send('yposition', index)) - end - def entrycget(index, key) - case key.to_s - when 'text', 'label', 'show' - tk_send 'entrycget', index, "-#{key}" - when 'font', 'kanjifont' - #fnt = tk_tcl2ruby(tk_send('entrycget', index, "-#{key}")) - fnt = tk_tcl2ruby(tk_send('entrycget', index, '-font')) - unless fnt.kind_of?(TkFont) - fnt = tagfontobj(index, fnt) - end - if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font - else - fnt - end - else - tk_tcl2ruby(tk_send('entrycget', index, "-#{key}")) - end - end - def entryconfigure(index, key, val=None) - if key.kind_of? Hash - if (key['font'] || key[:font] || - key['kanjifont'] || key[:kanjifont] || - key['latinfont'] || key[:latinfont] || - key['asciifont'] || key[:asciifont]) - tagfont_configure(index, _symbolkey2str(key)) - else - tk_send 'entryconfigure', index, *hash_kv(key) - end - - else - if (key == 'font' || key == :font || - key == 'kanjifont' || key == :kanjifont || - key == 'latinfont' || key == :latinfont || - key == 'asciifont' || key == :asciifont ) - if val == None - tagfontobj(index) - else - tagfont_configure(index, {key=>val}) - end - else - tk_call 'entryconfigure', index, "-#{key}", val - end - end - self - end - - def entryconfiginfo(index, key=nil) - if key - case key.to_s - when 'text', 'label', 'show' - conf = tk_split_simplelist(tk_send('entryconfigure',index,"-#{key}")) - when 'font', 'kanjifont' - conf = tk_split_simplelist(tk_send('entryconfigure',index,"-#{key}")) - conf[4] = tagfont_configinfo(index, conf[4]) - else - conf = tk_split_list(tk_send('entryconfigure',index,"-#{key}")) - end - conf[0] = conf[0][1..-1] - conf - else - ret = tk_split_simplelist(tk_send('entryconfigure', - 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 - } - 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 - end -end - -class TkMenuClone<TkMenu - def initialize(parent, type=None) - widgetname = nil - if parent.kind_of? Hash - keys = _symbolkey2str(parent) - parent = keys.delete('parent') - widgetname = keys.delete('widgetname') - type = keys.delete('type'); type = None unless type - end - unless parent.kind_of?(TkMenu) - fail ArgumentError, "parent must be TkMenu" - end - @parent = parent - install_win(@parent.path, widgetname) - tk_call @parent.path, 'clone', @path, type - end -end - -module TkSystemMenu - def initialize(parent, keys=nil) - if parent.kind_of? Hash - keys = _symbolkey2str(parent) - parent = keys.delete('parent') - end - unless parent.kind_of? TkMenu - fail ArgumentError, "parent must be a TkMenu object" - end - @path = Kernel.format("%s.%s", parent.path, self.class::SYSMENU_NAME) - #TkComm::Tk_WINDOWS[@path] = self - TkCore::INTERP.tk_windows[@path] = self - if self.method(:create_self).arity == 0 - p 'create_self has no arg' if $DEBUG - create_self - configure(keys) if keys - else - p 'create_self has an arg' if $DEBUG - create_self(keys) - end - end -end - -class TkSysMenu_Help<TkMenu - # for all platform - include TkSystemMenu - SYSMENU_NAME = 'help' -end - -class TkSysMenu_System<TkMenu - # for Windows - include TkSystemMenu - SYSMENU_NAME = 'system' -end - -class TkSysMenu_Apple<TkMenu - # for Machintosh - include TkSystemMenu - SYSMENU_NAME = 'apple' -end - -class TkMenubutton<TkLabel - TkCommandNames = ['menubutton'.freeze].freeze - WidgetClassName = 'Menubutton'.freeze - WidgetClassNames[WidgetClassName] = self - def create_self(keys) - if keys and keys != None - tk_call 'menubutton', @path, *hash_kv(keys) - else - tk_call 'menubutton', @path - end - end - private :create_self -end - -class TkOptionMenubutton<TkMenubutton - TkCommandNames = ['tk_optionMenu'.freeze].freeze - - class OptionMenu<TkMenu - def initialize(path) #==> return value of tk_optionMenu - @path = path - #TkComm::Tk_WINDOWS[@path] = self - TkCore::INTERP.tk_windows[@path] = self - end - end - - def initialize(parent=nil, var=TkVariable.new, firstval=nil, *vals) - if parent.kind_of? Hash - keys = _symbolkey2str(parent) - parent = keys['parent'] - var = keys['variable'] if keys['variable'] - firstval, *vals = keys['values'] - end - fail 'variable option must be TkVariable' unless var.kind_of? TkVariable - @variable = var - firstval = @variable.value unless firstval - @variable.value = firstval - install_win(if parent then parent.path end) - @menu = OptionMenu.new(tk_call('tk_optionMenu', @path, @variable.id, - firstval, *vals)) - end - - def value - @variable.value - 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.add(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 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 -end - -module TkComposite - include Tk - extend Tk - - def initialize(parent=nil, *args) - @delegates = {} - - if parent.kind_of? Hash - keys = _symbolkey2str(parent) - parent = keys.delete('parent') - @frame = TkFrame.new(parent) - @delegates['DEFAULT'] = @frame - @path = @epath = @frame.path - initialize_composite(keys) - else - @frame = TkFrame.new(parent) - @delegates['DEFAULT'] = @frame - @path = @epath = @frame.path - initialize_composite(*args) - end - end - - def epath - @epath - end - - def initialize_composite(*args) end - private :initialize_composite - - def delegate(option, *wins) - if @delegates[option].kind_of?(Array) - for i in wins - @delegates[option].push(i) - end - else - @delegates[option] = wins - end - end - - def configure(slot, value=None) - if slot.kind_of? Hash - slot.each{|slot,value| configure slot, value} - else - if @delegates and @delegates[slot] - for i in @delegates[slot] - if not i - i = @delegates['DEFALUT'] - redo - else - last = i.configure(slot, value) - end - end - last - else - super - end - end - end -end - -module TkClipboard - include Tk - extend Tk - - TkCommandNames = ['clipboard'.freeze].freeze - - def self.clear(win=nil) - if win - tk_call 'clipboard', 'clear', '-displayof', win - else - tk_call 'clipboard', 'clear' - end - end - def self.clear_on_display(win) - tk_call 'clipboard', 'clear', '-displayof', win - end - - def self.get(type=nil) - if type - tk_call 'clipboard', 'get', '-type', type - else - tk_call 'clipboard', 'get' - end - end - def self.get_on_display(win, type=nil) - if type - tk_call 'clipboard', 'get', '-displayof', win, '-type', type - else - tk_call 'clipboard', 'get', '-displayof', win - end - end - - def self.set(data, keys=nil) - clear - append(data, keys) - end - def self.set_on_display(win, data, keys=nil) - clear(win) - append_on_display(win, data, keys) - end - - def self.append(data, keys=nil) - args = ['clipboard', 'append'] - args += hash_kv(keys) - args += ['--', data] - tk_call(*args) - end - def self.append_on_display(win, data, keys=nil) - args = ['clipboard', 'append', '-displayof', win] - args += hash_kv(keys) - args += ['--', data] - tk_call(*args) - end - - def clear - TkClipboard.clear_on_display(self) - self - end - def get(type=nil) - TkClipboard.get_on_display(self, type) - end - def set(data, keys=nil) - TkClipboard.set_on_display(self, data, keys) - self - end - def append(data, keys=nil) - TkClipboard.append_on_display(self, data, keys) - self - end -end - -# widget_destroy_hook -require 'tkvirtevent' -TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|xpath| - path = xpath[1..-1] - if (widget = TkCore::INTERP.tk_windows[path]) - if widget.respond_to?(:__destroy_hook__) - begin - widget.__destroy_hook__ - rescue Exception - end - end - end - }, 'x%W') # freeze core modules #TclTkLib.freeze @@ -5916,27 +2817,11 @@ TkBindTag::ALL.bind(TkVirtualEvent.new('Destroy'), proc{|xpath| #TkCore.freeze #Tk.freeze -# autoload -autoload :TkCanvas, 'tkcanvas' -autoload :TkImage, 'tkcanvas' -autoload :TkBitmapImage, 'tkcanvas' -autoload :TkPhotoImage, 'tkcanvas' -autoload :TkEntry, 'tkentry' -autoload :TkSpinbox, 'tkentry' -autoload :TkText, 'tktext' -autoload :TkDialog, 'tkdialog' -autoload :TkDialog2, 'tkdialog' -autoload :TkWarning, 'tkdialog' -autoload :TkWarning2, 'tkdialog' -autoload :TkMenubar, 'tkmenubar' -autoload :TkAfter, 'tkafter' -autoload :TkTimer, 'tkafter' -autoload :TkPalette, 'tkpalette' -autoload :TkFont, 'tkfont' -autoload :TkBgError, 'tkbgerror' -autoload :TkManageFocus, 'tkmngfocus' -autoload :TkPalette, 'tkpalette' -autoload :TkWinDDE, 'tkwinpkg' -autoload :TkWinRegistry, 'tkwinpkg' -autoload :TkMacResource, 'tkmacpkg' -autoload :TkConsole, 'tkconsole' +module Tk + autoload :AUTO_PATH, 'tk/variable' + autoload :TCL_PACKAGE_PATH, 'tk/variable' + autoload :PACKAGE_PATH, 'tk/variable' + autoload :TCL_LIBRARY_PATH, 'tk/variable' + autoload :LIBRARY_PATH, 'tk/variable' + autoload :TCL_PRECISION, 'tk/variable' +end diff --git a/ext/tk/lib/tkafter.rb b/ext/tk/lib/tkafter.rb index 53e78b8808..f65945884c 100644 --- a/ext/tk/lib/tkafter.rb +++ b/ext/tk/lib/tkafter.rb @@ -1,414 +1,4 @@ # -# tkafter.rb : methods for Tcl/Tk after command +# tkafter.rb - load tk/after.rb # -# $Id$ -# -require 'tk' - -class TkTimer - include TkCore - extend TkCore - - TkCommandNames = ['after'.freeze].freeze - - Tk_CBID = ['a'.freeze, '00000'.taint].freeze - Tk_CBTBL = {}.taint - - TkCore::INTERP.add_tk_procs('rb_after', 'id', <<-'EOL') - if {[set st [catch {ruby [format "TkTimer.callback %%Q!%s!" $id]} ret]] != 0} { - return -code $st $ret - } { - return $ret - } - EOL - - - ############################### - # class methods - ############################### - def self.callback(obj_id) - @after_id = nil - ex_obj = Tk_CBTBL[obj_id] - return "" if ex_obj == nil; # canceled - ex_obj.cb_call - end - - def self.info - tk_call('after', 'info').split(' ').collect!{|id| - ret = Tk_CBTBL.find{|key,val| val.after_id == id} - (ret == nil)? id: ret[1] - } - end - - ############################### - # instance methods - ############################### - def do_callback - @in_callback = true - begin - @return_value = @current_proc.call(self) - rescue Exception => e - if @cancel_on_exception - cancel - @return_value = e - return e - else - fail e - end - end - if @set_next - set_next_callback(@current_args) - else - @set_next = true - end - @in_callback = false - @return_value - end - - def set_callback(sleep, args=nil) - @after_script = "rb_after #{@id}" - @after_id = tk_call('after', sleep, @after_script) - @current_args = args - @current_script = [sleep, @after_script] - self - end - - def set_next_callback(args) - if @running == false || @proc_max == 0 || @do_loop == 0 - Tk_CBTBL.delete(@id) ;# for GC - @running = false - @wait_var.value = 0 - return - end - if @current_pos >= @proc_max - if @do_loop < 0 || (@do_loop -= 1) > 0 - @current_pos = 0 - else - Tk_CBTBL.delete(@id) ;# for GC - @running = false - @wait_var.value = 0 - return - end - end - - @current_args = args - - if @sleep_time.kind_of? Proc - sleep = @sleep_time.call(self) - else - sleep = @sleep_time - end - @current_sleep = sleep - - cmd, *cmd_args = @loop_proc[@current_pos] - @current_pos += 1 - @current_proc = cmd - - set_callback(sleep, cmd_args) - end - - def initialize(*args) - @id = Tk_CBID.join - Tk_CBID[1].succ! - - @wait_var = TkVariable.new(0) - - @cb_cmd = TkCore::INTERP.get_cb_entry(self.method(:do_callback)) - - @set_next = true - - @init_sleep = 0 - @init_proc = nil - @init_args = [] - - @current_script = [] - @current_proc = nil - @current_args = nil - @return_value = nil - - @sleep_time = 0 - @current_sleep = 0 - @loop_exec = 0 - @do_loop = 0 - @loop_proc = [] - @proc_max = 0 - @current_pos = 0 - - @after_id = nil - @after_script = nil - - @cancel_on_exception = true - - set_procs(*args) if args != [] - - @running = false - @in_callback = false - end - - attr :after_id - attr :after_script - attr :current_proc - attr :current_args - attr :current_sleep - alias :current_interval :current_sleep - attr :return_value - - attr_accessor :loop_exec - - def cb_call - @cb_cmd.call - end - - def get_procs - [@init_sleep, @init_proc, @init_args, @sleep_time, @loop_exec, @loop_proc] - end - - def current_status - [@running, @current_sleep, @current_proc, @current_args, - @do_loop, @cancel_on_exception] - end - - def cancel_on_exception? - @cancel_on_exception - end - - def cancel_on_exception=(mode) - @cancel_on_exception = mode - self - end - - def running? - @running - end - - def loop_rest - @do_loop - end - - def loop_rest=(rest) - @do_loop = rest - self - end - - def set_procs(interval, loop_exec, *procs) - if !interval == 'idle' \ - && !interval.kind_of?(Integer) && !interval.kind_of?(Proc) - fail Kernel.format("%s need to be Integer or Proc", interval.inspect) - end - @sleep_time = interval - - @loop_proc = [] - procs.each{|e| - if e.kind_of? Proc - @loop_proc.push([e]) - else - @loop_proc.push(e) - end - } - @proc_max = @loop_proc.size - @current_pos = 0 - - @do_loop = 0 - if loop_exec - if loop_exec.kind_of?(Integer) && loop_exec < 0 - @loop_exec = -1 - elsif loop_exec == nil || loop_exec == false || loop_exec == 0 - @loop_exec = 1 - else - if not loop_exec.kind_of?(Integer) - fail Kernel.format("%s need to be Integer", loop_exec.inspect) - end - @loop_exec = loop_exec - end - @do_loop = @loop_exec - end - - self - end - - def add_procs(*procs) - procs.each{|e| - if e.kind_of? Proc - @loop_proc.push([e]) - else - @loop_proc.push(e) - end - } - @proc_max = @loop_proc.size - - self - end - - def delete_procs(*procs) - procs.each{|e| - if e.kind_of? Proc - @loop_proc.delete([e]) - else - @loop_proc.delete(e) - end - } - @proc_max = @loop_proc.size - - cancel if @proc_max == 0 - - self - end - - def delete_at(n) - @loop_proc.delete_at(n) - @proc_max = @loop_proc.size - cancel if @proc_max == 0 - self - end - - def set_start_proc(sleep, init_proc, *init_args) - if !sleep == 'idle' && !sleep.kind_of?(Integer) - fail Kernel.format("%s need to be Integer", sleep.inspect) - end - @init_sleep = sleep - @init_proc = init_proc - @init_args = init_args - self - end - - def start(*init_args) - return nil if @running - - Tk_CBTBL[@id] = self - @do_loop = @loop_exec - @current_pos = 0 - - argc = init_args.size - if argc > 0 - sleep = init_args.shift - if !sleep == 'idle' && !sleep.kind_of?(Integer) - fail Kernel.format("%s need to be Integer", sleep.inspect) - end - @init_sleep = sleep - end - @init_proc = init_args.shift if argc > 1 - @init_args = init_args if argc > 0 - - @current_sleep = @init_sleep - @running = true - if @init_proc - if not @init_proc.kind_of? Proc - fail Kernel.format("%s need to be Proc", @init_proc.inspect) - end - @current_proc = @init_proc - set_callback(@init_sleep, @init_args) - @set_next = false if @in_callback - else - set_next_callback(@init_args) - end - - self - end - - def reset(*reset_args) - restart() if @running - - if @init_proc - @return_value = @init_proc.call(self) - else - @return_value = nil - end - - @current_pos = 0 - @current_args = @init_args - @set_next = false if @in_callback - - self - end - - def restart(*restart_args) - cancel if @running - if restart_args == [] - start(@init_sleep, @init_proc, *@init_args) - else - start(*restart_args) - end - end - - def cancel - @running = false - @wait_var.value = 0 - tk_call 'after', 'cancel', @after_id if @after_id - @after_id = nil - Tk_CBTBL.delete(@id) ;# for GC - self - end - alias stop cancel - - def continue(wait=nil) - fail RuntimeError, "is already running" if @running - sleep, cmd = @current_script - fail RuntimeError, "no procedure to continue" unless cmd - if wait - if not wait.kind_of? Integer - fail RuntimeError, Kernel.format("%s need to be Integer", wait.inspect) - end - sleep = wait - end - Tk_CBTBL[@id] = self - @running = true - @after_id = tk_call('after', sleep, cmd) - self - end - - def skip - fail RuntimeError, "is not running now" unless @running - cancel - Tk_CBTBL[@id] = self - @running = true - set_next_callback(@current_args) - self - end - - def info - if @after_id - inf = tk_split_list(tk_call('after', 'info', @after_id)) - [Tk_CBTBL[inf[0][1]], inf[1]] - else - nil - end - end - - def wait(on_thread = true, check_root = false) - if $SAFE >= 4 - fail SecurityError, "can't wait timer at $SAFE >= 4" - end - - unless @running - if @return_value.kind_of?(Exception) - fail @return_value - else - return @return_value - end - end - - @wait_var.wait(on_thread, check_root) - if @return_value.kind_of?(Exception) - fail @return_value - else - @return_value - end - end - def eventloop_wait(check_root = false) - wait(false, check_root) - end - def thread_wait(check_root = false) - wait(true, check_root) - end - def tkwait(on_thread = true) - wait(on_thread, true) - end - def eventloop_tkwait - wait(false, true) - end - def thread_tkwait - wait(true, true) - end -end - -TkAfter = TkTimer +require 'tk/timer' diff --git a/ext/tk/lib/tkbgerror.rb b/ext/tk/lib/tkbgerror.rb index 760a3901b3..deba7a57fa 100644 --- a/ext/tk/lib/tkbgerror.rb +++ b/ext/tk/lib/tkbgerror.rb @@ -1,29 +1,4 @@ # -# tkbgerror -- bgerror ( tkerror ) module -# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> +# tkbgerror.rb - load tk/bgerror.rb # -require 'tk' - -module TkBgError - extend Tk - - TkCommandNames = ['bgerror'.freeze].freeze - - def bgerror(message) - tk_call 'bgerror', message - end - alias tkerror bgerror - alias show bgerror - module_function :bgerror, :tkerror, :show - - def set_handler(hdlr = Proc.new) #==> handler :: proc{|msg| ...body... } - tk_call('proc', 'bgerror', 'msg', install_cmd(hdlr) + ' $msg') - end - def set_default - begin - tk_call('rename', 'bgerror', '') - rescue RuntimeError - end - end - module_function :set_handler, :set_default -end +require 'tk/bgerror' diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb index ccb02c0564..9524614291 100644 --- a/ext/tk/lib/tkcanvas.rb +++ b/ext/tk/lib/tkcanvas.rb @@ -1,1021 +1,4 @@ # -# tkcanvas.rb - Tk canvas classes -# $Date$ -# by Yukihiro Matsumoto <matz@caelum.co.jp> -# $Date$ -# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> - -require "tk" -require 'tkfont' - -module TkTreatCItemFont - include TkTreatItemFont - - ItemCMD = ['itemconfigure'.freeze, TkComm::None].freeze - def __conf_cmd(idx) - ItemCMD[idx] - end - - def __item_pathname(tagOrId) - if tagOrId.kind_of?(TkcItem) || tagOrId.kind_of?(TkcTag) - self.path + ';' + tagOrId.id.to_s - else - self.path + ';' + tagOrId.to_s - end - end - - private :__conf_cmd, :__item_pathname -end - -class TkCanvas<TkWindow - include TkTreatCItemFont - include Scrollable - - TkCommandNames = ['canvas'.freeze].freeze - WidgetClassName = 'Canvas'.freeze - WidgetClassNames[WidgetClassName] = self - - def __destroy_hook__ - TkcItem::CItemID_TBL.delete(@path) - end - - def create_self(keys) - if keys and keys != None - tk_call 'canvas', @path, *hash_kv(keys) - else - tk_call 'canvas', @path - end - end - private :create_self - - def tagid(tag) - if tag.kind_of?(TkcItem) || tag.kind_of?(TkcTag) - tag.id - else - tag - end - end - private :tagid - - def addtag(tag, mode, *args) - tk_send 'addtag', tagid(tag), mode, *args - self - end - def addtag_above(tagOrId, target) - addtag(tagOrId, 'above', tagid(target)) - end - def addtag_all(tagOrId) - addtag(tagOrId, 'all') - end - def addtag_below(tagOrId, target) - addtag(tagOrId, 'below', tagid(target)) - end - def addtag_closest(tagOrId, x, y, halo=None, start=None) - addtag(tagOrId, 'closest', x, y, halo, start) - end - def addtag_enclosed(tagOrId, x1, y1, x2, y2) - addtag(tagOrId, 'enclosed', x1, y1, x2, y2) - end - def addtag_overlapping(tagOrId, x1, y1, x2, y2) - addtag(tagOrId, 'overlapping', x1, y1, x2, y2) - end - def addtag_withtag(tagOrId, tag) - addtag(tagOrId, 'withtag', tagid(tag)) - end - - def bbox(tagOrId, *tags) - list(tk_send('bbox', tagid(tagOrId), *tags.collect{|t| tagid(t)})) - end - - def itembind(tag, context, cmd=Proc.new, args=nil) - _bind([path, "bind", tagid(tag)], context, cmd, args) - self - end - - def itembind_append(tag, context, cmd=Proc.new, args=nil) - _bind_append([path, "bind", tagid(tag)], context, cmd, args) - self - end - - def itembind_remove(tag, context) - _bind_remove([path, "bind", tagid(tag)], context) - self - end - - def itembindinfo(tag, context=nil) - _bindinfo([path, "bind", tagid(tag)], context) - end - - def canvasx(x, *args) - tk_tcl2ruby(tk_send('canvasx', x, *args)) - end - def canvasy(y, *args) - tk_tcl2ruby(tk_send('canvasy', y, *args)) - end - - def coords(tag, *args) - if args == [] - tk_split_list(tk_send('coords', tagid(tag))) - else - tk_send('coords', tagid(tag), *(args.flatten)) - end - end - - def dchars(tag, first, last=None) - tk_send 'dchars', tagid(tag), first, last - self - end - - def delete(*args) - if TkcItem::CItemID_TBL[self.path] - find('withtag', *args).each{|item| - TkcItem::CItemID_TBL[self.path].delete(item.id) - } - end - tk_send 'delete', *args.collect{|t| tagid(t)} - self - end - alias remove delete - - def dtag(tag, tag_to_del=None) - tk_send 'dtag', tagid(tag), tag_to_del - self - end - - def find(mode, *args) - list(tk_send('find', mode, *args)).collect!{|id| - TkcItem.id2obj(self, id) - } - end - def find_above(target) - find('above', tagid(target)) - end - def find_all - find('all') - end - def find_below(target) - find('below', tagid(target)) - end - def find_closest(x, y, halo=None, start=None) - find('closest', x, y, halo, start) - end - def find_enclosed(x1, y1, x2, y2) - find('enclosed', x1, y1, x2, y2) - end - def find_overlapping(x1, y1, x2, y2) - find('overlapping', x1, y1, x2, y2) - end - def find_withtag(tag) - find('withtag', tag) - end - - def itemfocus(tagOrId=nil) - if tagOrId - tk_send 'focus', tagid(tagOrId) - self - else - ret = tk_send('focus') - if ret == "" - nil - else - TkcItem.id2obj(self, ret) - end - end - end - - def gettags(tagOrId) - list(tk_send('gettags', tagid(tagOrId))).collect{|tag| - TkcTag.id2obj(self, tag) - } - end - - def icursor(tagOrId, index) - tk_send 'icursor', tagid(tagOrId), index - self - end - - def index(tagOrId, index) - number(tk_send('index', tagid(tagOrId), index)) - end - - def insert(tagOrId, index, string) - tk_send 'insert', tagid(tagOrId), index, string - self - end - - def itemcget(tagOrId, option) - case option.to_s - when 'dash', 'activedash', 'disableddash' - conf = tk_send('itemcget', tagid(tagOrId), "-#{option}") - if conf =~ /^[0-9]/ - list(conf) - else - conf - end - when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' - tk_send 'itemcget', tagid(tagOrId), "-#{option}" - when 'font', 'kanjifont' - #fnt = tk_tcl2ruby(tk_send('itemcget', tagid(tagOrId), "-#{option}")) - fnt = tk_tcl2ruby(tk_send('itemcget', tagid(tagOrId), '-font')) - unless fnt.kind_of?(TkFont) - fnt = tagfontobj(tagid(tagOrId), fnt) - end - if option.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font - else - fnt - end - else - tk_tcl2ruby tk_send('itemcget', tagid(tagOrId), "-#{option}") - end - end - - def itemconfigure(tagOrId, key, value=None) - if key.kind_of? Hash - key = _symbolkey2str(key) - if ( key['font'] || key['kanjifont'] \ - || key['latinfont'] || key['asciifont'] ) - tagfont_configure(tagid(tagOrId), key.dup) - else - tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(key) - end - - else - if ( key == 'font' || key == :font || - key == 'kanjifont' || key == :kanjifont || - key == 'latinfont' || key == :latinfont || - key == 'asciifont' || key == :asciifont ) - if value == None - tagfontobj(tagid(tagOrId)) - else - tagfont_configure(tagid(tagOrId), {key=>value}) - end - else - tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value - end - end - self - end -# def itemconfigure(tagOrId, key, value=None) -# if key.kind_of? Hash -# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(key) -# else -# tk_send 'itemconfigure', tagid(tagOrId), "-#{key}", value -# end -# end -# def itemconfigure(tagOrId, keys) -# tk_send 'itemconfigure', tagid(tagOrId), *hash_kv(keys) -# end - - def itemconfiginfo(tagOrId, key=nil) - if key - case key.to_s - when 'dash', 'activedash', 'disableddash' - conf = tk_split_simplelist(tk_send('itemconfigure', - tagid(tagOrId), "-#{key}")) - if conf[3] && conf[3] =~ /^[0-9]/ - conf[3] = list(conf[3]) - end - if conf[4] && conf[4] =~ /^[0-9]/ - conf[4] = list(conf[4]) - end - when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' - conf = tk_split_simplelist(tk_send('itemconfigure', - tagid(tagOrId), "-#{key}")) - when 'font', 'kanjifont' - conf = tk_split_simplelist(tk_send('itemconfigure', - tagid(tagOrId),"-#{key}") ) - conf[4] = tagfont_configinfo(tagid(tagOrId), conf[4]) - else - conf = tk_split_list(tk_send('itemconfigure', - tagid(tagOrId), "-#{key}")) - end - conf[0] = conf[0][1..-1] - conf - else - ret = tk_split_simplelist(tk_send('itemconfigure', - tagid(tagOrId))).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] - when 'text', 'label', 'show', 'data', 'file', 'maskdata', 'maskfile' - when 'dash', 'activedash', 'disableddash' - if conf[3] && conf[3] =~ /^[0-9]/ - conf[3] = list(conf[3]) - end - if conf[4] && conf[4] =~ /^[0-9]/ - conf[4] = list(conf[4]) - end - 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 - } - fontconf = ret.assoc('font') - if fontconf - ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'} - fontconf[4] = tagfont_configinfo(tagid(tagOrId), fontconf[4]) - ret.push(fontconf) - else - ret - end - end - end - - def lower(tag, below=None) - tk_send 'lower', tagid(tag), tagid(below) - self - end - - def move(tag, x, y) - tk_send 'move', tagid(tag), x, y - self - end - - def postscript(keys) - tk_send "postscript", *hash_kv(keys) - end - - def raise(tag, above=None) - tk_send 'raise', tagid(tag), tagid(above) - self - end - - def scale(tag, x, y, xs, ys) - tk_send 'scale', tagid(tag), x, y, xs, ys - self - end - - def scan_mark(x, y) - tk_send 'scan', 'mark', x, y - self - end - def scan_dragto(x, y) - tk_send 'scan', 'dragto', x, y - self - end - - def select(mode, *args) - r = tk_send('select', mode, *args) - (mode == 'item')? TkcItem.id2obj(self, r): self - end - def select_adjust(tagOrId, index) - select('adjust', tagid(tagOrId), index) - end - def select_clear - select('clear') - end - def select_from(tagOrId, index) - select('from', tagid(tagOrId), index) - end - def select_item - select('item') - end - def select_to(tagOrId, index) - select('to', tagid(tagOrId), index) - end - - def itemtype(tag) - TkcItem.type2class(tk_send('type', tagid(tag))) - end -end - -module TkcTagAccess - include TkComm - include TkTreatTagFont - - def addtag(tag) - @c.addtag(tag, 'with', @id) - self - end - - def bbox - @c.bbox(@id) - end - - def bind(seq, cmd=Proc.new, args=nil) - @c.itembind @id, seq, cmd, args - self - end - - def bind_append(seq, cmd=Proc.new, args=nil) - @c.itembind_append @id, seq, cmd, args - self - end - - def bind_remove(seq) - @c.itembind_remove @id, seq - self - end - - def bindinfo(seq=nil) - @c.itembindinfo @id, seq - end - - def cget(option) - @c.itemcget @id, option - end - - def configure(key, value=None) - @c.itemconfigure @id, key, value - self - end -# def configure(keys) -# @c.itemconfigure @id, keys -# end - - def configinfo(key=nil) - @c.itemconfiginfo @id, key - end - - def coords(*args) - @c.coords @id, *args - end - - def dchars(first, last=None) - @c.dchars @id, first, last - self - end - - def dtag(tag_to_del=None) - @c.dtag @id, tag_to_del - self - end - - def find - @c.find 'withtag', @id - end - alias list find - - def focus - @c.itemfocus @id - end - - def gettags - @c.gettags @id - end - - def icursor(index) - @c.icursor @id, index - self - end - - def index(index) - @c.index @id, index - end - - def insert(beforethis, string) - @c.insert @id, beforethis, string - self - end - - def lower(belowthis=None) - @c.lower @id, belowthis - self - end - - def move(xamount, yamount) - @c.move @id, xamount, yamount - self - end - - def raise(abovethis=None) - @c.raise @id, abovethis - self - end - - def scale(xorigin, yorigin, xscale, yscale) - @c.scale @id, xorigin, yorigin, xscale, yscale - self - end - - def select_adjust(index) - @c.select('adjust', @id, index) - self - end - def select_from(index) - @c.select('from', @id, index) - self - end - def select_to(index) - @c.select('to', @id, index) - self - end - - def itemtype - @c.itemtype @id - end - - # Following operators support logical expressions of canvas tags - # (for Tk8.3+). - # If tag1.path is 't1' and tag2.path is 't2', then - # ltag = tag1 & tag2; ltag.path => "(t1)&&(t2)" - # ltag = tag1 | tag2; ltag.path => "(t1)||(t2)" - # ltag = tag1 ^ tag2; ltag.path => "(t1)^(t2)" - # ltag = - tag1; ltag.path => "!(t1)" - def & (tag) - if tag.kind_of? TkObject - TkcTagString.new(@c, '(' + @id + ')&&(' + tag.path + ')') - else - TkcTagString.new(@c, '(' + @id + ')&&(' + tag.to_s + ')') - end - end - - def | (tag) - if tag.kind_of? TkObject - TkcTagString.new(@c, '(' + @id + ')||(' + tag.path + ')') - else - TkcTagString.new(@c, '(' + @id + ')||(' + tag.to_s + ')') - end - end - - def ^ (tag) - if tag.kind_of? TkObject - TkcTagString.new(@c, '(' + @id + ')^(' + tag.path + ')') - else - TkcTagString.new(@c, '(' + @id + ')^(' + tag.to_s + ')') - end - end - - def -@ - TkcTagString.new(@c, '!(' + @id + ')') - end -end - -class TkcTag<TkObject - include TkcTagAccess - - CTagID_TBL = TkCore::INTERP.create_table - Tk_CanvasTag_ID = ['ctag'.freeze, '00000'.taint].freeze - - TkCore::INTERP.init_ip_env{ CTagID_TBL.clear } - - def TkcTag.id2obj(canvas, id) - cpath = canvas.path - return id unless CTagID_TBL[cpath] - CTagID_TBL[cpath][id]? CTagID_TBL[cpath][id]: id - end - - def initialize(parent, mode=nil, *args) - if not parent.kind_of?(TkCanvas) - fail Kernel.format("%s need to be TkCanvas", parent.inspect) - end - @c = parent - @cpath = parent.path - @path = @id = Tk_CanvasTag_ID.join - CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] - CTagID_TBL[@cpath][@id] = self - Tk_CanvasTag_ID[1].succ! - if mode - tk_call @c.path, "addtag", @id, mode, *args - end - end - def id - @id - end - - def delete - @c.delete @id - CTagID_TBL[@cpath].delete(@id) if CTagID_TBL[@cpath] - self - end - alias remove delete - alias destroy delete - - def set_to_above(target) - @c.addtag_above(@id, target) - self - end - alias above set_to_above - - def set_to_all - @c.addtag_all(@id) - self - end - alias all set_to_all - - def set_to_below(target) - @c.addtag_below(@id, target) - self - end - alias below set_to_below - - def set_to_closest(x, y, halo=None, start=None) - @c.addtag_closest(@id, x, y, halo, start) - self - end - alias closest set_to_closest - - def set_to_enclosed(x1, y1, x2, y2) - @c.addtag_enclosed(@id, x1, y1, x2, y2) - self - end - alias enclosed set_to_enclosed - - def set_to_overlapping(x1, y1, x2, y2) - @c.addtag_overlapping(@id, x1, y1, x2, y2) - self - end - alias overlapping set_to_overlapping - - def set_to_withtag(target) - @c.addtag_withtag(@id, target) - self - end - alias withtag set_to_withtag -end - -class TkcTagString<TkcTag - def self.new(parent, name, *args) - if CTagID_TBL[parent.path] && CTagID_TBL[parent.path][name] - return CTagID_TBL[parent.path][name] - else - super(parent, name, *args) - end - end - - def initialize(parent, name, mode=nil, *args) - if not parent.kind_of?(TkCanvas) - fail Kernel.format("%s need to be TkCanvas", parent.inspect) - end - @c = parent - @cpath = parent.path - @path = @id = name - CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] - CTagID_TBL[@cpath][@id] = self - if mode - tk_call @c.path, "addtag", @id, mode, *args - end - end -end -TkcNamedTag = TkcTagString - -class TkcTagAll<TkcTag - def initialize(parent) - if not parent.kind_of?(TkCanvas) - fail Kernel.format("%s need to be TkCanvas", parent.inspect) - end - @c = parent - @cpath = parent.path - @path = @id = 'all' - CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] - CTagID_TBL[@cpath][@id] = self - end -end - -class TkcTagCurrent<TkcTag - def initialize(parent) - if not parent.kind_of?(TkCanvas) - fail Kernel.format("%s need to be TkCanvas", parent.inspect) - end - @c = parent - @cpath = parent.path - @path = @id = 'current' - CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] - CTagID_TBL[@cpath][@id] = self - end -end - -class TkcGroup<TkcTag - Tk_cGroup_ID = ['tkcg'.freeze, '00000'.taint].freeze - def create_self(parent, *args) - if not parent.kind_of?(TkCanvas) - fail Kernel.format("%s need to be TkCanvas", parent.inspect) - end - @c = parent - @cpath = parent.path - @path = @id = Tk_cGroup_ID.join - CTagID_TBL[@cpath] = {} unless CTagID_TBL[@cpath] - CTagID_TBL[@cpath][@id] = self - Tk_cGroup_ID[1].succ! - add(*args) if args != [] - end - private :create_self - - def include(*tags) - for i in tags - i.addtag @id - end - self - end - - def exclude(*tags) - for i in tags - i.delete @id - end - self - end -end - -class TkcItem<TkObject - include TkcTagAccess - - CItemTypeToClass = {} - CItemID_TBL = TkCore::INTERP.create_table - - TkCore::INTERP.init_ip_env{ CItemID_TBL.clear } - - def TkcItem.type2class(type) - CItemTypeToClass[type] - end - - def TkcItem.id2obj(canvas, id) - cpath = canvas.path - return id unless CItemID_TBL[cpath] - CItemID_TBL[cpath][id]? CItemID_TBL[cpath][id]: id - end - - def initialize(parent, *args) - if not parent.kind_of?(TkCanvas) - fail Kernel.format("%s need to be TkCanvas", parent.inspect) - end - @parent = @c = parent - @path = parent.path - fontkeys = {} - if args.size == 1 && args[0].kind_of?(Hash) - args[0] = _symbolkey2str(args[0]) - coords = args[0].delete('coords') - if not coords.kind_of?(Array) - fail "coords parameter must be given by an Array" - end - args[0,0] = coords.flatten - end - if args[-1].kind_of? Hash - keys = _symbolkey2str(args.pop) - ['font', 'kanjifont', 'latinfont', 'asciifont'].each{|key| - fontkeys[key] = keys.delete(key) if keys.key?(key) - } - args += hash_kv(keys) - end - @id = create_self(*args).to_i ;# 'canvas item id' is integer number - CItemID_TBL[@path] = {} unless CItemID_TBL[@path] - CItemID_TBL[@path][@id] = self - configure(fontkeys) unless fontkeys.empty? - -######## old version -# if args[-1].kind_of? Hash -# keys = args.pop -# end -# @id = create_self(*args).to_i ;# 'canvas item id' is integer number -# CItemID_TBL[@path] = {} unless CItemID_TBL[@path] -# CItemID_TBL[@path][@id] = self -# if keys -# # tk_call @path, 'itemconfigure', @id, *hash_kv(keys) -# configure(keys) if keys -# end -######## - end - def create_self(*args); end - private :create_self - - def id - @id - end - - def delete - @c.delete @id - CItemID_TBL[@path].delete(@id) if CItemID_TBL[@path] - self - end - alias remove delete - alias destroy delete -end - -class TkcArc<TkcItem - CItemTypeToClass['arc'] = self - def create_self(*args) - tk_call(@path, 'create', 'arc', *args) - end - private :create_self -end - -class TkcBitmap<TkcItem - CItemTypeToClass['bitmap'] = self - def create_self(*args) - tk_call(@path, 'create', 'bitmap', *args) - end - private :create_self -end - -class TkcImage<TkcItem - CItemTypeToClass['image'] = self - def create_self(*args) - tk_call(@path, 'create', 'image', *args) - end - private :create_self -end - -class TkcLine<TkcItem - CItemTypeToClass['line'] = self - def create_self(*args) - tk_call(@path, 'create', 'line', *args) - end - private :create_self -end - -class TkcOval<TkcItem - CItemTypeToClass['oval'] = self - def create_self(*args) - tk_call(@path, 'create', 'oval', *args) - end - private :create_self -end - -class TkcPolygon<TkcItem - CItemTypeToClass['polygon'] = self - def create_self(*args) - tk_call(@path, 'create', 'polygon', *args) - end - private :create_self -end - -class TkcRectangle<TkcItem - CItemTypeToClass['rectangle'] = self - def create_self(*args) - tk_call(@path, 'create', 'rectangle', *args) - end - private :create_self -end - -class TkcText<TkcItem - CItemTypeToClass['text'] = self - def create_self(*args) - tk_call(@path, 'create', 'text', *args) - end - private :create_self -end - -class TkcWindow<TkcItem - CItemTypeToClass['window'] = self - def create_self(*args) - keys = args.pop - if keys && keys.kind_of?(Hash) - keys = _symbolkey2str(keys) - win = keys['window'] - keys['window'] = win.epath if win.kind_of?(TkWindow) - end - args.push(keys) if keys - tk_call(@path, 'create', 'window', *args) - end - private :create_self -end - -class TkImage<TkObject - include Tk - - TkCommandNames = ['image'.freeze].freeze - - Tk_IMGTBL = TkCore::INTERP.create_table - Tk_Image_ID = ['i'.freeze, '00000'.taint].freeze - - TkCore::INTERP.init_ip_env{ Tk_IMGTBL.clear } - - def initialize(keys=nil) - @path = Tk_Image_ID.join - Tk_Image_ID[1].succ! - tk_call 'image', 'create', @type, @path, *hash_kv(keys) - Tk_IMGTBL[@path] = self - end - - def delete - Tk_IMGTBL.delete(@id) if @id - tk_call('image', 'delete', @path) - self - end - def height - number(tk_call('image', 'height', @path)) - end - def inuse - bool(tk_call('image', 'inuse', @path)) - end - def itemtype - tk_call('image', 'type', @path) - end - def width - number(tk_call('image', 'width', @path)) - end - - def TkImage.names - Tk.tk_call('image', 'names').split.collect!{|id| - (Tk_IMGTBL[id])? Tk_IMGTBL[id] : id - } - end - - def TkImage.types - Tk.tk_call('image', 'types').split - end -end - -class TkBitmapImage<TkImage - def initialize(*args) - @type = 'bitmap' - super - end -end - -class TkPhotoImage<TkImage - def initialize(*args) - @type = 'photo' - super - end - - def blank - tk_send 'blank' - self - end - - def cget(option) - case option.to_s - when 'data', 'file' - tk_send 'cget', option - else - tk_tcl2ruby tk_send('cget', option) - end - end - - def copy(source, *opts) - args = opts.collect{|term| - if term.kind_of?(String) && term.include?(?\s) - term.split - else - term - end - }.flatten - - tk_send 'copy', source, *args - - self - end - - def data(keys=nil) - tk_send('data', *hash_kv(keys)) - end - - def get(x, y) - tk_send('get', x, y).split.collect{|n| n.to_i} - end - - def put(data, *to) - if to == [] - tk_send 'put', data - else - tk_send 'put', data, '-to', *to - end - self - end - - def read(file, *opts) - args = opts.collect{|term| - if term.kind_of?(String) && term.include?(?\s) - term.split - else - term - end - }.flatten - - tk_send 'read', file, *args - - self - end - - def redither - tk_send 'redither' - self - end - - def get_transparency(x, y) - bool(tk_send('transparency', 'get', x, y)) - end - def set_transparency(x, y, st) - tk_send('transparency', 'set', x, y, st) - self - end - - def write(file, *opts) - args = opts.collect{|term| - if term.kind_of?(String) && term.include?(?\s) - term.split - else - term - end - }.flatten - - tk_send 'write', file, *args - - self - end -end +# tkcanvas.rb - load tk/canvas.rb +# +require 'tk/canvas' diff --git a/ext/tk/lib/tkconsole.rb b/ext/tk/lib/tkconsole.rb index d97df159fc..9960ddb8ac 100644 --- a/ext/tk/lib/tkconsole.rb +++ b/ext/tk/lib/tkconsole.rb @@ -1,28 +1,4 @@ # -# tkconsole.rb : control the console on system without a real console +# tkconsole.rb - load tk/console.rb # -require 'tk' - -module TkConsole - include Tk - extend Tk - - TkCommandNames = ['console'.freeze].freeze - - def self.title(str=None) - tk_call 'console', str - end - def self.hide - tk_call 'console', 'hide' - end - def self.show - tk_call 'console', 'show' - end - def self.eval(tcl_script) - # - # supports a Tcl script only - # I have no idea to support a Ruby script seamlessly. - # - tk_call 'console', 'eval', tcl_script - end -end +require 'tk/console' diff --git a/ext/tk/lib/tkdialog.rb b/ext/tk/lib/tkdialog.rb index a581f3becc..bec5e5d29a 100644 --- a/ext/tk/lib/tkdialog.rb +++ b/ext/tk/lib/tkdialog.rb @@ -1,276 +1,4 @@ -require "tk" - -class TkDialog2 < TkWindow - extend Tk - - TkCommandNames = ['tk_dialog'.freeze].freeze - - def self.show(*args) - dlog = self.new(*args) - dlog.show - dlog - end - - def _set_button_config(configs) - set_config = proc{|c,i| - if $VERBOSE && (c.has_key?('command') || c.has_key?(:command)) - STDERR.print("Warning: cannot give a command option " + - "to the dialog button#{i}. It was removed.\n") - end - c.delete('command'); c.delete(:command) - @config << Kernel.format("%s.button%s configure %s; ", - @path, i, hash_kv(c).join(' ')) - } - case configs - when Proc - @buttons.each_index{|i| - if (c = configs.call(i)).kind_of? Hash - set_config.call(c,i) - end - } - - when Array - @buttons.each_index{|i| - if (c = configs[i]).kind_of? Hash - set_config.call(c,i) - end - } - - when Hash - @buttons.each_with_index{|s,i| - if (c = configs[s]).kind_of? Hash - set_config.call(c,i) - end - } - end - @config = 'after idle {' + @config + '};' if @config != "" - end - private :_set_button_config - - # initialize tk_dialog - def create_self(keys) - @var = TkVariable.new - - @title = title - - @message = message - @message_config = message_config - @msgframe_config = msgframe_config - - @bitmap = bitmap - @bitmap_config = message_config - - @default_button = default_button - - @buttons = buttons - @button_configs = proc{|num| button_configs(num)} - @btnframe_config = btnframe_config - - #@config = "puts [winfo children .w0000];" - @config = "" - - @command = nil - - if keys.kind_of? Hash - @title = keys['title'] if keys.key? 'title' - @message = keys['message'] if keys.key? 'message' - @bitmap = keys['bitmap'] if keys.key? 'bitmap' - @bitmap = '{}' if @bitmap == nil || @bitmap == "" - @default_button = keys['default'] if keys.key? 'default' - @buttons = keys['buttons'] if keys.key? 'buttons' - - @command = keys['prev_command'] - - @message_config = keys['message_config'] if keys.key? 'message_config' - @msgframe_config = keys['msgframe_config'] if keys.key? 'msgframe_config' - @bitmap_config = keys['bitmap_config'] if keys.key? 'bitmap_config' - @button_configs = keys['button_configs'] if keys.key? 'button_configs' - @btnframe_config = keys['btnframe_config'] if keys.key? 'btnframe_config' - end - - if @title.include? ?\s - @title = '{' + @title + '}' - end - - if @buttons.kind_of? Array - _set_button_config(@buttons.collect{|cfg| - (cfg.kind_of? Array)? cfg[1]: nil}) - @buttons = @buttons.collect{|cfg| (cfg.kind_of? Array)? cfg[0]: cfg} - end - if @buttons.kind_of? Hash - _set_button_config(@buttons) - @buttons = @buttons.keys - end - @buttons = tk_split_simplelist(@buttons) if @buttons.kind_of? String - @buttons = @buttons.collect{|s| - if s.kind_of? Array - s = s.join(' ') - end - if s.include? ?\s - '{' + s + '}' - else - s - end - } - - if @message_config.kind_of? Hash - @config << Kernel.format("%s.msg configure %s;", - @path, hash_kv(@message_config).join(' ')) - end - - if @msgframe_config.kind_of? Hash - @config << Kernel.format("%s.top configure %s;", - @path, hash_kv(@msgframe_config).join(' ')) - end - - if @btnframe_config.kind_of? Hash - @config << Kernel.format("%s.bot configure %s;", - @path, hash_kv(@btnframe_config).join(' ')) - end - - if @bitmap_config.kind_of? Hash - @config << Kernel.format("%s.bitmap configure %s;", - @path, hash_kv(@bitmap_config).join(' ')) - end - - _set_button_config(@button_configs) if @button_configs - - if @command.kind_of? Proc - @command.call(self) - end - end - private :create_self - - def show - if @default_button.kind_of? String - default_button = @buttons.index(@default_button) - else - default_button = @default_button - end - default_button = '{}' if default_button == nil - Tk.ip_eval('eval {global '+@var.id+';'+@config+ - 'set '+@var.id+' [tk_dialog '+ - @path+" "+@title+" {#{@message}} "+@bitmap+" "+ - String(default_button)+" "+@buttons.join(' ')+']}') - end - - def value - return @var.value.to_i - end - ###################################################### - # # - # these methods must be overridden for each dialog # - # # - ###################################################### - private - - def title - # returns a title string of the dialog window - return "DIALOG" - end - def message - # returns a message text to display on the dialog - return "MESSAGE" - end - def message_config - # returns a Hash {option=>value, ...} for the message text - return nil - end - def msgframe_config - # returns a Hash {option=>value, ...} for the message text frame - return nil - end - def bitmap - # returns a bitmap name or a bitmap file path - # (@ + path ; e.g. '@/usr/share/bitmap/sample.xbm') - return "info" - end - def bitmap_config - # returns nil or a Hash {option=>value, ...} for the bitmap - return nil - end - def default_button - # returns a default button's number or name - # if nil or null string, set no-default - return 0 - end - def buttons - #return "BUTTON1 BUTTON2" - return ["BUTTON1", "BUTTON2"] - end - def button_configs(num) - # returns nil / Proc / Array or Hash (see _set_button_config) - return nil - end - def btnframe_config - # returns nil or a Hash {option=>value, ...} for the button frame - return nil - end -end - - # -# TkDialog : with showing at initialize +# tkdialog.rb - load tk/dialog.rb # -class TkDialog < TkDialog2 - def self.show(*args) - self.new(*args) - end - - def initialize(*args) - super(*args) - show - end -end - - -# -# dialog for warning -# -class TkWarning2 < TkDialog2 - def initialize(parent = nil, mes = nil) - if !mes - if parent.kind_of? TkWindow - mes = "" - else - mes = parent.to_s - parent = nil - end - end - super(parent, :message=>mes) - end - - def show(mes = nil) - mes_bup = @message - @message = mes if mes - ret = super() - @message = mes_bup - ret - end - - ####### - private - - def title - return "WARNING"; - end - def bitmap - return "warning"; - end - def default_button - return 0; - end - def buttons - return "OK"; - end -end - -class TkWarning < TkWarning2 - def self.show(*args) - self.new(*args) - end - def initialize(*args) - super(*args) - show - end -end +require 'tk/dialog' diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb index fe9a7b6277..2dcfcab5da 100644 --- a/ext/tk/lib/tkentry.rb +++ b/ext/tk/lib/tkentry.rb @@ -1,292 +1,4 @@ # -# tkentry.rb - Tk entry classes -# $Date$ -# by Yukihiro Matsumoto <matz@caelum.co.jp> - -require 'tk.rb' - -class TkEntry<TkLabel - include Scrollable - - TkCommandNames = ['entry'.freeze].freeze - WidgetClassName = 'Entry'.freeze - WidgetClassNames[WidgetClassName] = self - - class ValidateCmd - include TkComm - - module Action - Insert = 1 - Delete = 0 - Others = -1 - Focus = -1 - Forced = -1 - Textvariable = -1 - TextVariable = -1 - end - - class ValidateArgs - VARG_KEY = 'disvPSVW' - VARG_TYPE = 'nxeseesw' - - def self.scan_args(arg_str, arg_val) - enc = Tk.encoding - arg_cnv = [] - arg_str.strip.split(/\s+/).each_with_index{|kwd,idx| - if kwd =~ /^%(.)$/ - if num = VARG_KEY.index($1) - case VARG_TYPE[num] - when ?n - arg_cnv << TkComm::number(arg_val[idx]) - when ?s - arg_cnv << TkComm::string(arg_val[idx]) - when ?e - if enc - arg_cnv << Tk.fromUTF8(TkComm::string(arg_val[idx]), enc) - else - arg_cnv << TkComm::string(arg_val[idx]) - end - when ?w - arg_cnv << TkComm::window(arg_val[idx]) - when ?x - idx = TkComm::number(arg_val[idx]) - if idx < 0 - arg_cnv << nil - else - arg_cnv << idx - end - else - arg_cnv << arg_val[idx] - end - else - arg_cnv << arg_val[idx] - end - else - arg_cnv << arg_val[idx] - end - } - arg_cnv - end - - def initialize(d,i,s,v,pp,ss,vv,ww) - @action = d - @index = i - @current = s - @type = v - @value = pp - @string = ss - @triggered = vv - @widget = ww - end - attr :action - attr :index - attr :current - attr :type - attr :value - attr :string - attr :triggered - attr :widget - end - - def initialize(cmd = Proc.new, args=nil) - if args - @id = - install_cmd(proc{|*arg| - TkUtil.eval_cmd(proc{|*v| (cmd.call(*v))? '1': '0'}, - *ValidateArgs.scan_args(args, arg)) - }) + " " + args - else - args = ' %d %i %s %v %P %S %V %W' - @id = - install_cmd(proc{|*arg| - TkUtil.eval_cmd(proc{|*v| (cmd.call(*v))? '1': '0'}, - ValidateArgs.new(*ValidateArgs \ - .scan_args(args,arg))) - }) + args - end - end - - def to_eval - @id - end - end - - def create_self(keys) - tk_call 'entry', @path - if keys and keys != None - configure(keys) - end - end - private :create_self - - def configure(slot, value=None) - if slot.kind_of? Hash - slot = _symbolkey2str(slot) - if slot['vcmd'].kind_of? Array - cmd, *args = slot['vcmd'] - slot['vcmd'] = ValidateCmd.new(cmd, args.join(' ')) - elsif slot['vcmd'].kind_of? Proc - slot['vcmd'] = ValidateCmd.new(slot['vcmd']) - end - if slot['validatecommand'].kind_of? Array - cmd, *args = slot['validatecommand'] - slot['validatecommand'] = ValidateCmd.new(cmd, args.join(' ')) - elsif slot['validatecommand'].kind_of? Proc - slot['validatecommand'] = ValidateCmd.new(slot['validatecommand']) - end - if slot['invcmd'].kind_of? Array - cmd, *args = slot['invcmd'] - slot['invcmd'] = ValidateCmd.new(cmd, args.join(' ')) - elsif slot['invcmd'].kind_of? Proc - slot['invcmd'] = ValidateCmd.new(slot['invcmd']) - end - if slot['invalidcommand'].kind_of? Array - cmd, *args = slot['invalidcommand'] - slot['invalidcommand'] = ValidateCmd.new(cmd, args.join(' ')) - elsif slot['invalidcommand'].kind_of? Proc - slot['invalidcommand'] = ValidateCmd.new(slot['invalidcommand']) - end - super(slot) - else - if (slot == 'vcmd' || slot == :vcmd || - slot == 'validatecommand' || slot == :validatecommand || - slot == 'invcmd' || slot == :invcmd || - slot == 'invalidcommand' || slot == :invalidcommand) - if value.kind_of? Array - cmd, *args = value - value = ValidateCmd.new(cmd, args.join(' ')) - elsif value.kind_of? Proc - value = ValidateCmd.new(value) - end - end - super(slot, value) - end - self - end - - def bbox(index) - list(tk_send('bbox', index)) - end - def cursor - number(tk_send('index', 'insert')) - end - def cursor=(index) - tk_send 'icursor', index - self - end - def index(index) - number(tk_send('index', index)) - end - def insert(pos,text) - tk_send 'insert', pos, text - self - end - def delete(first, last=None) - tk_send 'delete', first, last - self - end - def mark(pos) - tk_send 'scan', 'mark', pos - self - end - def dragto(pos) - tk_send 'scan', 'dragto', pos - self - end - def selection_adjust(index) - tk_send 'selection', 'adjust', index - self - end - def selection_clear - tk_send 'selection', 'clear' - self - end - def selection_from(index) - tk_send 'selection', 'from', index - self - end - def selection_present() - bool(tk_send('selection', 'present')) - end - def selection_range(s, e) - tk_send 'selection', 'range', s, e - self - end - def selection_to(index) - tk_send 'selection', 'to', index - self - end - - def invoke_validate - bool(tk_send('validate')) - end - def validate(mode = nil) - if mode - configure 'validate', mode - else - invoke_validate - end - end - - def validatecommand(cmd = Proc.new, args = nil) - if cmd.kind_of?(ValidateCmd) - configure('validatecommand', cmd) - elsif args - configure('validatecommand', [cmd, args]) - else - configure('validatecommand', cmd) - end - end - alias vcmd validatecommand - - def invalidcommand(cmd = Proc.new, args = nil) - if cmd.kind_of?(ValidateCmd) - configure('invalidcommand', cmd) - elsif args - configure('invalidcommand', [cmd, args]) - else - configure('invalidcommand', cmd) - end - end - alias invcmd invalidcommand - - def value - tk_send 'get' - end - def value= (val) - tk_send 'delete', 0, 'end' - tk_send 'insert', 0, val - end -end - -class TkSpinbox<TkEntry - TkCommandNames = ['spinbox'.freeze].freeze - WidgetClassName = 'Spinbox'.freeze - WidgetClassNames[WidgetClassName] = self - - def create_self(keys) - tk_call 'spinbox', @path - if keys and keys != None - configure(keys) - end - end - private :create_self - - def identify(x, y) - tk_send 'identify', x, y - end - - def spinup - tk_send 'invoke', 'spinup' - self - end - - def spindown - tk_send 'invoke', 'spindown' - self - end - - def set(str) - tk_send 'set', str - end -end +# tkentry.rb - load tk/entry.rb +# +require 'tk/entry' diff --git a/ext/tk/lib/tkfont.rb b/ext/tk/lib/tkfont.rb index ff7bbc74e4..38a96633de 100644 --- a/ext/tk/lib/tkfont.rb +++ b/ext/tk/lib/tkfont.rb @@ -1,1390 +1,4 @@ # -# tkfont.rb - the class to treat fonts on Ruby/Tk +# tkfont.rb - load tk/font.rb # -# by Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp) -# -require 'tk' - -class TkFont - include Tk - extend TkCore - - TkCommandNames = ['font'.freeze].freeze - - Tk_FontID = ["@font".freeze, "00000".taint].freeze - Tk_FontNameTBL = TkCore::INTERP.create_table - Tk_FontUseTBL = TkCore::INTERP.create_table - - TkCore::INTERP.init_ip_env{ - Tk_FontNameTBL.clear - Tk_FontUseTBL.clear - } - - # set default font - case Tk::TK_VERSION - when /^4\.*/ - DEFAULT_LATIN_FONT_NAME = 'a14'.freeze - DEFAULT_KANJI_FONT_NAME = 'k14'.freeze - - when /^8\.*/ - if JAPANIZED_TK - begin - fontnames = tk_call('font', 'names') - case fontnames - when /defaultgui/ - # Tcl/Tk-JP for Windows - ltn = 'defaultgui' - knj = 'defaultgui' - when /Mincho:Helvetica-Bold-12/ - # Tcl/Tk-JP for UNIX/X - ltn, knj = tk_split_simplelist(tk_call('font', 'configure', - 'Mincho:Helvetica-Bold-12', - '-compound')) - else - # unknown Tcl/Tk-JP - platform = tk_call('set', 'tcl_platform(platform)') - case platform - when 'unix' - ltn = {'family'=>'Helvetica'.freeze, - 'size'=>-12, 'weight'=>'bold'.freeze} - #knj = 'k14' - #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0' - knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0' - when 'windows' - ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} - knj = 'mincho' - when 'macintosh' - ltn = 'system' - knj = 'mincho' - else # unknown - ltn = 'Helvetica' - knj = 'mincho' - end - end - rescue - ltn = 'Helvetica' - knj = 'mincho' - end - - else # not JAPANIZED_TK - begin - platform = tk_call('set', 'tcl_platform(platform)') - case platform - when 'unix' - ltn = {'family'=>'Helvetica'.freeze, - 'size'=>-12, 'weight'=>'bold'.freeze} - #knj = 'k14' - #knj = '-misc-fixed-medium-r-normal--14-*-*-*-c-*-jisx0208.1983-0' - knj = '-*-fixed-bold-r-normal--12-*-*-*-c-*-jisx0208.1983-0' - when 'windows' - ltn = {'family'=>'MS Sans Serif'.freeze, 'size'=>8} - knj = 'mincho' - when 'macintosh' - ltn = 'system' - knj = 'mincho' - else # unknown - ltn = 'Helvetica' - knj = 'mincho' - end - rescue - ltn = 'Helvetica' - knj = 'mincho' - end - - knj = ltn - end - - DEFAULT_LATIN_FONT_NAME = ltn.freeze - DEFAULT_KANJI_FONT_NAME = knj.freeze - - else # unknown version - DEFAULT_LATIN_FONT_NAME = 'Helvetica'.freeze - DEFAULT_KANJI_FONT_NAME = 'mincho'.freeze - - end - - if $DEBUG - print "default latin font = "; p DEFAULT_LATIN_FONT_NAME - print "default kanji font = "; p DEFAULT_KANJI_FONT_NAME - end - - - ################################### - class DescendantFont - def initialize(compound, type) - unless compound.kind_of?(TkFont) - fail ArgumentError, "a TkFont object is expected for the 1st argument" - end - @compound = compound - case type - when 'kanji', 'latin', 'ascii' - @type = type - else - fail ArgumentError, "unknown type '#{type}'" - end - end - - def dup - fail RuntimeError, "cannot dupulicate a descendant font" - end - def clone - fail RuntimeError, "cannot clone a descendant font" - end - - def to_eval - @compound.__send__(@type + '_font_id') - end - def font - @compound.__send__(@type + '_font_id') - end - - def [](slot) - @compound.__send__(@type + '_configinfo', slot) - end - def []=(slot, value=None) - @compound.__send__(@type + '_configure', slot, value) - end - - def method_missing(id, *args) - @compound.__send__(@type + '_' + id.id2name, *args) - end - end - - - ################################### - # class methods - ################################### - def TkFont.families(window=nil) - case (Tk::TK_VERSION) - when /^4\.*/ - ['fixed'] - - when /^8\.*/ - if window - tk_split_simplelist(tk_call('font', 'families', '-displayof', window)) - else - tk_split_simplelist(tk_call('font', 'families')) - end - end - end - - def TkFont.names - case (Tk::TK_VERSION) - when /^4\.*/ - r = ['fixed'] - r += ['a14', 'k14'] if JAPANIZED_TK - Tk_FontNameTBL.each_value{|obj| r.push(obj)} - r | [] - - when /^8\.*/ - tk_split_simplelist(tk_call('font', 'names')) - - end - end - - def TkFont.create_copy(font) - fail 'source-font must be a TkFont object' unless font.kind_of? TkFont - keys = {} - font.configinfo.each{|key,value| keys[key] = value } - TkFont.new(font.latin_font_id, font.kanji_font_id, keys) - end - - def TkFont.get_obj(name) - if name =~ /^(@font[0-9]+)(|c|l|k)$/ - Tk_FontNameTBL[$1] - else - nil - end - end - - def TkFont.init_widget_font(path, *args) - case (Tk::TK_VERSION) - when /^4\.*/ - conf = tk_split_simplelist(tk_call(*args)). - find_all{|prop| prop[0..5]=='-font ' || prop[0..10]=='-kanjifont '}. - collect{|prop| tk_split_simplelist(prop)} - if font_inf = conf.assoc('-font') - ltn = font_inf[4] - ltn = nil if ltn == [] - else - #ltn = nil - raise RuntimeError, "unknown option '-font'" - end - if font_inf = conf.assoc('-kanjifont') - knj = font_inf[4] - knj = nil if knj == [] - else - knj = nil - end - TkFont.new(ltn, knj).call_font_configure(path, *(args + [{}])) - - when /^8\.*/ - font_prop = tk_split_simplelist(tk_call(*args)).find{|prop| - prop[0..5] == '-font ' - } - unless font_prop - raise RuntimeError, "unknown option '-font'" - end - fnt = tk_split_simplelist(font_prop)[4] - if fnt == "" - TkFont.new(nil, nil).call_font_configure(path, *(args + [{}])) - else - begin - compound = tk_split_simplelist( - Hash[*tk_split_simplelist(tk_call('font', 'configure', - fnt))].collect{|key,value| - [key[1..-1], value] - }.assoc('compound')[1]) - rescue - compound = [] - end - if compound == [] - #TkFont.new(fnt, DEFAULT_KANJI_FONT_NAME) \ - #.call_font_configure(path, *(args + [{}])) - TkFont.new(fnt).call_font_configure(path, *(args + [{}])) - else - TkFont.new(compound[0], compound[1]) \ - .call_font_configure(path, *(args + [{}])) - end - end - end - end - - def TkFont.used_on(path=nil) - if path - Tk_FontUseTBL[path] - else - Tk_FontUseTBL.values | [] - end - end - - def TkFont.failsafe(font) - begin - if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK - tk_call('font', 'failsafe', font) - end - rescue - end - end - - ################################### - # instance methods - ################################### - private - ################################### - def initialize(ltn=nil, knj=nil, keys=nil) - @id = Tk_FontID.join - Tk_FontID[1].succ! - Tk_FontNameTBL[@id] = self - - @latin_desscendant = nil - @kanji_desscendant = nil - - if knj.kind_of?(Hash) && !keys - keys = knj - knj = nil - end - - # compound font check - if Tk::TK_VERSION == '8.0' && JAPANIZED_TK - begin - compound = tk_split_simplelist(tk_call('font', 'configure', - ltn, '-compound')) - if knj == nil - if compound != [] - ltn, knj = compound - end - else - if compound != [] - ltn = compound[0] - end - compound = tk_split_simplelist(tk_call('font', 'configure', - knj, '-compound')) - if compound != [] - knj = compound[1] - end - end - rescue - end - end - - if ltn - knj = ltn if JAPANIZED_TK && !knj - else - ltn = DEFAULT_LATIN_FONT_NAME - knj = DEFAULT_KANJI_FONT_NAME if JAPANIZED_TK && !knj - end - - create_compoundfont(ltn, knj, keys) - end - - def _get_font_info_from_hash(font) - font = _symbolkey2str(font) - foundry = (info = font['foundry'] .to_s)? info: '*' - family = (info = font['family'] .to_s)? info: '*' - weight = (info = font['weight'] .to_s)? info: '*' - slant = (info = font['slant'] .to_s)? info: '*' - swidth = (info = font['swidth'] .to_s)? info: '*' - adstyle = (info = font['adstyle'] .to_s)? info: '*' - pixels = (info = font['pixels'] .to_s)? info: '*' - points = (info = font['points'] .to_s)? info: '*' - resx = (info = font['resx'] .to_s)? info: '*' - resy = (info = font['resy'] .to_s)? info: '*' - space = (info = font['space'] .to_s)? info: '*' - avgWidth = (info = font['avgWidth'].to_s)? info: '*' - charset = (info = font['charset'] .to_s)? info: '*' - encoding = (info = font['encoding'].to_s)? info: '*' - - [foundry, family, weight, slant, swidth, adstyle, - pixels, points, resx, resy, space, avgWidth, charset, encoding] - end - - def create_latinfont_tk4x(font) - if font.kind_of? Hash - @latinfont = '-' + _get_font_info_from_hash(font).join('-') + '-' - - elsif font.kind_of? Array - finfo = {} - finfo['family'] = font[0].to_s - if font[1] - fsize = font[1].to_s - if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = $2 - else - finfo['points'] = $2 - end - else - finfo['points'] = '13' - end - end - font[2..-1].each{|style| - case (style) - when 'normal' - finfo['weight'] = style - when 'bold' - finfo['weight'] = style - when 'roman' - finfo['slant'] = 'r' - when 'italic' - finfo['slant'] = 'i' - end - } - - @latinfont = '-' + _get_font_info_from_hash(finfo).join('-') + '-' - - elsif font.kind_of? TkFont - @latinfont = font.latin_font - - else - if font - @latinfont = font - else - @latinfont = DEFAULT_LATIN_FONT_NAME - end - - end - end - - def create_kanjifont_tk4x(font) - unless JAPANIZED_TK - @kanjifont = "" - return - end - - if font.kind_of? Hash - @kanjifont = '-' + _get_font_info_from_hash(font).join('-') + '-' - - elsif font.kind_of? Array - finfo = {} - finfo['family'] = font[0].to_s - if font[1] - fsize = font[1].to_s - if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = $2 - else - finfo['points'] = $2 - end - else - finfo['points'] = '13' - end - end - font[2..-1].each{|style| - case (style) - when 'normal' - finfo['weight'] = style - when 'bold' - finfo['weight'] = style - when 'roman' - finfo['slant'] = 'r' - when 'italic' - finfo['slant'] = 'i' - end - } - - @kanjifont = '-' + _get_font_info_from_hash(finfo).join('-') + '-' - elsif font.kind_of? TkFont - @kanjifont = font.kanji_font_id - else - if font - @kanjifont = font - else - @kanjifont = DEFAULT_KANJI_FONT_NAME - end - end - end - - def create_compoundfont_tk4x(ltn, knj, keys) - create_latinfont(ltn) - create_kanjifont(knj) - - if JAPANIZED_TK - @compoundfont = [[@latinfont], [@kanjifont]] - @fontslot = {'font'=>@latinfont, 'kanjifont'=>@kanjifont} - else - @compoundfont = @latinfont - @fontslot = {'font'=>@latinfont} - end - end - - def create_latinfont_tk8x(font) - @latinfont = @id + 'l' - - if JAPANIZED_TK - if font.kind_of? Hash - if font[:charset] || font['charset'] - tk_call('font', 'create', @latinfont, *hash_kv(font)) - else - tk_call('font', 'create', @latinfont, - '-charset', 'iso8859', *hash_kv(font)) - end - elsif font.kind_of? Array - tk_call('font', 'create', @latinfont, '-copy', array2tk_list(font)) - tk_call('font', 'configure', @latinfont, '-charset', 'iso8859') - elsif font.kind_of? TkFont - tk_call('font', 'create', @latinfont, '-copy', font.latin_font) - elsif font - tk_call('font', 'create', @latinfont, '-copy', font, - '-charset', 'iso8859') - else - tk_call('font', 'create', @latinfont, '-charset', 'iso8859') - end - else - if font.kind_of? Hash - tk_call('font', 'create', @latinfont, *hash_kv(font)) - else - keys = {} - if font.kind_of? Array - actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} - elsif font.kind_of? TkFont - actual_core(font.latin_font).each{|key,val| keys[key] = val} - elsif font - actual_core(font).each{|key,val| keys[key] = val} - end - tk_call('font', 'create', @latinfont, *hash_kv(keys)) - end - - if font && @compoundfont - keys = {} - actual_core(@latinfont).each{|key,val| keys[key] = val} - tk_call('font', 'configure', @compoundfont, *hash_kv(keys)) - end - end - end - - def create_kanjifont_tk8x(font) - @kanjifont = @id + 'k' - - if JAPANIZED_TK - if font.kind_of? Hash - if font[:charset] || font['charset'] - tk_call('font', 'create', @kanjifont, *hash_kv(font)) - else - tk_call('font', 'create', @kanjifont, - '-charset', 'jisx0208.1983', *hash_kv(font)) - end - elsif font.kind_of? Array - tk_call('font', 'create', @kanjifont, '-copy', array2tk_list(font)) - tk_call('font', 'configure', @kanjifont, '-charset', 'jisx0208.1983') - elsif font.kind_of? TkFont - tk_call('font', 'create', @kanjifont, '-copy', font.kanji_font_id) - elsif font - tk_call('font', 'create', @kanjifont, '-copy', font, - '-charset', 'jisx0208.1983') - else - tk_call('font', 'create', @kanjifont, '-charset', 'jisx0208.1983') - end - # end of JAPANIZED_TK - - else - if font.kind_of? Hash - tk_call('font', 'create', @kanjifont, *hash_kv(font)) - else - keys = {} - if font.kind_of? Array - actual_core(array2tk_list(font)).each{|key,val| keys[key] = val} - elsif font.kind_of? TkFont - actual_core(font.kanji_font_id).each{|key,val| keys[key] = val} - elsif font - actual_core(font).each{|key,val| keys[key] = val} - end - tk_call('font', 'create', @kanjifont, *hash_kv(keys)) - end - - if font && @compoundfont - keys = {} - actual_core(@kanjifont).each{|key,val| keys[key] = val} - tk_call('font', 'configure', @compoundfont, *hash_kv(keys)) - end - end - end - - def create_compoundfont_tk8x(ltn, knj, keys) - create_latinfont(ltn) - create_kanjifont(knj) - - @compoundfont = @id + 'c' - if JAPANIZED_TK - unless keys - keys = {} - else - keys = keys.dup - end - if (tk_call('font', 'configure', @latinfont, '-underline') == '1' && - tk_call('font', 'configure', @kanjifont, '-underline') == '1' && - !keys.key?('underline')) - keys['underline'] = true - end - if (tk_call('font', 'configure', @latinfont, '-overstrike') == '1' && - tk_call('font', 'configure', @kanjifont, '-overstrike') == '1' && - !keys.key?('overstrike')) - keys['overstrike'] = true - end - - @fontslot = {'font'=>@compoundfont} - begin - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - rescue RuntimeError => e - if ltn == knj - if e.message =~ /kanji font .* specified/ - tk_call('font', 'delete', @latinfont) - create_latinfont(DEFAULT_LATIN_FONT_NAME) - opts = [] - Hash[*(tk_split_simplelist(tk_call('font', 'configure', - @kanjifont)))].each{|k,v| - case k - when '-size', '-weight', '-slant', '-underline', '-overstrike' - opts << k << v - end - } - tk_call('font', 'configure', @latinfont, *opts) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - - elsif e.message =~ /ascii font .* specified/ - tk_call('font', 'delete', @kanjifont) - create_kanjifont(DEFAULT_KANJI_FONT_NAME) - opts = [] - Hash[*(tk_split_simplelist(tk_call('font', 'configure', - @latinfont)))].each{|k,v| - case k - when '-size', '-weight', '-slant', '-underline', '-overstrike' - opts << k << v - end - } - tk_call('font', 'configure', @kanjifont, *opts) - tk_call('font', 'create', @compoundfont, - '-compound', [@latinfont, @kanjifont], *hash_kv(keys)) - - else - raise e - end - else - raise e - end - end - else - tk_call('font', 'create', @compoundfont) - - 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 - - if knj - kanjikeys = {} - begin - actual_core(@kanjifont).each{|key,val| kanjikeys[key] = val} - rescue - kanjikeys {} - end - if kanjikeys != {} - tk_call('font', 'configure', @compoundfont, *hash_kv(kanjikeys)) - end - end - - @fontslot = {'font'=>@compoundfont} - tk_call('font', 'configure', @compoundfont, *hash_kv(keys)) - end - end - - def actual_core_tk4x(font, window=nil, option=nil) - # dummy - if option - "" - else - [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], - ['underline',[]], ['overstrike',[]], ['charset',[]], - ['pointadjust',[]]] - end - end - - def actual_core_tk8x(font, window=nil, option=nil) - if option == 'compound' - "" - elsif option - if window - tk_call('font', 'actual', font, "-displayof", window, "-#{option}") - else - tk_call('font', 'actual', font, "-#{option}") - end - else - l = tk_split_simplelist(if window - tk_call('font', 'actual', font, - "-displayof", window) - else - tk_call('font', 'actual', font) - end) - r = [] - while key=l.shift - if key == '-compound' - l.shift - else - r.push [key[1..-1], l.shift] - end - end - r - end - end - - def configure_core_tk4x(font, slot, value=None) - #"" - self - end - - def configinfo_core_tk4x(font, option=nil) - # dummy - if option - "" - else - [['family',[]], ['size',[]], ['weight',[]], ['slant',[]], - ['underline',[]], ['overstrike',[]], ['charset',[]], - ['pointadjust',[]]] - end - 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 - - 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 - - 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 - - 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 configinfo_core_tk8x(font, option=nil) - if option == 'compound' - "" - elsif option - tk_call('font', 'configure', font, "-#{option}") - else - l = tk_split_simplelist(tk_call('font', 'configure', font)) - r = [] - while key=l.shift - if key == '-compound' - l.shift - else - r.push [key[1..-1], l.shift] - end - end - r - end - end - - def delete_core_tk4x - Tk_FontNameTBL.delete(@id) - Tk_FontUseTBL.delete_if{|key,value| value == self} - 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} - 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 = w.split(';') - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'font'=>@latinfont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, '-font', @latinfont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, '-font', @latinfont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, '-font', @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 - } - self - end - - def kanji_replace_core_tk4x(knj) - return self unless JAPANIZED_TK - - 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 = w.split(';') - winobj = tk_tcl2ruby(win) -# winobj.tagfont_configure(tag, {'kanjifont'=>@kanjifont}) - if winobj.kind_of? TkText - tk_call(win, 'tag', 'configure', tag, '-kanjifont', @kanjifont) - elsif winobj.kind_of? TkCanvas - tk_call(win, 'itemconfigure', tag, '-kanjifont', @kanjifont) - elsif winobj.kind_of? TkMenu - tk_call(win, 'entryconfigure', tag, '-kanjifont', @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 - 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 - - begin - tk_call('font', 'delete', @latinfont) - rescue - 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 - - 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 - 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 - end - - begin - tk_call('font', 'delete', @kanjifont) - rescue - end - create_kanjifont(knj) - - 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_core_tk4x(window, text) - 0 - end - - def measure_core_tk8x(window, text) - if window - number(tk_call('font', 'measure', @compoundfont, - '-displayof', window, text)) - else - number(tk_call('font', 'measure', @compoundfont, text)) - end - end - - def metrics_core_tk4x(font, window, option=nil) - # dummy - if option - "" - else - [['ascent',[]], ['descent',[]], ['linespace',[]], ['fixed',[]]] - end - end - - def metrics_core_tk8x(font, window, option=nil) - if option - if window - number(tk_call('font', 'metrics', font, - "-displayof", window, "-#{option}")) - else - number(tk_call('font', 'metrics', font, "-#{option}")) - end - else - l = tk_split_list(if window - tk_call('font','metrics',font,"-displayof",window) - else - tk_call('font','metrics',font) - end) - r = [] - while key=l.shift - r.push [key[1..-1], l.shift.to_i] - end - r - end - end - - ################################### - # private alias - ################################### - case (Tk::TK_VERSION) - when /^4\.*/ - 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 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-4]/ - 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 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 - - when /^8\.*/ - 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 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 - ################################### - 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 - end - - def call_font_configure(path, *args) - args += hash_kv(args.pop.update(@fontslot)) - tk_call(*args) - Tk_FontUseTBL[path] = self - self - end - - def used - ret = [] - Tk_FontUseTBL.each{|key,value| - if key.include?(';') - win, tag = key.split(';') - winobj = tk_tcl2ruby(win) - if winobj.kind_of? TkText - ret.push([winobj, winobj.tagid2obj(tag)]) - elsif winobj.kind_of? TkCanvas - if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag - ret.push([winobj, tagobj]) - elsif (tagobj = TkcItem.id2obj(tag)).kind_of? TkcItem - ret.push([winobj, tagobj]) - else - ret.push([winobj, tag]) - end - elsif winobj.kind_of? TkMenu - ret.push([winobj, tag]) - else - ret.push([win, tag]) - end - else - ret.push(tk_tcl2ruby(key)) if value == self - end - } - ret - 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 - @latin_descendant = DescendantFont.new(self, 'latin') - end - end - alias latinfont latin_font - - def kanji_font_id - @kanjifont - end - - def kanji_font - # @kanjifont - if @kanji_descendant - @kanji_descendant - else - @kanji_descendant = DescendantFont.new(self, 'kanji') - end - end - alias kanjifont kanji_font - - def actual(option=nil) - actual_core(@compoundfont, nil, option) - end - - def actual_displayof(window, option=nil) - window = '.' unless window - actual_core(@compoundfont, window, option) - end - - def latin_actual(option=nil) - actual_core(@latinfont, nil, option) - end - - def latin_actual_displayof(window, option=nil) - window = '.' unless window - actual_core(@latinfont, window, 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 kanji_actual_displayof(window, option=nil) - #if JAPANIZED_TK - if @kanjifont != "" - window = '.' unless window - actual_core(@kanjifont, window, option) - else - actual_core_tk4x(nil, window, option) - end - end - - def [](slot) - configinfo slot - end - - def []=(slot, val) - configure slot, val - end - - def configure(slot, value=None) - configure_core(@compoundfont, slot, value) - self - end - - def configinfo(slot=nil) - configinfo_core(@compoundfont, slot) - end - - def delete - delete_core - end - - def latin_configure(slot, value=None) - if JAPANIZED_TK - configure_core(@latinfont, slot, value) - else - configure(slot, value) - end - self - end - - def latin_configinfo(slot=nil) - if JAPANIZED_TK - 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 - #"" - configure(slot, value) - end - self - end - - def kanji_configinfo(slot=nil) - #if JAPANIZED_TK - if @kanjifont != "" - configinfo_core(@kanjifont, slot) - else - #[] - configinfo(slot) - end - end - - def replace(ltn, knj) - latin_replace(ltn) - kanji_replace(knj) - self - end - - def latin_replace(ltn) - latin_replace_core(ltn) - reset_pointadjust - self - end - - def kanji_replace(knj) - kanji_replace_core(knj) - reset_pointadjust - self - end - - def measure(text) - measure_core(nil, text) - end - - def measure_displayof(window, text) - window = '.' unless window - measure_core(window, text) - end - - def metrics(option=nil) - metrics_core(@compoundfont, nil, option) - end - - def metrics_displayof(window, option=nil) - window = '.' unless window - metrics_core(@compoundfont, window, option) - end - - def latin_metrics(option=nil) - metrics_core(@latinfont, nil, option) - end - - def latin_metrics_displayof(window, option=nil) - window = '.' unless window - metrics_core(@latinfont, window, option) - end - - def kanji_metrics(option=nil) - if JAPANIZED_TK - metrics_core(@kanjifont, nil, option) - else - metrics_core_tk4x(nil, nil, option) - end - end - - def kanji_metrics_displayof(window, option=nil) - if JAPANIZED_TK - window = '.' unless window - metrics_core(@kanjifont, window, option) - else - metrics_core_tk4x(nil, window, 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 - rescue - end - self - end - - ################################### - # public 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 - - ################################### - 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 - -module TkTreatTagFont - def font_configinfo - @parent.tagfont_configinfo(@id) - end -# alias font font_configinfo - - def font_configure(slot) - @parent.tagfont_configure(@id, slot) - self - end - - def latinfont_configure(ltn, keys=nil) - @parent.latintagfont_configure(@id, ltn, keys) - self - end - alias asciifont_configure latinfont_configure - - def kanjifont_configure(knj, keys=nil) - @parent.kanjitagfont_configure(@id, ltn, keys) - self - end - - def font_copy(window, wintag=nil) - @parent.tagfont_copy(@id, window, wintag) - self - end - - def latinfont_copy(window, wintag=nil) - @parent.latintagfont_copy(@id, window, wintag) - self - end - alias asciifont_copy latinfont_copy - - def kanjifont_copy(window, wintag=nil) - @parent.kanjitagfont_copy(@id, window, wintag) - self - end -end +require 'tk/font' diff --git a/ext/tk/lib/tkmacpkg.rb b/ext/tk/lib/tkmacpkg.rb index 3bac5e6c3e..35560e78ce 100644 --- a/ext/tk/lib/tkmacpkg.rb +++ b/ext/tk/lib/tkmacpkg.rb @@ -1,56 +1,4 @@ # -# tkmacpkg.rb : methods for Tcl/Tk packages for Macintosh -# 2000/11/22 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> +# tkmacpkg.rb - load tk/macpkg.rb # -# ATTENTION !! -# This is NOT TESTED. Because I have no test-environment. -# -# -require 'tk' - -module TkMacResource - extend Tk - extend TkMacResource - - TkCommandNames = ['resource'.freeze].freeze - - tk_call('package', 'require', 'resource') - - def close(rsrcRef) - tk_call('resource', 'close', rsrcRef) - end - - def delete(rsrcType, opts=nil) - tk_call('resource', 'delete', *(hash_kv(opts) + rsrcType)) - end - - def files(rsrcRef=nil) - if rsrcRef - tk_call('resource', 'files', rsrcRef) - else - tk_split_simplelist(tk_call('resource', 'files')) - end - end - - def list(rsrcType, rsrcRef=nil) - tk_split_simplelist(tk_call('resource', 'list', rsrcType, rsrcRef)) - end - - def open(fname, access=nil) - tk_call('resource', 'open', fname, access) - end - - def read(rsrcType, rsrcID, rsrcRef=nil) - tk_call('resource', 'read', rsrcType, rsrcID, rsrcRef) - end - - def types(rsrcRef=nil) - tk_split_simplelist(tk_call('resource', 'types', rsrcRef)) - end - - def write(rsrcType, data, opts=nil) - tk_call('resource', 'write', *(hash_kv(opts) + rsrcType + data)) - end - - module_function :close, :delete, :files, :list, :open, :read, :types, :write -end +require 'tk/macpkg' diff --git a/ext/tk/lib/tkmenubar.rb b/ext/tk/lib/tkmenubar.rb index 0d29571eb7..70214fda1a 100644 --- a/ext/tk/lib/tkmenubar.rb +++ b/ext/tk/lib/tkmenubar.rb @@ -1,143 +1,4 @@ # -# tkmenubar.rb +# tkmenubar.rb - load tk/menubar.rb # -# Copyright (C) 1998 maeda shugo. All rights reserved. -# This file can be distributed under the terms of the Ruby. - -# Usage: -# -# menu_spec = [ -# [['File', 0], -# ['Open', proc{puts('Open clicked')}, 0], -# '---', -# ['Quit', proc{exit}, 0]], -# [['Edit', 0], -# ['Cut', proc{puts('Cut clicked')}, 2], -# ['Copy', proc{puts('Copy clicked')}, 0], -# ['Paste', proc{puts('Paste clicked')}, 0]] -# ] -# menubar = TkMenubar.new(nil, menu_spec, -# 'tearoff'=>false, -# 'foreground'=>'grey40', -# 'activeforeground'=>'red', -# 'font'=>'-adobe-helvetica-bold-r-*--12-*-iso8859-1') -# menubar.pack('side'=>'top', 'fill'=>'x') -# -# -# OR -# -# -# menubar = TkMenubar.new -# menubar.add_menu([['File', 0], -# ['Open', proc{puts('Open clicked')}, 0], -# '---', -# ['Quit', proc{exit}, 0]]) -# menubar.add_menu([['Edit', 0], -# ['Cut', proc{puts('Cut clicked')}, 2], -# ['Copy', proc{puts('Copy clicked')}, 0], -# ['Paste', proc{puts('Paste clicked')}, 0]]) -# menubar.configure('tearoff', false) -# menubar.configure('foreground', 'grey40') -# menubar.configure('activeforeground', 'red') -# menubar.configure('font', '-adobe-helvetica-bold-r-*--12-*-iso8859-1') -# menubar.pack('side'=>'top', 'fill'=>'x') - -# The format of the menu_spec is: -# [ -# [ -# [button text, underline, accelerator], -# [menu label, command, underline, accelerator], -# '---', # separator -# ... -# ], -# ... -# ] - -# underline and accelerator are optional parameters. -# Hashes are OK instead of Arrays. - -# To use add_menu, configuration must be done by calling configure after -# adding all menus by add_menu, not by the constructor arguments. - -require "tk" - -class TkMenubar<TkFrame - - include TkComposite - - def initialize(parent = nil, spec = nil, options = nil) - if parent.kind_of? Hash - options = _symbolkey2str(parent) - spec = options.delete('spec') - super(options) - else - super(parent, options) - end - - @menus = [] - - if spec - for menu_info in spec - add_menu(menu_info) - end - end - - if options - for key, value in options - configure(key, value) - end - end - end - - def add_menu(menu_info) - btn_info = menu_info.shift - mbtn = TkMenubutton.new(@frame) - - if btn_info.kind_of?(Hash) - for key, value in btn_info - mbtn.configure(key, value) - end - elsif btn_info.kind_of?(Array) - mbtn.configure('text', btn_info[0]) if btn_info[0] - mbtn.configure('underline', btn_info[1]) if btn_info[1] - mbtn.configure('accelerator', btn_info[2]) if btn_info[2] - else - mbtn.configure('text', btn_info) - end - - menu = TkMenu.new(mbtn) - - for item_info in menu_info - if item_info.kind_of?(Hash) - menu.add('command', item_info) - elsif item_info.kind_of?(Array) - options = {} - options['label'] = item_info[0] if item_info[0] - options['command'] = item_info[1] if item_info[1] - options['underline'] = item_info[2] if item_info[2] - options['accelerator'] = item_info[3] if item_info[3] - menu.add('command', options) - elsif /^-+$/ =~ item_info - menu.add('sep') - else - menu.add('command', 'label' => item_info) - end - end - - mbtn.menu(menu) - @menus.push([mbtn, menu]) - delegate('tearoff', menu) - delegate('foreground', mbtn, menu) - delegate('background', mbtn, menu) - delegate('disabledforeground', mbtn, menu) - delegate('activeforeground', mbtn, menu) - delegate('activebackground', mbtn, menu) - delegate('font', mbtn, menu) - delegate('kanjifont', mbtn, menu) - mbtn.pack('side' => 'left') - end - - def [](index) - return @menus[index] - end -end +require 'tk/menubar' diff --git a/ext/tk/lib/tkmngfocus.rb b/ext/tk/lib/tkmngfocus.rb index 461525009f..fe70950e8e 100644 --- a/ext/tk/lib/tkmngfocus.rb +++ b/ext/tk/lib/tkmngfocus.rb @@ -1,33 +1,4 @@ # -# tkmngfocus.rb : methods for Tcl/Tk standard library 'focus.tcl' -# by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> +# tkmngfocus.rb - load tk/mngfocus.rb # -require 'tk' - -module TkManageFocus - extend Tk - - TkCommandNames = [ - 'tk_focusFollowMouse'.freeze, - 'tk_focusNext'.freeze, - 'tk_focusPrev'.freeze - ].freeze - - def TkManageFocus.followsMouse - tk_call 'tk_focusFollowsMouse' - end - - def TkManageFocus.next(window) - tk_tcl2ruby(tk_call('tk_focusNext', window)) - end - def focusNext - TkManageFocus.next(self) - end - - def TkManageFocus.prev(window) - tk_tcl2ruby(tk_call('tk_focusPrev', window)) - end - def focusPrev - TkManageFocus.prev(self) - end -end +require 'tk/mngfocus' diff --git a/ext/tk/lib/tkpalette.rb b/ext/tk/lib/tkpalette.rb index dc2fd47e5c..56b203bbb9 100644 --- a/ext/tk/lib/tkpalette.rb +++ b/ext/tk/lib/tkpalette.rb @@ -1,54 +1,4 @@ # -# tkpalette.rb : methods for Tcl/Tk standard library 'palette.tcl' -# 1998/06/21 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> +# tkpalette.rb - load tk/palette.rb # -require 'tk' - -module TkPalette - include Tk - extend Tk - - TkCommandNames = [ - 'tk_setPalette'.freeze, - 'tk_bisque'.freeze, - 'tkDarken'.freeze - ].freeze - - def TkPalette.set(*args) - args = args.to_a.flatten if args.kind_of? Hash - tk_call 'tk_setPalette', *args - end - def TkPalette.setPalette(*args) - TkPalette.set(*args) - end - - def TkPalette.bisque - tk_call 'tk_bisque' - end - - def TkPalette.darken(color, percent) - tk_call 'tkDarken', color, percent - end - - def TkPalette.recolorTree(window, colors) - if not colors.kind_of?(Hash) - fail "2nd arg need to be Hash" - end - - colors.each{|key, value| - begin - if window.cget(key) == tk_call('set', "tkPalette(#{key})") - window[key] = colors[key] - end - rescue - # ignore - end - } - - TkWinfo.children(window).each{|w| TkPalette.recolorTree(w, colors)} - end - - def recolorTree(colors) - TkPalette.recolorTree(self, colors) - end -end +require 'tk/palette' diff --git a/ext/tk/lib/tkscrollbox.rb b/ext/tk/lib/tkscrollbox.rb index 3f1191c740..6093b2e4e7 100644 --- a/ext/tk/lib/tkscrollbox.rb +++ b/ext/tk/lib/tkscrollbox.rb @@ -1,30 +1,4 @@ # -# tkscrollbox.rb - Tk Listbox with Scrollbar -# as an example of Composite Widget -# $Date$ -# by Yukihiro Matsumoto <matz@netlab.co.jp> - -require 'tk.rb' - -class TkScrollbox<TkListbox - include TkComposite - def initialize_composite(keys=nil) - list = TkListbox.new(@frame) - scroll = TkScrollbar.new(@frame) - @path = list.path - - list.configure 'yscroll', scroll.path+" set" - list.pack 'side'=>'left','fill'=>'both','expand'=>'yes' - scroll.configure 'command', list.path+" yview" - scroll.pack 'side'=>'right','fill'=>'y' - - delegate('DEFAULT', list) - delegate('foreground', list) - delegate('background', list, scroll) - delegate('borderwidth', @frame) - delegate('relief', @frame) - - configure keys if keys - end - private :initialize_composite -end +# tkscrollbox.rb - load tk/scrollbox.rb +# +require 'tk/scrollbox' diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb index 2d37fb8c05..97ad62a3ea 100644 --- a/ext/tk/lib/tktext.rb +++ b/ext/tk/lib/tktext.rb @@ -1,1356 +1,4 @@ # -# tktext.rb - Tk text classes -# $Date$ -# by Yukihiro Matsumoto <matz@caelum.co.jp> - -require 'tk.rb' -require 'tkfont' - -module TkTreatTextTagFont - include TkTreatItemFont - - ItemCMD = ['tag'.freeze, 'configure'.freeze].freeze - def __conf_cmd(idx) - ItemCMD[idx] - end - - def __item_pathname(tagOrId) - if tagOrId.kind_of?(TkTextTag) - self.path + ';' + tagOrId.id - else - self.path + ';' + tagOrId - end - end - - private :__conf_cmd, :__item_pathname -end - -class TkText<TkTextWin - ItemConfCMD = ['tag'.freeze, 'configure'.freeze].freeze - include TkTreatTextTagFont - include Scrollable - - TkCommandNames = ['text'.freeze].freeze - WidgetClassName = 'Text'.freeze - WidgetClassNames[WidgetClassName] = self - - def self.new(*args, &block) - obj = super(*args){} - obj.init_instance_variable - obj.instance_eval(&block) if defined? yield - obj - end - - def init_instance_variable - @cmdtbl = [] - @tags = {} - end - - def __destroy_hook__ - TTagID_TBL.delete(@path) - TMarkID_TBL.delete(@path) - end - - def create_self(keys) - if keys and keys != None - tk_call 'text', @path, *hash_kv(keys) - else - tk_call 'text', @path - end - init_instance_variable - end - private :create_self - - def index(index) - tk_send 'index', index - end - - def value - tk_send 'get', "1.0", "end - 1 char" - end - - def value= (val) - tk_send 'delete', "1.0", 'end' - tk_send 'insert', "1.0", val - end - - def _addcmd(cmd) - @cmdtbl.push cmd - end - - def _addtag(name, obj) - @tags[name] = obj - end - - def tagid2obj(tagid) - if @tags[tagid] - @tags[tagid] - else - tagid - end - end - - def tag_names(index=None) - tk_split_simplelist(tk_send('tag', 'names', index)).collect{|elt| - tagid2obj(elt) - } - end - - def mark_names - tk_split_simplelist(tk_send('mark', 'names')).collect{|elt| - tagid2obj(elt) - } - end - - def mark_gravity(mark, direction=nil) - if direction - tk_send 'mark', 'gravity', mark, direction - self - else - tk_send 'mark', 'gravity', mark - end - end - - def mark_set(mark, index) - tk_send 'mark', 'set', mark, index - self - end - alias set_mark mark_set - - def mark_unset(*marks) - tk_send 'mark', 'unset', *marks - self - end - alias unset_mark mark_unset - - def mark_next(index) - tagid2obj(tk_send('mark', 'next', index)) - end - alias next_mark mark_next - - def mark_previous(index) - tagid2obj(tk_send('mark', 'previous', index)) - end - alias previous_mark mark_previous - - def image_cget(index, slot) - case slot.to_s - when 'text', 'label', 'show', 'data', 'file' - tk_send('image', 'cget', index, "-#{slot}") - else - tk_tcl2ruby(tk_send('image', 'cget', index, "-#{slot}")) - end - end - - def image_configure(index, slot, value=None) - if slot.kind_of? Hash - tk_send('image', 'configure', index, *hash_kv(slot)) - else - tk_send('image', 'configure', index, "-#{slot}", value) - end - self - end - - def image_configinfo(index, slot = nil) - if slot - case slot.to_s - when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(tk_send('image', 'configure', - index, "-#{slot}")) - else - conf = tk_split_list(tk_send('image', 'configure', - index, "-#{slot}")) - end - conf[0] = conf[0][1..-1] - conf - else - tk_split_simplelist(tk_send('image', 'configure', - index)).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] - when 'text', 'label', 'show', 'data', 'file' - 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 - } - end - end - - def image_names - tk_split_simplelist(tk_send('image', 'names')).collect{|elt| - tagid2obj(elt) - } - end - - def set_insert(index) - tk_send 'mark', 'set', 'insert', index - self - end - - def set_current(index) - tk_send 'mark', 'set', 'current', index - self - end - - def insert(index, chars, *tags) - if tags[0].kind_of? Array - # multiple chars-taglist argument - args = [chars] - while tags.size > 0 - tags.shift.collect{|x|_get_eval_string(x)}.join(' ') # taglist - args << tags.shift if tags.size > 0 # chars - end - super index, *args - else - # single chars-taglist argument - super index, chars, tags.collect{|x|_get_eval_string(x)}.join(' ') - end - end - - def destroy - @tags = {} unless @tags - @tags.each_value do |t| - t.destroy - end - super - end - - def backspace - self.delete 'insert' - end - - def compare(idx1, op, idx2) - bool(tk_send('compare', idx1, op, idx2)) - end - - def debug - bool(tk_send('debug')) - end - def debug=(boolean) - tk_send 'debug', boolean - self - end - def bbox(index) - list(tk_send('bbox', index)) - end - - def dlineinfo(index) - list(tk_send('dlineinfo', index)) - end - - def modified? - bool(tk_send('edit', 'modified')) - end - def modified(mode) - tk_send('edit', 'modified', mode) - self - end - def edit_redo - tk_send('edit', 'redo') - self - end - def edit_reset - tk_send('edit', 'reset') - self - end - def edit_separator - tk_send('edit', 'separator') - self - end - def edit_undo - tk_send('edit', 'undo') - self - end - - def yview_pickplace(*what) - tk_send 'yview', '-pickplace', *what - self - end - - def xview_pickplace(*what) - tk_send 'xview', '-pickplace', *what - self - end - - def text_copy - # Tk8.4 feature - tk_call('tk_textCopy', @path) - end - - def text_cut - # Tk8.4 feature - tk_call('tk_textCut', @path) - end - - def text_paste - # Tk8.4 feature - tk_call('tk_textPaste', @path) - end - - def tag_add(tag, index1, index2=None) - tk_send 'tag', 'add', tag, index1, index2 - self - end - alias addtag tag_add - alias add_tag tag_add - - def tag_delete(*tags) - tk_send 'tag', 'delete', *tags - if TkTextTag::TTagID_TBL[@path] - tags.each{|tag| - if tag.kind_of? TkTextTag - TTagID_TBL[@path].delete(tag.id) - else - TTagID_TBL[@path].delete(tag) - end - } - end - self - end - alias deltag tag_delete - alias delete_tag tag_delete - - def tag_bind(tag, seq, cmd=Proc.new, args=nil) - _bind([@path, 'tag', 'bind', tag], seq, cmd, args) - self - end - - def tag_bind_append(tag, seq, cmd=Proc.new, args=nil) - _bind_append([@path, 'tag', 'bind', tag], seq, cmd, args) - self - end - - def tag_bind_remove(tag, seq) - _bind_remove([@path, 'tag', 'bind', tag], seq) - self - end - - def tag_bindinfo(tag, context=nil) - _bindinfo([@path, 'tag', 'bind', tag], context) - end - - def tag_cget(tag, key) - case key.to_s - when 'text', 'label', 'show', 'data', 'file' - tk_call(@path, 'tag', 'cget', tag, "-#{key}") - when 'font', 'kanjifont' - #fnt = tk_tcl2ruby(tk_send('tag', 'cget', tag, "-#{key}")) - fnt = tk_tcl2ruby(tk_send('tag', 'cget', tag, '-font')) - unless fnt.kind_of?(TkFont) - fnt = tagfontobj(tag, fnt) - end - if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font - else - fnt - end - else - tk_tcl2ruby(tk_call(@path, 'tag', 'cget', tag, "-#{key}")) - end - end - - def tag_configure(tag, key, val=None) - if key.kind_of? Hash - key = _symbolkey2str(key) - if ( key['font'] || key['kanjifont'] \ - || key['latinfont'] || key['asciifont'] ) - tagfont_configure(tag, key) - else - tk_send 'tag', 'configure', tag, *hash_kv(key) - end - - else - if key == 'font' || key == :font || - key == 'kanjifont' || key == :kanjifont || - key == 'latinfont' || key == :latinfont || - key == 'asciifont' || key == :asciifont - if val == None - tagfontobj(tag) - else - tagfont_configure(tag, {key=>val}) - end - else - tk_send 'tag', 'configure', tag, "-#{key}", val - end - end - self - end - - def tag_configinfo(tag, key=nil) - if key - case key.to_s - when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(tk_send('tag','configure',tag,"-#{key}")) - when 'font', 'kanjifont' - conf = tk_split_simplelist(tk_send('tag','configure',tag,"-#{key}") ) - conf[4] = tagfont_configinfo(tag, conf[4]) - else - conf = tk_split_list(tk_send('tag','configure',tag,"-#{key}")) - end - conf[0] = conf[0][1..-1] - conf - else - ret = tk_split_simplelist(tk_send('tag', 'configure', - tag)).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] - when 'text', 'label', 'show', 'data', 'file' - 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 - } - fontconf = ret.assoc('font') - if fontconf - ret.delete_if{|item| item[0] == 'font' || item[0] == 'kanjifont'} - fontconf[4] = tagfont_configinfo(tag, fontconf[4]) - ret.push(fontconf) - else - ret - end - end - end - - def tag_raise(tag, above=None) - tk_send 'tag', 'raise', tag, above - self - end - - def tag_lower(tag, below=None) - tk_send 'tag', 'lower', tag, below - self - end - - def tag_remove(tag, *index) - tk_send 'tag', 'remove', tag, *index - self - end - - def tag_ranges(tag) - l = tk_split_simplelist(tk_send('tag', 'ranges', tag)) - r = [] - while key=l.shift - r.push [key, l.shift] - end - r - end - - def tag_nextrange(tag, first, last=None) - tk_split_list(tk_send('tag', 'nextrange', tag, first, last)) - end - - def tag_prevrange(tag, first, last=None) - tk_split_list(tk_send('tag', 'prevrange', tag, first, last)) - end - - def window_cget(index, slot) - case slot.to_s - when 'text', 'label', 'show', 'data', 'file' - tk_send('window', 'cget', index, "-#{slot}") - when 'font', 'kanjifont' - #fnt = tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}")) - fnt = tk_tcl2ruby(tk_send('window', 'cget', index, '-font')) - unless fnt.kind_of?(TkFont) - fnt = tagfontobj(index, fnt) - end - if slot.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font - else - fnt - end - else - tk_tcl2ruby(tk_send('window', 'cget', index, "-#{slot}")) - end - end - - def window_configure(index, slot, value=None) - if index.kind_of? TkTextWindow - index.configure(slot, value) - else - if slot.kind_of? Hash - slot = _symbolkey2str(slot) - win = slot['window'] - slot['window'] = win.epath if win.kind_of?(TkWindow) - if slot['create'] - p_create = slot['create'] - if p_create.kind_of? Proc - slot['create'] = install_cmd(proc{ - id = p_create.call - if id.kind_of?(TkWindow) - id.epath - else - id - end - }) - end - end - tk_send('window', 'configure', index, *hash_kv(slot)) - else - if slot == 'window' || slot == :window - id = value - value = id.epath if id.kind_of?(TkWindow) - end - if slot == 'create' || slot == :create - p_create = value - if p_create.kind_of? Proc - value = install_cmd(proc{ - id = p_create.call - if id.kind_of?(TkWindow) - id.epath - else - id - end - }) - end - end - tk_send('window', 'configure', index, "-#{slot}", value) - end - end - self - end - - def window_configinfo(win, slot = nil) - if slot - case slot.to_s - when 'text', 'label', 'show', 'data', 'file' - conf = tk_split_simplelist(tk_send('window', 'configure', - win, "-#{slot}")) - else - conf = tk_split_list(tk_send('window', 'configure', - win, "-#{slot}")) - end - conf[0] = conf[0][1..-1] - conf - else - tk_split_simplelist(tk_send('window', 'configure', - win)).collect{|conflist| - conf = tk_split_simplelist(conflist) - conf[0] = conf[0][1..-1] - case conf[0] - when 'text', 'label', 'show', 'data', 'file' - 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 - } - end - end - - def window_names - tk_split_simplelist(tk_send('window', 'names')).collect{|elt| - tagid2obj(elt) - } - end - - def _ktext_length(txt) - if $KCODE !~ /n/i - return txt.gsub(/[^\Wa-zA-Z_\d]/, ' ').length - end - - # $KCODE == 'NONE' - if JAPANIZED_TK - tk_call('kstring', 'length', txt).to_i - else - begin - tk_call('encoding', 'convertto', 'ascii', txt).length - rescue StandardError, NameError - # sorry, I have no plan - txt.length - end - end - end - private :_ktext_length - - def search_with_length(pat,start,stop=None) - pat = pat.chr if pat.kind_of? Integer - if stop != None - return ["", 0] if compare(start,'>=',stop) - txt = get(start,stop) - if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(start + " + #{pos} chars"), pat.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index(start + " + #{pos} chars"), $&.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(match), match] - end - else - return ["", 0] - end - else - txt = get(start,'end - 1 char') - if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(start + " + #{pos} chars"), pat.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index(start + " + #{pos} chars"), $&.split('').length] - return [index(start + " + #{pos} chars"), - _ktext_length(match), match] - end - else - txt = get('1.0','end - 1 char') - if (pos = txt.index(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), - _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end - else - return ["", 0] - end - end - end - end - - def search(pat,start,stop=None) - search_with_length(pat,start,stop)[0] - end - - def rsearch_with_length(pat,start,stop=None) - pat = pat.chr if pat.kind_of? Integer - if stop != None - return ["", 0] if compare(start,'<=',stop) - txt = get(stop,start) - if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index(stop + " + #{pos} chars"), pat.split('').length] - return [index(stop + " + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index(stop + " + #{pos} chars"), $&.split('').length] - return [index(stop + " + #{pos} chars"), _ktext_length(match), match] - end - else - return ["", 0] - end - else - txt = get('1.0',start) - if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end - else - txt = get('1.0','end - 1 char') - if (pos = txt.rindex(pat)) - match = $& - #pos = txt[0..(pos-1)].split('').length if pos > 0 - pos = _ktext_length(txt[0..(pos-1)]) if pos > 0 - if pat.kind_of? String - #return [index("1.0 + #{pos} chars"), pat.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(pat), pat.dup] - else - #return [index("1.0 + #{pos} chars"), $&.split('').length] - return [index("1.0 + #{pos} chars"), _ktext_length(match), match] - end - else - return ["", 0] - end - end - end - end - - def rsearch(pat,start,stop=None) - rsearch_with_length(pat,start,stop)[0] - end - - def dump(type_info, *index, &block) - args = type_info.collect{|inf| '-' + inf} - args << '-command' << block if block - str = tk_send('dump', *(args + index)) - result = [] - sel = nil - i = 0 - while i < str.size - # retrieve key - idx = str.index(/ /, i) - result.push str[i..(idx-1)] - i = idx + 1 - - # retrieve value - case result[-1] - when 'text' - if str[i] == ?{ - # text formed as {...} - val, i = _retrieve_braced_text(str, i) - result.push val - else - # text which may contain backslahes - val, i = _retrieve_backslashed_text(str, i) - result.push val - end - else - idx = str.index(/ /, i) - val = str[i..(idx-1)] - case result[-1] - when 'mark' - case val - when 'insert' - result.push TkTextMarkInsert.new(self) - when 'current' - result.push TkTextMarkCurrent.new(self) - when 'anchor' - result.push TkTextMarkAnchor.new(self) - else - result.push tk_tcl2ruby(val) - end - when 'tagon' - if val == 'sel' - if sel - result.push sel - else - result.push TkTextTagSel.new(self) - end - else - result.push tk_tcl2ruby(val) - end - when 'tagoff' - result.push tk_tcl2ruby(val) - when 'window' - result.push tk_tcl2ruby(val) - end - i = idx + 1 - end - - # retrieve index - idx = str.index(/ /, i) - if idx - result.push str[i..(idx-1)] - i = idx + 1 - else - result.push str[i..-1] - break - end - end - - kvis = [] - until result.empty? - kvis.push [result.shift, result.shift, result.shift] - end - kvis # result is [[key1, value1, index1], [key2, value2, index2], ...] - end - - def _retrieve_braced_text(str, i) - cnt = 0 - idx = i - while idx < str.size - case str[idx] - when ?{ - cnt += 1 - when ?} - cnt -= 1 - if cnt == 0 - break - end - end - idx += 1 - end - return str[i+1..idx-1], idx + 2 - end - private :_retrieve_braced_text - - def _retrieve_backslashed_text(str, i) - j = i - idx = nil - loop { - idx = str.index(/ /, j) - if str[idx-1] == ?\\ - j += 1 - else - break - end - } - val = str[i..(idx-1)] - val.gsub!(/\\( |\{|\})/, '\1') - return val, idx + 1 - end - private :_retrieve_backslashed_text - - def dump_all(*index, &block) - dump(['all'], *index, &block) - end - def dump_mark(*index, &block) - dump(['mark'], *index, &block) - end - def dump_tag(*index, &block) - dump(['tag'], *index, &block) - end - def dump_text(*index, &block) - dump(['text'], *index, &block) - end - def dump_window(*index, &block) - dump(['window'], *index, &block) - end - def dump_image(*index, &block) - dump(['image'], *index, &block) - end -end - -class TkTextTag<TkObject - include TkTreatTagFont - - TTagID_TBL = TkCore::INTERP.create_table - Tk_TextTag_ID = ['tag'.freeze, '00000'.taint].freeze - - TkCore::INTERP.init_ip_env{ TTagID_TBL.clear } - - def TkTextTag.id2obj(text, id) - tpath = text.path - return id unless TTagID_TBL[tpath] - TTagID_TBL[tpath][id]? TTagID_TBL[tpath][id]: id - end - - def initialize(parent, *args) - if not parent.kind_of?(TkText) - fail Kernel.format("%s need to be TkText", parent.inspect) - end - @parent = @t = parent - @tpath = parent.path - @path = @id = Tk_TextTag_ID.join - TTagID_TBL[@id] = self - TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath] - TTagID_TBL[@tpath][@id] = self - Tk_TextTag_ID[1].succ! - #tk_call @t.path, "tag", "configure", @id, *hash_kv(keys) - if args != [] then - keys = args.pop - if keys.kind_of? Hash then - add(*args) if args != [] - configure(keys) - else - args.push keys - add(*args) - end - end - @t._addtag id, self - end - - def id - @id - end - - def first - @id + '.first' - end - - def last - @id + '.last' - end - - def add(*index) - tk_call @t.path, 'tag', 'add', @id, *index - self - end - - def remove(*index) - tk_call @t.path, 'tag', 'remove', @id, *index - self - end - - def ranges - l = tk_split_simplelist(tk_call(@t.path, 'tag', 'ranges', @id)) - r = [] - while key=l.shift - r.push [key, l.shift] - end - r - end - - def nextrange(first, last=None) - tk_split_list(tk_call(@t.path, 'tag', 'nextrange', @id, first, last)) - end - - def prevrange(first, last=None) - tk_split_list(tk_call(@t.path, 'tag', 'prevrange', @id, first, last)) - end - - def [](key) - cget key - end - - def []=(key,val) - configure key, val - end - - def cget(key) - case key.to_s - when 'text', 'label', 'show', 'data', 'file' - tk_call @t.path, 'tag', 'cget', @id, "-#{key}" - when 'font', 'kanjifont' - #fnt = tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, "-#{key}")) - fnt = tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, '-font')) - unless fnt.kind_of?(TkFont) - fnt = tagfontobj(@id, fnt) - end - if key.to_s == 'kanjifont' && JAPANIZED_TK && TK_VERSION =~ /^4\.*/ - # obsolete; just for compatibility - fnt.kanji_font - else - fnt - end - else - tk_tcl2ruby(tk_call(@t.path, 'tag', 'cget', @id, "-#{key}")) - end - end - - def configure(key, val=None) - @t.tag_configure @id, key, val - end -# def configure(key, val=None) -# if key.kind_of? Hash -# tk_call @t.path, 'tag', 'configure', @id, *hash_kv(key) -# else -# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", val -# end -# end -# def configure(key, value) -# if value == FALSE -# value = "0" -# elsif value.kind_of? Proc -# value = install_cmd(value) -# end -# tk_call @t.path, 'tag', 'configure', @id, "-#{key}", value -# end - - def configinfo(key=nil) - @t.tag_configinfo @id, key - end - - def bind(seq, cmd=Proc.new, args=nil) - _bind([@t.path, 'tag', 'bind', @id], seq, cmd, args) - self - end - - def bind_append(seq, cmd=Proc.new, args=nil) - _bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args) - self - end - - def bind_remove(seq) - _bind_remove([@t.path, 'tag', 'bind', @id], seq) - self - end - - def bindinfo(context=nil) - _bindinfo([@t.path, 'tag', 'bind', @id], context) - end - - def raise(above=None) - tk_call @t.path, 'tag', 'raise', @id, above - self - end - - def lower(below=None) - tk_call @t.path, 'tag', 'lower', @id, below - self - end - - def destroy - tk_call @t.path, 'tag', 'delete', @id - TTagID_TBL[@tpath].delete(@id) if TTagID_TBL[@tpath] - self - end -end - -class TkTextNamedTag<TkTextTag - def self.new(parent, name, *args) - if TTagID_TBL[parent.path] && TTagID_TBL[parent.path][name] - tagobj = TTagID_TBL[parent.path][name] - if args != [] then - keys = args.pop - if keys.kind_of? Hash then - tagobj.add(*args) if args != [] - tagobj.configure(keys) - else - args.push keys - tagobj.add(*args) - end - end - return tagobj - else - super(parent, name, *args) - end - end - - def initialize(parent, name, *args) - if not parent.kind_of?(TkText) - fail Kernel.format("%s need to be TkText", parent.inspect) - end - @parent = @t = parent - @tpath = parent.path - @path = @id = name - TTagID_TBL[@tpath] = {} unless TTagID_TBL[@tpath] - TTagID_TBL[@tpath][@id] = self unless TTagID_TBL[@tpath][@id] - #if mode - # tk_call @t.path, "addtag", @id, *args - #end - if args != [] then - keys = args.pop - if keys.kind_of? Hash then - add(*args) if args != [] - configure(keys) - else - args.push keys - add(*args) - end - end - @t._addtag id, self - end -end - -class TkTextTagSel<TkTextNamedTag - def self.new(parent, *args) - super(parent, 'sel', *args) - end -end - -class TkTextMark<TkObject - TMarkID_TBL = TkCore::INTERP.create_table - Tk_TextMark_ID = ['mark'.freeze, '00000'.taint].freeze - - TkCore::INTERP.init_ip_env{ TMarkID_TBL.clear } - - def TkTextMark.id2obj(text, id) - tpath = text.path - return id unless TMarkID_TBL[tpath] - TMarkID_TBL[tpath][id]? TMarkID_TBL[tpath][id]: id - end - - def initialize(parent, index) - if not parent.kind_of?(TkText) - fail Kernel.format("%s need to be TkText", parent.inspect) - end - @parent = @t = parent - @tpath = parent.path - @path = @id = Tk_TextMark_ID.join - TMarkID_TBL[@id] = self - TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath] - TMarkID_TBL[@tpath][@id] = self - Tk_TextMark_ID[1].succ! - tk_call @t.path, 'mark', 'set', @id, index - @t._addtag id, self - end - - def id - @id - end - - def +(mod) - @id + ' + ' + mod - end - def -(mod) - @id + ' - ' + mod - end - - def set(where) - tk_call @t.path, 'mark', 'set', @id, where - self - end - - def unset - tk_call @t.path, 'mark', 'unset', @id - self - end - alias destroy unset - - def gravity - tk_call @t.path, 'mark', 'gravity', @id - end - - def gravity=(direction) - tk_call @t.path, 'mark', 'gravity', @id, direction - self - end - - def next(index = nil) - if index - @t.tagid2obj(tk_call(@t.path, 'mark', 'next', index)) - else - @t.tagid2obj(tk_call(@t.path, 'mark', 'next', @id)) - end - end - - def previous(index = nil) - if index - @t.tagid2obj(tk_call(@t.path, 'mark', 'previous', index)) - else - @t.tagid2obj(tk_call(@t.path, 'mark', 'previous', @id)) - end - end -end - -class TkTextNamedMark<TkTextMark - def self.new(parent, name, *args) - if TMarkID_TBL[parent.path] && TMarkID_TBL[parent.path][name] - return TMarkID_TBL[parent.path][name] - else - super(parent, name, *args) - end - end - - def initialize(parent, name, index=nil) - if not parent.kind_of?(TkText) - fail Kernel.format("%s need to be TkText", parent.inspect) - end - @parent = @t = parent - @tpath = parent.path - @path = @id = name - TMarkID_TBL[@id] = self - TMarkID_TBL[@tpath] = {} unless TMarkID_TBL[@tpath] - TMarkID_TBL[@tpath][@id] = self unless TMarkID_TBL[@tpath][@id] - tk_call @t.path, 'mark', 'set', @id, index if index - @t._addtag id, self - end -end - -class TkTextMarkInsert<TkTextNamedMark - def self.new(parent,*args) - super(parent, 'insert', *args) - end -end - -class TkTextMarkCurrent<TkTextMark - def self.new(parent,*args) - super(parent, 'current', *args) - end -end - -class TkTextMarkAnchor<TkTextMark - def self.new(parent,*args) - super(parent, 'anchor', *args) - end -end - -class TkTextWindow<TkObject - def initialize(parent, index, keys) - if not parent.kind_of?(TkText) - fail Kernel.format("%s need to be TkText", parent.inspect) - end - @t = parent - if index == 'end' - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) - elsif index.kind_of? TkTextMark - if tk_call(@t.path,'index',index.path) == tk_call(@t.path,'index','end') - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) - else - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index.path)) - end - else - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index)) - end - @path.gravity = 'left' - @index = @path.path - keys = _symbolkey2str(keys) - @id = keys['window'] - keys['window'] = @id.epath if @id.kind_of?(TkWindow) - if keys['create'] - @p_create = keys['create'] - if @p_create.kind_of? Proc - keys['create'] = install_cmd(proc{ - @id = @p_create.call - if @id.kind_of?(TkWindow) - @id.epath - else - @id - end - }) - end - end - tk_call @t.path, 'window', 'create', @index, *hash_kv(keys) - end - - def [](slot) - cget(slot) - end - def []=(slot, value) - configure(slot, value) - end - - def cget(slot) - @t.window_cget(@index, slot) - end - - def configure(slot, value=None) - if slot.kind_of? Hash - slot = _symbolkey2str(slot) - if slot['window'] - @id = slot['window'] - slot['window'] = @id.epath if @id.kind_of?(TkWindow) - end - if slot['create'] - self.create=slot.delete('create') - end - if slot.size > 0 - tk_call(@t.path, 'window', 'configure', @index, *hash_kv(slot)) - end - else - if slot == 'window' || slot == :window - @id = value - value = @id.epath if @id.kind_of?(TkWindow) - end - if slot == 'create' || slot == :create - self.create=value - else - tk_call(@t.path, 'window', 'configure', @index, "-#{slot}", value) - end - end - self - end - - def configinfo(slot = nil) - @t.window_configinfo(@index, slot) - end - - def window - @id - end - - def window=(value) - @id = value - value = @id.epath if @id.kind_of?(TkWindow) - tk_call @t.path, 'window', 'configure', @index, '-window', value - end - - def create - @p_create - end - - def create=(value) - @p_create = value - if @p_create.kind_of? Proc - value = install_cmd(proc{ - @id = @p_create.call - if @id.kind_of?(TkWindow) - @id.epath - else - @id - end - }) - end - tk_call @t.path, 'window', 'configure', @index, '-create', value - end -end - -class TkTextImage<TkObject - def initialize(parent, index, keys) - if not parent.kind_of?(TkText) - fail Kernel.format("%s need to be TkText", parent.inspect) - end - @t = parent - if index == 'end' - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) - elsif index.kind_of? TkTextMark - if tk_call(@t.path,'index',index.path) == tk_call(@t.path,'index','end') - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', 'end - 1 chars')) - else - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index.path)) - end - else - @path = TkTextMark.new(@t, tk_call(@t.path, 'index', index)) - end - @path.gravity = 'left' - @index = @path.path - @id = tk_call(@t.path, 'image', 'create', @index, *hash_kv(keys)) - end - - def [](slot) - cget(slot) - end - def []=(slot, value) - configure(slot, value) - end - - def cget(slot) - @t.image_cget(@index, slot) - end - - def configure(slot, value=None) - @t.image_configure(@index, slot, value) - self - end -# def configure(slot, value) -# tk_call @t.path, 'image', 'configure', @index, "-#{slot}", value -# end - - def configinfo(slot = nil) - @t.image_configinfo(@index, slot) - end - - def image - img = tk_call(@t.path, 'image', 'configure', @index, '-image') - TkImage::Tk_IMGTBL[img]? TkImage::Tk_IMGTBL[img] : img - end - - def image=(value) - tk_call @t.path, 'image', 'configure', @index, '-image', value - self - end -end +# tktext.rb - load tk/text.rb +# +require 'tk/text' diff --git a/ext/tk/lib/tkvirtevent.rb b/ext/tk/lib/tkvirtevent.rb index ccd3448434..f4fae19a0a 100644 --- a/ext/tk/lib/tkvirtevent.rb +++ b/ext/tk/lib/tkvirtevent.rb @@ -1,85 +1,4 @@ # -# tkvirtevent.rb : treats virtual events -# 1998/07/16 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> +# tkvirtevent.rb - load tk/virtevent.rb # -require 'tk' - -class TkVirtualEvent<TkObject - extend Tk - - TkCommandNames = ['event'.freeze].freeze - - TkVirtualEventID = ["<VirtEvent".freeze, "00000".taint, ">".freeze].freeze - TkVirtualEventTBL = TkCore::INTERP.create_table - - TkCore::INTERP.init_ip_env{ TkVirtualEventTBL.clear } - - class PreDefVirtEvent<self - def initialize(event) - @path = @id = event - TkVirtualEvent::TkVirtualEventTBL[@id] = self - end - end - - def TkVirtualEvent.getobj(event) - obj = TkVirtualEventTBL[event] - if obj - obj - else - if tk_call('event', 'info').index("<#{event}>") - PreDefVirtEvent.new(event) - else - fail ArgumentError, "undefined virtual event '<#{event}>'" - end - end - end - - def TkVirtualEvent.info - tk_call('event', 'info').split(/\s+/).collect!{|seq| - TkVirtualEvent.getobj(seq[1..-2]) - } - end - - def initialize(*sequences) - @path = @id = TkVirtualEventID.join - TkVirtualEventID[1].succ! - add(*sequences) - end - - def add(*sequences) - if sequences != [] - tk_call('event', 'add', "<#{@id}>", - *(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) ) - TkVirtualEventTBL[@id] = self - end - self - end - - def delete(*sequences) - if sequences == [] - tk_call('event', 'delete', "<#{@id}>") - TkVirtualEventTBL.delete(@id) - else - tk_call('event', 'delete', "<#{@id}>", - *(sequences.collect{|seq| "<#{tk_event_sequence(seq)}>"}) ) - TkVirtualEventTBL.delete(@id) if info == [] - end - self - end - - def info - tk_call('event', 'info', "<#{@id}>").split(/\s+/).collect!{|seq| - l = seq.scan(/<*[^<>]+>*/).collect!{|subseq| - case (subseq) - when /^<<[^<>]+>>$/ - TkVirtualEvent.getobj(subseq[1..-2]) - when /^<[^<>]+>$/ - subseq[1..-2] - else - subseq.split('') - end - }.flatten - (l.size == 1) ? l[0] : l - } - end -end +require 'tk/virtevent' diff --git a/ext/tk/lib/tkwinpkg.rb b/ext/tk/lib/tkwinpkg.rb index 7762b3a596..83371c546d 100644 --- a/ext/tk/lib/tkwinpkg.rb +++ b/ext/tk/lib/tkwinpkg.rb @@ -1,84 +1,4 @@ # -# tkwinpkg.rb : methods for Tcl/Tk packages for Microsoft Windows -# 2000/11/22 by Hidetoshi Nagai <nagai@ai.kyutech.ac.jp> +# tkwinpkg.rb - load tk/winpkg.rb # -# ATTENTION !! -# This is NOT TESTED. Because I have no test-environment. -# -# -require 'tk' - -module TkWinDDE - extend Tk - extend TkWinDDE - - TkCommandNames = ['dde'.freeze].freeze - - tk_call('package', 'require', 'dde') - - def servername(topic=nil) - tk_call('dde', 'servername', topic) - end - - def execute(service, topic, data) - tk_call('dde', 'execute', service, topic, data) - end - - def async_execute(service, topic, data) - tk_call('dde', '-async', 'execute', service, topic, data) - end - - def poke(service, topic, item, data) - tk_call('dde', 'poke', service, topic, item, data) - end - - def request(service, topic, item) - tk_call('dde', 'request', service, topic, item) - end - - def services(service, topic) - tk_call('dde', 'services', service, topic) - end - - def eval(topic, cmd, *args) - tk_call('dde', 'eval', topic, cmd, *args) - end - - module_function :servername, :execute, :async_execute, - :poke, :request, :services, :eval -end - -module TkWinRegistry - extend Tk - extend TkWinRegistry - - TkCommandNames = ['registry'.freeze].freeze - - tk_call('package', 'require', 'registry') - - def delete(keynam, valnam=nil) - tk_call('registry', 'delete', keynam, valnam) - end - - def get(keynam, valnam) - tk_call('registry', 'get', keynam, valnam) - end - - def keys(keynam) - tk_split_simplelist(tk_call('registry', 'keys', keynam)) - end - - def set(keynam, valnam=nil, data=nil, dattype=nil) - tk_call('registry', 'set', keynam, valnam, data, dattype) - end - - def type(keynam, valnam) - tk_call('registry', 'type', keynam, valnam) - end - - def values(keynam) - tk_split_simplelist(tk_call('registry', 'values', keynam)) - end - - module_function :delete, :get, :keys, :set, :type, :values -end +require 'tk/winpkg' diff --git a/ext/tk/sample/demos-en/README.tkencoding b/ext/tk/sample/demos-en/README.tkencoding index 8fcb494c03..f576bc593e 100644 --- a/ext/tk/sample/demos-en/README.tkencoding +++ b/ext/tk/sample/demos-en/README.tkencoding @@ -1,3 +1,8 @@ +This is a original document of 'tkencoding.rb'. +The library 'tkencoding.rb' is obsolete. +Functions of tkencoding.rb is already included into Ruby/Tk. + +------------------------------------------------- tkencoding.rbを用いた日本語の表示について Copyright (C) 1999/07, Takaaki Tateishi <ttate@jaist.ac.jp> diff --git a/ext/tk/sample/demos-en/arrow.rb b/ext/tk/sample/demos-en/arrow.rb index 8ee13254ea..3f07b8e660 100644 --- a/ext/tk/sample/demos-en/arrow.rb +++ b/ext/tk/sample/demos-en/arrow.rb @@ -150,7 +150,7 @@ if TkWinfo.depth($arrow_canvas) > 1 $demo_arrowInfo.activeStyle = {'fill'=>'red', 'outline'=>'black', 'width'=>1} else $demo_arrowInfo.bigLineStyle = {'fill'=>'black', - 'stipple'=>'@'+[$demo_dir, 'images', 'grey.25'].join(File::Separator)} + 'stipple'=>'@'+[$demo_dir,'..','images','grey.25'].join(File::Separator)} $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1} $demo_arrowInfo.activeStyle = {'fill'=>'black','outline'=>'black','width'=>1} end diff --git a/ext/tk/sample/demos-en/bind.rb b/ext/tk/sample/demos-en/bind.rb index 5d30d228f0..ab2a32de82 100644 --- a/ext/tk/sample/demos-en/bind.rb +++ b/ext/tk/sample/demos-en/bind.rb @@ -67,7 +67,7 @@ TkText.new($bind_demo){|t| tagstyle_normal = {'foreground'=>'', 'background'=>''} end - # テキスト挿入 + # insert text insert 'insert', "The same tag mechanism that controls display styles in text widgets can also be used to associate Tcl commands with regions of text, so that mouse or keyboard actions on the text cause particular Tcl commands to be invoked. For example, in the text below the descriptions of the canvas demonstrations have been tagged. When you move the mouse over a demo description the description lights up, and when you press button 1 over a description then that particular demonstration is invoked. " diff --git a/ext/tk/sample/demos-en/browse2 b/ext/tk/sample/demos-en/browse2 index 304a5f547e..edad04dbcb 100644 --- a/ext/tk/sample/demos-en/browse2 +++ b/ext/tk/sample/demos-en/browse2 @@ -39,11 +39,11 @@ class Browse } # Set up bindings for the browser. - base.bind('Control-c', - proc{ - base.destroy + base.bind('Destroy', proc{ Browse::BROWSE_WIN_COUNTER.value = \ - Browse::BROWSE_WIN_COUNTER.to_i - 1}) + Browse::BROWSE_WIN_COUNTER.to_i - 1 + }) + base.bind('Control-c', proc{base.destroy}) list.bind('Double-Button-1', proc{TkSelection.get.each{|f| self.browse dir, f}}) end diff --git a/ext/tk/sample/demos-en/cscroll.rb b/ext/tk/sample/demos-en/cscroll.rb index 2f2be60da2..8250c6e5e6 100644 --- a/ext/tk/sample/demos-en/cscroll.rb +++ b/ext/tk/sample/demos-en/cscroll.rb @@ -52,7 +52,7 @@ unless $tk_version =~ /^4\.[01]/ TkGrid.columnconfigure($cscroll_grid, 0, 'weight'=>1, 'minsize'=>0) end -# canvas 設定 +# canvas $cscroll_canvas = TkCanvas.new($cscroll_demo, 'relief'=>'sunken', 'borderwidth'=>2, 'scrollregion'=>['-11c', '-11c', '50c', '20c'] diff --git a/ext/tk/sample/demos-en/dialog1.rb b/ext/tk/sample/demos-en/dialog1.rb index 374fedc985..af476ecd05 100644 --- a/ext/tk/sample/demos-en/dialog1.rb +++ b/ext/tk/sample/demos-en/dialog1.rb @@ -22,7 +22,7 @@ class TkDialog_Demo1 < TkDialog end def buttons - ["Dismiss", "", "Show Code"] + # ["Dismiss", "", "Show Code"] ["OK", "Cancel", "Show Code"] end end diff --git a/ext/tk/sample/demos-en/entry3.rb b/ext/tk/sample/demos-en/entry3.rb index 44f788225c..3ec162e482 100644 --- a/ext/tk/sample/demos-en/entry3.rb +++ b/ext/tk/sample/demos-en/entry3.rb @@ -158,6 +158,8 @@ def validatePhoneChange(widget, vmode, idx, char) widget.insert(idx, $phoneNumberMap[char] || char) Tk.after_idle(proc{phoneSkipRight(widget, -1)}) return true + # Tk.update(true) # Don't work 'update' inter validation callback. + # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1). end return false end diff --git a/ext/tk/sample/demos-en/icon.rb b/ext/tk/sample/demos-en/icon.rb index 7557257ef4..0acf8c041a 100644 --- a/ext/tk/sample/demos-en/icon.rb +++ b/ext/tk/sample/demos-en/icon.rb @@ -48,30 +48,33 @@ TkFrame.new($icon_demo) {|frame| # image flagup = \ -TkBitmapImage.new('file'=>[$demo_dir, +TkBitmapImage.new('file'=>[$demo_dir,'..', 'images','flagup.xbm'].join(File::Separator), 'maskfile'=>\ - [$demo_dir,'images','flagup.xbm'].join(File::Separator)) + [$demo_dir,'..','images','flagup.xbm'].join(File::Separator)) flagdown = \ -TkBitmapImage.new('file'=>[$demo_dir, +TkBitmapImage.new('file'=>[$demo_dir,'..', 'images','flagdown.xbm'].join(File::Separator), 'maskfile'=>\ - [$demo_dir,'images','flagdown.xbm'].join(File::Separator)) + [$demo_dir,'..', + 'images','flagdown.xbm'].join(File::Separator)) -# 変数生成 +# create variable letters = TkVariable.new # frame TkFrame.new($icon_demo, 'borderwidth'=>10){|w| TkFrame.new(w) {|f| TkRadioButton.new(f){ - bitmap '@' + [$demo_dir,'images','letters.xbm'].join(File::Separator) + bitmap '@' + [$demo_dir,'..', + 'images','letters.xbm'].join(File::Separator) variable letters value 'full' }.pack('side'=>'top', 'expand'=>'yes') TkRadioButton.new(f){ - bitmap '@' + [$demo_dir,'images','noletter.xbm'].join(File::Separator) + bitmap '@' + [$demo_dir,'..', + 'images','noletter.xbm'].join(File::Separator) variable letters value 'empty' }.pack('side'=>'top', 'expand'=>'yes') @@ -86,7 +89,8 @@ TkFrame.new($icon_demo, 'borderwidth'=>10){|w| }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m') TkCheckButton.new(w) { - bitmap '@' + [$demo_dir,'images','letters.xbm'].join(File::Separator) + bitmap '@' + [$demo_dir,'..', + 'images','letters.xbm'].join(File::Separator) indicatoron 0 selectcolor 'SeaGreen1' }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m') diff --git a/ext/tk/sample/demos-en/image1.rb b/ext/tk/sample/demos-en/image1.rb index 8d39b20049..05c9705c9c 100644 --- a/ext/tk/sample/demos-en/image1.rb +++ b/ext/tk/sample/demos-en/image1.rb @@ -47,10 +47,10 @@ TkFrame.new($image1_demo) {|frame| # image image1a = \ -TkPhotoImage.new('file'=>[$demo_dir, +TkPhotoImage.new('file'=>[$demo_dir,'..', 'images','earth.gif'].join(File::Separator)) image1b = \ -TkPhotoImage.new('file'=>[$demo_dir, +TkPhotoImage.new('file'=>[$demo_dir,'..', 'images','earthris.gif'].join(File::Separator)) # label diff --git a/ext/tk/sample/demos-en/image2.rb b/ext/tk/sample/demos-en/image2.rb index 9924195675..1aff7173be 100644 --- a/ext/tk/sample/demos-en/image2.rb +++ b/ext/tk/sample/demos-en/image2.rb @@ -46,8 +46,8 @@ TkFrame.new($image2_demo) {|frame| }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') -# 変数生成 -$dirName = TkVariable.new([$demo_dir,'images'].join(File::Separator)) +# create variable +$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator)) # image $image2a = TkPhotoImage.new diff --git a/ext/tk/sample/demos-en/image3.rb b/ext/tk/sample/demos-en/image3.rb index d997ef7772..d7d823ccf2 100644 --- a/ext/tk/sample/demos-en/image3.rb +++ b/ext/tk/sample/demos-en/image3.rb @@ -75,7 +75,7 @@ TkFrame.new($image3_demo) {|frame| }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # variable -$dirName = TkVariable.new([$demo_dir,'images'].join(File::Separator)) +$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator)) # image begin diff --git a/ext/tk/sample/demos-en/images/earth.gif b/ext/tk/sample/demos-en/images/earth.gif Binary files differdeleted file mode 100644 index 3ae4a9ce01..0000000000 --- a/ext/tk/sample/demos-en/images/earth.gif +++ /dev/null diff --git a/ext/tk/sample/demos-en/images/earthris.gif b/ext/tk/sample/demos-en/images/earthris.gif Binary files differdeleted file mode 100644 index 48f08c4421..0000000000 --- a/ext/tk/sample/demos-en/images/earthris.gif +++ /dev/null diff --git a/ext/tk/sample/demos-en/images/face.xbm b/ext/tk/sample/demos-en/images/face.xbm deleted file mode 100644 index 03d829f4d1..0000000000 --- a/ext/tk/sample/demos-en/images/face.xbm +++ /dev/null @@ -1,173 +0,0 @@ -#define face_width 108 -#define face_height 144 -#define face_x_hot 48 -#define face_y_hot 80 -static char face_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x09, - 0x20, 0x80, 0x24, 0x05, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x88, - 0x24, 0x20, 0x80, 0x24, 0x00, 0x00, 0x00, 0x10, 0x80, 0x04, 0x00, 0x01, - 0x00, 0x01, 0x40, 0x0a, 0x09, 0x00, 0x92, 0x04, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x40, 0x12, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x84, - 0x24, 0x40, 0x22, 0xa8, 0x02, 0x14, 0x84, 0x92, 0x40, 0x42, 0x12, 0x04, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x52, 0x11, 0x00, 0x12, 0x00, - 0x40, 0x02, 0x00, 0x20, 0x00, 0x08, 0x00, 0xaa, 0x02, 0x54, 0x85, 0x24, - 0x00, 0x10, 0x12, 0x00, 0x00, 0x81, 0x44, 0x00, 0x90, 0x5a, 0x00, 0xea, - 0x1b, 0x00, 0x80, 0x40, 0x40, 0x02, 0x00, 0x08, 0x00, 0x20, 0xa2, 0x05, - 0x8a, 0xb4, 0x6e, 0x45, 0x12, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10, 0x02, - 0xa8, 0x92, 0x00, 0xda, 0x5f, 0x10, 0x00, 0x10, 0xa1, 0x04, 0x20, 0x41, - 0x02, 0x00, 0x5a, 0x25, 0xa0, 0xff, 0xfb, 0x05, 0x41, 0x02, 0x04, 0x00, - 0x00, 0x08, 0x40, 0x80, 0xec, 0x9b, 0xec, 0xfe, 0x7f, 0x01, 0x04, 0x20, - 0x90, 0x02, 0x04, 0x00, 0x08, 0x20, 0xfb, 0x2e, 0xf5, 0xff, 0xff, 0x57, - 0x00, 0x04, 0x02, 0x00, 0x00, 0x20, 0x01, 0xc1, 0x6e, 0xab, 0xfa, 0xff, - 0xff, 0x05, 0x90, 0x20, 0x48, 0x02, 0x00, 0x04, 0x20, 0xa8, 0xdf, 0xb5, - 0xfe, 0xff, 0xff, 0x0b, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x04, 0xe0, - 0xbb, 0xef, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x04, 0x48, 0x02, 0x00, 0x20, - 0x80, 0xf4, 0x6f, 0xfb, 0xff, 0xff, 0xff, 0x20, 0x90, 0x40, 0x02, 0x00, - 0x00, 0x04, 0x08, 0xb8, 0xf6, 0xff, 0xff, 0xdf, 0xbe, 0x12, 0x45, 0x10, - 0x90, 0x04, 0x90, 0x00, 0x22, 0xfa, 0xff, 0xff, 0xff, 0xbb, 0xd7, 0xe9, - 0x3a, 0x02, 0x02, 0x00, 0x04, 0x90, 0x80, 0xfe, 0xdf, 0xf6, 0xb7, 0xef, - 0xbe, 0x56, 0x57, 0x40, 0x48, 0x09, 0x00, 0x04, 0x00, 0xfa, 0xf5, 0xdf, - 0xed, 0x5a, 0xd5, 0xea, 0xbd, 0x09, 0x00, 0x00, 0x40, 0x00, 0x92, 0xfe, - 0xbf, 0x7d, 0xb7, 0x6a, 0x55, 0xbf, 0xf7, 0x02, 0x11, 0x01, 0x00, 0x91, - 0x00, 0xff, 0xff, 0xaf, 0x55, 0x55, 0x5b, 0xeb, 0xef, 0x22, 0x04, 0x04, - 0x04, 0x00, 0xa4, 0xff, 0xf7, 0xad, 0xaa, 0xaa, 0xaa, 0xbe, 0xfe, 0x03, - 0x20, 0x00, 0x10, 0x44, 0x80, 0xff, 0x7f, 0x55, 0x12, 0x91, 0x2a, 0xeb, - 0xbf, 0x0b, 0x82, 0x02, 0x00, 0x00, 0xd1, 0x7f, 0xdf, 0xa2, 0xa4, 0x54, - 0x55, 0xfd, 0xfd, 0x47, 0x08, 0x08, 0x00, 0x21, 0xe4, 0xff, 0x37, 0x11, - 0x09, 0xa5, 0xaa, 0xb6, 0xff, 0x0d, 0x80, 0x00, 0x00, 0x04, 0xd0, 0xff, - 0x4f, 0x44, 0x20, 0x48, 0x55, 0xfb, 0xff, 0x27, 0x11, 0x02, 0x40, 0x40, - 0xe2, 0xfb, 0x15, 0x11, 0x4a, 0x55, 0x4a, 0x7d, 0xf7, 0x0f, 0x00, 0x00, - 0x04, 0x08, 0xf8, 0xdf, 0x52, 0x44, 0x01, 0x52, 0xb5, 0xfa, 0xff, 0x0f, - 0x49, 0x02, 0x00, 0x02, 0xe9, 0xf6, 0x0a, 0x11, 0xa4, 0x88, 0x4a, 0x6d, - 0xff, 0x5f, 0x00, 0x00, 0x10, 0x20, 0xf0, 0x2f, 0x21, 0x44, 0x10, 0x52, - 0xb5, 0xfa, 0xff, 0x0f, 0x44, 0x04, 0x80, 0x08, 0xf8, 0xab, 0x8a, 0x00, - 0x81, 0xa4, 0xd4, 0xd6, 0xfe, 0x2f, 0x00, 0x00, 0x04, 0x40, 0xb5, 0x2d, - 0x21, 0x08, 0x04, 0x90, 0xaa, 0xfa, 0xff, 0x1f, 0x11, 0x01, 0x00, 0x04, - 0xf0, 0x57, 0x0a, 0x22, 0x40, 0x4a, 0xda, 0x5e, 0xfb, 0x1f, 0x40, 0x00, - 0x40, 0x20, 0xba, 0x95, 0x90, 0x00, 0x01, 0xa0, 0xaa, 0xea, 0xff, 0x5f, - 0x02, 0x02, 0x00, 0x01, 0xe8, 0x57, 0x05, 0x00, 0x00, 0x12, 0xd5, 0xfe, - 0xfd, 0x1f, 0x48, 0x00, 0x04, 0x48, 0x7a, 0x95, 0x08, 0x02, 0x10, 0x40, - 0xaa, 0x55, 0xf7, 0x1f, 0x00, 0x09, 0x20, 0x00, 0xf8, 0x57, 0x22, 0x10, - 0x00, 0x28, 0xa9, 0xfa, 0xff, 0x5f, 0x02, 0x00, 0x00, 0x49, 0xdd, 0x29, - 0x01, 0x00, 0x80, 0x80, 0xaa, 0xd7, 0xff, 0x0f, 0x10, 0x00, 0x08, 0x00, - 0xf8, 0x96, 0x08, 0x00, 0x00, 0x20, 0x54, 0xfa, 0xee, 0x3f, 0x81, 0x04, - 0x40, 0x24, 0xfe, 0x55, 0x82, 0x00, 0x00, 0x82, 0xd2, 0xad, 0xff, 0x0f, - 0x08, 0x00, 0x04, 0x80, 0x6c, 0x97, 0x00, 0x00, 0x02, 0x20, 0xa9, 0xf6, - 0xdf, 0x5f, 0x00, 0x02, 0x20, 0x09, 0xfa, 0x49, 0x12, 0x00, 0x20, 0x84, - 0x54, 0xdb, 0xfe, 0x1f, 0x91, 0x00, 0x00, 0x00, 0xf8, 0x2b, 0x00, 0x20, - 0x00, 0x40, 0xa4, 0xf6, 0xbb, 0x1f, 0x04, 0x00, 0x44, 0x92, 0x7e, 0x95, - 0x02, 0x00, 0x00, 0x89, 0xaa, 0xdd, 0xff, 0x1f, 0x20, 0x09, 0x10, 0x00, - 0xf4, 0x57, 0x20, 0x01, 0x08, 0x20, 0xa9, 0x76, 0xff, 0x5f, 0x02, 0x00, - 0x00, 0x21, 0xfc, 0x4a, 0x05, 0x00, 0x01, 0x80, 0x54, 0xdb, 0xff, 0x1e, - 0x08, 0x02, 0x04, 0x08, 0xf9, 0x2b, 0x00, 0x00, 0x40, 0x28, 0xd2, 0xf6, - 0xff, 0xbf, 0x80, 0x00, 0x90, 0x00, 0xbc, 0x92, 0x08, 0x10, 0x00, 0x82, - 0x54, 0xdb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x44, 0xf9, 0x55, 0x02, 0x01, - 0x00, 0x20, 0xaa, 0xbd, 0xfd, 0x3f, 0x08, 0x04, 0x04, 0x10, 0xf4, 0x2a, - 0x01, 0x00, 0x22, 0x80, 0xd4, 0xf6, 0xff, 0x5f, 0x82, 0x00, 0x40, 0x02, - 0xf8, 0x55, 0x20, 0x00, 0x00, 0x50, 0x6a, 0xdf, 0xfe, 0x3f, 0x00, 0x00, - 0x00, 0x48, 0xe9, 0x4a, 0x05, 0x08, 0x00, 0xa5, 0xd5, 0xf5, 0xff, 0x3f, - 0x10, 0x01, 0x10, 0x01, 0xb0, 0xab, 0x92, 0x02, 0x40, 0xf8, 0xbf, 0xde, - 0xfe, 0x5f, 0x02, 0x04, 0x04, 0x48, 0xfa, 0xd4, 0x6f, 0x20, 0x84, 0xef, - 0xff, 0xfb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x00, 0xe0, 0xed, 0xbf, 0x0b, - 0xa1, 0x7e, 0xff, 0xbf, 0xfd, 0x5f, 0x04, 0x01, 0x20, 0x49, 0xd2, 0xfb, - 0xfe, 0x55, 0xd4, 0xff, 0xff, 0xf6, 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, - 0xc0, 0xaa, 0xfb, 0x2b, 0xa2, 0xfe, 0xff, 0xdf, 0xee, 0x1f, 0x91, 0x00, - 0x82, 0xa4, 0xa4, 0xf5, 0xff, 0x57, 0xd5, 0xff, 0xbf, 0xfd, 0xff, 0x4d, - 0x00, 0x00, 0x20, 0x00, 0x88, 0x5b, 0xff, 0x2f, 0x69, 0xff, 0xff, 0xdb, - 0xfe, 0x1f, 0x24, 0x02, 0x00, 0x49, 0xa2, 0xd6, 0xff, 0x5f, 0xea, 0xff, - 0x7f, 0x7f, 0x7f, 0x0d, 0x00, 0x00, 0x10, 0x00, 0x40, 0xab, 0xf7, 0xbb, - 0xf0, 0xdf, 0xff, 0xd5, 0xff, 0xbf, 0x82, 0x04, 0x42, 0x24, 0x91, 0xd5, - 0xaa, 0xae, 0xd4, 0xaa, 0x52, 0x7b, 0xff, 0x15, 0x08, 0x00, 0x00, 0x01, - 0x04, 0x55, 0xd5, 0x55, 0x70, 0x5b, 0x75, 0xdd, 0xdf, 0x1f, 0x40, 0x00, - 0x08, 0x48, 0xa0, 0x4a, 0xa9, 0x56, 0xea, 0x56, 0xad, 0x6a, 0x7d, 0x9b, - 0x04, 0x01, 0x00, 0x02, 0x42, 0x2a, 0xd5, 0xaa, 0xa8, 0xaa, 0xaa, 0xfa, - 0xdf, 0x2f, 0x10, 0x04, 0x22, 0x48, 0x08, 0x45, 0x2a, 0x15, 0x68, 0x55, - 0x55, 0xd7, 0x76, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x40, 0x2a, 0x80, 0xa0, - 0xb2, 0x09, 0x48, 0xb9, 0xdf, 0x17, 0x22, 0x01, 0x00, 0x24, 0x45, 0x8a, - 0x24, 0x4a, 0x54, 0x51, 0x91, 0xf6, 0x6e, 0x4b, 0x00, 0x04, 0x90, 0x00, - 0x80, 0x52, 0x00, 0x20, 0x69, 0x05, 0xa4, 0xaa, 0xff, 0x1e, 0x48, 0x00, - 0x02, 0x92, 0x08, 0x05, 0x81, 0x94, 0xd4, 0x92, 0x40, 0xfd, 0xb6, 0x8b, - 0x00, 0x01, 0x40, 0x00, 0x82, 0x54, 0x00, 0x48, 0x68, 0x05, 0x90, 0xa4, - 0xef, 0x06, 0x24, 0x00, 0x08, 0x12, 0x10, 0x05, 0x00, 0x10, 0xb5, 0x01, - 0x42, 0xfb, 0xbf, 0x43, 0x00, 0x09, 0x00, 0x40, 0x81, 0xa8, 0x08, 0x4a, - 0xaa, 0x96, 0x90, 0xac, 0x6d, 0x15, 0x22, 0x00, 0x20, 0x09, 0x04, 0x15, - 0x80, 0x28, 0xdc, 0x01, 0x24, 0xfb, 0xbf, 0x01, 0x80, 0x04, 0x09, 0x00, - 0x40, 0x48, 0x02, 0x45, 0xb2, 0x2e, 0x41, 0x6d, 0xef, 0x05, 0x11, 0x00, - 0x40, 0x52, 0x02, 0x15, 0x29, 0x2a, 0xac, 0x42, 0x54, 0xfb, 0x3b, 0x51, - 0x84, 0x00, 0x08, 0x00, 0x20, 0x54, 0x80, 0x05, 0xb5, 0x3d, 0xa2, 0xb6, - 0xdf, 0x00, 0x20, 0x04, 0x20, 0x49, 0x89, 0xa8, 0x6a, 0x29, 0xac, 0xd6, - 0x54, 0xff, 0x3f, 0x84, 0x00, 0x01, 0x04, 0x10, 0x00, 0x94, 0xa8, 0x56, - 0xda, 0x5f, 0xab, 0xd5, 0x1e, 0x10, 0x48, 0x00, 0x90, 0x82, 0x48, 0xa8, - 0xb2, 0xac, 0xfd, 0x55, 0xd5, 0xfe, 0x9f, 0x80, 0x00, 0x0a, 0x02, 0x08, - 0x02, 0x55, 0x5a, 0x75, 0xff, 0xaf, 0xb6, 0xf7, 0x2d, 0x12, 0x92, 0x00, - 0x10, 0x20, 0x10, 0xa8, 0x54, 0xd5, 0xbf, 0x5d, 0xad, 0xdd, 0x0f, 0x00, - 0x00, 0x04, 0x40, 0x09, 0x84, 0xa8, 0xaa, 0x5a, 0xed, 0xeb, 0x6a, 0xff, - 0x9f, 0xa4, 0x24, 0x01, 0x02, 0xa0, 0x20, 0x50, 0x55, 0xd5, 0xbe, 0xae, - 0xad, 0xfd, 0x16, 0x00, 0x10, 0x04, 0x20, 0x0a, 0x08, 0xb4, 0xaa, 0x95, - 0xaa, 0x7b, 0xb7, 0xdb, 0x5f, 0x92, 0x04, 0x01, 0x84, 0x20, 0x21, 0x51, - 0xd5, 0x2a, 0xa9, 0xee, 0xd5, 0xfe, 0x0d, 0x00, 0x20, 0x04, 0x10, 0x00, - 0x08, 0x50, 0xe9, 0xd7, 0xd4, 0xfb, 0xb5, 0xff, 0x9f, 0x24, 0x09, 0x01, - 0x42, 0x4a, 0xa2, 0x64, 0xd5, 0x55, 0x7b, 0x7f, 0xda, 0x7d, 0x4f, 0x00, - 0x20, 0x04, 0x00, 0x80, 0x00, 0xa0, 0x2a, 0x13, 0x84, 0x6a, 0x55, 0xff, - 0x1d, 0x48, 0x8a, 0x00, 0x94, 0x24, 0x8a, 0xc8, 0xaa, 0x42, 0x20, 0x5d, - 0xf5, 0xff, 0x5f, 0x01, 0x00, 0x02, 0x01, 0x00, 0x20, 0xa2, 0x4a, 0x1a, - 0x82, 0x56, 0xda, 0xbd, 0x3f, 0x92, 0x92, 0x00, 0x90, 0x92, 0x00, 0x40, - 0x95, 0x6a, 0xf4, 0x55, 0x6d, 0xff, 0xd6, 0x00, 0x00, 0x0a, 0x04, 0x20, - 0x14, 0x49, 0x4b, 0xaa, 0xaa, 0x56, 0xf5, 0xff, 0xbf, 0xab, 0xa4, 0x00, - 0x20, 0x89, 0x40, 0x80, 0xaa, 0xaa, 0xaa, 0xaa, 0xde, 0xbf, 0xeb, 0x03, - 0x00, 0x02, 0x04, 0x02, 0x0a, 0x10, 0x2b, 0x2a, 0x55, 0x5b, 0xf5, 0xff, - 0xd7, 0x2f, 0x92, 0x00, 0x10, 0x28, 0x21, 0x01, 0x56, 0x95, 0xa0, 0x56, - 0xdf, 0xef, 0xea, 0x87, 0x40, 0x0a, 0x42, 0x41, 0x00, 0x90, 0xaa, 0x52, - 0xb6, 0xad, 0xfa, 0xff, 0xd5, 0x2f, 0x14, 0x00, 0x00, 0x04, 0x95, 0x04, - 0xaa, 0xac, 0x55, 0x6b, 0xff, 0xb7, 0xea, 0x9f, 0x40, 0x02, 0x28, 0x51, - 0x00, 0x40, 0x58, 0xd5, 0xda, 0xd6, 0x6e, 0x7f, 0xf9, 0x3f, 0x12, 0x04, - 0x02, 0x04, 0x49, 0x25, 0x55, 0xaa, 0x77, 0xab, 0xff, 0x2b, 0xfd, 0x3f, - 0x48, 0x01, 0x20, 0x41, 0x00, 0x00, 0x58, 0xa9, 0xda, 0xea, 0xfd, 0xaf, - 0xfa, 0xff, 0x02, 0x04, 0x08, 0x14, 0x29, 0x49, 0x52, 0x55, 0x55, 0x55, - 0xff, 0x8d, 0xfe, 0x3f, 0xa8, 0x00, 0x02, 0x41, 0x00, 0x02, 0xa0, 0xa2, - 0xaa, 0xea, 0xff, 0x53, 0xfd, 0xff, 0x02, 0x04, 0x50, 0x04, 0x25, 0xa8, - 0x54, 0x49, 0x52, 0xb5, 0xbf, 0x8a, 0xfe, 0xff, 0xa9, 0x08, 0x04, 0x50, - 0x80, 0x02, 0xa1, 0x2a, 0x95, 0xea, 0xff, 0xa1, 0xff, 0xff, 0x03, 0x02, - 0x90, 0x02, 0x09, 0x08, 0x44, 0x49, 0x52, 0xbd, 0x7f, 0xca, 0xff, 0xff, - 0x2b, 0x09, 0x04, 0x48, 0x40, 0x82, 0x90, 0x56, 0xa9, 0xf6, 0xbf, 0xd0, - 0xff, 0xff, 0x47, 0x00, 0x50, 0x02, 0x15, 0x11, 0x40, 0x95, 0xaa, 0xfd, - 0x2f, 0xe9, 0xff, 0xff, 0x8f, 0x0a, 0x84, 0x50, 0x40, 0x84, 0x14, 0xaa, - 0x6a, 0xff, 0x5f, 0xf2, 0xff, 0xff, 0x7f, 0x00, 0x10, 0x02, 0x09, 0x10, - 0x40, 0x7d, 0xf7, 0xff, 0x0b, 0xfc, 0xff, 0xff, 0xaf, 0x02, 0x84, 0x50, - 0x42, 0x85, 0x12, 0xd0, 0xdd, 0xff, 0xa7, 0xf2, 0xff, 0xff, 0xff, 0x04, - 0x00, 0x0a, 0x08, 0x10, 0x48, 0xf8, 0xff, 0xff, 0x0a, 0xfe, 0xff, 0xff, - 0x7f, 0x03, 0xa4, 0x80, 0xa2, 0x8a, 0x02, 0x68, 0xff, 0xff, 0x52, 0xfd, - 0xff, 0xff, 0xff, 0x07, 0x00, 0x2a, 0x08, 0x20, 0x28, 0xdc, 0xff, 0x5f, - 0x05, 0xff, 0xff, 0xff, 0xff, 0x0d, 0x92, 0x40, 0x22, 0x09, 0x02, 0xea, - 0xfb, 0xaf, 0x48, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x12, 0x81, 0xa0, - 0x48, 0x9c, 0x6e, 0x93, 0xa2, 0xff, 0xff, 0xff, 0xff, 0x07, 0xa8, 0x40, - 0x28, 0x0a, 0x02, 0x74, 0xb5, 0x45, 0x81, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x02, 0x0a, 0x81, 0x20, 0x08, 0xae, 0xaa, 0x90, 0xe8, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x90, 0x40, 0x28, 0x88, 0x12, 0x58, 0x15, 0x50, 0xd0, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x44, 0x0a, 0x41, 0x21, 0x08, 0xae, 0x04, 0x14, - 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, 0x14, 0x88, 0x04, 0xba, - 0x02, 0x28, 0xe8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x42, 0x15, 0x41, 0x21, - 0x05, 0xad, 0x00, 0x05, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, - 0x24, 0x8a, 0x0e, 0x36, 0x00, 0x0a, 0xf4, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x42, 0x25, 0x90, 0xd0, 0x8b, 0xc2, 0x41, 0x05, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x10, 0x08, 0x05, 0xe8, 0x8e, 0x58, 0x80, 0x02, 0xfa, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x4a, 0x20, 0xa8, 0xba, 0x0b, 0x2b, 0x51, 0x01, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x8a, 0x02, 0xe8, 0xaf, 0x84, - 0x90, 0x04, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x52, 0x21, 0x54, 0xbf, - 0x1f, 0x15, 0xa5, 0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x08, - 0x01, 0xfa, 0xb6, 0xa4, 0x52, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x4a, 0xa2, 0x54, 0xef, 0x5f, 0x4b, 0xa4, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x80, 0x10, 0x82, 0xfe, 0xbf, 0x92, 0x52, 0x42, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x12, 0x42, 0xa8, 0xbf, 0x1f, 0x24, 0x80, 0xa0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, 0x8a, 0xf7, 0x37, 0x80, - 0x52, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x82, 0xe0, 0xff, - 0x1f, 0x00, 0x20, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, - 0xca, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x10, 0x42, 0xf0, 0xfd, 0x1b, 0x00, 0x50, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0xa4, 0x10, 0xc5, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x00, 0x22, 0xf8, 0xff, 0x0e, 0x00, 0x00, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xaa, 0x88, 0xe2, 0xff, 0x0f, 0x10, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x25, 0xfa, 0xff, - 0x0f, 0x01, 0x11, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xfb, - 0xfb, 0xff, 0x7f, 0x5d, 0xd5, 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f}; diff --git a/ext/tk/sample/demos-en/images/flagdown.xbm b/ext/tk/sample/demos-en/images/flagdown.xbm deleted file mode 100644 index 55abc51825..0000000000 --- a/ext/tk/sample/demos-en/images/flagdown.xbm +++ /dev/null @@ -1,27 +0,0 @@ -#define flagdown_width 48 -#define flagdown_height 48 -static char flagdown_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe1, 0x00, 0x00, - 0x00, 0x00, 0x70, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04, - 0x00, 0x00, 0x03, 0x00, 0x06, 0x06, 0x00, 0x80, 0x01, 0x00, 0x06, 0x07, - 0x00, 0xc0, 0x1f, 0x00, 0x87, 0x07, 0x00, 0xe0, 0x7f, 0x80, 0xc7, 0x07, - 0x00, 0x70, 0xe0, 0xc0, 0xe5, 0x07, 0x00, 0x38, 0x80, 0xe1, 0x74, 0x07, - 0x00, 0x18, 0x80, 0x71, 0x3c, 0x07, 0x00, 0x0c, 0x00, 0x3b, 0x1e, 0x03, - 0x00, 0x0c, 0x00, 0x1f, 0x0f, 0x00, 0x00, 0x86, 0x1f, 0x8e, 0x07, 0x00, - 0x00, 0x06, 0x06, 0xc6, 0x05, 0x00, 0x00, 0x06, 0x00, 0xc6, 0x05, 0x00, - 0x00, 0x06, 0x00, 0xc6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, - 0x7f, 0x06, 0x00, 0x06, 0xe4, 0xff, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, - 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x06, 0x00, - 0x00, 0x06, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00, - 0x00, 0x06, 0x00, 0xc6, 0x00, 0x00, 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, - 0x00, 0x06, 0x00, 0x36, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3e, 0x00, 0x00, - 0x00, 0xfe, 0xff, 0x2f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x27, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0xf7, 0xbf, 0x8e, 0xfc, 0xdf, 0xf8, 0x9d, 0xeb, 0x9b, 0x76, 0xd2, 0x7a, - 0x46, 0x30, 0xe2, 0x0f, 0xe1, 0x47, 0x55, 0x84, 0x48, 0x11, 0x84, 0x19}; diff --git a/ext/tk/sample/demos-en/images/flagup.xbm b/ext/tk/sample/demos-en/images/flagup.xbm deleted file mode 100644 index 6eb0d846a3..0000000000 --- a/ext/tk/sample/demos-en/images/flagup.xbm +++ /dev/null @@ -1,27 +0,0 @@ -#define flagup_width 48 -#define flagup_height 48 -static char flagup_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xef, 0x6a, 0x00, - 0x00, 0x00, 0xc0, 0x7b, 0x75, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x6a, 0x00, - 0x00, 0x00, 0x30, 0x60, 0x75, 0x00, 0x00, 0x00, 0x18, 0xe0, 0x7f, 0x00, - 0x00, 0x00, 0x0c, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x06, 0xe0, 0x04, 0x00, - 0x00, 0x00, 0x03, 0xe0, 0x04, 0x00, 0x00, 0x80, 0x01, 0xe0, 0x06, 0x00, - 0x00, 0xc0, 0x1f, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0xe0, 0x07, 0x00, - 0x00, 0x70, 0xe0, 0xe0, 0x05, 0x00, 0x00, 0x38, 0x80, 0xe1, 0x04, 0x00, - 0x00, 0x18, 0x80, 0xf1, 0x04, 0x00, 0x00, 0x0c, 0x00, 0xfb, 0x04, 0x00, - 0x00, 0x0c, 0x00, 0xff, 0x04, 0x00, 0x00, 0x86, 0x1f, 0xee, 0x04, 0x00, - 0x00, 0x06, 0x06, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00, - 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x66, 0x04, 0x00, - 0x7f, 0x56, 0x52, 0x06, 0xe4, 0xff, 0x00, 0x76, 0x55, 0x06, 0x04, 0x00, - 0x00, 0x56, 0x57, 0x06, 0x04, 0x00, 0x00, 0x56, 0x55, 0x06, 0x06, 0x00, - 0x00, 0x56, 0xd5, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00, - 0x54, 0x06, 0x00, 0xc6, 0x54, 0x55, 0xaa, 0x06, 0x00, 0x66, 0xaa, 0x2a, - 0x54, 0x06, 0x00, 0x36, 0x55, 0x55, 0xaa, 0x06, 0x00, 0xbe, 0xaa, 0x2a, - 0x54, 0xfe, 0xff, 0x6f, 0x55, 0x55, 0xaa, 0xfc, 0xff, 0xa7, 0xaa, 0x2a, - 0x54, 0x01, 0x88, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a, - 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a, - 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a, - 0x54, 0x55, 0x8d, 0x50, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa8, 0xaa, 0x2a, - 0x54, 0x55, 0x95, 0x54, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2a, - 0x54, 0x55, 0x55, 0x55, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/ext/tk/sample/demos-en/images/gray25.xbm b/ext/tk/sample/demos-en/images/gray25.xbm deleted file mode 100644 index b234b3cb0b..0000000000 --- a/ext/tk/sample/demos-en/images/gray25.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define grey_width 16 -#define grey_height 16 -static char grey_bits[] = { - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44}; diff --git a/ext/tk/sample/demos-en/images/grey.25 b/ext/tk/sample/demos-en/images/grey.25 deleted file mode 100644 index b234b3cb0b..0000000000 --- a/ext/tk/sample/demos-en/images/grey.25 +++ /dev/null @@ -1,6 +0,0 @@ -#define grey_width 16 -#define grey_height 16 -static char grey_bits[] = { - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44}; diff --git a/ext/tk/sample/demos-en/images/grey.5 b/ext/tk/sample/demos-en/images/grey.5 deleted file mode 100644 index 37688893f0..0000000000 --- a/ext/tk/sample/demos-en/images/grey.5 +++ /dev/null @@ -1,6 +0,0 @@ -#define grey_width 16 -#define grey_height 16 -static char grey_bits[] = { - 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, - 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, - 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa}; diff --git a/ext/tk/sample/demos-en/images/letters.xbm b/ext/tk/sample/demos-en/images/letters.xbm deleted file mode 100644 index 0f12568d1a..0000000000 --- a/ext/tk/sample/demos-en/images/letters.xbm +++ /dev/null @@ -1,27 +0,0 @@ -#define letters_width 48 -#define letters_height 48 -static char letters_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, - 0x00, 0xfa, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, - 0x00, 0x3a, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2e, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x21, - 0xa0, 0x03, 0x00, 0x00, 0x70, 0x21, 0x20, 0x00, 0x00, 0x00, 0x50, 0x21, - 0xa0, 0x1f, 0x00, 0x00, 0x50, 0x21, 0x20, 0x00, 0x00, 0x00, 0x70, 0x21, - 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21, - 0xfa, 0x01, 0x00, 0x80, 0x0b, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0a, 0x21, - 0xba, 0x01, 0x00, 0x80, 0x0a, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0b, 0x21, - 0x3a, 0x00, 0x00, 0x00, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21, - 0x02, 0xc0, 0xfb, 0x03, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3f, - 0x02, 0xc0, 0xbd, 0x0f, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, - 0x02, 0xc0, 0x7f, 0x7b, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, - 0x02, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, - 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/ext/tk/sample/demos-en/images/noletter.xbm b/ext/tk/sample/demos-en/images/noletter.xbm deleted file mode 100644 index 5774124efe..0000000000 --- a/ext/tk/sample/demos-en/images/noletter.xbm +++ /dev/null @@ -1,27 +0,0 @@ -#define noletters_width 48 -#define noletters_height 48 -static char noletters_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, - 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00, - 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01, - 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x07, - 0xe0, 0x01, 0x00, 0x00, 0xf0, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x78, 0x0e, - 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x1e, 0x70, 0x00, 0x00, 0x00, 0x1e, 0x1c, - 0x38, 0x00, 0x00, 0x00, 0x0f, 0x38, 0x38, 0x00, 0x00, 0x80, 0x07, 0x38, - 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x1c, 0x04, 0x00, 0xe0, 0x41, 0x70, - 0x1c, 0x04, 0x00, 0xf0, 0x40, 0x70, 0x1c, 0x74, 0x00, 0x78, 0x4e, 0x70, - 0x0e, 0x04, 0x00, 0x3c, 0x4a, 0xe0, 0x0e, 0x74, 0x03, 0x1e, 0x4a, 0xe0, - 0x0e, 0x04, 0x00, 0x0f, 0x4e, 0xe0, 0x0e, 0x04, 0x80, 0x07, 0x40, 0xe0, - 0x0e, 0x04, 0xf8, 0x0f, 0x40, 0xe0, 0x0e, 0x04, 0xe0, 0x01, 0x40, 0xe0, - 0x0e, 0x04, 0xf8, 0x00, 0x40, 0xe0, 0x0e, 0x04, 0x78, 0x00, 0x40, 0xe0, - 0x0e, 0x04, 0xfc, 0xf3, 0x40, 0xe0, 0x1c, 0x04, 0x1e, 0x00, 0x40, 0x70, - 0x1c, 0x04, 0x0f, 0x00, 0x40, 0x70, 0x1c, 0x84, 0x07, 0x00, 0x40, 0x70, - 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x38, 0xe0, 0x01, 0x00, 0x00, 0x38, - 0x38, 0xf0, 0x00, 0x00, 0x00, 0x38, 0x70, 0x78, 0x00, 0x00, 0x00, 0x1c, - 0xf0, 0x3c, 0x00, 0x00, 0x00, 0x1e, 0xe0, 0x1e, 0x00, 0x00, 0x00, 0x0e, - 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x80, 0x07, - 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01, - 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00, - 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00}; diff --git a/ext/tk/sample/demos-en/images/pattern.xbm b/ext/tk/sample/demos-en/images/pattern.xbm deleted file mode 100644 index df31baf789..0000000000 --- a/ext/tk/sample/demos-en/images/pattern.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define foo_width 16 -#define foo_height 16 -static char foo_bits[] = { - 0x60, 0x06, 0x90, 0x09, 0x90, 0x09, 0xb0, 0x0d, 0x4e, 0x72, 0x49, 0x92, - 0x71, 0x8e, 0x8e, 0x71, 0x8e, 0x71, 0x71, 0x8e, 0x49, 0x92, 0x4e, 0x72, - 0xb0, 0x0d, 0x90, 0x09, 0x90, 0x09, 0x60, 0x06}; diff --git a/ext/tk/sample/demos-en/images/tcllogo.gif b/ext/tk/sample/demos-en/images/tcllogo.gif Binary files differdeleted file mode 100644 index 3fc7720b17..0000000000 --- a/ext/tk/sample/demos-en/images/tcllogo.gif +++ /dev/null diff --git a/ext/tk/sample/demos-en/images/teapot.ppm b/ext/tk/sample/demos-en/images/teapot.ppm deleted file mode 100644 index 78afefbf82..0000000000 --- a/ext/tk/sample/demos-en/images/teapot.ppm +++ /dev/null @@ -1,56 +0,0 @@ -P6 -256 256 -255 -\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\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g{mi~ojqll\Xn^Yp`Zpa[qa\rb]rc^sc^sd_ue`wf`xgayhayhayhbxyyyyyy~ywgbvfateasd`qd`pc`nb_la_ut|ssxqrunpZUXVRWROUMMSHIRIC@967-/3'+0(*-ACF?AD;=@#%( -.+>1(B3)B2&F4'E4)gTGlXJs^OzcTzaPqfethgvjhbVTcWUdXVeYWfZXg[Yh\Zi]Zi][j^\usususts~tt~tt}tt|st{stut~tt|sszrsyqrwpquoqsmpqloXTXTQWPOULLSSJEA<:=99757335./2113)+.'),)+.8:="( -"6*#5*">2)>0&A2'C3(I8-^OFbRHfUJjXMq^RwcVzfYfRDfQCdN@zdTqijrjksklrklrklrklqjmpjmpjmojmojmnimmimkhliflscYm`Xg\VbYT^VRE>;A<:>98:77645:873220/0,-/)+.*,/#%( & - -&3#.$-% .% .& /&!,#,#@70A71XNHXNHWNHWNHZRLYQLYQLXQLWQLWPLUOLSNLQMKOLJMJJ0//.-.,,-&(+"(!' - -%' %$#" ! !$ - - - - - -* - ;?E7CU;HY=I[ diff --git a/ext/tk/sample/demos-en/items.rb b/ext/tk/sample/demos-en/items.rb index 8447430694..974d7caef9 100644 --- a/ext/tk/sample/demos-en/items.rb +++ b/ext/tk/sample/demos-en/items.rb @@ -123,7 +123,7 @@ TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c', '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c', 'width'=>3, 'fill'=>red, 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c', - 'stipple'=>'@'+[$demo_dir, + 'stipple'=>'@'+[$demo_dir,'..', 'images','gray25.xbm'].join(File::Separator), 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c', @@ -139,7 +139,7 @@ TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c', TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c', '16.5c','4.5c','13.5c','7.5c','12c','6c', 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round', - 'stipple'=>'@'+[$demo_dir, + 'stipple'=>'@'+[$demo_dir, '..', 'images', 'gray25.xbm'].join(File::Separator), 'fill'=>red, 'tags'=>$tag_item ) @@ -154,7 +154,7 @@ TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c', TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c', '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c', '7.5c','22c','7.5c', - 'stipple'=>'@' + [$demo_dir, + 'stipple'=>'@' + [$demo_dir, '..', 'images', 'gray25.xbm'].join(File::Separator), 'outline'=>'black', 'tags'=>$tag_item ) @@ -164,7 +164,7 @@ TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c', TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c', 'fill'=>green, 'tags'=>$tag_item ) TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir, + 'stipple'=>'@'+[$demo_dir,'..', 'images','gray25.xbm'].join(File::Separator), 'fill'=>blue, 'tags'=>$tag_item ) @@ -174,7 +174,7 @@ TkcOval.new(cvs, '11c','9.5c','14c','12.5c', TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c', 'fill'=>green, 'tags'=>$tag_item ) TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir, + 'stipple'=>'@'+[$demo_dir,'..', 'images','gray25.xbm'].join(File::Separator), 'fill'=>blue, 'tags'=>$tag_item ) @@ -188,7 +188,7 @@ TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue, TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c') if $tk_version =~ /^4\.[01]/ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, - 'stipple'=>'@' + [$demo_dir, + 'stipple'=>'@' + [$demo_dir, '..', 'images', 'grey.5'].join(File::Separator), 'text'=>'Stippled characters', 'tags'=>$tag_item ) else @@ -206,7 +206,7 @@ TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black', # 'tags'=>$tag_item) TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', 'outline'=>blue, 'start'=>135, 'extent'=>270, - 'outlinestipple'=>'@'+[$demo_dir, + 'outlinestipple'=>'@'+[$demo_dir, '..', 'images','gray25.xbm'].join(File::Separator), 'tags'=>$tag_item) TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice', @@ -221,14 +221,14 @@ TkcText.new(cvs, '15c', '16.2c', 'text'=>'Bitmaps', 'anchor'=>'n') # 'bitmap'=>'@' + ['images', 'face'].join(File::Separator), # 'tags'=>$tag_item) TkcBitmap.new(cvs, '13c','20c', - 'bitmap'=>'@' + [$demo_dir, + 'bitmap'=>'@' + [$demo_dir, '..', 'images', 'face.xbm'].join(File::Separator), 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','18.5c', # 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator), # 'tags'=>$tag_item) TkcBitmap.new(cvs, '17c','18.5c', - 'bitmap'=>'@' + [$demo_dir, + 'bitmap'=>'@' + [$demo_dir, '..', 'images', 'noletter.xbm'].join(File::Separator), 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','21.5c', @@ -236,7 +236,7 @@ TkcBitmap.new(cvs, '17c','18.5c', # 'tags'=>$tag_item) # TkcBitmap.new(cvs, '17c','21.5c') { - bitmap '@' + [$demo_dir, 'images', 'letters.xbm'].join(File::Separator) + bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator) tags $tag_item } #TkcBitmap.new(cvs, '17c','21.5c') { diff --git a/ext/tk/sample/demos-en/label.rb b/ext/tk/sample/demos-en/label.rb index ef1bfa6f8a..96f76d35f1 100644 --- a/ext/tk/sample/demos-en/label.rb +++ b/ext/tk/sample/demos-en/label.rb @@ -60,7 +60,7 @@ f_right = TkFrame.new($label_demo) ].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')} TkLabel.new(f_right) { - bitmap('@' + [$demo_dir,'images','face.xbm'].join(File::Separator)) + bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator)) borderwidth 2 relief 'sunken' }.pack('side'=>'top') diff --git a/ext/tk/sample/demos-en/menu.rb b/ext/tk/sample/demos-en/menu.rb index 7ea3fd2ebb..c29f6e90da 100644 --- a/ext/tk/sample/demos-en/menu.rb +++ b/ext/tk/sample/demos-en/menu.rb @@ -15,7 +15,7 @@ $menu_demo = TkToplevel.new {|w| positionWindow(w) } -# menu frame 生成 +# menu frame $menu_frame = TkFrame.new($menu_demo, 'relief'=>'raised', 'bd'=>2) $menu_frame.pack('side'=>'top', 'fill'=>'x') @@ -149,7 +149,8 @@ TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m| TkMenu.new(m, 'tearoff'=>false) {|icon_menu| m.configure('menu'=>icon_menu) add('command', - 'bitmap'=>'@'+[$demo_dir,'images','pattern.xbm'].join(File::Separator), + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.', 'bitmap'=>'', 'default'=>0, diff --git a/ext/tk/sample/demos-en/menu84.rb b/ext/tk/sample/demos-en/menu84.rb index 82e29f6475..8f7be97707 100644 --- a/ext/tk/sample/demos-en/menu84.rb +++ b/ext/tk/sample/demos-en/menu84.rb @@ -157,7 +157,8 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0) add('command', 'hidemargin'=>1, - 'bitmap'=>'@'+[$demo_dir,'images','pattern.xbm'].join(File::Separator), + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', 'text'=>'The menu entry you invoked displays a bitmap rather than a text string. Other than this, it is just like any other menu entry.', 'bitmap'=>'', 'default'=>0, diff --git a/ext/tk/sample/demos-en/menubu.rb b/ext/tk/sample/demos-en/menubu.rb index 42a5931dd1..cc1ccafa76 100644 --- a/ext/tk/sample/demos-en/menubu.rb +++ b/ext/tk/sample/demos-en/menubu.rb @@ -58,7 +58,7 @@ TkFrame.new($menubu_demo) {|frame| TkButton.new(frame) { text 'Show Code' - command proc{showCode 'menu'} + command proc{showCode 'menubu'} }.pack('side'=>'left', 'expand'=>'yes') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') diff --git a/ext/tk/sample/demos-en/radio2.rb b/ext/tk/sample/demos-en/radio2.rb index aefd81bdca..090e75c2cb 100644 --- a/ext/tk/sample/demos-en/radio2.rb +++ b/ext/tk/sample/demos-en/radio2.rb @@ -1,4 +1,4 @@ -# radio.rb +# radio2.rb # # This demonstration script creates a toplevel window containing # several radiobutton widgets. @@ -14,8 +14,8 @@ end # demo toplevel widget $radio2_demo = TkToplevel.new {|w| - title("Radiobutton Demonstration") - iconname("radio") + title("Radiobutton Demonstration 2") + iconname("radio2") positionWindow(w) } @@ -47,7 +47,7 @@ TkFrame.new($radio2_demo) {|frame| TkButton.new(frame) { text 'Show Code' - command proc{showCode 'radio'} + command proc{showCode 'radio2'} }.pack('side'=>'left', 'expand'=>'yes') TkButton.new(frame) { diff --git a/ext/tk/sample/demos-en/ruler.rb b/ext/tk/sample/demos-en/ruler.rb index f5e7add516..03a00b75b6 100644 --- a/ext/tk/sample/demos-en/ruler.rb +++ b/ext/tk/sample/demos-en/ruler.rb @@ -76,11 +76,13 @@ $demo_rulerInfo.normalStyle = {'fill'=>'black'} if TkWinfo.depth($ruler_canvas) > 1 $demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''} $demo_rulerInfo.deleteStyle = {'fill'=>'red', - 'stipple'=>'@'+[$demo_dir, 'images', 'gray25.xbm'].join(File::Separator)} + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator)} else $demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''} $demo_rulerInfo.deleteStyle = {'fill'=>'black', - 'stipple'=>'@'+[$demo_dir, 'images', 'gray25.xbm'].join(File::Separator)} + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator)} end TkcLine.new($ruler_canvas, diff --git a/ext/tk/sample/demos-en/search.rb b/ext/tk/sample/demos-en/search.rb index 2b27cdbb42..59a8117bb7 100644 --- a/ext/tk/sample/demos-en/search.rb +++ b/ext/tk/sample/demos-en/search.rb @@ -133,7 +133,7 @@ TkFrame.new($search_demo) {|f| } }.pack('side'=>'top', 'fill'=>'x') -$search_text = TkText.new($search_demo, 'setgrid'=>true) {|t| +$search_text = TkText.new($search_demo, 'setgrid'=>true, 'wrap'=>'word') {|t| $search_Tag = TkTextTag.new(t) TkScrollbar.new($search_demo, 'command'=>proc{|*args| t.yview(*args)}) {|sc| t.yscrollcommand(proc{|first,last| sc.set first,last}) @@ -146,45 +146,33 @@ $search_text = TkText.new($search_demo, 'setgrid'=>true) {|t| if TkWinfo.depth($search_demo) > 1 textToggle(proc{ - begin - $search_Tag.configure('background'=>'#ce5555', - 'foreground'=>'white') - rescue - end + $search_Tag.configure('background'=>'#ce5555', + 'foreground'=>'white') }, 800, proc{ - begin - $search_Tag.configure('background'=>'', 'foreground'=>'') - rescue - end + $search_Tag.configure('background'=>'', 'foreground'=>'') }, 200 ) else textToggle(proc{ - begin - $search_Tag.configure('background'=>'black', - 'foreground'=>'white') - rescue - end + $search_Tag.configure('background'=>'black', + 'foreground'=>'white') }, 800, proc{ - begin - $search_Tag.configure('background'=>'', 'foreground'=>'') - rescue - end + $search_Tag.configure('background'=>'', 'foreground'=>'') }, 200 ) end -$search_text.insert('1.0', '\ -This window demonstrates how to use the tagging facilities in text -widgets to implement a searching mechanism. First, type a file name -in the top entry, then type <Return> or click on "Load File". Then -type a string in the lower entry and type <Return> or click on -"Load File". This will cause all of the instances of the string to -be tagged with the tag "search", and it will arrange for the tag\'s -display attributes to change to make all of the strings blink.') +$search_text.insert('1.0', "\ +This window demonstrates how to use the tagging facilities in text \ +widgets to implement a searching mechanism. First, type a file name \ +in the top entry, then type <Return> or click on \"Load File\". Then \ +type a string in the lower entry and type <Return> or click on \ +\"Load File\". This will cause all of the instances of the string to \ +be tagged with the tag \"search\", and it will arrange for the tag\'s \ +display attributes to change to make all of the strings blink.") $search_text.set_insert '0.0' $search_fileName.value = '' diff --git a/ext/tk/sample/demos-en/style.rb b/ext/tk/sample/demos-en/style.rb index 8bf9c09662..def83d1a2f 100644 --- a/ext/tk/sample/demos-en/style.rb +++ b/ext/tk/sample/demos-en/style.rb @@ -94,7 +94,7 @@ TkText.new($style_demo){|t| 'relief'=>'sunken', 'borderwidth'=>1) end - # テキストタグ設定 (その他) + # if $tk_version =~ /^4\.[01]/ style_tag_bgstipple = TkTextTag.new(t, 'background'=>'black', 'borderwidth'=>0, diff --git a/ext/tk/sample/demos-en/tcolor b/ext/tk/sample/demos-en/tcolor index 6d023f0f8b..5b29797906 100644 --- a/ext/tk/sample/demos-en/tcolor +++ b/ext/tk/sample/demos-en/tcolor @@ -1,30 +1,28 @@ #!/usr/bin/env ruby # # tcolor -- -# このスクリプトはRGB,HSB,CYM形式をサポートする -# 簡易カラーエディタです。 +# simple color editor which supports RGB, HSB and CYM color space # # Copyright (C) 1998 Takaaki Tateishi(ttate@jaist.ac.jp) # last update: Thu Jun 18 06:32:35 JST 1998 # -# まずはtk.rbを読み込む。 - require "tk" -# Tkによって変更される変数はTkVariableのインスタンスを使う。 +# use TkVariable instance for the variable which is changed by Tk interpreter $colorSpace = TkVariable.new(:rgb) +$master = nil $red = 65535 $green = 0 $blue = 0 $color = "#ffff00000000" $updating = TkVariable.new(0) $autoUpdate = TkVariable.new(1) -$name = TkVariable.new("") -# $command = TkVariable.new("print(%%,\"\n\")") -$command = TkVariable.new("") +$name = TkVariable.new($color) +$command = TkVariable.new("print(%%,\"\n\")") +# $command = TkVariable.new("") $label1 = TkVariable.new("label1") $label2 = TkVariable.new("label2") $label3 = TkVariable.new("label3") @@ -36,7 +34,7 @@ if (TkVarAccess.new('tcl_platform')['platform'] == 'unix') end -# 各イベント用のメソッド +# methods for events def rgbToHsv(red,green,blue) @@ -134,6 +132,8 @@ def tc_scaleChanged return end + $master = :scale if $master == nil + scale1 = $root.middle.middle.scale1 scale2 = $root.middle.middle.scale2 scale3 = $root.middle.middle.scale3 @@ -158,11 +158,13 @@ def tc_scaleChanged raise(Exception,"unknown colorSpace") end $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i) + $name.value = $color if $master == :scale $root.middle.right.set_color($color) if( $autoUpdate.to_i == 1 ) doUpdate end - Tk.update(TRUE) + Tk.update(true) + $master = nil if $master == :scale end @@ -196,6 +198,8 @@ end def tc_loadNamedColor(name) + $name.value = name + $master = :name if $master == nil if name[0,1] != "#" list = TkWinfo.rgb($root.middle.right.swatch,name) $red = list[0] @@ -222,9 +226,9 @@ def tc_loadNamedColor(name) if strlist.length != 3 raise(eException,"syntax error in color name \"#{name}\"") end - $red = strlist[0].to_i - $green = strlist[1].to_i - $blue = strlist[2].to_i + $red = strlist[0].hex + $green = strlist[1].hex + $blue = strlist[2].hex } $red = $red << shift $green = $green << shift @@ -237,6 +241,8 @@ def tc_loadNamedColor(name) if $autoUpdate.to_i == 1 doUpdate end + Tk.update(true) + $master = nil if $master == :name end @@ -259,10 +265,7 @@ def changeColorSpace(space) end - - - -# tcolor用のメニュー +# menu class TkColorMenuFrame<TkFrame def initialize(parent) @@ -270,10 +273,10 @@ class TkColorMenuFrame<TkFrame "relief"=>"raised", "borderwidth"=>"2") - # Fileメニューボタンの生成 + # File menubutton @file = TkMenubutton.new(self){|button| - # Fileメニューの作成 + # File menu @file_menu = TkMenu.new(button){ add "radio", "label" => "RGB color space", @@ -311,7 +314,7 @@ class TkColorMenuFrame<TkFrame "command" => proc{exit} } - # FileメニューとFileボタンを関連付ける + # assign File menu to File button menu @file_menu text "File" @@ -323,7 +326,7 @@ class TkColorMenuFrame<TkFrame end -# 下部のフレームのためのクラス +# bottom frame class TkColorBotFrame<TkFrame def initialize(parent) super(parent, @@ -349,7 +352,7 @@ class TkColorBotFrame<TkFrame end -# 中段左のフレーム +# left side frame of middle level class TkColorMiddleLeftFrame<TkFrame def initialize(parent) super(parent) @@ -393,9 +396,8 @@ class TkColorMiddleLeftFrame<TkFrame end -# 中段中央のフレーム +# middle frame of middle level class TkColorMiddleMiddleFrame<TkFrame - # @scale1,@scale2,@scale3を外部から参照のみ許可する。(変更不可) attr_reader :scale1, :scale2, :scale3 def initialize(parent) @@ -470,7 +472,7 @@ end -# 中段のフレーム +# middle level frame class TkColorMiddleFrame<TkFrame attr_reader :left, :middle, :right @@ -513,7 +515,7 @@ end $root = TkColor.new - -# イベントを待つ為にループに入る。 changeColorSpace :rgb + +# start eventloop Tk.mainloop diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget index aa702883de..f529792e78 100644 --- a/ext/tk/sample/demos-en/widget +++ b/ext/tk/sample/demos-en/widget @@ -10,12 +10,7 @@ # as needed. require 'tk' - -#unless /^8\.[1-9]/ =~ Tk::TCL_VERSION && !Tk::JAPANIZED_TK -# require 'tkencoding' -#end - -require 'tkafter' +# require 'tkafter' ### $DEBUG=1 ########## @@ -33,12 +28,78 @@ $root = TkRoot.new{title "Ruby/Tk Widget Demonstration"} # tk $tk_version = Tk::TK_VERSION +$tk_major_ver, $tk_minor_ver = $tk_version.split('.').map{|n| n.to_i} +$tk_patchlevel = Tk::TK_PATCHLEVEL # tcl_platform $tk_platform = TkVarAccess.new('tcl_platform') # -$font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) +case($tk_version) +when /^4.*/ + $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) +else + $font = TkFont.new('Helvetica -12') +end + +# images +$image = {} + +if $tk_major_ver >= 8 +$image['refresh'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAQAPMAAMz/zCpnKdb/1z9mPypbKBtLGy9NMPL/9Or+6+P+4j1Y + PwQKBP7//xMLFAYBCAEBASH5BAEAAAAALAAAAAAQABAAAwR0EAD3Gn0Vyw0e + ++CncU7IIAezMA/nhUqSLJizvSdCEEjy2ZIV46AwDAoDHwPYGSoEiUJAAGJ6 + EDHBNCFINW5OqABKSFk/B9lUa94IDwIFgewFMwQDQwCZQCztTgM9Sl8SOEMG + KSAthiaOjBMPDhQONBiXABEAOw== +EOD +end + +if $tk_major_ver >= 8 +$image['view'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAQAPMAAMz/zP///8DAwICAgH9/fwAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAwRIcMhJB7h3hM33 + KFjWdQQYap1QrCaGBmrRrS4nj5b53jOgbwXBKGACoYLDIuAoHCmZyYvR1rT5 + RMAq8LqcIYGsrjPsW1XOmFUEADs= +EOD +end + +if $tk_major_ver >= 8 +$image['delete'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAOAKEAAIQAAO/n3v///////yH5BAEKAAIALAAAAAAQAA4AAAIm + lI9pAKHbIHNoVhYhTdjlJ2AWKG2g+CldmB6rxo2uybYhbS80eRQAOw== +EOD +end + +if $tk_major_ver >= 8 +$image['print'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AAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAACH5BAEAAEEALAAAAAAaABMAQAj/AIMIHBhkg0GC + CBMGIQEiQgseQT4oeCBBAokgRYYQ0JBixg8hRIiUUEBBYYmTByBwiCBCRYwH + CxY8cKFw4AogRXLqLAJkQ80gCBBg3BkxZswTNGh4MGqgQQUMJRHCwMkTSE+D + Pn8eCKBhxIMhO3ei2OHDBw6sWSlMMMoWgwwfMDZI8GBjx44NARZwEGGi5MkS + PcIWKRGz5YgLbAco+KkQBQoJIRgjdGEVq+SaJajqtNrzMgsPCmoIzqmDgmWE + KOBuUKAAwYabYTfs4OHjY0giGyhk4MAWRI4eKyRQqPgggYUXPH4A+XBAgwoK + DiIsCFxjA9sFEVQQCRJCAYAFDJxiKhAxvMTonEFimrhhYinTBgWiCvxLNX3M + DkkpsKV5OYhjBxCMYAICAigUEAA7 +EOD +end # TkMenubar.new($root, @@ -48,6 +109,7 @@ TkMenubar.new($root, ['Quit', proc{exit}, 0, 'Meta-Q'] ]]).pack('side'=>'top', 'fill'=>'x') $root.bind('F1', proc{aboutBox}) +$root.bind('Meta-q', proc{exit}) =begin TkFrame.new($root){|frame| @@ -67,7 +129,7 @@ if $tk_version =~ /^4\.[01]/ scr = TkScrollbar.new($root, 'orient'=>'vertical') txt = TkText.new($root) { wrap 'word' - width 60 + width 70 height 30 font $font setgrid 'yes' @@ -84,7 +146,7 @@ else } txt = TkText.new($root) { wrap 'word' - width 60 + width 70 height 30 font $font setgrid 'yes' @@ -92,6 +154,7 @@ else padx 4 pady 2 takefocus 0 + bd 1 yscrollcommand proc{|first,last| scr.set first,last} } scr.command(proc{|*args| txt.yview(*args)}) @@ -123,7 +186,7 @@ tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*- tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c') -if TkWinfo.depth($root) == '1' +if TkWinfo.depth($root) == 1 tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', 'underline'=>1) $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', @@ -206,21 +269,25 @@ txt.insert('end', "3. Buttons.\n", tag_demo, "demo-button") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. Checkbuttons (select any of a group).\n", tag_demo, "demo-check") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "5. Radiobuttons (select one of a group).\n", tag_demo, "demo-radio") +txt.insert('end', "5. Checkbuttons (if supported).\n", tag_demo, "demo-check2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. Radiobuttons (select one of a group).\n", tag_demo, "demo-radio") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "6. Radiobuttons (if supported 'compound' option).\n", tag_demo, "demo-radio2") +txt.insert('end', "7. Radiobuttons (if supported 'compound' option).\n", tag_demo, "demo-radio2") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "7. A 15-puzzle game made out of buttons.\n", tag_demo, "demo-puzzle") +txt.insert('end', "8. Radiobuttons (if supported).\n", tag_demo, "demo-radio3") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "8. Iconic buttons that use bitmaps.\n", tag_demo, "demo-icon") +txt.insert('end', "9. A 15-puzzle game made out of buttons.\n", tag_demo, "demo-puzzle") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "9. Two labels displaying images.\n", tag_demo, "demo-image1") +txt.insert('end', "10. Iconic buttons that use bitmaps.\n", tag_demo, "demo-icon") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "10. A simple user interface for viewing images.\n", tag_demo, "demo-image2") +txt.insert('end', "11. Two labels displaying images.\n", tag_demo, "demo-image1") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "11. A simple user interface for viewing images. (if supported)\n", tag_demo, "demo-image3") +txt.insert('end', "12. A simple user interface for viewing images.\n", tag_demo, "demo-image2") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "12. Labelled frames (if supported)\n", tag_demo, "demo-labelframe") +txt.insert('end', "13. A simple user interface for viewing images. (if supported)\n", tag_demo, "demo-image3") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "14. Labelled frames (if supported)\n", tag_demo, "demo-labelframe") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -260,7 +327,9 @@ txt.insert('end', "3. Hypertext (tag bindings).\n", tag_demo, "demo-bind") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. A text widget with embedded windows.\n", tag_demo, "demo-twind") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "5. A search tool built with a text widget.\n", tag_demo, "demo-search") +txt.insert('end', "5. A text widget with embedded windows. (if supported)\n", tag_demo, "demo-twind2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. A search tool built with a text widget.\n", tag_demo, "demo-search") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -278,7 +347,9 @@ txt.insert('end', "5. A ruler with adjustable tab stops.\n", tag_demo, "demo-rul txt.insert('end', " \n ", tag_demospace) txt.insert('end', "6. A building floor plan.\n", tag_demo, "demo-floor") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "7. A simple scrollable canvas.\n", tag_demo, "demo-cscroll") +txt.insert('end', "7. A building floor plan. (another way to create canvas items)\n", tag_demo, "demo-floor2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "8. A simple scrollable canvas.\n", tag_demo, "demo-cscroll") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -350,7 +421,7 @@ end # args - Any number of names of variables. $showVarsWin = {} -def showVars (parent, *args) +def showVars1(parent, *args) if $showVarsWin[parent.path] begin $showVarsWin[parent.path].destroy @@ -385,11 +456,54 @@ def showVars (parent, *args) $showVarsWin[parent.path] = w end +def showVars2(parent, *args) + if $showVarsWin[parent.path] + begin + $showVarsWin[parent.path].destroy + rescue + end + end + $showVarsWin[parent.path] = TkToplevel.new(parent) {|w| + title "Variable values" + + TkLabelFrame.new(w, :text=>"Variable values:", + :font=>{:family=>'Helvetica', :size=>14}){|f| + args.each{|vnam,vbody| + TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'), + TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'), + :padx=>2, :pady=>2, :sticky=>'w') + } + + f.grid(:sticky=>'news', :padx=>4) + f.grid_columnconfig(1, :weight=>1) + f.grid_rowconfig(100, :weight=>1) + } + TkButton.new(w, :text=>"OK", :width=>8, :default=>:active, + :command=>proc{w.destroy}){|b| + w.bind('Return', proc{b.invoke}) + w.bind('Escape', proc{b.invoke}) + + b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4]) + } + w.grid_columnconfig(0, :weight=>1) + w.grid_rowconfig(0, :weight=>1) + } +end + +if $tk_major_ver < 8 + alias showVars showVars1 +elsif $tk_major_ver == 8 && $tk_minor_ver < 5 + alias showVars showVars1 +else # ver >= 8.5 + alias showVars showVars2 +end + # invoke -- # This procedure is called when the user clicks on a demo description. # It is responsible for invoking the demonstration. # # Arguments: +# txt - Name of text widget # index - The index of the character that the user clicked on. def invoke (txt, index) @@ -399,7 +513,8 @@ def invoke (txt, index) txt.cursor('watch') Tk.update # eval `cat #{tag[5..-1]}.rb` - eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb` +# eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb` + eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join Tk.update # txt.cursor('xterm') txt.cursor(cursor) @@ -433,13 +548,13 @@ end # a demonstration and allows it to be edited and reinvoked. # # Arguments: -# w - The name of the demonstration's window, which can be +# demo - The name of the demonstration's window, which can be # used to derive the name of the file containing its code. -def showCode (demo) +def showCode1(demo) file = "#{demo}.rb" $code_window = nil unless defined? $code_window - if $code_window == nil || TkWinfo.exist?($code_window) == '0' + if $code_window == nil || TkWinfo.exist?($code_window) == false $code_window = TkToplevel.new(nil) f = TkFrame.new($code_window) TkButton.new(f) { @@ -516,16 +631,192 @@ def showCode (demo) fid.close end +def showCode2(demo) + file = "#{demo}.rb" + $code_window = nil unless defined? $code_window + if $code_window == nil || TkWinfo.exist?($code_window) == false + $code_window = TkToplevel.new(nil) + tf = TkFrame.new($code_window) + $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30, + :wrap=>'word', :bd=>1, :setgrid=>true, + :highlightthickness=>0, :pady=>2, :padx=>3) + xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} + yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} + TkGrid($code_text, yscr, :sticky=>'news') + #TkGrid(xscr) + tf.grid_rowconfigure(0, :weight=>1) + tf.grid_columnconfigure(0, :weight=>1) + + bf = TkFrame.new($code_window) + + b_dis = TkButton.new(bf, :text=>'Dismiss', :default=>:active, + :command=>proc{ + $code_window.destroy + $code_window = nil + }, + :image=>$image['delete'], :compound=>:left) + b_prn = TkButton.new(bf, :text=>'Print Code', + :command=>proc{printCode($code_text, file)}, + :image=>$image['print'], :compound=>:left) + b_run = TkButton.new(bf, :text=>'Rerun Demo', + :command=>proc{eval($code_text.get('1.0','end'))}, + :image=>$image['refresh'], :compound=>:left) + + TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4]) + bf.grid_columnconfigure(0, :weight=>1) + + TkGrid(tf, :sticky=>'news') + TkGrid(bf, :sticky=>'ew') + $code_window.grid_columnconfigure(0, :weight=>1) + $code_window.grid_rowconfigure(0, :weight=>1) + + $code_window.bind('Return', proc{|win| + b_dis.invoke unless win.kind_of?(TkText) + }, '%W') + $code_window.bindinfo('Return').each{|cmd, arg| + $code_window.bind_append('Escape', cmd, arg) + } + else + $code_window.deiconify + $code_window.raise + end + + $code_window.title("Demo code: #{file}") + $code_window.iconname(file) + fid = open([$demo_dir, file].join(File::Separator), 'r') + $code_text.delete('1.0', 'end') + $code_text.insert('1.0', fid.read) + TkTextMarkInsert.new($code_text,'1.0') + fid.close +end + +if $tk_major_ver < 8 + alias showCode showCode1 +elsif $tk_major_ver == 8 && $tk_minor_ver < 5 + alias showCode showCode1 +else # ver >= 8.5 + alias showCode showCode2 +end + + +# printCode -- +# Prints the source code currently displayed in the See Code dialog. +# Much thanks to Arjen Markus for this. +# +# Arguments: +# txt - Name of text widget containing code to print +# file - Name of the original file (implicitly for title) + +def printCode(txt, file) + code = txt.get('1.0', 'end - 1c') + dir = '.' + dir = ENV['HOME'] if ENV['HOME'] + dir = ENV['TMP'] if ENV['TMP'] + dir = ENV['TEMP'] if ENV['TEMP'] + + fname = [dir, 'tkdemo-' + file].join(File::Separator) + open(fname, 'w'){|fid| fid.print(code)} + begin + case Tk::TCL_PLATFORM('platform') + when 'unix' + msg = `lp -c #{fname}` + unless $?.exitstatus == 0 + Tk.messageBox(:title=>'Print spooling failure', + :message=>'Print spooling probably failed: ' + msg) + end + when 'windows' + begin + printTextWin32(fname) + rescue => e + Tk.messageBox(:title=>'Print spooling failure', + :message=>'Print spooling probably failed: ' + + e.message) + end + when 'macintosh' + Tk.messageBox(:title=>'Operation not Implemented', + :message=>'Oops, sorry: not implemented yet!') + else + Tk.messageBox(:title=>'Operation not Implemented', + :message=>'Wow! Unknown platform: ' + + Tk::TCL_PLATFORM('platform')) + end + ensure + File.delete(fname) + end +end + +# printTextWin32 -- +# Print a file under Windows +# +# Arguments: +# filename - Name of the file +# +def printTextWin32(fname) + require 'win32/registry' + begin + app = Win32::Registry::HKEY_CLASSES_ROOT['.txt'] + pcmd = nil + Win32::Registry::HKEY_CLASSES_ROOT.open("#{app}\\shell\\print"){|reg| + pcmd = reg['command'] + } + rescue + app = Tk.tk_call('auto_execok', 'notepad.exe') + pcmd = "#{app} /p %1" + end + + pcmd.gsub!('%1', fname) + puts pcmd + cmd = Tk.tk_call('auto_execok', 'start') + ' /min ' + pcmd + + msg = `#{cmd}` + unless $?.exitstatus == 0 + fail RuntimeError, msg + end +end + # aboutBox # # Pops up a message box with an "about" message # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk widget demonstration Ver.1.3.2-en\n\n( based on Tk 8.1 Copyright (c) 1996-1997 Sun Microsystems, Inc. )\n\nRunning Version :: Ruby#{VERSION}/Tk#{$tk_version}") + 'message'=>"Ruby/Tk widget demonstration Ver.1.4.3-en\n\n" + + "based on demos of Tk8.1 -- 8.5 " + + "( Copyright:: " + + "(c) 1996-1997 Sun Microsystems, Inc. / " + + "(c) 1997-2000 Ajuba Solutions, Inc. / " + + "(c) 2001-2003 Donal K. Fellows )\n\n" + + "Your Ruby & Tk Version ::\n" + + "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}") end -################################ +######################################### +# start demos if given at command line +no_launcher = false +if ARGV[0] == '-n' + ARGV.shift + no_launcher = true if ARGV.size > 0 +end +ARGV.each{|cmd| + if cmd =~ /(.*).rb/ + cmd = $1 + end + eval IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join +} +if no_launcher + $root.withdraw # hide root window + Thread.start{ + loop do + count = 0 + $root.winfo_children.each{|w| + count += 1 if w.kind_of?(TkToplevel) + } + $root.destroy if count == 0 + end + } +end +######################################### +# start eventloop Tk.mainloop diff --git a/ext/tk/sample/demos-jp/arrow.rb b/ext/tk/sample/demos-jp/arrow.rb index 3640798db1..70fe346b65 100644 --- a/ext/tk/sample/demos-jp/arrow.rb +++ b/ext/tk/sample/demos-jp/arrow.rb @@ -104,7 +104,8 @@ TkLabel.new($arrow_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', # frame 生成 $arrow_buttons = TkFrame.new($arrow_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $arrow_demo $arrow_demo = nil @@ -146,7 +147,7 @@ if TkWinfo.depth($arrow_canvas) > 1 $demo_arrowInfo.activeStyle = {'fill'=>'red', 'outline'=>'black', 'width'=>1} else $demo_arrowInfo.bigLineStyle = {'fill'=>'black', - 'stipple'=>'@'+[$demo_dir, 'images', 'grey.25'].join(File::Separator)} + 'stipple'=>'@'+[$demo_dir,'..','images','grey.25'].join(File::Separator)} $demo_arrowInfo.boxStyle = {'fill'=>'', 'outline'=>'black', 'width'=>1} $demo_arrowInfo.activeStyle = {'fill'=>'black','outline'=>'black','width'=>1} end diff --git a/ext/tk/sample/demos-jp/bind.rb b/ext/tk/sample/demos-jp/bind.rb index 1f221a6293..eebd62fc09 100644 --- a/ext/tk/sample/demos-jp/bind.rb +++ b/ext/tk/sample/demos-jp/bind.rb @@ -18,7 +18,8 @@ $bind_demo = TkToplevel.new {|w| # frame 生成 TkFrame.new($bind_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $bind_demo $bind_demo = nil diff --git a/ext/tk/sample/demos-jp/bitmap.rb b/ext/tk/sample/demos-jp/bitmap.rb index a400862881..644b960815 100644 --- a/ext/tk/sample/demos-jp/bitmap.rb +++ b/ext/tk/sample/demos-jp/bitmap.rb @@ -46,7 +46,8 @@ TkLabel.new($bitmap_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', # frame 生成 $bitmap_buttons = TkFrame.new($bitmap_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $bitmap_demo $bitmap_demo = nil diff --git a/ext/tk/sample/demos-jp/browse2 b/ext/tk/sample/demos-jp/browse2 index 304a5f547e..edad04dbcb 100644 --- a/ext/tk/sample/demos-jp/browse2 +++ b/ext/tk/sample/demos-jp/browse2 @@ -39,11 +39,11 @@ class Browse } # Set up bindings for the browser. - base.bind('Control-c', - proc{ - base.destroy + base.bind('Destroy', proc{ Browse::BROWSE_WIN_COUNTER.value = \ - Browse::BROWSE_WIN_COUNTER.to_i - 1}) + Browse::BROWSE_WIN_COUNTER.to_i - 1 + }) + base.bind('Control-c', proc{base.destroy}) list.bind('Double-Button-1', proc{TkSelection.get.each{|f| self.browse dir, f}}) end diff --git a/ext/tk/sample/demos-jp/button.rb b/ext/tk/sample/demos-jp/button.rb index 33247261f2..20f8cae299 100644 --- a/ext/tk/sample/demos-jp/button.rb +++ b/ext/tk/sample/demos-jp/button.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 $button_buttons = TkFrame.new($button_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $button_demo $button_demo = nil diff --git a/ext/tk/sample/demos-jp/check.rb b/ext/tk/sample/demos-jp/check.rb index 50c21fac0e..88e90c71d0 100644 --- a/ext/tk/sample/demos-jp/check.rb +++ b/ext/tk/sample/demos-jp/check.rb @@ -20,7 +20,7 @@ msg = TkLabel.new($check_demo) { font $font wraplength '4i' justify 'left' - text "下には 3 つのチェックボタンが表示されています。クリックするとボタンの選択状態が変わり、Tcl 変数にそのボタンの状態を示す値を設定します。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" + text "下には 3 つのチェックボタンが表示されています。クリックするとボタンの選択状態が変わり、Tcl 変数 ( TkVariable オブジェクトでアクセスできます ) にそのボタンの状態を示す値を設定します。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" } msg.pack('side'=>'top') @@ -32,7 +32,8 @@ sober = TkVariable.new(0) # frame 生成 TkFrame.new($check_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $check_demo $check_demo = nil @@ -61,6 +62,6 @@ TkFrame.new($check_demo) {|frame| # checkbutton 生成 [ TkCheckButton.new($check_demo, 'text'=>'ワイパー OK', 'variable'=>wipers), TkCheckButton.new($check_demo, 'text'=>'ブレーキ OK', 'variable'=>brakes), - TkCheckButton.new($check_demo, 'text'=>'ドライバー素面', 'variable'=>sober) + TkCheckButton.new($check_demo, 'text'=>'運転手 素面', 'variable'=>sober) ].each{|w| w.relief('flat'); w.pack('side'=>'top', 'pady'=>2, 'anchor'=>'w')} diff --git a/ext/tk/sample/demos-jp/clrpick.rb b/ext/tk/sample/demos-jp/clrpick.rb index 55cfd9c7c6..284611a774 100644 --- a/ext/tk/sample/demos-jp/clrpick.rb +++ b/ext/tk/sample/demos-jp/clrpick.rb @@ -22,7 +22,8 @@ TkLabel.new($clrpick_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', # frame 生成 TkFrame.new($clrpick_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $clrpick_demo $clrpick_demo = nil diff --git a/ext/tk/sample/demos-jp/colors.rb b/ext/tk/sample/demos-jp/colors.rb index f9a5983e75..c6128f9c00 100644 --- a/ext/tk/sample/demos-jp/colors.rb +++ b/ext/tk/sample/demos-jp/colors.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($colors_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $colors_demo $colors_demo = nil diff --git a/ext/tk/sample/demos-jp/cscroll.rb b/ext/tk/sample/demos-jp/cscroll.rb index 7f5ffa2f02..d128b63a7b 100644 --- a/ext/tk/sample/demos-jp/cscroll.rb +++ b/ext/tk/sample/demos-jp/cscroll.rb @@ -24,7 +24,8 @@ TkLabel.new($cscroll_demo, 'font'=>$font, 'wraplength'=>'4i', # frame 生成 $cscroll_buttons = TkFrame.new($cscroll_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $cscroll_demo $cscroll_demo = nil diff --git a/ext/tk/sample/demos-jp/ctext.rb b/ext/tk/sample/demos-jp/ctext.rb index 6d9355e2f8..4704b41411 100644 --- a/ext/tk/sample/demos-jp/ctext.rb +++ b/ext/tk/sample/demos-jp/ctext.rb @@ -30,7 +30,8 @@ TkLabel.new($ctext_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', # frame 生成 $ctext_buttons = TkFrame.new($ctext_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $ctext_demo $ctext_demo = nil diff --git a/ext/tk/sample/demos-jp/dialog1.rb b/ext/tk/sample/demos-jp/dialog1.rb index 5b578a981d..0d6181bfc6 100644 --- a/ext/tk/sample/demos-jp/dialog1.rb +++ b/ext/tk/sample/demos-jp/dialog1.rb @@ -34,5 +34,5 @@ when 0 when 1 print "あなたは「キャンセル」を押しましたね。\n" when 2 - showCode dialog1 + showCode 'dialog1' end diff --git a/ext/tk/sample/demos-jp/dialog2.rb b/ext/tk/sample/demos-jp/dialog2.rb index 4819f18a03..36b2356cc1 100644 --- a/ext/tk/sample/demos-jp/dialog2.rb +++ b/ext/tk/sample/demos-jp/dialog2.rb @@ -37,6 +37,6 @@ when 0 when 1 print "あなたは「キャンセル」を押しましたね。\n" when 2 - showCode dialog2 + showCode 'dialog2' end diff --git a/ext/tk/sample/demos-jp/entry1.rb b/ext/tk/sample/demos-jp/entry1.rb index 273b6728df..edf3b5f71d 100644 --- a/ext/tk/sample/demos-jp/entry1.rb +++ b/ext/tk/sample/demos-jp/entry1.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($entry1_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $entry1_demo $entry1_demo = nil diff --git a/ext/tk/sample/demos-jp/entry2.rb b/ext/tk/sample/demos-jp/entry2.rb index 7efac005f0..7d5740e663 100644 --- a/ext/tk/sample/demos-jp/entry2.rb +++ b/ext/tk/sample/demos-jp/entry2.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($entry2_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $entry2_demo $entry2_demo = nil diff --git a/ext/tk/sample/demos-jp/entry3.rb b/ext/tk/sample/demos-jp/entry3.rb index 9bf3f62097..f0e9bc868b 100644 --- a/ext/tk/sample/demos-jp/entry3.rb +++ b/ext/tk/sample/demos-jp/entry3.rb @@ -41,7 +41,7 @@ EOL TkFrame.new($entry3_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') - TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{ + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ $entry3_demo.destroy $entry3_demo = nil }).pack(:side=>:left, :expand=>true) @@ -161,6 +161,8 @@ def validatePhoneChange(widget, vmode, idx, char) widget.delete(idx) widget.insert(idx, $phoneNumberMap[char] || char) Tk.after_idle(proc{phoneSkipRight(widget, -1)}) + # Tk.update(true) # Don't work 'update' inter validation callback. + # It depends on Tcl/Tk side (tested on Tcl/Tk8.5a1). return true end return false diff --git a/ext/tk/sample/demos-jp/filebox.rb b/ext/tk/sample/demos-jp/filebox.rb index 1754596706..78ae50a45b 100644 --- a/ext/tk/sample/demos-jp/filebox.rb +++ b/ext/tk/sample/demos-jp/filebox.rb @@ -22,7 +22,8 @@ TkLabel.new($filebox_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left', # frame 生成 TkFrame.new($filebox_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $filebox_demo $filebox_demo = nil diff --git a/ext/tk/sample/demos-jp/floor.rb b/ext/tk/sample/demos-jp/floor.rb index bb655d5b55..d9d17ee949 100644 --- a/ext/tk/sample/demos-jp/floor.rb +++ b/ext/tk/sample/demos-jp/floor.rb @@ -1595,7 +1595,8 @@ TkLabel.new($floor_demo, 'font'=>$font, 'wraplength'=>'8i', 'justify'=>'left', # frame 生成 $floor_buttons = TkFrame.new($floor_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $floor_demo $floor_demo = nil diff --git a/ext/tk/sample/demos-jp/form.rb b/ext/tk/sample/demos-jp/form.rb index 35baeed46b..fe456d3943 100644 --- a/ext/tk/sample/demos-jp/form.rb +++ b/ext/tk/sample/demos-jp/form.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top', 'fill'=>'x') # frame 生成 TkFrame.new($form_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $form_demo $form_demo = nil diff --git a/ext/tk/sample/demos-jp/hscale.rb b/ext/tk/sample/demos-jp/hscale.rb index 4333239c73..37d215435c 100644 --- a/ext/tk/sample/demos-jp/hscale.rb +++ b/ext/tk/sample/demos-jp/hscale.rb @@ -24,7 +24,8 @@ msg.pack('side'=>'top') TkFrame.new($hscale_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc { tmppath = $hscale_demo $hscale_demo = nil diff --git a/ext/tk/sample/demos-jp/icon.rb b/ext/tk/sample/demos-jp/icon.rb index 9b39d33847..3180787dac 100644 --- a/ext/tk/sample/demos-jp/icon.rb +++ b/ext/tk/sample/demos-jp/icon.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($icon_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $icon_demo $icon_demo = nil @@ -44,15 +45,16 @@ TkFrame.new($icon_demo) {|frame| # image 生成 flagup = \ -TkBitmapImage.new('file'=>[$demo_dir, - 'images','flagup.bmp'].join(File::Separator), +TkBitmapImage.new('file'=>[$demo_dir,'..', + 'images','flagup.xbm'].join(File::Separator), 'maskfile'=>\ - [$demo_dir,'images','flagup.bmp'].join(File::Separator)) + [$demo_dir,'..','images','flagup.xbm'].join(File::Separator)) flagdown = \ -TkBitmapImage.new('file'=>[$demo_dir, - 'images','flagdown.bmp'].join(File::Separator), +TkBitmapImage.new('file'=>[$demo_dir,'..', + 'images','flagdown.xbm'].join(File::Separator), 'maskfile'=>\ - [$demo_dir,'images','flagdown.bmp'].join(File::Separator)) + [$demo_dir,'..', + 'images','flagdown.xbm'].join(File::Separator)) # 変数生成 letters = TkVariable.new @@ -61,13 +63,15 @@ letters = TkVariable.new TkFrame.new($icon_demo, 'borderwidth'=>10){|w| TkFrame.new(w) {|f| TkRadioButton.new(f){ - bitmap '@' + [$demo_dir,'images','letters.bmp'].join(File::Separator) + bitmap '@' + [$demo_dir,'..', + 'images','letters.xbm'].join(File::Separator) variable letters value 'full' }.pack('side'=>'top', 'expand'=>'yes') TkRadioButton.new(f){ - bitmap '@' + [$demo_dir,'images','noletter.bmp'].join(File::Separator) + bitmap '@' + [$demo_dir,'..', + 'images','noletter.xbm'].join(File::Separator) variable letters value 'empty' }.pack('side'=>'top', 'expand'=>'yes') @@ -82,7 +86,8 @@ TkFrame.new($icon_demo, 'borderwidth'=>10){|w| }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m') TkCheckButton.new(w) { - bitmap '@' + [$demo_dir,'images','letters.bmp'].join(File::Separator) + bitmap '@' + [$demo_dir,'..', + 'images','letters.xbm'].join(File::Separator) indicatoron 0 selectcolor 'SeaGreen1' }.pack('side'=>'left', 'expand'=>'yes', 'padx'=>'5m') diff --git a/ext/tk/sample/demos-jp/image1.rb b/ext/tk/sample/demos-jp/image1.rb index bfe47c47af..3d47f844e5 100644 --- a/ext/tk/sample/demos-jp/image1.rb +++ b/ext/tk/sample/demos-jp/image1.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($image1_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $image1_demo $image1_demo = nil @@ -44,10 +45,10 @@ TkFrame.new($image1_demo) {|frame| # image 生成 image1a = \ -TkPhotoImage.new('file'=>[$demo_dir, +TkPhotoImage.new('file'=>[$demo_dir,'..', 'images','earth.gif'].join(File::Separator)) image1b = \ -TkPhotoImage.new('file'=>[$demo_dir, +TkPhotoImage.new('file'=>[$demo_dir,'..', 'images','earthris.gif'].join(File::Separator)) # label 生成 diff --git a/ext/tk/sample/demos-jp/image2.rb b/ext/tk/sample/demos-jp/image2.rb index 07f9b17ebe..e2e2a2b036 100644 --- a/ext/tk/sample/demos-jp/image2.rb +++ b/ext/tk/sample/demos-jp/image2.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($image2_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $image2_demo $image2_demo = nil @@ -43,7 +44,7 @@ TkFrame.new($image2_demo) {|frame| }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # 変数生成 -$dirName = TkVariable.new([$demo_dir,'images'].join(File::Separator)) +$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator)) # image 生成 $image2a = TkPhotoImage.new diff --git a/ext/tk/sample/demos-jp/image3.rb b/ext/tk/sample/demos-jp/image3.rb index 84257a2b32..d42650f45f 100644 --- a/ext/tk/sample/demos-jp/image3.rb +++ b/ext/tk/sample/demos-jp/image3.rb @@ -20,29 +20,29 @@ $image3_demo = TkToplevel.new {|w| } # -def loadDir(w) +def loadDir3(w) w.delete(0,'end') Dir.glob([$dirName,'*'].join(File::Separator)).sort.each{|f| w.insert('end',File.basename(f)) } end -# selectAndLoadDir -- +# selectAndLoadDir3 -- # This procedure pops up a dialog to ask for a directory to load into # the listobx and (if the user presses OK) reloads the directory # listbox from the directory named in the demo's entry. # # Arguments: # w - Name of the toplevel window of the demo. -def selectAndLoadDir(w, lbox) +def selectAndLoadDir3(w, lbox) dir = Tk.chooseDirectory(:initialdir=>$dirName, :parent=>w, :mustexist=>true) if dir.length > 0 $dirName.value = dir - loadDir(lbox) + loadDir3(lbox) end end -def loadImage(w,x,y) +def loadImage3(w,x,y) $image3a.file([$dirName, w.get("@#{x},#{y}")].join(File::Separator)) end @@ -59,7 +59,8 @@ msg.pack('side'=>'top') # frame TkFrame.new($image3_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $image3_demo $image3_demo = nil @@ -75,7 +76,7 @@ TkFrame.new($image3_demo) {|frame| }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') # variable -$dirName = TkVariable.new([$demo_dir,'images'].join(File::Separator)) +$dirName = TkVariable.new([$demo_dir,'..','images'].join(File::Separator)) # image begin @@ -96,16 +97,16 @@ image3_lbx = TkListbox.new(image3_ff, :width=>20, :height=>10) { yscrollbar(TkScrollbar.new(image3_ff).pack(:side=>:left, :fill=>:y, :expand=>true)) insert(0, *(%w(earth.gif earthris.gif teapot.ppm))) - bind('Double-1', proc{|x,y| loadImage(self, x, y)}, '%x %y') + bind('Double-1', proc{|x,y| loadImage3(self, x, y)}, '%x %y') } image3_ent = TkEntry.new(image3_df, :width=>30, :textvariable=>$dirName){ pack(:side=>:left, :fill=>:both, :padx=>'2m', :pady=>'2m', :expand=>true) - bind('Return', proc{loadDir(image3_lbx)}) + bind('Return', proc{loadDir3(image3_lbx)}) } TkButton.new(image3_df, :pady=>0, :padx=>'2m', :text=>"ディレクトリ選択", - :command=>proc{selectAndLoadDir(image3_ent, image3_lbx)}) { + :command=>proc{selectAndLoadDir3(image3_ent, image3_lbx)}) { pack(:side=>:left, :fill=>:y, :padx=>[0, '2m'], :pady=>'2m') } diff --git a/ext/tk/sample/demos-jp/images/earth.gif b/ext/tk/sample/demos-jp/images/earth.gif Binary files differdeleted file mode 100644 index 3ae4a9ce01..0000000000 --- a/ext/tk/sample/demos-jp/images/earth.gif +++ /dev/null diff --git a/ext/tk/sample/demos-jp/images/earthris.gif b/ext/tk/sample/demos-jp/images/earthris.gif Binary files differdeleted file mode 100644 index 48f08c4421..0000000000 --- a/ext/tk/sample/demos-jp/images/earthris.gif +++ /dev/null diff --git a/ext/tk/sample/demos-jp/images/face.bmp b/ext/tk/sample/demos-jp/images/face.bmp deleted file mode 100644 index 03d829f4d1..0000000000 --- a/ext/tk/sample/demos-jp/images/face.bmp +++ /dev/null @@ -1,173 +0,0 @@ -#define face_width 108 -#define face_height 144 -#define face_x_hot 48 -#define face_y_hot 80 -static char face_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x09, - 0x20, 0x80, 0x24, 0x05, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x88, - 0x24, 0x20, 0x80, 0x24, 0x00, 0x00, 0x00, 0x10, 0x80, 0x04, 0x00, 0x01, - 0x00, 0x01, 0x40, 0x0a, 0x09, 0x00, 0x92, 0x04, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x40, 0x12, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x84, - 0x24, 0x40, 0x22, 0xa8, 0x02, 0x14, 0x84, 0x92, 0x40, 0x42, 0x12, 0x04, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x52, 0x11, 0x00, 0x12, 0x00, - 0x40, 0x02, 0x00, 0x20, 0x00, 0x08, 0x00, 0xaa, 0x02, 0x54, 0x85, 0x24, - 0x00, 0x10, 0x12, 0x00, 0x00, 0x81, 0x44, 0x00, 0x90, 0x5a, 0x00, 0xea, - 0x1b, 0x00, 0x80, 0x40, 0x40, 0x02, 0x00, 0x08, 0x00, 0x20, 0xa2, 0x05, - 0x8a, 0xb4, 0x6e, 0x45, 0x12, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10, 0x02, - 0xa8, 0x92, 0x00, 0xda, 0x5f, 0x10, 0x00, 0x10, 0xa1, 0x04, 0x20, 0x41, - 0x02, 0x00, 0x5a, 0x25, 0xa0, 0xff, 0xfb, 0x05, 0x41, 0x02, 0x04, 0x00, - 0x00, 0x08, 0x40, 0x80, 0xec, 0x9b, 0xec, 0xfe, 0x7f, 0x01, 0x04, 0x20, - 0x90, 0x02, 0x04, 0x00, 0x08, 0x20, 0xfb, 0x2e, 0xf5, 0xff, 0xff, 0x57, - 0x00, 0x04, 0x02, 0x00, 0x00, 0x20, 0x01, 0xc1, 0x6e, 0xab, 0xfa, 0xff, - 0xff, 0x05, 0x90, 0x20, 0x48, 0x02, 0x00, 0x04, 0x20, 0xa8, 0xdf, 0xb5, - 0xfe, 0xff, 0xff, 0x0b, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x04, 0xe0, - 0xbb, 0xef, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x04, 0x48, 0x02, 0x00, 0x20, - 0x80, 0xf4, 0x6f, 0xfb, 0xff, 0xff, 0xff, 0x20, 0x90, 0x40, 0x02, 0x00, - 0x00, 0x04, 0x08, 0xb8, 0xf6, 0xff, 0xff, 0xdf, 0xbe, 0x12, 0x45, 0x10, - 0x90, 0x04, 0x90, 0x00, 0x22, 0xfa, 0xff, 0xff, 0xff, 0xbb, 0xd7, 0xe9, - 0x3a, 0x02, 0x02, 0x00, 0x04, 0x90, 0x80, 0xfe, 0xdf, 0xf6, 0xb7, 0xef, - 0xbe, 0x56, 0x57, 0x40, 0x48, 0x09, 0x00, 0x04, 0x00, 0xfa, 0xf5, 0xdf, - 0xed, 0x5a, 0xd5, 0xea, 0xbd, 0x09, 0x00, 0x00, 0x40, 0x00, 0x92, 0xfe, - 0xbf, 0x7d, 0xb7, 0x6a, 0x55, 0xbf, 0xf7, 0x02, 0x11, 0x01, 0x00, 0x91, - 0x00, 0xff, 0xff, 0xaf, 0x55, 0x55, 0x5b, 0xeb, 0xef, 0x22, 0x04, 0x04, - 0x04, 0x00, 0xa4, 0xff, 0xf7, 0xad, 0xaa, 0xaa, 0xaa, 0xbe, 0xfe, 0x03, - 0x20, 0x00, 0x10, 0x44, 0x80, 0xff, 0x7f, 0x55, 0x12, 0x91, 0x2a, 0xeb, - 0xbf, 0x0b, 0x82, 0x02, 0x00, 0x00, 0xd1, 0x7f, 0xdf, 0xa2, 0xa4, 0x54, - 0x55, 0xfd, 0xfd, 0x47, 0x08, 0x08, 0x00, 0x21, 0xe4, 0xff, 0x37, 0x11, - 0x09, 0xa5, 0xaa, 0xb6, 0xff, 0x0d, 0x80, 0x00, 0x00, 0x04, 0xd0, 0xff, - 0x4f, 0x44, 0x20, 0x48, 0x55, 0xfb, 0xff, 0x27, 0x11, 0x02, 0x40, 0x40, - 0xe2, 0xfb, 0x15, 0x11, 0x4a, 0x55, 0x4a, 0x7d, 0xf7, 0x0f, 0x00, 0x00, - 0x04, 0x08, 0xf8, 0xdf, 0x52, 0x44, 0x01, 0x52, 0xb5, 0xfa, 0xff, 0x0f, - 0x49, 0x02, 0x00, 0x02, 0xe9, 0xf6, 0x0a, 0x11, 0xa4, 0x88, 0x4a, 0x6d, - 0xff, 0x5f, 0x00, 0x00, 0x10, 0x20, 0xf0, 0x2f, 0x21, 0x44, 0x10, 0x52, - 0xb5, 0xfa, 0xff, 0x0f, 0x44, 0x04, 0x80, 0x08, 0xf8, 0xab, 0x8a, 0x00, - 0x81, 0xa4, 0xd4, 0xd6, 0xfe, 0x2f, 0x00, 0x00, 0x04, 0x40, 0xb5, 0x2d, - 0x21, 0x08, 0x04, 0x90, 0xaa, 0xfa, 0xff, 0x1f, 0x11, 0x01, 0x00, 0x04, - 0xf0, 0x57, 0x0a, 0x22, 0x40, 0x4a, 0xda, 0x5e, 0xfb, 0x1f, 0x40, 0x00, - 0x40, 0x20, 0xba, 0x95, 0x90, 0x00, 0x01, 0xa0, 0xaa, 0xea, 0xff, 0x5f, - 0x02, 0x02, 0x00, 0x01, 0xe8, 0x57, 0x05, 0x00, 0x00, 0x12, 0xd5, 0xfe, - 0xfd, 0x1f, 0x48, 0x00, 0x04, 0x48, 0x7a, 0x95, 0x08, 0x02, 0x10, 0x40, - 0xaa, 0x55, 0xf7, 0x1f, 0x00, 0x09, 0x20, 0x00, 0xf8, 0x57, 0x22, 0x10, - 0x00, 0x28, 0xa9, 0xfa, 0xff, 0x5f, 0x02, 0x00, 0x00, 0x49, 0xdd, 0x29, - 0x01, 0x00, 0x80, 0x80, 0xaa, 0xd7, 0xff, 0x0f, 0x10, 0x00, 0x08, 0x00, - 0xf8, 0x96, 0x08, 0x00, 0x00, 0x20, 0x54, 0xfa, 0xee, 0x3f, 0x81, 0x04, - 0x40, 0x24, 0xfe, 0x55, 0x82, 0x00, 0x00, 0x82, 0xd2, 0xad, 0xff, 0x0f, - 0x08, 0x00, 0x04, 0x80, 0x6c, 0x97, 0x00, 0x00, 0x02, 0x20, 0xa9, 0xf6, - 0xdf, 0x5f, 0x00, 0x02, 0x20, 0x09, 0xfa, 0x49, 0x12, 0x00, 0x20, 0x84, - 0x54, 0xdb, 0xfe, 0x1f, 0x91, 0x00, 0x00, 0x00, 0xf8, 0x2b, 0x00, 0x20, - 0x00, 0x40, 0xa4, 0xf6, 0xbb, 0x1f, 0x04, 0x00, 0x44, 0x92, 0x7e, 0x95, - 0x02, 0x00, 0x00, 0x89, 0xaa, 0xdd, 0xff, 0x1f, 0x20, 0x09, 0x10, 0x00, - 0xf4, 0x57, 0x20, 0x01, 0x08, 0x20, 0xa9, 0x76, 0xff, 0x5f, 0x02, 0x00, - 0x00, 0x21, 0xfc, 0x4a, 0x05, 0x00, 0x01, 0x80, 0x54, 0xdb, 0xff, 0x1e, - 0x08, 0x02, 0x04, 0x08, 0xf9, 0x2b, 0x00, 0x00, 0x40, 0x28, 0xd2, 0xf6, - 0xff, 0xbf, 0x80, 0x00, 0x90, 0x00, 0xbc, 0x92, 0x08, 0x10, 0x00, 0x82, - 0x54, 0xdb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x44, 0xf9, 0x55, 0x02, 0x01, - 0x00, 0x20, 0xaa, 0xbd, 0xfd, 0x3f, 0x08, 0x04, 0x04, 0x10, 0xf4, 0x2a, - 0x01, 0x00, 0x22, 0x80, 0xd4, 0xf6, 0xff, 0x5f, 0x82, 0x00, 0x40, 0x02, - 0xf8, 0x55, 0x20, 0x00, 0x00, 0x50, 0x6a, 0xdf, 0xfe, 0x3f, 0x00, 0x00, - 0x00, 0x48, 0xe9, 0x4a, 0x05, 0x08, 0x00, 0xa5, 0xd5, 0xf5, 0xff, 0x3f, - 0x10, 0x01, 0x10, 0x01, 0xb0, 0xab, 0x92, 0x02, 0x40, 0xf8, 0xbf, 0xde, - 0xfe, 0x5f, 0x02, 0x04, 0x04, 0x48, 0xfa, 0xd4, 0x6f, 0x20, 0x84, 0xef, - 0xff, 0xfb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x00, 0xe0, 0xed, 0xbf, 0x0b, - 0xa1, 0x7e, 0xff, 0xbf, 0xfd, 0x5f, 0x04, 0x01, 0x20, 0x49, 0xd2, 0xfb, - 0xfe, 0x55, 0xd4, 0xff, 0xff, 0xf6, 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, - 0xc0, 0xaa, 0xfb, 0x2b, 0xa2, 0xfe, 0xff, 0xdf, 0xee, 0x1f, 0x91, 0x00, - 0x82, 0xa4, 0xa4, 0xf5, 0xff, 0x57, 0xd5, 0xff, 0xbf, 0xfd, 0xff, 0x4d, - 0x00, 0x00, 0x20, 0x00, 0x88, 0x5b, 0xff, 0x2f, 0x69, 0xff, 0xff, 0xdb, - 0xfe, 0x1f, 0x24, 0x02, 0x00, 0x49, 0xa2, 0xd6, 0xff, 0x5f, 0xea, 0xff, - 0x7f, 0x7f, 0x7f, 0x0d, 0x00, 0x00, 0x10, 0x00, 0x40, 0xab, 0xf7, 0xbb, - 0xf0, 0xdf, 0xff, 0xd5, 0xff, 0xbf, 0x82, 0x04, 0x42, 0x24, 0x91, 0xd5, - 0xaa, 0xae, 0xd4, 0xaa, 0x52, 0x7b, 0xff, 0x15, 0x08, 0x00, 0x00, 0x01, - 0x04, 0x55, 0xd5, 0x55, 0x70, 0x5b, 0x75, 0xdd, 0xdf, 0x1f, 0x40, 0x00, - 0x08, 0x48, 0xa0, 0x4a, 0xa9, 0x56, 0xea, 0x56, 0xad, 0x6a, 0x7d, 0x9b, - 0x04, 0x01, 0x00, 0x02, 0x42, 0x2a, 0xd5, 0xaa, 0xa8, 0xaa, 0xaa, 0xfa, - 0xdf, 0x2f, 0x10, 0x04, 0x22, 0x48, 0x08, 0x45, 0x2a, 0x15, 0x68, 0x55, - 0x55, 0xd7, 0x76, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x40, 0x2a, 0x80, 0xa0, - 0xb2, 0x09, 0x48, 0xb9, 0xdf, 0x17, 0x22, 0x01, 0x00, 0x24, 0x45, 0x8a, - 0x24, 0x4a, 0x54, 0x51, 0x91, 0xf6, 0x6e, 0x4b, 0x00, 0x04, 0x90, 0x00, - 0x80, 0x52, 0x00, 0x20, 0x69, 0x05, 0xa4, 0xaa, 0xff, 0x1e, 0x48, 0x00, - 0x02, 0x92, 0x08, 0x05, 0x81, 0x94, 0xd4, 0x92, 0x40, 0xfd, 0xb6, 0x8b, - 0x00, 0x01, 0x40, 0x00, 0x82, 0x54, 0x00, 0x48, 0x68, 0x05, 0x90, 0xa4, - 0xef, 0x06, 0x24, 0x00, 0x08, 0x12, 0x10, 0x05, 0x00, 0x10, 0xb5, 0x01, - 0x42, 0xfb, 0xbf, 0x43, 0x00, 0x09, 0x00, 0x40, 0x81, 0xa8, 0x08, 0x4a, - 0xaa, 0x96, 0x90, 0xac, 0x6d, 0x15, 0x22, 0x00, 0x20, 0x09, 0x04, 0x15, - 0x80, 0x28, 0xdc, 0x01, 0x24, 0xfb, 0xbf, 0x01, 0x80, 0x04, 0x09, 0x00, - 0x40, 0x48, 0x02, 0x45, 0xb2, 0x2e, 0x41, 0x6d, 0xef, 0x05, 0x11, 0x00, - 0x40, 0x52, 0x02, 0x15, 0x29, 0x2a, 0xac, 0x42, 0x54, 0xfb, 0x3b, 0x51, - 0x84, 0x00, 0x08, 0x00, 0x20, 0x54, 0x80, 0x05, 0xb5, 0x3d, 0xa2, 0xb6, - 0xdf, 0x00, 0x20, 0x04, 0x20, 0x49, 0x89, 0xa8, 0x6a, 0x29, 0xac, 0xd6, - 0x54, 0xff, 0x3f, 0x84, 0x00, 0x01, 0x04, 0x10, 0x00, 0x94, 0xa8, 0x56, - 0xda, 0x5f, 0xab, 0xd5, 0x1e, 0x10, 0x48, 0x00, 0x90, 0x82, 0x48, 0xa8, - 0xb2, 0xac, 0xfd, 0x55, 0xd5, 0xfe, 0x9f, 0x80, 0x00, 0x0a, 0x02, 0x08, - 0x02, 0x55, 0x5a, 0x75, 0xff, 0xaf, 0xb6, 0xf7, 0x2d, 0x12, 0x92, 0x00, - 0x10, 0x20, 0x10, 0xa8, 0x54, 0xd5, 0xbf, 0x5d, 0xad, 0xdd, 0x0f, 0x00, - 0x00, 0x04, 0x40, 0x09, 0x84, 0xa8, 0xaa, 0x5a, 0xed, 0xeb, 0x6a, 0xff, - 0x9f, 0xa4, 0x24, 0x01, 0x02, 0xa0, 0x20, 0x50, 0x55, 0xd5, 0xbe, 0xae, - 0xad, 0xfd, 0x16, 0x00, 0x10, 0x04, 0x20, 0x0a, 0x08, 0xb4, 0xaa, 0x95, - 0xaa, 0x7b, 0xb7, 0xdb, 0x5f, 0x92, 0x04, 0x01, 0x84, 0x20, 0x21, 0x51, - 0xd5, 0x2a, 0xa9, 0xee, 0xd5, 0xfe, 0x0d, 0x00, 0x20, 0x04, 0x10, 0x00, - 0x08, 0x50, 0xe9, 0xd7, 0xd4, 0xfb, 0xb5, 0xff, 0x9f, 0x24, 0x09, 0x01, - 0x42, 0x4a, 0xa2, 0x64, 0xd5, 0x55, 0x7b, 0x7f, 0xda, 0x7d, 0x4f, 0x00, - 0x20, 0x04, 0x00, 0x80, 0x00, 0xa0, 0x2a, 0x13, 0x84, 0x6a, 0x55, 0xff, - 0x1d, 0x48, 0x8a, 0x00, 0x94, 0x24, 0x8a, 0xc8, 0xaa, 0x42, 0x20, 0x5d, - 0xf5, 0xff, 0x5f, 0x01, 0x00, 0x02, 0x01, 0x00, 0x20, 0xa2, 0x4a, 0x1a, - 0x82, 0x56, 0xda, 0xbd, 0x3f, 0x92, 0x92, 0x00, 0x90, 0x92, 0x00, 0x40, - 0x95, 0x6a, 0xf4, 0x55, 0x6d, 0xff, 0xd6, 0x00, 0x00, 0x0a, 0x04, 0x20, - 0x14, 0x49, 0x4b, 0xaa, 0xaa, 0x56, 0xf5, 0xff, 0xbf, 0xab, 0xa4, 0x00, - 0x20, 0x89, 0x40, 0x80, 0xaa, 0xaa, 0xaa, 0xaa, 0xde, 0xbf, 0xeb, 0x03, - 0x00, 0x02, 0x04, 0x02, 0x0a, 0x10, 0x2b, 0x2a, 0x55, 0x5b, 0xf5, 0xff, - 0xd7, 0x2f, 0x92, 0x00, 0x10, 0x28, 0x21, 0x01, 0x56, 0x95, 0xa0, 0x56, - 0xdf, 0xef, 0xea, 0x87, 0x40, 0x0a, 0x42, 0x41, 0x00, 0x90, 0xaa, 0x52, - 0xb6, 0xad, 0xfa, 0xff, 0xd5, 0x2f, 0x14, 0x00, 0x00, 0x04, 0x95, 0x04, - 0xaa, 0xac, 0x55, 0x6b, 0xff, 0xb7, 0xea, 0x9f, 0x40, 0x02, 0x28, 0x51, - 0x00, 0x40, 0x58, 0xd5, 0xda, 0xd6, 0x6e, 0x7f, 0xf9, 0x3f, 0x12, 0x04, - 0x02, 0x04, 0x49, 0x25, 0x55, 0xaa, 0x77, 0xab, 0xff, 0x2b, 0xfd, 0x3f, - 0x48, 0x01, 0x20, 0x41, 0x00, 0x00, 0x58, 0xa9, 0xda, 0xea, 0xfd, 0xaf, - 0xfa, 0xff, 0x02, 0x04, 0x08, 0x14, 0x29, 0x49, 0x52, 0x55, 0x55, 0x55, - 0xff, 0x8d, 0xfe, 0x3f, 0xa8, 0x00, 0x02, 0x41, 0x00, 0x02, 0xa0, 0xa2, - 0xaa, 0xea, 0xff, 0x53, 0xfd, 0xff, 0x02, 0x04, 0x50, 0x04, 0x25, 0xa8, - 0x54, 0x49, 0x52, 0xb5, 0xbf, 0x8a, 0xfe, 0xff, 0xa9, 0x08, 0x04, 0x50, - 0x80, 0x02, 0xa1, 0x2a, 0x95, 0xea, 0xff, 0xa1, 0xff, 0xff, 0x03, 0x02, - 0x90, 0x02, 0x09, 0x08, 0x44, 0x49, 0x52, 0xbd, 0x7f, 0xca, 0xff, 0xff, - 0x2b, 0x09, 0x04, 0x48, 0x40, 0x82, 0x90, 0x56, 0xa9, 0xf6, 0xbf, 0xd0, - 0xff, 0xff, 0x47, 0x00, 0x50, 0x02, 0x15, 0x11, 0x40, 0x95, 0xaa, 0xfd, - 0x2f, 0xe9, 0xff, 0xff, 0x8f, 0x0a, 0x84, 0x50, 0x40, 0x84, 0x14, 0xaa, - 0x6a, 0xff, 0x5f, 0xf2, 0xff, 0xff, 0x7f, 0x00, 0x10, 0x02, 0x09, 0x10, - 0x40, 0x7d, 0xf7, 0xff, 0x0b, 0xfc, 0xff, 0xff, 0xaf, 0x02, 0x84, 0x50, - 0x42, 0x85, 0x12, 0xd0, 0xdd, 0xff, 0xa7, 0xf2, 0xff, 0xff, 0xff, 0x04, - 0x00, 0x0a, 0x08, 0x10, 0x48, 0xf8, 0xff, 0xff, 0x0a, 0xfe, 0xff, 0xff, - 0x7f, 0x03, 0xa4, 0x80, 0xa2, 0x8a, 0x02, 0x68, 0xff, 0xff, 0x52, 0xfd, - 0xff, 0xff, 0xff, 0x07, 0x00, 0x2a, 0x08, 0x20, 0x28, 0xdc, 0xff, 0x5f, - 0x05, 0xff, 0xff, 0xff, 0xff, 0x0d, 0x92, 0x40, 0x22, 0x09, 0x02, 0xea, - 0xfb, 0xaf, 0x48, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x12, 0x81, 0xa0, - 0x48, 0x9c, 0x6e, 0x93, 0xa2, 0xff, 0xff, 0xff, 0xff, 0x07, 0xa8, 0x40, - 0x28, 0x0a, 0x02, 0x74, 0xb5, 0x45, 0x81, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x02, 0x0a, 0x81, 0x20, 0x08, 0xae, 0xaa, 0x90, 0xe8, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x90, 0x40, 0x28, 0x88, 0x12, 0x58, 0x15, 0x50, 0xd0, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x44, 0x0a, 0x41, 0x21, 0x08, 0xae, 0x04, 0x14, - 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, 0x14, 0x88, 0x04, 0xba, - 0x02, 0x28, 0xe8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x42, 0x15, 0x41, 0x21, - 0x05, 0xad, 0x00, 0x05, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, - 0x24, 0x8a, 0x0e, 0x36, 0x00, 0x0a, 0xf4, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x42, 0x25, 0x90, 0xd0, 0x8b, 0xc2, 0x41, 0x05, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x10, 0x08, 0x05, 0xe8, 0x8e, 0x58, 0x80, 0x02, 0xfa, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x4a, 0x20, 0xa8, 0xba, 0x0b, 0x2b, 0x51, 0x01, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x8a, 0x02, 0xe8, 0xaf, 0x84, - 0x90, 0x04, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x52, 0x21, 0x54, 0xbf, - 0x1f, 0x15, 0xa5, 0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x08, - 0x01, 0xfa, 0xb6, 0xa4, 0x52, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x4a, 0xa2, 0x54, 0xef, 0x5f, 0x4b, 0xa4, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x80, 0x10, 0x82, 0xfe, 0xbf, 0x92, 0x52, 0x42, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x12, 0x42, 0xa8, 0xbf, 0x1f, 0x24, 0x80, 0xa0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, 0x8a, 0xf7, 0x37, 0x80, - 0x52, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x82, 0xe0, 0xff, - 0x1f, 0x00, 0x20, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, - 0xca, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x10, 0x42, 0xf0, 0xfd, 0x1b, 0x00, 0x50, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0xa4, 0x10, 0xc5, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x00, 0x22, 0xf8, 0xff, 0x0e, 0x00, 0x00, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xaa, 0x88, 0xe2, 0xff, 0x0f, 0x10, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x25, 0xfa, 0xff, - 0x0f, 0x01, 0x11, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xfb, - 0xfb, 0xff, 0x7f, 0x5d, 0xd5, 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f}; diff --git a/ext/tk/sample/demos-jp/images/flagdown.bmp b/ext/tk/sample/demos-jp/images/flagdown.bmp deleted file mode 100644 index 55abc51825..0000000000 --- a/ext/tk/sample/demos-jp/images/flagdown.bmp +++ /dev/null @@ -1,27 +0,0 @@ -#define flagdown_width 48 -#define flagdown_height 48 -static char flagdown_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xe1, 0x00, 0x00, - 0x00, 0x00, 0x70, 0x80, 0x01, 0x00, 0x00, 0x00, 0x18, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x0c, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04, - 0x00, 0x00, 0x03, 0x00, 0x06, 0x06, 0x00, 0x80, 0x01, 0x00, 0x06, 0x07, - 0x00, 0xc0, 0x1f, 0x00, 0x87, 0x07, 0x00, 0xe0, 0x7f, 0x80, 0xc7, 0x07, - 0x00, 0x70, 0xe0, 0xc0, 0xe5, 0x07, 0x00, 0x38, 0x80, 0xe1, 0x74, 0x07, - 0x00, 0x18, 0x80, 0x71, 0x3c, 0x07, 0x00, 0x0c, 0x00, 0x3b, 0x1e, 0x03, - 0x00, 0x0c, 0x00, 0x1f, 0x0f, 0x00, 0x00, 0x86, 0x1f, 0x8e, 0x07, 0x00, - 0x00, 0x06, 0x06, 0xc6, 0x05, 0x00, 0x00, 0x06, 0x00, 0xc6, 0x05, 0x00, - 0x00, 0x06, 0x00, 0xc6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, - 0x7f, 0x06, 0x00, 0x06, 0xe4, 0xff, 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, - 0x00, 0x06, 0x00, 0x06, 0x04, 0x00, 0x00, 0x06, 0x00, 0x06, 0x06, 0x00, - 0x00, 0x06, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00, - 0x00, 0x06, 0x00, 0xc6, 0x00, 0x00, 0x00, 0x06, 0x00, 0x66, 0x00, 0x00, - 0x00, 0x06, 0x00, 0x36, 0x00, 0x00, 0x00, 0x06, 0x00, 0x3e, 0x00, 0x00, - 0x00, 0xfe, 0xff, 0x2f, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x27, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, 0x00, 0x00, 0x88, 0x20, 0x00, 0x00, - 0xf7, 0xbf, 0x8e, 0xfc, 0xdf, 0xf8, 0x9d, 0xeb, 0x9b, 0x76, 0xd2, 0x7a, - 0x46, 0x30, 0xe2, 0x0f, 0xe1, 0x47, 0x55, 0x84, 0x48, 0x11, 0x84, 0x19}; diff --git a/ext/tk/sample/demos-jp/images/flagup.bmp b/ext/tk/sample/demos-jp/images/flagup.bmp deleted file mode 100644 index 6eb0d846a3..0000000000 --- a/ext/tk/sample/demos-jp/images/flagup.bmp +++ /dev/null @@ -1,27 +0,0 @@ -#define flagup_width 48 -#define flagup_height 48 -static char flagup_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, - 0x00, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xef, 0x6a, 0x00, - 0x00, 0x00, 0xc0, 0x7b, 0x75, 0x00, 0x00, 0x00, 0xe0, 0xe0, 0x6a, 0x00, - 0x00, 0x00, 0x30, 0x60, 0x75, 0x00, 0x00, 0x00, 0x18, 0xe0, 0x7f, 0x00, - 0x00, 0x00, 0x0c, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x06, 0xe0, 0x04, 0x00, - 0x00, 0x00, 0x03, 0xe0, 0x04, 0x00, 0x00, 0x80, 0x01, 0xe0, 0x06, 0x00, - 0x00, 0xc0, 0x1f, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0xe0, 0x07, 0x00, - 0x00, 0x70, 0xe0, 0xe0, 0x05, 0x00, 0x00, 0x38, 0x80, 0xe1, 0x04, 0x00, - 0x00, 0x18, 0x80, 0xf1, 0x04, 0x00, 0x00, 0x0c, 0x00, 0xfb, 0x04, 0x00, - 0x00, 0x0c, 0x00, 0xff, 0x04, 0x00, 0x00, 0x86, 0x1f, 0xee, 0x04, 0x00, - 0x00, 0x06, 0x06, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00, - 0x00, 0x06, 0x00, 0xe6, 0x04, 0x00, 0x00, 0x06, 0x00, 0x66, 0x04, 0x00, - 0x7f, 0x56, 0x52, 0x06, 0xe4, 0xff, 0x00, 0x76, 0x55, 0x06, 0x04, 0x00, - 0x00, 0x56, 0x57, 0x06, 0x04, 0x00, 0x00, 0x56, 0x55, 0x06, 0x06, 0x00, - 0x00, 0x56, 0xd5, 0x06, 0x03, 0x00, 0x00, 0x06, 0x00, 0x86, 0x01, 0x00, - 0x54, 0x06, 0x00, 0xc6, 0x54, 0x55, 0xaa, 0x06, 0x00, 0x66, 0xaa, 0x2a, - 0x54, 0x06, 0x00, 0x36, 0x55, 0x55, 0xaa, 0x06, 0x00, 0xbe, 0xaa, 0x2a, - 0x54, 0xfe, 0xff, 0x6f, 0x55, 0x55, 0xaa, 0xfc, 0xff, 0xa7, 0xaa, 0x2a, - 0x54, 0x01, 0x88, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a, - 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a, - 0x54, 0x55, 0x8d, 0x60, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa0, 0xaa, 0x2a, - 0x54, 0x55, 0x8d, 0x50, 0x55, 0x55, 0xaa, 0xaa, 0x8a, 0xa8, 0xaa, 0x2a, - 0x54, 0x55, 0x95, 0x54, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x2a, - 0x54, 0x55, 0x55, 0x55, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/ext/tk/sample/demos-jp/images/gray25.bmp b/ext/tk/sample/demos-jp/images/gray25.bmp deleted file mode 100644 index b234b3cb0b..0000000000 --- a/ext/tk/sample/demos-jp/images/gray25.bmp +++ /dev/null @@ -1,6 +0,0 @@ -#define grey_width 16 -#define grey_height 16 -static char grey_bits[] = { - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44}; diff --git a/ext/tk/sample/demos-jp/images/grey.25 b/ext/tk/sample/demos-jp/images/grey.25 deleted file mode 100644 index b234b3cb0b..0000000000 --- a/ext/tk/sample/demos-jp/images/grey.25 +++ /dev/null @@ -1,6 +0,0 @@ -#define grey_width 16 -#define grey_height 16 -static char grey_bits[] = { - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44, - 0x11, 0x11, 0x44, 0x44, 0x11, 0x11, 0x44, 0x44}; diff --git a/ext/tk/sample/demos-jp/images/grey.5 b/ext/tk/sample/demos-jp/images/grey.5 deleted file mode 100644 index 37688893f0..0000000000 --- a/ext/tk/sample/demos-jp/images/grey.5 +++ /dev/null @@ -1,6 +0,0 @@ -#define grey_width 16 -#define grey_height 16 -static char grey_bits[] = { - 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, - 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, - 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa}; diff --git a/ext/tk/sample/demos-jp/images/letters.bmp b/ext/tk/sample/demos-jp/images/letters.bmp deleted file mode 100644 index 0f12568d1a..0000000000 --- a/ext/tk/sample/demos-jp/images/letters.bmp +++ /dev/null @@ -1,27 +0,0 @@ -#define letters_width 48 -#define letters_height 48 -static char letters_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, - 0x00, 0xfa, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, - 0x00, 0x3a, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2e, - 0xe0, 0xff, 0xff, 0xff, 0xff, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x21, - 0xa0, 0x03, 0x00, 0x00, 0x70, 0x21, 0x20, 0x00, 0x00, 0x00, 0x50, 0x21, - 0xa0, 0x1f, 0x00, 0x00, 0x50, 0x21, 0x20, 0x00, 0x00, 0x00, 0x70, 0x21, - 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21, - 0xfa, 0x01, 0x00, 0x80, 0x0b, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0a, 0x21, - 0xba, 0x01, 0x00, 0x80, 0x0a, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0b, 0x21, - 0x3a, 0x00, 0x00, 0x00, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21, - 0x02, 0xc0, 0xfb, 0x03, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3f, - 0x02, 0xc0, 0xbd, 0x0f, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, - 0x02, 0xc0, 0x7f, 0x7b, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, - 0x02, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, - 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/ext/tk/sample/demos-jp/images/noletter.bmp b/ext/tk/sample/demos-jp/images/noletter.bmp deleted file mode 100644 index 5774124efe..0000000000 --- a/ext/tk/sample/demos-jp/images/noletter.bmp +++ /dev/null @@ -1,27 +0,0 @@ -#define noletters_width 48 -#define noletters_height 48 -static char noletters_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, - 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00, - 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01, - 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x07, - 0xe0, 0x01, 0x00, 0x00, 0xf0, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x78, 0x0e, - 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x1e, 0x70, 0x00, 0x00, 0x00, 0x1e, 0x1c, - 0x38, 0x00, 0x00, 0x00, 0x0f, 0x38, 0x38, 0x00, 0x00, 0x80, 0x07, 0x38, - 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x1c, 0x04, 0x00, 0xe0, 0x41, 0x70, - 0x1c, 0x04, 0x00, 0xf0, 0x40, 0x70, 0x1c, 0x74, 0x00, 0x78, 0x4e, 0x70, - 0x0e, 0x04, 0x00, 0x3c, 0x4a, 0xe0, 0x0e, 0x74, 0x03, 0x1e, 0x4a, 0xe0, - 0x0e, 0x04, 0x00, 0x0f, 0x4e, 0xe0, 0x0e, 0x04, 0x80, 0x07, 0x40, 0xe0, - 0x0e, 0x04, 0xf8, 0x0f, 0x40, 0xe0, 0x0e, 0x04, 0xe0, 0x01, 0x40, 0xe0, - 0x0e, 0x04, 0xf8, 0x00, 0x40, 0xe0, 0x0e, 0x04, 0x78, 0x00, 0x40, 0xe0, - 0x0e, 0x04, 0xfc, 0xf3, 0x40, 0xe0, 0x1c, 0x04, 0x1e, 0x00, 0x40, 0x70, - 0x1c, 0x04, 0x0f, 0x00, 0x40, 0x70, 0x1c, 0x84, 0x07, 0x00, 0x40, 0x70, - 0x3c, 0xfc, 0xff, 0xff, 0x7f, 0x78, 0x38, 0xe0, 0x01, 0x00, 0x00, 0x38, - 0x38, 0xf0, 0x00, 0x00, 0x00, 0x38, 0x70, 0x78, 0x00, 0x00, 0x00, 0x1c, - 0xf0, 0x3c, 0x00, 0x00, 0x00, 0x1e, 0xe0, 0x1e, 0x00, 0x00, 0x00, 0x0e, - 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x07, 0x00, 0x00, 0x80, 0x07, - 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x1f, 0x00, 0x00, 0xf0, 0x01, - 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x7f, 0x00, - 0x00, 0xf0, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x07, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0xf0, 0x1f, 0x00, 0x00}; diff --git a/ext/tk/sample/demos-jp/images/pattern.bmp b/ext/tk/sample/demos-jp/images/pattern.bmp deleted file mode 100644 index df31baf789..0000000000 --- a/ext/tk/sample/demos-jp/images/pattern.bmp +++ /dev/null @@ -1,6 +0,0 @@ -#define foo_width 16 -#define foo_height 16 -static char foo_bits[] = { - 0x60, 0x06, 0x90, 0x09, 0x90, 0x09, 0xb0, 0x0d, 0x4e, 0x72, 0x49, 0x92, - 0x71, 0x8e, 0x8e, 0x71, 0x8e, 0x71, 0x71, 0x8e, 0x49, 0x92, 0x4e, 0x72, - 0xb0, 0x0d, 0x90, 0x09, 0x90, 0x09, 0x60, 0x06}; diff --git a/ext/tk/sample/demos-jp/images/tcllogo.gif b/ext/tk/sample/demos-jp/images/tcllogo.gif Binary files differdeleted file mode 100644 index 3fc7720b17..0000000000 --- a/ext/tk/sample/demos-jp/images/tcllogo.gif +++ /dev/null diff --git a/ext/tk/sample/demos-jp/images/teapot.ppm b/ext/tk/sample/demos-jp/images/teapot.ppm deleted file mode 100644 index 78afefbf82..0000000000 --- a/ext/tk/sample/demos-jp/images/teapot.ppm +++ /dev/null @@ -1,56 +0,0 @@ -P6 -256 256 -255 -\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\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[ diff --git a/ext/tk/sample/demos-jp/items.rb b/ext/tk/sample/demos-jp/items.rb index e1007c5a8d..d80751064b 100644 --- a/ext/tk/sample/demos-jp/items.rb +++ b/ext/tk/sample/demos-jp/items.rb @@ -26,7 +26,8 @@ TkLabel.new($items_demo) { # frame 生成 TkFrame.new($items_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $items_demo $items_demo = nil @@ -119,8 +120,8 @@ TkcLine.new(cvs, '5c','6c','9c','6c','9c','1c','8c','1c','8c','4.8c','8.8c', '8.6c','1.4c','8.4c','1.4c','8.4c','4.4c', 'width'=>3, 'fill'=>red, 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','5c','7c','5c','7c','7c','9c','7c', 'width'=>'.5c', - 'stipple'=>'@'+[$demo_dir, - 'images','gray25.bmp'].join(File::Separator), + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), 'arrow'=>'both', 'arrowshape'=>'15 15 7', 'tags'=>$tag_item ) TkcLine.new(cvs, '1c','7c','1.75c','5.8c','2.5c','7c','3.25c','5.8c','4c','7c', 'width'=>'.5c', 'capstyle'=>'round', 'join'=>'round', @@ -135,8 +136,8 @@ TkcLine.new(cvs, '15.5c','1c','19.5c','1.5c','15.5c','4.5c','19.5c','4c', TkcLine.new(cvs, '12c','6c','13.5c','4.5c','16.5c','7.5c','18c','6c', '16.5c','4.5c','13.5c','7.5c','12c','6c', 'smooth'=>'on', 'width'=>'3m', 'capstyle'=>'round', - 'stipple'=>'@'+[$demo_dir, - 'images', 'gray25.bmp'].join(File::Separator), + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator), 'fill'=>red, 'tags'=>$tag_item ) TkcText.new(cvs, '25c', '.2c', 'text'=>'多角形', 'anchor'=>'n') @@ -150,8 +151,8 @@ TkcPolygon.new(cvs, '25c','4c','25c','4c','25c','1c','26c','1c','27c','4c', TkcPolygon.new(cvs, '22c','4.5c','25c','4.5c','25c','6.75c','28c','6.75c', '28c','5.25c','24c','5.25c','24c','6.0c','26c','6c','26c', '7.5c','22c','7.5c', - 'stipple'=>'@' + [$demo_dir, - 'images', 'gray25.bmp'].join(File::Separator), + 'stipple'=>'@' + [$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator), 'outline'=>'black', 'tags'=>$tag_item ) TkcText.new(cvs, '5c', '8.2c', 'text'=>'矩形', 'anchor'=>'n') @@ -160,8 +161,8 @@ TkcRectangle.new(cvs, '1c','9.5c','4c','12.5c', TkcRectangle.new(cvs, '0.5c','13.5c','4.5c','15.5c', 'fill'=>green, 'tags'=>$tag_item ) TkcRectangle.new(cvs, '6c','10c','9c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir, - 'images','gray25.bmp'].join(File::Separator), + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), 'fill'=>blue, 'tags'=>$tag_item ) TkcText.new(cvs, '15c', '8.2c', 'text'=>'楕円', 'anchor'=>'n') @@ -170,8 +171,8 @@ TkcOval.new(cvs, '11c','9.5c','14c','12.5c', TkcOval.new(cvs, '10.5c','13.5c','14.5c','15.5c', 'fill'=>green, 'tags'=>$tag_item ) TkcOval.new(cvs, '16c','10c','19c','15c', 'outline'=>'', - 'stipple'=>'@'+[$demo_dir, - 'images','gray25.bmp'].join(File::Separator), + 'stipple'=>'@'+[$demo_dir,'..', + 'images','gray25.xbm'].join(File::Separator), 'fill'=>blue, 'tags'=>$tag_item ) TkcText.new(cvs, '25c', '8.2c', 'text'=>'テキスト', 'anchor'=>'n') @@ -186,7 +187,7 @@ TkcText.new(cvs, '25.5c', '11c', 'anchor'=>'w', 'font'=>font1, 'fill'=>blue, TkcRectangle.new(cvs, '24.9c','13.9c','25.1c','14.1c') if $tk_version =~ /^4\.[01]/ TkcText.new(cvs, '25c', '14c', 'anchor'=>'c', 'font'=>font2, 'fill'=>red, - 'stipple'=>'@' + [$demo_dir, + 'stipple'=>'@' + [$demo_dir, '..', 'images', 'grey.5'].join(File::Separator), 'text'=>'Stippled characters', 'tags'=>$tag_item ) else @@ -204,8 +205,8 @@ TkcArc.new(cvs, '0.5c','17c','7c','20c', 'fill'=>green, 'outline'=>'black', # 'tags'=>$tag_item) TkcArc.new(cvs, '6.5c','17c','9.5c','20c', 'width'=>'4m', 'style'=>'arc', 'outline'=>blue, 'start'=>135, 'extent'=>270, - 'outlinestipple'=>'@'+[$demo_dir, - 'images','gray25.bmp'].join(File::Separator), + 'outlinestipple'=>'@'+[$demo_dir, '..', + 'images','gray25.xbm'].join(File::Separator), 'tags'=>$tag_item) TkcArc.new(cvs, '0.5c','20c','9.5c','24c', 'width'=>'4m', 'style'=>'pieslice', 'fill'=>'', 'outline'=>red, 'start'=>225, 'extent'=>90, @@ -219,22 +220,22 @@ TkcText.new(cvs, '15c', '16.2c', 'text'=>'ビットマップ', 'anchor'=>'n') # 'bitmap'=>'@' + ['images', 'face'].join(File::Separator), # 'tags'=>$tag_item) TkcBitmap.new(cvs, '13c','20c', - 'bitmap'=>'@' + [$demo_dir, - 'images', 'face.bmp'].join(File::Separator), + 'bitmap'=>'@' + [$demo_dir, '..', + 'images', 'face.xbm'].join(File::Separator), 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','18.5c', # 'bitmap'=>'@' + ['images', 'noletters'].join(File::Separator), # 'tags'=>$tag_item) TkcBitmap.new(cvs, '17c','18.5c', - 'bitmap'=>'@' + [$demo_dir, - 'images', 'noletter.bmp'].join(File::Separator), + 'bitmap'=>'@' + [$demo_dir, '..', + 'images', 'noletter.xbm'].join(File::Separator), 'tags'=>$tag_item) #TkcBitmap.new(cvs, '17c','21.5c', # 'bitmap'=>'@' + ['images', 'letters'].join(File::Separator), # 'tags'=>$tag_item) # ↓の形式でも可能 TkcBitmap.new(cvs, '17c','21.5c') { - bitmap '@' + [$demo_dir, 'images', 'letters.bmp'].join(File::Separator) + bitmap '@' + [$demo_dir, '..', 'images', 'letters.xbm'].join(File::Separator) tags $tag_item } #TkcBitmap.new(cvs, '17c','21.5c') { @@ -357,7 +358,7 @@ end def itemDrag(c,x,y) x = c.canvasx(x) y = c.canvasy(y) - c.move 'current', x - $lastX, y - $lastY + c.move('current', x - $lastX, y - $lastY) $lastX = x $lastY = y end diff --git a/ext/tk/sample/demos-jp/label.rb b/ext/tk/sample/demos-jp/label.rb index 80ab5f3d8f..425654216c 100644 --- a/ext/tk/sample/demos-jp/label.rb +++ b/ext/tk/sample/demos-jp/label.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($label_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $label_demo $label_demo = nil @@ -56,7 +57,7 @@ f_right = TkFrame.new($label_demo) ].each{|w| w.pack('side'=>'top', 'expand'=>'yes', 'pady'=>2, 'anchor'=>'w')} TkLabel.new(f_right) { - bitmap('@' + [$demo_dir,'images','face.bmp'].join(File::Separator)) + bitmap('@' + [$demo_dir,'..','images','face.xbm'].join(File::Separator)) borderwidth 2 relief 'sunken' }.pack('side'=>'top') diff --git a/ext/tk/sample/demos-jp/labelframe.rb b/ext/tk/sample/demos-jp/labelframe.rb index 044fcd23ae..8f76ffacfb 100644 --- a/ext/tk/sample/demos-jp/labelframe.rb +++ b/ext/tk/sample/demos-jp/labelframe.rb @@ -37,7 +37,7 @@ EOL TkFrame.new($labelframe_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') - TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{ + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ $labelframe_demo.destroy $labelframe_demo = nil }).pack(:side=>:left, :expand=>true) diff --git a/ext/tk/sample/demos-jp/menu.rb b/ext/tk/sample/demos-jp/menu.rb index fb32623cc8..79d5b3d4ca 100644 --- a/ext/tk/sample/demos-jp/menu.rb +++ b/ext/tk/sample/demos-jp/menu.rb @@ -31,7 +31,8 @@ TkLabel.new($menu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { # frame 生成 TkFrame.new($menu_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $menu_demo $menu_demo = nil @@ -150,7 +151,8 @@ TkMenubutton.new($menu_frame, 'text'=>'Icons', 'underline'=>0) {|m| TkMenu.new(m, 'tearoff'=>false) {|icon_menu| m.configure('menu'=>icon_menu) add('command', - 'bitmap'=>'@'+[$demo_dir,'images','pattern.bmp'].join(File::Separator), + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', 'text'=>'今あなたが選択したメニューの項目はテキストではなくビットマップを表示していました。それ以外の点では他のメニュー項目と変わりません。', 'bitmap'=>'', 'default'=>0, diff --git a/ext/tk/sample/demos-jp/menu84.rb b/ext/tk/sample/demos-jp/menu84.rb index ea5fdf6487..78d4e68872 100644 --- a/ext/tk/sample/demos-jp/menu84.rb +++ b/ext/tk/sample/demos-jp/menu84.rb @@ -45,7 +45,8 @@ TkFrame.new($menu84_demo) {|frame| # frame TkFrame.new($menu84_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $menu84_demo $menu84_demo = nil @@ -68,8 +69,8 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| $menu84_frame.add('cascade', 'label'=>'File', 'menu'=>m, 'underline'=>0) add('command', 'label'=>'Open...', 'command'=>proc{fail 'これは単なるデモですから、"Open..." 項目の機能は特に定義されてはいません。'}) add('command', 'label'=>'New', 'command'=>proc{fail 'これは単なるデモですから、"New" 項目の機能は特に定義されてはいません。'}) - add('command', 'label'=>'Save', 'command'=>proc{fail 'これは単なるでもですから、"Save" 項目の機能は特に定義されてはいません。'}) - add('command', 'label'=>'Save As...', 'command'=>proc{fail 'これは単なるでもですから、"Save As..." 項目の機能は特に定義されてはいません。'}) + add('command', 'label'=>'Save', 'command'=>proc{fail 'これは単なるデモですから、"Save" 項目の機能は特に定義されてはいません。'}) + add('command', 'label'=>'Save As...', 'command'=>proc{fail 'これは単なるデモですから、"Save As..." 項目の機能は特に定義されてはいません。'}) add('separator') add('command', 'label'=>'Print Setup...', 'command'=>proc{fail 'これは単なるデモですから、"Print Setup..." 項目の機能は特に定義されてはいません。'}) add('command', 'label'=>'Print...', 'command'=>proc{fail 'これは単なるデモですから、"Print..." 項目の機能は特に定義されてはいません。'}) @@ -157,7 +158,8 @@ TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| TkMenu.new($menu84_frame, 'tearoff'=>false) {|m| $menu84_frame.add('cascade', 'label'=>'Icons', 'menu'=>m, 'underline'=>0) add('command', 'hidemargin'=>1, - 'bitmap'=>'@'+[$demo_dir,'images','pattern.bmp'].join(File::Separator), + 'bitmap'=>'@'+[$demo_dir,'..', + 'images','pattern.xbm'].join(File::Separator), 'command'=>proc{TkDialog.new('title'=>'Bitmap Menu Entry', 'text'=>'あなたが選択したメニュー項目は、文字列の代わりにビットマップイメージで項目を表示したものです。それ以外の点では、ほかのメニュー項目との間で特に違いがあるわけではありません。', 'bitmap'=>'', 'default'=>0, diff --git a/ext/tk/sample/demos-jp/menu8x.rb b/ext/tk/sample/demos-jp/menu8x.rb index a6d3c5e09e..08598f88f8 100644 --- a/ext/tk/sample/demos-jp/menu8x.rb +++ b/ext/tk/sample/demos-jp/menu8x.rb @@ -26,7 +26,8 @@ TkLabel.new($menu8x_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { # frame 生成 TkFrame.new($menu8x_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $menu8x_demo $menu8x_demo = nil @@ -36,7 +37,7 @@ TkFrame.new($menu8x_demo) {|frame| TkButton.new(frame) { text 'コード参照' - command proc{showCode 'menu'} + command proc{showCode 'menu8x'} }.pack('side'=>'left', 'expand'=>'yes') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') @@ -62,7 +63,8 @@ TkFrame.new($menu8x_demo) {|frame| # frame 生成 TkFrame.new($menu8x_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $menu8x_demo $menu8x_demo = nil @@ -72,7 +74,7 @@ TkFrame.new($menu8x_demo) {|frame| TkButton.new(frame) { text 'コード参照' - command proc{showCode 'menu'} + command proc{showCode 'menu8x'} }.pack('side'=>'left', 'expand'=>'yes') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') diff --git a/ext/tk/sample/demos-jp/menubu.rb b/ext/tk/sample/demos-jp/menubu.rb index 8b4d7980d2..1308014183 100644 --- a/ext/tk/sample/demos-jp/menubu.rb +++ b/ext/tk/sample/demos-jp/menubu.rb @@ -43,7 +43,8 @@ TkLabel.new($menubu_demo,'font'=>$font,'wraplength'=>'4i','justify'=>'left') { # frame 生成 TkFrame.new($menubu_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $menubu_demo $menubu_demo = nil @@ -53,7 +54,7 @@ TkFrame.new($menubu_demo) {|frame| TkButton.new(frame) { text 'コード参照' - command proc{showCode 'menu'} + command proc{showCode 'menubu'} }.pack('side'=>'left', 'expand'=>'yes') }.pack('side'=>'bottom', 'fill'=>'x', 'pady'=>'2m') @@ -156,7 +157,8 @@ center = TkFrame.new(body) { TkFrame.new($menubu_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc { tmppath = $menubu_demo $menubu_demo = nil diff --git a/ext/tk/sample/demos-jp/msgbox.rb b/ext/tk/sample/demos-jp/msgbox.rb index cf53d70487..03ab1f7dbe 100644 --- a/ext/tk/sample/demos-jp/msgbox.rb +++ b/ext/tk/sample/demos-jp/msgbox.rb @@ -22,7 +22,8 @@ TkLabel.new($msgbox_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', # frame 生成 TkFrame.new($msgbox_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $msgbox_demo $msgbox_demo = nil diff --git a/ext/tk/sample/demos-jp/paned1.rb b/ext/tk/sample/demos-jp/paned1.rb index 99e6b6cddb..cd51e34aa0 100644 --- a/ext/tk/sample/demos-jp/paned1.rb +++ b/ext/tk/sample/demos-jp/paned1.rb @@ -30,7 +30,7 @@ EOL TkFrame.new($paned1_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') - TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{ + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ $paned1_demo.destroy $paned1_demo = nil }).pack(:side=>:left, :expand=>true) diff --git a/ext/tk/sample/demos-jp/paned2.rb b/ext/tk/sample/demos-jp/paned2.rb index 9df88c4b97..b0261d50f0 100644 --- a/ext/tk/sample/demos-jp/paned2.rb +++ b/ext/tk/sample/demos-jp/paned2.rb @@ -30,7 +30,7 @@ EOL TkFrame.new($paned2_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') - TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{ + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ $paned2_demo.destroy $paned2_demo = nil }).pack(:side=>:left, :expand=>true) diff --git a/ext/tk/sample/demos-jp/plot.rb b/ext/tk/sample/demos-jp/plot.rb index 464dd4441d..c8025d8bf9 100644 --- a/ext/tk/sample/demos-jp/plot.rb +++ b/ext/tk/sample/demos-jp/plot.rb @@ -24,7 +24,8 @@ TkLabel.new($plot_demo, 'font'=>$font, 'wraplength'=>'4i', 'justify'=>'left', # frame 生成 $plot_buttons = TkFrame.new($plot_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $plot_demo $plot_demo = nil diff --git a/ext/tk/sample/demos-jp/puzzle.rb b/ext/tk/sample/demos-jp/puzzle.rb index 24c48693a9..afef8fcb09 100644 --- a/ext/tk/sample/demos-jp/puzzle.rb +++ b/ext/tk/sample/demos-jp/puzzle.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($puzzle_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $puzzle_demo $puzzle_demo = nil diff --git a/ext/tk/sample/demos-jp/radio.rb b/ext/tk/sample/demos-jp/radio.rb index 871503029e..5858b4222a 100644 --- a/ext/tk/sample/demos-jp/radio.rb +++ b/ext/tk/sample/demos-jp/radio.rb @@ -31,7 +31,8 @@ color = TkVariable.new # frame 生成 TkFrame.new($radio_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $radio_demo $radio_demo = nil diff --git a/ext/tk/sample/demos-jp/radio2.rb b/ext/tk/sample/demos-jp/radio2.rb index 62425af90d..c7b98e6312 100644 --- a/ext/tk/sample/demos-jp/radio2.rb +++ b/ext/tk/sample/demos-jp/radio2.rb @@ -1,4 +1,4 @@ -# radio.rb +# radio2.rb # # This demonstration script creates a toplevel window containing # several radiobutton widgets. @@ -14,8 +14,8 @@ end # demo toplevel widget $radio2_demo = TkToplevel.new {|w| - title("Radiobutton Demonstration") - iconname("radio") + title("Radiobutton Demonstration 2") + iconname("radio2") positionWindow(w) } @@ -24,7 +24,7 @@ msg = TkLabel.new($radio2_demo) { font $font wraplength '5i' justify 'left' - text "下には2つのラジオボタングループが表示されています。ボタンをクリックすると、そのボタンだけがそのグループの中で選択されます。各グループに対してそのグループの中のどのボタンが選択されているかを示す変数が割り当てられています。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" + text "下には3つのラジオボタングループが表示されています。ボタンをクリックすると、そのボタンだけがそのグループの中で選択されます。各グループに対してそのグループの中のどのボタンが選択されているかを示す変数が割り当てられています。現在の変数の値を見るには「変数参照」ボタンをクリックしてください。" } msg.pack('side'=>'top') @@ -36,7 +36,8 @@ align = TkVariable.new # frame TkFrame.new($radio2_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $radio2_demo $radio2_demo = nil @@ -47,7 +48,7 @@ TkFrame.new($radio2_demo) {|frame| TkButton.new(frame) { text 'コード参照' - command proc{showCode 'radio'} + command proc{showCode 'radio2'} }.pack('side'=>'left', 'expand'=>'yes') TkButton.new(frame) { diff --git a/ext/tk/sample/demos-jp/rolodex-j b/ext/tk/sample/demos-jp/rolodex-j index 1c482aafb2..dcc18cfa51 100644 --- a/ext/tk/sample/demos-jp/rolodex-j +++ b/ext/tk/sample/demos-jp/rolodex-j @@ -4,7 +4,7 @@ # このスクリプトは Tom LaStrange の rolodex の一部です。 # # Copyright (C) 1998 by Takaaki Tateishi <ttate@jaist.ac.jp> -# Time-stamp: "03/08/02 14:01:54 nagai" +# Time-stamp: "04/04/09 00:32:12 nagai" # require "tk" diff --git a/ext/tk/sample/demos-jp/ruler.rb b/ext/tk/sample/demos-jp/ruler.rb index d1a7818be4..5d8c0443c1 100644 --- a/ext/tk/sample/demos-jp/ruler.rb +++ b/ext/tk/sample/demos-jp/ruler.rb @@ -37,7 +37,8 @@ TkLabel.new($ruler_demo, 'font'=>$font, 'wraplength'=>'5i', 'justify'=>'left', # frame 生成 $ruler_buttons = TkFrame.new($ruler_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $ruler_demo $ruler_demo = nil @@ -72,11 +73,13 @@ $demo_rulerInfo.normalStyle = {'fill'=>'black'} if TkWinfo.depth($ruler_canvas) > 1 $demo_rulerInfo.activeStyle = {'fill'=>'red', 'stipple'=>''} $demo_rulerInfo.deleteStyle = {'fill'=>'red', - 'stipple'=>'@'+[$demo_dir, 'images', 'gray25.bmp'].join(File::Separator)} + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator)} else $demo_rulerInfo.activeStyle = {'fill'=>'black', 'stipple'=>''} $demo_rulerInfo.deleteStyle = {'fill'=>'black', - 'stipple'=>'@'+[$demo_dir, 'images', 'gray25.bmp'].join(File::Separator)} + 'stipple'=>'@'+[$demo_dir, '..', + 'images', 'gray25.xbm'].join(File::Separator)} end TkcLine.new($ruler_canvas, diff --git a/ext/tk/sample/demos-jp/sayings.rb b/ext/tk/sample/demos-jp/sayings.rb index f627396e0f..bcbdd7a5e7 100644 --- a/ext/tk/sample/demos-jp/sayings.rb +++ b/ext/tk/sample/demos-jp/sayings.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($sayings_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $sayings_demo $sayings_demo = nil diff --git a/ext/tk/sample/demos-jp/search.rb b/ext/tk/sample/demos-jp/search.rb index 538c607c01..3ae7de769d 100644 --- a/ext/tk/sample/demos-jp/search.rb +++ b/ext/tk/sample/demos-jp/search.rb @@ -77,7 +77,8 @@ $search_demo = TkToplevel.new {|w| # frame 生成 $search_buttons = TkFrame.new($search_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $search_demo $search_demo = nil @@ -141,45 +142,33 @@ $search_text = TkText.new($search_demo, 'setgrid'=>true) {|t| if TkWinfo.depth($search_demo) > 1 textToggle(proc{ - begin - $search_Tag.configure('background'=>'#ce5555', - 'foreground'=>'white') - rescue - end + $search_Tag.configure('background'=>'#ce5555', + 'foreground'=>'white') }, 800, proc{ - begin - $search_Tag.configure('background'=>'', 'foreground'=>'') - rescue - end + $search_Tag.configure('background'=>'', 'foreground'=>'') }, 200 ) else textToggle(proc{ - begin - $search_Tag.configure('background'=>'black', - 'foreground'=>'white') - rescue - end + $search_Tag.configure('background'=>'black', + 'foreground'=>'white') }, 800, proc{ - begin - $search_Tag.configure('background'=>'', 'foreground'=>'') - rescue - end + $search_Tag.configure('background'=>'', 'foreground'=>'') }, 200 ) end -$search_text.insert('1.0', '\ -このウィンドウは検索機構を実現するのにテキスト widget のタグ機能がどの -ように使われるのかをデモするものです。まず上のエントリにファイル名を入 -れ、<リターン> を押すか「ロード」ボタンを押してください。次にその下の -エントリに文字列を入力し、<リターン> を押すか「反転」ボタンを押してく -ださい。するとファイル中の、検索文字列と一致する部分に全て "search_Tag" -というタグがつけられ、タグの表示属性としてその文字列が点滅するように -設定されます。') +$search_text.insert('1.0', "\ +このウィンドウは検索機構を実現するのにテキスト widget のタグ機能がどの \ +ように使われるのかをデモするものです。まず上のエントリにファイル名を入 \ +れ、<リターン> を押すか「ロード」ボタンを押してください。次にその下の \ +エントリに文字列を入力し、<リターン> を押すか「反転」ボタンを押してく \ +ださい。するとファイル中の、検索文字列と一致する部分に全て \"search_Tag\" \ +というタグがつけられ、タグの表示属性としてその文字列が点滅するように \ +設定されます。") $search_text.set_insert '0.0' $search_fileName.value = '' diff --git a/ext/tk/sample/demos-jp/spin.rb b/ext/tk/sample/demos-jp/spin.rb index 4f6edc13c0..69d6d71d8d 100644 --- a/ext/tk/sample/demos-jp/spin.rb +++ b/ext/tk/sample/demos-jp/spin.rb @@ -41,7 +41,7 @@ EOL TkFrame.new($spin_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') - TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{ + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ $spin_demo.destroy $spin_demo = nil }).pack(:side=>:left, :expand=>true) diff --git a/ext/tk/sample/demos-jp/states.rb b/ext/tk/sample/demos-jp/states.rb index cf8a6768b6..dfae821261 100644 --- a/ext/tk/sample/demos-jp/states.rb +++ b/ext/tk/sample/demos-jp/states.rb @@ -27,7 +27,8 @@ msg.pack('side'=>'top') # frame 生成 TkFrame.new($states_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $states_demo $states_demo = nil diff --git a/ext/tk/sample/demos-jp/style.rb b/ext/tk/sample/demos-jp/style.rb index d58c6115ae..458479611b 100644 --- a/ext/tk/sample/demos-jp/style.rb +++ b/ext/tk/sample/demos-jp/style.rb @@ -18,7 +18,8 @@ $style_demo = TkToplevel.new {|w| # frame 生成 TkFrame.new($style_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $style_demo $style_demo = nil diff --git a/ext/tk/sample/demos-jp/tcolor b/ext/tk/sample/demos-jp/tcolor index 391ce4c446..fc697df63e 100644 --- a/ext/tk/sample/demos-jp/tcolor +++ b/ext/tk/sample/demos-jp/tcolor @@ -16,15 +16,16 @@ require "tk" # Tkによって変更される変数はTkVariableのインスタンスを使う。 $colorSpace = TkVariable.new(:rgb) +$master = nil $red = 65535 $green = 0 $blue = 0 $color = "#ffff00000000" $updating = TkVariable.new(0) $autoUpdate = TkVariable.new(1) -$name = TkVariable.new("") -# $command = TkVariable.new("print(%%,\"\n\")") -$command = TkVariable.new("") +$name = TkVariable.new($color) +$command = TkVariable.new("print(%%,\"\n\")") +# $command = TkVariable.new("") $label1 = TkVariable.new("label1") $label2 = TkVariable.new("label2") $label3 = TkVariable.new("label3") @@ -134,6 +135,8 @@ def tc_scaleChanged return end + $master = :scale if $master == nil + scale1 = $root.middle.middle.scale1 scale2 = $root.middle.middle.scale2 scale3 = $root.middle.middle.scale3 @@ -158,11 +161,13 @@ def tc_scaleChanged raise(Exception,"unknown colorSpace") end $color = format("#%04x%04x%04x",$red.to_i,$green.to_i,$blue.to_i) + $name.value = $color if $master == :scale $root.middle.right.set_color($color) if( $autoUpdate.to_i == 1 ) doUpdate end - Tk.update(TRUE) + Tk.update(true) + $master = nil if $master == :scale end @@ -196,6 +201,8 @@ end def tc_loadNamedColor(name) + $name.value = name + $master = :name if $master == nil if name[0,1] != "#" list = TkWinfo.rgb($root.middle.right.swatch,name) $red = list[0] @@ -222,9 +229,9 @@ def tc_loadNamedColor(name) if strlist.length != 3 raise(eException,"syntax error in color name \"#{name}\"") end - $red = strlist[0].to_i - $green = strlist[1].to_i - $blue = strlist[2].to_i + $red = strlist[0].hex + $green = strlist[1].hex + $blue = strlist[2].hex } $red = $red << shift $green = $green << shift @@ -237,6 +244,8 @@ def tc_loadNamedColor(name) if $autoUpdate.to_i == 1 doUpdate end + Tk.update(true) + $master = nil if $master == :name end diff --git a/ext/tk/sample/demos-jp/text.rb b/ext/tk/sample/demos-jp/text.rb index 179589d820..bec95ee525 100644 --- a/ext/tk/sample/demos-jp/text.rb +++ b/ext/tk/sample/demos-jp/text.rb @@ -25,7 +25,8 @@ end # frame 生成 TkFrame.new($text_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $text_demo $text_demo = nil diff --git a/ext/tk/sample/demos-jp/twind.rb b/ext/tk/sample/demos-jp/twind.rb index d35acd24d0..8716ad7278 100644 --- a/ext/tk/sample/demos-jp/twind.rb +++ b/ext/tk/sample/demos-jp/twind.rb @@ -18,7 +18,8 @@ $twind_demo = TkToplevel.new {|w| # frame 生成 $twind_buttons = TkFrame.new($twind_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc{ tmppath = $twind_demo $twind_demo = nil @@ -75,7 +76,7 @@ TkTextWindow.new($twind_text, 'end', command proc{textWindOn $twind_text,$twind_buttons} cursor 'top_left_arrow' }) -$twind_text.insert('end', 'にします。また2つめのボタンをクリックすると') +$twind_text.insert('end', "にします。また2つめのボタンをクリックすると\n") $twind_text.insert('end', '水平方向のスクロールを') TkTextWindow.new($twind_text, 'end', 'window'=>TkButton.new($twind_text) { diff --git a/ext/tk/sample/demos-jp/unicodeout.rb b/ext/tk/sample/demos-jp/unicodeout.rb index d408a36aae..37cc1699bb 100644 --- a/ext/tk/sample/demos-jp/unicodeout.rb +++ b/ext/tk/sample/demos-jp/unicodeout.rb @@ -41,7 +41,7 @@ EOL TkFrame.new($unicodeout_demo){|f| pack(:side=>:bottom, :fill=>:x, :pady=>'2m') - TkButton.new(f, :text=>'了解', :width=>15, :command=>proc{ + TkButton.new(f, :text=>'閉じる', :width=>15, :command=>proc{ $unicodeout_demo.destroy $unicodeout_demo = nil }).pack(:side=>:left, :expand=>true) diff --git a/ext/tk/sample/demos-jp/vscale.rb b/ext/tk/sample/demos-jp/vscale.rb index 4cb8e0f6b7..86f6f7cdee 100644 --- a/ext/tk/sample/demos-jp/vscale.rb +++ b/ext/tk/sample/demos-jp/vscale.rb @@ -24,7 +24,8 @@ msg.pack('side'=>'top', 'padx'=>'.5c') TkFrame.new($vscale_demo) {|frame| TkButton.new(frame) { - text '了解' + #text '了解' + text '閉じる' command proc { tmppath = $vscale_demo $vscale_demo = nil diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index 696a9073cc..0544127cbb 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -1,8 +1,11 @@ #!/usr/bin/env ruby +# 漢字コード設定 ( tk.rb のロード時の encoding 推定/設定に使われる ) +$KCODE = 'euc' + # tk 関係ライブラリの読み込み require 'tk' -require 'tkafter' +# require 'tkafter' # widget demo directory 位置の獲得 $demo_dir = File.dirname($0) @@ -12,43 +15,106 @@ $root = TkRoot.new{title "Widget Demonstration"} # tk バージョンの取得 $tk_version = Tk::TK_VERSION +$tk_major_ver, $tk_minor_ver = $tk_version.split('.').map{|n| n.to_i} +$tk_patchlevel = Tk::TK_PATCHLEVEL # tcl_platform 情報へのアクセスオブジェクト $tk_platform = TkVarAccess.new('tcl_platform') # フォント設定 -$font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) -knjfont = '-*-r-*--16-*-jisx0208.1983-0' -$kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', - knjfont) -TkOption.add('*kanjiFont', knjfont, 'startupFile') -$msg_kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', - '-*-r-*--24-*-jisx0208.1983-0') ####### -#case($tk_version) -#when /^4.*/ -# $font = '-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*' -# $kanji_font = '-*--16-*-jisx0208.1983-0' -# $msg_kanji_font = '-*--24-*-jisx0208.1983-0' -# $knjfont_opt = 'kanjifont' -# TkOption.add('*kanjiFont', $kanji_font, 'startupFile') -# -#when /^8.*/ -# Tk.tk_call('font', 'create', '@ascii', -# '-copy', '-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*') -# Tk.tk_call('font', 'create', '@kanji', -# '-copy', '-*--16-*-jisx0208.1983-0') -# Tk.tk_call('font', 'create', '@msg_knj', -# '-copy', '-*--24-*-jisx0208.1983-0') -# Tk.tk_call('font', 'create', '@cFont', '-compound', '@ascii @kanji') -# Tk.tk_call('font', 'create', '@cMsgFont', '-compound', '@ascii @msg_knj') -# $font = '-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*' -# $kanji_font = '@cFont' -# $msg_kanji_font = '@cMsgFont' -# $knjfont_opt = 'font' -#end +case($tk_version) +when /^4.*/ + $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) + knjfont = '-*--16-*-jisx0208.1983-0' + $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', + knjfont) + TkOption.add('*kanjiFont', knjfont, 'startupFile') + $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', + '-*--24-*-jisx0208.1983-0') + +#when '8.0' +# $font = TkFont.new('Helvetica -12') +# $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12') +# TkOption.add('*kanjiFont', knjfont, 'startupFile') +# $msg_kanji_font=TkFont.new('Helvetica 16', 'Gothic 16 bold') + +when /^8.*/ + $font = TkFont.new('Helvetica -12') + $kanji_font = TkFont.new('Helvetica -12', 'Mincho -12') + TkOption.add('*kanjiFont', knjfont, 'startupFile') + $msg_kanji_font=TkFont.new('Helvetica 16', 'Gothic 16 bold') + +else + $font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', nil) + knjfont = '-*--16-*-jisx0208.1983-0' + $kanji_font = TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', + knjfont) + TkOption.add('*kanjiFont', knjfont, 'startupFile') + $msg_kanji_font=TkFont.new('-*-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*', + '-*--24-*-jisx0208.1983-0') +end ####### +# イメージ設定 +$image = {} + +if $tk_major_ver >= 8 +$image['refresh'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAQAPMAAMz/zCpnKdb/1z9mPypbKBtLGy9NMPL/9Or+6+P+4j1Y + PwQKBP7//xMLFAYBCAEBASH5BAEAAAAALAAAAAAQABAAAwR0EAD3Gn0Vyw0e + ++CncU7IIAezMA/nhUqSLJizvSdCEEjy2ZIV46AwDAoDHwPYGSoEiUJAAGJ6 + EDHBNCFINW5OqABKSFk/B9lUa94IDwIFgewFMwQDQwCZQCztTgM9Sl8SOEMG + KSAthiaOjBMPDhQONBiXABEAOw== +EOD +end + +if $tk_major_ver >= 8 +$image['view'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAQAPMAAMz/zP///8DAwICAgH9/fwAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAwRIcMhJB7h3hM33 + KFjWdQQYap1QrCaGBmrRrS4nj5b53jOgbwXBKGACoYLDIuAoHCmZyYvR1rT5 + RMAq8LqcIYGsrjPsW1XOmFUEADs= +EOD +end + +if $tk_major_ver >= 8 +$image['delete'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhEAAOAKEAAIQAAO/n3v///////yH5BAEKAAIALAAAAAAQAA4AAAIm + lI9pAKHbIHNoVhYhTdjlJ2AWKG2g+CldmB6rxo2uybYhbS80eRQAOw== +EOD +end + +if $tk_major_ver >= 8 +$image['print'] = TkPhotoImage.new(:height=>16, :format=>'GIF', :data=><<EOD) + R0lGODlhGgATAPcAACEQOTEpQjEpUkIpc0IxY0I5c0oxjEo5SlJCY1JCe1JK + UlpChFpCjFpGkFpSc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JBixg8hRIiUUEBBYYmTByBwiCBCRYwH + CxY8cKFw4AogRXLqLAJkQ80gCBBg3BkxZswTNGh4MGqgQQUMJRHCwMkTSE+D + Pn8eCKBhxIMhO3ei2OHDBw6sWSlMMMoWgwwfMDZI8GBjx44NARZwEGGi5MkS + PcIWKRGz5YgLbAco+KkQBQoJIRgjdGEVq+SaJajqtNrzMgsPCmoIzqmDgmWE + KOBuUKAAwYabYTfs4OHjY0giGyhk4MAWRI4eKyRQqPgggYUXPH4A+XBAgwoK + DiIsCFxjA9sFEVQQCRJCAYAFDJxiKhAxvMTonEFimrhhYinTBgWiCvxLNX3M + DkkpsKV5OYhjBxCMYAICAigUEAA7 +EOD +end + # メニュー設定 TkMenubar.new($root, [[['File', 0], @@ -57,6 +123,7 @@ TkMenubar.new($root, ['Quit', proc{exit}, 0, 'Meta-Q'] ]]).pack('side'=>'top', 'fill'=>'x') $root.bind('F1', proc{aboutBox}) +$root.bind('Meta-q', proc{exit}) =begin TkFrame.new($root){|frame| @@ -77,7 +144,7 @@ if $tk_version =~ /^4\.[01]/ txt = TkText.new($root) { #wrap 'word' wrap 'char' - width 60 + width 70 height 30 font $font setgrid 'yes' @@ -95,7 +162,7 @@ else txt = TkText.new($root) { #wrap 'word' wrap 'char' - width 60 + width 70 height 30 font $font setgrid 'yes' @@ -103,6 +170,7 @@ else padx 4 pady 2 takefocus 0 + bd 1 yscrollcommand proc{|first,last| scr.set first,last} } scr.command(proc{|*args| txt.yview(*args)}) @@ -124,11 +192,13 @@ end # テキストタグ設定 tag_title = TkTextTag.new(txt, 'font'=>'-*-Helvetica-Bold-R-Normal--*-180-*-*-*-*-*-*') -tag_kanji_title = TkTextTag.new(txt, 'kanjifont'=>$msg_kanji_font) -tag_middle = TkTextTag.new(txt, 'kanjifont'=>$kanji_font) +#tag_kanji_title = TkTextTag.new(txt, 'kanjifont'=>$msg_kanji_font) +#tag_middle = TkTextTag.new(txt, 'kanjifont'=>$kanji_font) +tag_kanji_title = TkTextTag.new(txt, 'font'=>$msg_kanji_font) +tag_middle = TkTextTag.new(txt, 'font'=>$kanji_font) tag_demospace = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c') -if TkWinfo.depth($root) == '1' +if TkWinfo.depth($root) == 1 tag_demo = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', 'underline'=>1) $tag_visited = TkTextTag.new(txt, 'lmargin1'=>'1c', 'lmargin2'=>'1c', @@ -218,28 +288,34 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. チェックボタン (複数を選択可能)\n", tag_demo, "demo-check") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "5. ラジオボタン (任意の一つを選択可能)\n", +txt.insert('end', "5. 3状態チェックボタン (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-check2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. ラジオボタン (任意の一つを選択可能)\n", tag_demo, "demo-radio") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "6. ラジオボタン (機能に対応したバージョンのTkが必要)\n", +txt.insert('end', "7. ラジオボタン (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-radio2") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "7. ボタンで作られた15-パズルゲーム\n", +txt.insert('end', "8. 3状態ラジオボタン (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-radio3") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "9. ボタンで作られた15-パズルゲーム\n", tag_demo, "demo-puzzle") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "8. ビットマップを使用したアイコンボタン\n", +txt.insert('end', "10. ビットマップを使用したアイコンボタン\n", tag_demo, "demo-icon") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "9. 画像を表示する二つのラベル\n", +txt.insert('end', "11. 画像を表示する二つのラベル\n", tag_demo, "demo-image1") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "10. 画像を見るための簡単なユーザインターフェース\n", +txt.insert('end', "12. 画像を見るための簡単なユーザインターフェース\n", tag_demo, "demo-image2") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "11. 画像を見るための簡単なユーザインターフェース (機能に対応したバージョンのTkが必要)\n", +txt.insert('end', "13. 画像を見るための簡単なユーザインターフェース (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-image3") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "12. ラベル付きフレーム (機能に対応したバージョンのTkが必要)\n", +txt.insert('end', "14. ラベル付きフレーム (機能に対応したバージョンのTkが必要)\n", tag_demo, "demo-labelframe") txt.insert('end', " \n ", tag_demospace) @@ -286,7 +362,10 @@ txt.insert('end', " \n ", tag_demospace) txt.insert('end', "4. ウィンドウを埋め込んだテキスト\n", tag_demo, "demo-twind") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "5. 検索\n", tag_demo, "demo-search") +txt.insert('end', "5. ウィンドウを埋め込んだテキスト (機能に対応したバージョンのTkが必要)\n", + tag_demo, "demo-twind2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "6. 検索\n", tag_demo, "demo-search") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "\n") @@ -305,7 +384,9 @@ txt.insert('end', "5. ルーラー\n", tag_demo, "demo-ruler") txt.insert('end', " \n ", tag_demospace) txt.insert('end', "6. フロアプラン\n", tag_demo, "demo-floor") txt.insert('end', " \n ", tag_demospace) -txt.insert('end', "7. スクロール可能なキャンバス\n", +txt.insert('end', "7. フロアプラン (異なるキャンバスアイテム作成方法を使用)\n", tag_demo, "demo-floor2") +txt.insert('end', " \n ", tag_demospace) +txt.insert('end', "8. スクロール可能なキャンバス\n", tag_demo, "demo-cscroll") txt.insert('end', " \n ", tag_demospace) @@ -381,14 +462,14 @@ end # 親ウィジェットと,変数名と TkVariable との組(配列)の並びを渡す $showVarsWin = {} -def showVars (parent, *args) +def showVars1(parent, *args) if $showVarsWin[parent.path] begin $showVarsWin[parent.path].destroy rescue end end - w = TkToplevel.new(parent) {|w| + top = TkToplevel.new(parent) {|w| title "Variable values" TkLabel.new(w) { text "変数値:" @@ -413,7 +494,49 @@ def showVars (parent, *args) command proc{w.destroy} }.pack('side'=>'bottom', 'pady'=>2) } - $showVarsWin[parent.path] = w + $showVarsWin[parent.path] = top +end + +def showVars2(parent, *args) + if $showVarsWin[parent.path] + begin + $showVarsWin[parent.path].destroy + rescue + end + end + $showVarsWin[parent.path] = TkToplevel.new(parent) {|w| + title "Variable values" + + TkLabelFrame.new(w, :text=>"変数値:", + :font=>{:family=>'Helvetica', :size=>14}){|f| + args.each{|vnam,vbody| + TkGrid(TkLabel.new(f, :text=>"#{vnam}: ", :anchor=>'w'), + TkLabel.new(f, :textvariable=>vbody, :anchor=>'w'), + :padx=>2, :pady=>2, :sticky=>'w') + } + + f.grid(:sticky=>'news', :padx=>4) + f.grid_columnconfig(1, :weight=>1) + f.grid_rowconfig(100, :weight=>1) + } + TkButton.new(w, :text=>"了解", :width=>8, :default=>:active, + :command=>proc{w.destroy}){|b| + w.bind('Return', proc{b.invoke}) + w.bind('Escape', proc{b.invoke}) + + b.grid(:sticky=>'e', :padx=>4, :pady=>[6, 4]) + } + w.grid_columnconfig(0, :weight=>1) + w.grid_rowconfig(0, :weight=>1) + } +end + +if $tk_major_ver < 8 + alias showVars showVars1 +elsif $tk_major_ver == 8 && $tk_minor_ver < 4 + alias showVars showVars1 +else # ver >= 8.4 + alias showVars showVars2 end # テキスト上での click に対する動作 @@ -424,7 +547,8 @@ def invoke (txt, index) txt.cursor('watch') Tk.update # eval `cat #{tag[5..-1]}.rb` - eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb` +# eval `cat #{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb` + eval IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join Tk.update # txt.cursor('xterm') txt.cursor(cursor) @@ -449,14 +573,15 @@ def showStatus (txt, index) end # ソースコードの表示 -def showCode (demo) +def showCode1(demo) file = "#{demo}.rb" $code_window = nil unless defined? $code_window - if $code_window == nil || TkWinfo.exist?($code_window) == '0' + if $code_window == nil || TkWinfo.exist?($code_window) == false $code_window = TkToplevel.new(nil) f = TkFrame.new($code_window) TkButton.new(f) { - text "了解" + #text "了解" + text "閉じる" command proc{ $code_window.destroy $code_window = nil @@ -528,13 +653,194 @@ def showCode (demo) fid.close end +def showCode2(demo) + file = "#{demo}.rb" + $code_window = nil unless defined? $code_window + if $code_window == nil || TkWinfo.exist?($code_window) == false + $code_window = TkToplevel.new(nil) + tf = TkFrame.new($code_window) + $code_text = TkText.new(tf, :font=>'Courier 10', :height=>30, + :wrap=>'word', :bd=>1, :setgrid=>true, + :highlightthickness=>0, :pady=>2, :padx=>3) + xscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} + yscr = TkScrollbar.new(tf, :bd=>1){assign($code_text)} + TkGrid($code_text, yscr, :sticky=>'news') + #TkGrid(xscr) + tf.grid_rowconfigure(0, :weight=>1) + tf.grid_columnconfigure(0, :weight=>1) + + bf = TkFrame.new($code_window) + + #b_dis = TkButton.new(bf, :text=>'了解', :default=>:active, + b_dis = TkButton.new(bf, :text=>'閉じる', :default=>:active, + :command=>proc{ + $code_window.destroy + $code_window = nil + }, + :image=>$image['delete'], :compound=>:left) + b_prn = TkButton.new(bf, :text=>'印刷', + :command=>proc{printCode($code_text, file)}, + :image=>$image['print'], :compound=>:left) + b_run = TkButton.new(bf, :text=>'再実行', + :command=>proc{eval($code_text.get('1.0','end'))}, + :image=>$image['refresh'], :compound=>:left) + + TkGrid('x', b_run, b_prn, b_dis, :padx=>4, :pady=>[6,4]) + bf.grid_columnconfigure(0, :weight=>1) + + TkGrid(tf, :sticky=>'news') + TkGrid(bf, :sticky=>'ew') + $code_window.grid_columnconfigure(0, :weight=>1) + $code_window.grid_rowconfigure(0, :weight=>1) + + $code_window.bind('Return', proc{|win| + b_dis.invoke unless win.kind_of?(TkText) + }, '%W') + $code_window.bindinfo('Return').each{|cmd, arg| + $code_window.bind_append('Escape', cmd, arg) + } + else + $code_window.deiconify + $code_window.raise + end + + $code_window.title("Demo code: #{file}") + $code_window.iconname(file) + fid = open([$demo_dir, file].join(File::Separator), 'r') + $code_text.delete('1.0', 'end') + $code_text.insert('1.0', fid.read) + TkTextMarkInsert.new($code_text,'1.0') + fid.close +end + +if $tk_major_ver < 8 + alias showCode showCode1 +elsif $tk_major_ver == 8 && $tk_minor_ver < 4 + alias showCode showCode1 +else # ver >= 8.4 + alias showCode showCode2 +end + + +# printCode -- +# Prints the source code currently displayed in the See Code dialog. +# Much thanks to Arjen Markus for this. +# +# Arguments: +# txt - Name of text widget containing code to print +# file - Name of the original file (implicitly for title) + +def printCode(txt, file) + code = txt.get('1.0', 'end - 1c') + dir = '.' + dir = ENV['HOME'] if ENV['HOME'] + dir = ENV['TMP'] if ENV['TMP'] + dir = ENV['TEMP'] if ENV['TEMP'] + + fname = [dir, 'tkdemo-' + file].join(File::Separator) + open(fname, 'w'){|fid| fid.print(code)} + begin + case Tk::TCL_PLATFORM('platform') + when 'unix' + msg = `lp -c #{fname}` + unless $?.exitstatus == 0 + Tk.messageBox(:title=>'Print spooling failure', + :message=>'エラーが発生しました.' + + '印刷に失敗したものと思われます : ' + msg) + end + when 'windows' + begin + printTextWin32(fname) + rescue => e + Tk.messageBox(:title=>'Print spooling failure', + :message=>'エラーが発生しました.' + + '印刷に失敗したものと思われます : ' + + e.message) + end + when 'macintosh' + Tk.messageBox(:title=>'Operation not Implemented', + :message=>'印刷機能はまだ実装されていません') + else + Tk.messageBox(:title=>'Operation not Implemented', + :message=>'検出された環境 ' + + Tk::TCL_PLATFORM('platform') + + ' は未知の環境であるため,' + + '印刷機能は実装されていません: ') + end + ensure + File.delete(fname) + end +end + +# printTextWin32 -- +# Print a file under Windows +# +# Arguments: +# filename - Name of the file +# +def printTextWin32(fname) + require 'win32/registry' + begin + app = Win32::Registry::HKEY_CLASSES_ROOT['.txt'] + pcmd = nil + Win32::Registry::HKEY_CLASSES_ROOT.open("#{app}\\shell\\print"){|reg| + pcmd = reg['command'] + } + rescue + app = Tk.tk_call('auto_execok', 'notepad.exe') + pcmd = "#{app} /p %1" + end + + pcmd.gsub!('%1', fname) + puts pcmd + cmd = Tk.tk_call('auto_execok', 'start') + ' /min ' + pcmd + + msg = `#{cmd}` + unless $?.exitstatus == 0 + fail RuntimeError, msg + end +end + # aboutBox # # Pops up a message box with an "about" message # def aboutBox Tk.messageBox('icon'=>'info', 'type'=>'ok', 'title'=>'About Widget Demo', - 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.3.2-jp\n\n( based on Tk ウィジェットデモ :: Copyright (c) 1996-1997 Sun Microsystems, Inc. )\n\nRunning Version :: Ruby#{VERSION}/Tk#{$tk_version}#{(Tk::JAPANIZED_TK)? 'jp': ''}") + 'message'=>"Ruby/Tk ウィジェットデモ Ver.1.4.3-jp\n\n" + + "based on demos of Tk8.1 -- 8.5 " + + "( Copyright:: " + + "(c) 1996-1997 Sun Microsystems, Inc. / " + + "(c) 1997-2000 Ajuba Solutions, Inc. / " + + "(c) 2001-2003 Donal K. Fellows )\n\n" + + "Your Ruby & Tk Version ::\n" + + "Ruby#{RUBY_VERSION}(#{RUBY_RELEASE_DATE})[#{RUBY_PLATFORM}] / Tk#{$tk_patchlevel}#{(Tk::JAPANIZED_TK)? '-jp': ''}") +end + +#################################### +# 引数で指定されたデモを起動する +no_launcher = false +if ARGV[0] == '-n' + ARGV.shift + no_launcher = true if ARGV.size > 0 +end +ARGV.each{|cmd| + if cmd =~ /(.*).rb/ + cmd = $1 + end + eval IO.readlines("#{[$demo_dir, cmd].join(File::Separator)}.rb").join +} +if no_launcher + $root.withdraw # hide root window + Thread.start{ + loop do + count = 0 + $root.winfo_children.each{|w| + count += 1 if w.kind_of?(TkToplevel) + } + $root.destroy if count == 0 + end + } end ################################ diff --git a/ext/tk/sample/safe-tk.rb b/ext/tk/sample/safe-tk.rb index 0a25c804f0..a93707220e 100644 --- a/ext/tk/sample/safe-tk.rb +++ b/ext/tk/sample/safe-tk.rb @@ -10,7 +10,6 @@ safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none, 'expand'=>false) #safe_slave2 = MultiTkIp.new_safeTk('fill'=>:none) #safe_slave2 = MultiTkIp.new_safeTk('expand'=>false) - cmd = Proc.new{|txt| ##################### ## from TkTimer2.rb diff --git a/ext/tk/sample/tkballoonhelp.rb b/ext/tk/sample/tkballoonhelp.rb index 312e376a07..b71c5746db 100644 --- a/ext/tk/sample/tkballoonhelp.rb +++ b/ext/tk/sample/tkballoonhelp.rb @@ -92,7 +92,7 @@ if __FILE__ == $0 TkButton.new('text'=>'This button has another balloon help') {|b| pack('fill'=>'x') TkBalloonHelp.new(b, 'text'=>'configured message', - 'interval'=>500, 'font'=>'courier', + 'interval'=>200, 'font'=>'courier', 'background'=>'gray', 'foreground'=>'red') } Tk.mainloop diff --git a/ext/tk/sample/tkline.rb b/ext/tk/sample/tkline.rb index 2406b0749f..5bdf3aec78 100644 --- a/ext/tk/sample/tkline.rb +++ b/ext/tk/sample/tkline.rb @@ -15,6 +15,8 @@ def start_random end end +Label.new('text'=>'Please press or drag button-1').pack + $c = Canvas.new $c.pack $start_x = start_y = 0 diff --git a/ext/tk/sample/tkmultilistbox.rb b/ext/tk/sample/tkmultilistbox.rb index c3787a0cf0..257cf95c39 100644 --- a/ext/tk/sample/tkmultilistbox.rb +++ b/ext/tk/sample/tkmultilistbox.rb @@ -109,7 +109,9 @@ class TkMultiListbox < TkListbox @v_scroll.set first, last } } - @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} } +# @v_scroll.command proc{|*args| @lbox_list.each{|lbox| lbox.yview *args} } + @v_scroll.command proc{|*args| p "";p [@lbox_list, args]; @lbox_list.each{|lbox| lbox.yview *args} } +# @v_scroll.command proc{|*args| p "";p [@lbox_list, args]; @lbox_list.each{|lbox| lbox.yview *args}; p [@lbox_list, args] } # binding for listboxes @mode = {} diff --git a/ext/tk/sample/tktextframe.rb b/ext/tk/sample/tktextframe.rb index 78efdf0970..5d16f2b0be 100644 --- a/ext/tk/sample/tktextframe.rb +++ b/ext/tk/sample/tktextframe.rb @@ -65,9 +65,9 @@ class TkTextFrame < TkText # vertical scrollbar : ON/OFF def vscroll(mode) st = TkGrid.info(@v_scroll) - if mode && st == [] then + if mode && st.size == 0 then @v_scroll.grid('row'=>0, 'column'=>1, 'sticky'=>'ns') - elsif !mode && st != [] then + elsif !mode && st.size != 0 then @v_scroll.ungrid end self @@ -76,10 +76,10 @@ class TkTextFrame < TkText # horizontal scrollbar : ON/OFF def hscroll(mode, wrap_mode="char") st = TkGrid.info(@h_scroll) - if mode && st == [] then + if mode && st.size == 0 then @h_scroll.grid('row'=>1, 'column'=>0, 'sticky'=>'ew') wrap 'none' # => self.wrap('none') - elsif !mode && st != [] then + elsif !mode && st.size != 0 then @h_scroll.ungrid wrap wrap_mode # => self.wrap(wrap_mode) end diff --git a/ext/tk/tkutil.c b/ext/tk/tkutil.c index b42069e234..cacc2622f0 100644 --- a/ext/tk/tkutil.c +++ b/ext/tk/tkutil.c @@ -1,6 +1,6 @@ /************************************************ - tk.c - + tkutil.c - $Author$ $Date$ @@ -9,37 +9,1176 @@ ************************************************/ #include "ruby.h" +#include "st.h" + +static VALUE cMethod; + +static VALUE cTclTkLib; + +static VALUE cTkObject; +static VALUE cTkCallbackEntry; + +static VALUE TK_None; + +static VALUE cCB_SUBST; +static VALUE cSUBST_INFO; + +static ID ID_split_tklist; +static ID ID_toUTF8; +static ID ID_fromUTF8; +static ID ID_path; +static ID ID_to_eval; +static ID ID_to_s; +static ID ID_install_cmd; +static ID ID_merge_tklist; +static ID ID_call; + +static ID ID_SUBST_INFO; + +static VALUE CALLBACK_TABLE; +static unsigned long CALLBACK_ID_NUM = 0; + +/*************************************/ + +static VALUE +tk_s_new(argc, argv, klass) + int argc; + VALUE *argv; + VALUE klass; +{ + VALUE obj = rb_class_new_instance(argc, argv, klass); + + if (rb_block_given_p()) rb_obj_instance_eval(0, 0, obj); + return obj; +} + +/*************************************/ static VALUE -tk_eval_cmd(argc, argv) +tkNone_to_s(self) + VALUE self; +{ + return rb_str_new2("None"); +} + +/*************************************/ + +static VALUE +tk_eval_cmd(argc, argv, self) int argc; VALUE argv[]; + VALUE self; { - VALUE cmd, rest; + volatile VALUE cmd, rest, arg; + volatile VALUE ret; + int status; rb_scan_args(argc, argv, "1*", &cmd, &rest); return rb_eval_cmd(cmd, rest, 0); } static VALUE -tk_s_new(argc, argv, klass) - int argc; +tk_do_callback(argc, argv, self) + int argc; VALUE *argv; - VALUE klass; + VALUE self; { - VALUE obj = rb_class_new_instance(argc, argv, klass); +#if 0 + volatile VALUE id; + volatile VALUE rest; + + rb_scan_args(argc, argv, "1*", &id, &rest); + return rb_apply(rb_hash_aref(CALLBACK_TABLE, id), ID_call, rest); +#endif + return rb_funcall2(rb_hash_aref(CALLBACK_TABLE, argv[0]), + ID_call, argc - 1, argv + 1); +} + +static char *cmd_id_head = "ruby_cmd TkUtil callback "; +static char *cmd_id_prefix = "cmd"; + +static VALUE +tk_install_cmd_core(cmd) + VALUE cmd; +{ + volatile VALUE id_num; + + id_num = ULONG2NUM(CALLBACK_ID_NUM++); + id_num = rb_funcall(id_num, ID_to_s, 0, 0); + id_num = rb_str_append(rb_str_new2(cmd_id_prefix), id_num); + rb_hash_aset(CALLBACK_TABLE, id_num, cmd); + return rb_str_append(rb_str_new2(cmd_id_head), id_num); +} + +static VALUE +tk_install_cmd(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + volatile VALUE cmd; + +#if 0 + if (rb_scan_args(argc, argv, "01", &cmd) == 0) { + cmd = rb_block_proc(); + } + return tk_install_cmd_core(cmd); +#endif + if (argc == 0) { + cmd = rb_block_proc(); + } else { + cmd = argv[0]; + } + return tk_install_cmd_core(cmd); +} + +static VALUE +tk_uninstall_cmd(self, cmd_id) + VALUE self; + VALUE cmd_id; +{ + int head_len = strlen(cmd_id_head); + int prefix_len = strlen(cmd_id_prefix); + + StringValue(cmd_id); + if (strncmp(cmd_id_head, RSTRING(cmd_id)->ptr, head_len) != 0) { + return Qnil; + } + if (strncmp(cmd_id_prefix, + RSTRING(cmd_id)->ptr + head_len, prefix_len) != 0) { + return Qnil; + } + + return rb_hash_delete(CALLBACK_TABLE, + rb_str_new2(RSTRING(cmd_id)->ptr + head_len)); +} + +static VALUE +tk_toUTF8(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + return rb_funcall2(cTclTkLib, ID_toUTF8, argc, argv); +} + +static VALUE +tk_fromUTF8(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + return rb_funcall2(cTclTkLib, ID_fromUTF8, argc, argv); +} + +static VALUE +fromDefaultEnc_toUTF8(str, self) + VALUE str; + VALUE self; +{ + VALUE argv[1]; + + argv[0] = str; + return tk_toUTF8(1, argv, self); +} + +static VALUE +fromUTF8_toDefaultEnc(str, self) + VALUE str; + VALUE self; +{ + VALUE argv[1]; + + argv[0] = str; + return tk_fromUTF8(1, argv, self); +} + + +static int +to_strkey(key, value, hash) + VALUE key; + VALUE value; + VALUE hash; +{ + if (key == Qundef) return ST_CONTINUE; + rb_hash_aset(hash, rb_funcall(key, ID_to_s, 0, 0), value); + return ST_CONTINUE; +} + +static VALUE +tk_symbolkey2str(self, keys) + VALUE self; + VALUE keys; +{ + volatile VALUE new_keys = rb_hash_new(); + + st_foreach(RHASH(keys)->tbl, to_strkey, new_keys); + return new_keys; +} + +static VALUE get_eval_string_core _((VALUE, VALUE, VALUE)); +static VALUE ary2list _((VALUE, VALUE)); +static VALUE hash2list _((VALUE, VALUE)); + +static VALUE +ary2list(ary, self) + VALUE ary; + VALUE self; +{ + int idx, size; + volatile VALUE val; + volatile VALUE dst; + + size = RARRAY(ary)->len; + dst = rb_ary_new2(size); + RARRAY(dst)->len = 0; + for(idx = 0; idx < size; idx++) { + val = RARRAY(ary)->ptr[idx]; + switch(TYPE(val)) { + case T_ARRAY: + RARRAY(dst)->ptr[RARRAY(dst)->len++] = ary2list(val, self); + break; + + case T_HASH: + RARRAY(dst)->ptr[RARRAY(dst)->len++] = hash2list(val, self); + break; + + default: + if (val != TK_None) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(val, Qnil, self); + } + } + } + return rb_apply(cTclTkLib, ID_merge_tklist, dst); +} + +static VALUE +key2keyname(key) + VALUE key; +{ + return rb_str_append(rb_str_new2("-"), rb_funcall(key, ID_to_s, 0, 0)); +} + +static VALUE +assoc2kv(assoc, ary, self) + VALUE assoc; + VALUE ary; + VALUE self; +{ + int i, j, len; + volatile VALUE pair; + volatile VALUE val; + volatile VALUE dst = rb_ary_new2(2 * RARRAY(assoc)->len); + + len = RARRAY(assoc)->len; + + for(i = 0; i < len; i++) { + pair = RARRAY(assoc)->ptr[i]; + if (TYPE(pair) != T_ARRAY) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair); + continue; + } + switch(RARRAY(assoc)->len) { + case 2: + RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(pair)->ptr[2]; + + case 1: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + case 0: + continue; + + default: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + val = rb_ary_new2(RARRAY(pair)->len - 1); + RARRAY(val)->len = 0; + for(j = 1; j < RARRAY(pair)->len; j++) { + RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j]; + } + + RARRAY(dst)->ptr[RARRAY(dst)->len++] = val; + } + } + + if (NIL_P(ary)) { + return dst; + } else { + return rb_ary_plus(ary, dst); + } +} + +static VALUE +assoc2kv_enc(assoc, ary, self) + VALUE assoc; + VALUE ary; + VALUE self; +{ + int i, j, len; + volatile VALUE pair; + volatile VALUE val; + volatile VALUE dst = rb_ary_new2(2 * RARRAY(assoc)->len); + + len = RARRAY(assoc)->len; + + for(i = 0; i < len; i++) { + pair = RARRAY(assoc)->ptr[i]; + if (TYPE(pair) != T_ARRAY) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] = key2keyname(pair); + continue; + } + switch(RARRAY(assoc)->len) { + case 2: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(RARRAY(pair)->ptr[2], Qtrue, self); + + case 1: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + case 0: + continue; + + default: + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = key2keyname(RARRAY(pair)->ptr[0]); + + val = rb_ary_new2(RARRAY(pair)->len - 1); + RARRAY(val)->len = 0; + for(j = 1; j < RARRAY(pair)->len; j++) { + RARRAY(val)->ptr[RARRAY(val)->len++] = RARRAY(pair)->ptr[j]; + } + + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(val, Qtrue, self); + } + } + + if (NIL_P(ary)) { + return dst; + } else { + return rb_ary_plus(ary, dst); + } +} + +static int +push_kv(key, val, ary) + VALUE key; + VALUE val; + VALUE ary; +{ + if (key == Qundef) return ST_CONTINUE; +#if 0 + rb_ary_push(ary, key2keyname(key)); + if (val != TK_None) rb_ary_push(ary, val); +#endif + RARRAY(ary)->ptr[RARRAY(ary)->len++] = key2keyname(key); + if (val != TK_None) RARRAY(ary)->ptr[RARRAY(ary)->len++] = val; + + return ST_CONTINUE; +} + +static VALUE +hash2kv(hash, ary, self) + VALUE hash; + VALUE ary; + VALUE self; +{ + volatile VALUE dst = rb_ary_new2(2 * RHASH(hash)->tbl->num_entries); + + RARRAY(dst)->len = 0; + + st_foreach(RHASH(hash)->tbl, push_kv, dst); + + if (NIL_P(ary)) { + return dst; + } else { + return rb_ary_plus(ary, dst); + } +} + +static int +push_kv_enc(key, val, args) + VALUE key; + VALUE val; + VALUE args; +{ + volatile VALUE ary = RARRAY(args)->ptr[0]; + + if (key == Qundef) return ST_CONTINUE; +#if 0 + rb_ary_push(ary, key2keyname(key)); + if (val != TK_None) { + rb_ary_push(ary, get_eval_string_core(val, Qtrue, + RARRAY(args)->ptr[1])); + } +#endif + RARRAY(ary)->ptr[RARRAY(ary)->len++] = key2keyname(key); + + if (val == TK_None) return ST_CONTINUE; + + RARRAY(ary)->ptr[RARRAY(ary)->len++] + = get_eval_string_core(val, Qtrue, RARRAY(args)->ptr[1]); + + return ST_CONTINUE; +} + +static VALUE +hash2kv_enc(hash, ary, self) + VALUE hash; + VALUE ary; + VALUE self; +{ + volatile VALUE args = rb_ary_new2(2); + volatile VALUE dst = rb_ary_new2(2 * RHASH(hash)->tbl->num_entries); + + RARRAY(dst)->len = 0; + + RARRAY(args)->ptr[0] = dst; + RARRAY(args)->ptr[1] = self; + RARRAY(args)->len = 2; + st_foreach(RHASH(hash)->tbl, push_kv_enc, args); + + if (NIL_P(ary)) { + return dst; + } else { + return rb_ary_plus(ary, dst); + } +} + +static VALUE +hash2list(hash, self) + VALUE hash; + VALUE self; +{ + return ary2list(hash2kv(hash, Qnil, self), self); +} + + +static VALUE +hash2list_enc(hash, self) + VALUE hash; + VALUE self; +{ + return ary2list(hash2kv_enc(hash, Qnil, self), self); +} + +static VALUE +tk_hash_kv(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + volatile VALUE hash, enc_flag, ary; + + ary = Qnil; + enc_flag = Qnil; + switch(argc) { + case 3: + ary = argv[2]; + case 2: + enc_flag = argv[1]; + case 1: + hash = argv[0]; + break; + case 0: + rb_raise(rb_eArgError, "too few arguments"); + default: /* >= 3 */ + rb_raise(rb_eArgError, "too many arguments"); + } + + switch(TYPE(hash)) { + case T_ARRAY: + if (RTEST(enc_flag)) { + return assoc2kv_enc(hash, ary, self); + } else { + return assoc2kv(hash, ary, self); + } + + case T_HASH: + if (RTEST(enc_flag)) { + return hash2kv_enc(hash, ary, self); + } else { + return hash2kv(hash, ary, self); + } + + case T_NIL: + if (NIL_P(ary)) { + return rb_ary_new(); + } else { + return ary; + } + + default: + if (hash == TK_None) { + if (NIL_P(ary)) { + return rb_ary_new(); + } else { + return ary; + } + } + rb_raise(rb_eArgError, "Hash is expected for 1st argument"); + } +} + +static VALUE +get_eval_string_core(obj, enc_flag, self) + VALUE obj; + VALUE enc_flag; + VALUE self; +{ + switch(TYPE(obj)) { + case T_FLOAT: + case T_FIXNUM: + case T_BIGNUM: + return rb_funcall(obj, ID_to_s, 0, 0); + + case T_STRING: + if (RTEST(enc_flag)) { + if (rb_respond_to(self, ID_toUTF8)) { + return rb_funcall(self, ID_toUTF8, 1, obj); + } else { + return fromDefaultEnc_toUTF8(obj, self); + } + } else { + return obj; + } + + case T_SYMBOL: + if (RTEST(enc_flag)) { + if (rb_respond_to(self, ID_toUTF8)) { + return rb_funcall(self, ID_toUTF8, 1, + rb_str_new2(rb_id2name(SYM2ID(obj)))); + } else { + return fromDefaultEnc_toUTF8(rb_str_new2(rb_id2name(SYM2ID(obj))), self); + } + } else { + return rb_str_new2(rb_id2name(SYM2ID(obj))); + } + + case T_HASH: + if (RTEST(enc_flag)) { + return hash2list_enc(obj, self); + } else { + return hash2list(obj, self); + } + + case T_ARRAY: + if (RTEST(enc_flag)) { + return fromDefaultEnc_toUTF8(ary2list(obj, self), self); + } else { + return ary2list(obj, self); + } + + case T_FALSE: + return rb_str_new2("0"); + + case T_TRUE: + return rb_str_new2("1"); + + case T_NIL: + return rb_str_new2(""); + + default: + if (rb_obj_is_kind_of(obj, cTkObject)) { + /* return rb_str_new3(rb_funcall(obj, ID_path, 0, 0)); */ + return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), + enc_flag, self); + } + + if (rb_obj_is_kind_of(obj, rb_cProc) + || rb_obj_is_kind_of(obj, cMethod) + || rb_obj_is_kind_of(obj, cTkCallbackEntry)) { + if (rb_respond_to(self, ID_install_cmd)) { + return rb_funcall(self, ID_install_cmd, 1, obj); + } else { + return tk_install_cmd(obj); + } + } + + if (obj == TK_None) return Qnil; + + if (rb_respond_to(obj, ID_to_eval)) { + /* return rb_funcall(obj, ID_to_eval, 0, 0); */ + return get_eval_string_core(rb_funcall(obj, ID_to_eval, 0, 0), + enc_flag, self); + } else if (rb_respond_to(obj, ID_path)) { + /* return rb_funcall(obj, ID_path, 0, 0); */ + return get_eval_string_core(rb_funcall(obj, ID_path, 0, 0), + enc_flag, self); + } else if (rb_respond_to(obj, ID_to_s)) { + return rb_funcall(obj, ID_to_s, 0, 0); + } + } + + rb_warning("fail to convert '%s' to string for Tk", + RSTRING(rb_funcall(obj, rb_intern("inspect"), 0, 0))->ptr); - if (rb_block_given_p()) rb_obj_instance_eval(0, 0, obj); return obj; } +static VALUE +tk_get_eval_string(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + volatile VALUE obj, enc_flag; + + if (rb_scan_args(argc, argv, "11", &obj, &enc_flag) == 1) { + enc_flag = Qnil; + } + + return get_eval_string_core(obj, enc_flag, self); +} + +static VALUE +tk_get_eval_enc_str(self, obj) + VALUE self; + VALUE obj; +{ + if (obj == TK_None) { + return obj; + } else { + return get_eval_string_core(obj, Qtrue, self); + } +} + +static VALUE +tk_conv_args(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + int idx; + volatile VALUE dst; + volatile VALUE head, enc_flag, rest; + + if (argc < 2) { + rb_raise(rb_eArgError, "too few arguments"); + } + dst = rb_ary_new2(argc - 2); + RARRAY(dst)->len = 0; + for(idx = 2; idx < argc; idx++) { + if (argv[idx] != TK_None) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = get_eval_string_core(argv[idx], argv[1], self); + } + } + + return rb_ary_plus(argv[0], dst); +} + + +/*************************************/ + +static VALUE +tcl2rb_bool(self, value) + VALUE self; + VALUE value; +{ + if (TYPE(value) == T_FIXNUM) { + if (NUM2INT(value) == 0) { + return Qfalse; + } else { + return Qtrue; + } + } + + rb_check_type(value, T_STRING); + + if (RSTRING(value)->ptr[0] == '\0' + || strcmp(RSTRING(value)->ptr, "0") == 0 + || strcmp(RSTRING(value)->ptr, "no") == 0 + || strcmp(RSTRING(value)->ptr, "false") == 0) { + return Qfalse; + } else { + return Qtrue; + } +} + +static VALUE +tkstr_to_dec(value) + VALUE value; +{ + return rb_cstr_to_inum(RSTRING(value)->ptr, 10, 1); +} + +static VALUE +tkstr_to_int(value) + VALUE value; +{ + return rb_cstr_to_inum(RSTRING(value)->ptr, 0, 1); +} + +static VALUE +tkstr_to_float(value) + VALUE value; +{ + return rb_float_new(rb_cstr_to_dbl(RSTRING(value)->ptr, 1)); +} + +static VALUE +tkstr_invalid_numstr(value) + VALUE value; +{ + rb_raise(rb_eArgError, + "invalid value for Number: '%s'", RSTRING(value)->ptr); + return Qnil; /*dummy*/ +} + +static VALUE +tkstr_rescue_float(value) + VALUE value; +{ + return rb_rescue2(tkstr_to_float, value, + tkstr_invalid_numstr, value, + rb_eArgError, 0); +} + +static VALUE +tkstr_to_number(value) + VALUE value; +{ + rb_check_type(value, T_STRING); + + return rb_rescue2(tkstr_to_int, value, + tkstr_rescue_float, value, + rb_eArgError, 0); +} + +static VALUE +tcl2rb_number(self, value) + VALUE self; + VALUE value; +{ + return tkstr_to_number(value); +} + +static VALUE +tkstr_to_str(value) + VALUE value; +{ + char * ptr; + int len; + + ptr = RSTRING(value)->ptr; + len = RSTRING(value)->len; + + if (len > 1 && *ptr == '{' && *(ptr + len - 1) == '}') { + return rb_str_new(ptr + 1, len - 2); + } + return value; +} + +static VALUE +tcl2rb_string(self, value) + VALUE self; + VALUE value; +{ + rb_check_type(value, T_STRING); + + return tkstr_to_str(value); +} + +static VALUE +tcl2rb_num_or_str(self, value) + VALUE self; + VALUE value; +{ + rb_check_type(value, T_STRING); + + return rb_rescue2(tkstr_to_number, value, + tkstr_to_str, value, + rb_eArgError, 0); +} + + +/*************************************/ + +struct cbsubst_info { + int size; + char *key; + char *type; + ID *ivar; + VALUE proc; +}; + +static void +subst_mark(ptr) + struct cbsubst_info *ptr; +{ + rb_gc_mark(ptr->proc); +} + +static void +subst_free(ptr) + struct cbsubst_info *ptr; +{ + if (ptr) { + if (ptr->key != (char*)NULL) free(ptr->key); + if (ptr->type != (char*)NULL) free(ptr->type); + if (ptr->ivar != (ID*)NULL) free(ptr->ivar); + free(ptr); + } +} + +static void +cbsubst_init() +{ + struct cbsubst_info *inf; + ID *ivar; + volatile VALUE proc; + + inf = ALLOC(struct cbsubst_info); + + inf->size = 0; + + inf->key = ALLOC_N(char, 1); + inf->key = ALLOC_N(char, 1); + inf->key[0] = '\0'; + + inf->type = ALLOC_N(char, 1); + inf->type[0] = '\0'; + + ivar = ALLOC_N(ID, 1); + inf->ivar = ivar; + + proc = rb_hash_new(); + inf->proc = proc; + + rb_const_set(cCB_SUBST, ID_SUBST_INFO, + Data_Wrap_Struct(cSUBST_INFO, subst_mark, subst_free, inf)); +} + +static VALUE +cbsubst_initialize(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; +{ + struct cbsubst_info *inf; + volatile VALUE proc; + int idx; + + Data_Get_Struct(rb_const_get(rb_obj_class(self), ID_SUBST_INFO), + struct cbsubst_info, inf); + + for(idx = 0; idx < argc; idx++) { + rb_ivar_set(self, inf->ivar[idx], argv[idx]); + } + + return self; +} + +static VALUE +cbsubst_get_subst_key(self, str) + VALUE self; + VALUE str; +{ + volatile VALUE list; + volatile VALUE ret; + int i, len; + char *buf, *ptr; + + list = rb_funcall(cTclTkLib, ID_split_tklist, 1, str); + + len = RARRAY(list)->len; + buf = ALLOC_N(char, len + 1); + + for(i = 0; i < len; i++) { + ptr = RSTRING(RARRAY(list)->ptr[i])->ptr; + if (*ptr == '%' && *(ptr + 2) == '\0') { + *(buf + i) = *(ptr + 1); + } else { + *(buf + i) = ' '; + } + } + *(buf + len) = '\0'; + + ret = rb_str_new2(buf); + free(buf); + return ret; +} + +static VALUE +cbsubst_get_all_subst_keys(self) + VALUE self; +{ + struct cbsubst_info *inf; + char *buf, *ptr; + int i, len; + volatile VALUE ret; + + Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), + struct cbsubst_info, inf); + + len = strlen(inf->key); + buf = ALLOC_N(char, 3*len); + ptr = buf; + for(i = 0; i < len; i++) { + *(ptr++) = '%'; + *(ptr++) = *(inf->key + i); + *(ptr++) = ' '; + } + *(buf + 3*len) = '\0'; + + ret = rb_ary_new3(2, rb_str_new2(inf->key), rb_str_new2(buf)); + + free(buf); + + return ret; +} + +static VALUE +cbsubst_table_setup(self, key_inf, proc_inf) + VALUE self; + VALUE key_inf; + VALUE proc_inf; +{ + struct cbsubst_info *subst_inf; + int idx; + int len = RARRAY(key_inf)->len; + char *key = ALLOC_N(char, len + 1); + char *type = ALLOC_N(char, len + 1); + ID *ivar = ALLOC_N(ID, len + 1); + volatile VALUE proc = rb_hash_new(); + volatile VALUE inf; + + /* init */ + subst_inf = ALLOC(struct cbsubst_info); + subst_inf->size = len; + subst_inf->key = key; + subst_inf->type = type; + subst_inf->ivar = ivar; + subst_inf->proc = proc; + + /* + * keys : array of [subst, type, ivar] + * subst ==> char code + * type ==> char code + * ivar ==> symbol + */ + for(idx = 0; idx < len; idx++) { + inf = RARRAY(key_inf)->ptr[idx]; + if (TYPE(inf) != T_ARRAY) continue; + *(key + idx) = (char)NUM2INT(RARRAY(inf)->ptr[0]); + *(type + idx) = (char)NUM2INT(RARRAY(inf)->ptr[1]); + + *(ivar + idx) + = rb_intern( + RSTRING( + rb_str_cat2(rb_str_new2("@"), + rb_id2name(SYM2ID(RARRAY(inf)->ptr[2]))) + )->ptr + ); + + rb_attr(self, SYM2ID(RARRAY(inf)->ptr[2]), 1, 0, Qtrue); + } + *(key + len) = '\0'; + *(type + len) = '\0'; + + /* + * procs : array of [type, proc] + * type ==> char code + * proc ==> proc/method/obj (must respond to 'call') + */ + len = RARRAY(proc_inf)->len; + for(idx = 0; idx < len; idx++) { + inf = RARRAY(proc_inf)->ptr[idx]; + if (TYPE(inf) != T_ARRAY) continue; + rb_hash_aset(proc, RARRAY(inf)->ptr[0], RARRAY(inf)->ptr[1]); + } + + rb_const_set(self, ID_SUBST_INFO, + Data_Wrap_Struct(cSUBST_INFO, subst_mark, + subst_free, subst_inf)); + + return self; +} + +static VALUE +cbsubst_scan_args(self, arg_key, val_ary) + VALUE self; + VALUE arg_key; + VALUE val_ary; +{ + struct cbsubst_info *inf; + int idx; + int len = RARRAY(val_ary)->len; + char c; + char *ptr; + volatile VALUE dst = rb_ary_new2(len); + volatile VALUE proc; + + Data_Get_Struct(rb_const_get(self, ID_SUBST_INFO), + struct cbsubst_info, inf); + + RARRAY(dst)->len = 0; + for(idx = 0; idx < len; idx++) { + if (idx >= RSTRING(arg_key)->len) { + proc = Qnil; + } else if (*(RSTRING(arg_key)->ptr + idx) == ' ') { + proc = Qnil; + } else { + ptr = strchr(inf->key, *(RSTRING(arg_key)->ptr + idx)); + if (ptr == (char*)NULL) { + proc = Qnil; + } else { + c = *(inf->type + (ptr - inf->key)); + proc = rb_hash_aref(inf->proc, INT2FIX(c)); + } + } + + if (NIL_P(proc)) { + RARRAY(dst)->ptr[RARRAY(dst)->len++] = RARRAY(val_ary)->ptr[idx]; + } else { + RARRAY(dst)->ptr[RARRAY(dst)->len++] + = rb_funcall(proc, ID_call, 1, RARRAY(val_ary)->ptr[idx]); + } + } + + return dst; +} + +static VALUE +cbsubst_inspect(self) + VALUE self; +{ + return rb_str_new2("CallbackSubst"); +} + +static VALUE +substinfo_inspect(self) + VALUE self; +{ + return rb_str_new2("SubstInfo"); +} + +/*************************************/ + +static VALUE +tk_cbe_inspect(self) + VALUE self; +{ + return rb_str_new2("TkCallbackEntry"); +} + +/*************************************/ + +static VALUE +tkobj_path(self) + VALUE self; +{ + return rb_ivar_get(self, ID_path); +} + +/*************************************/ + void Init_tkutil() { - VALUE mTK = rb_define_module("TkUtil"); + volatile VALUE tmp; + VALUE cTK = rb_define_class("TkKernel", rb_cObject); + VALUE mTK = rb_define_module("TkUtil"); - rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1); + /* --------------------- */ + rb_global_variable(&cMethod); + cMethod = rb_const_get(rb_cObject, rb_intern("Method")); + + ID_path = rb_intern("path"); + ID_to_eval = rb_intern("to_eval"); + ID_to_s = rb_intern("to_s"); + ID_install_cmd = rb_intern("install_cmd"); + ID_merge_tklist = rb_intern("_merge_tklist"); + ID_call = rb_intern("call"); + + /* --------------------- */ + cCB_SUBST = rb_define_class_under(mTK, "CallbackSubst", rb_cObject); + rb_define_singleton_method(cCB_SUBST, "inspect", cbsubst_inspect, 0); + + cSUBST_INFO = rb_define_class_under(cCB_SUBST, "Info", rb_cObject); + rb_define_singleton_method(cSUBST_INFO, "inspect", substinfo_inspect, 0); + + ID_SUBST_INFO = rb_intern("SUBST_INFO"); + rb_define_singleton_method(cCB_SUBST, "scan_args", cbsubst_scan_args, 2); + rb_define_singleton_method(cCB_SUBST, "_get_subst_key", + cbsubst_get_subst_key, 1); + rb_define_singleton_method(cCB_SUBST, "_get_all_subst_keys", + cbsubst_get_all_subst_keys, 0); + rb_define_singleton_method(cCB_SUBST, "_setup_subst_table", + cbsubst_table_setup, 2); + + rb_define_method(cCB_SUBST, "initialize", cbsubst_initialize, -1); + + cbsubst_init(); + + /* --------------------- */ + rb_global_variable(&cTkCallbackEntry); + cTkCallbackEntry = rb_define_class("TkCallbackEntry", cTK); + rb_define_singleton_method(cTkCallbackEntry, "inspect", tk_cbe_inspect, 0); + /* --------------------- */ + rb_global_variable(&cTkObject); + cTkObject = rb_define_class("TkObject", cTK); + rb_define_method(cTkObject, "path", tkobj_path, 0); + + /* --------------------- */ + rb_require("tcltklib"); + rb_global_variable(&cTclTkLib); + cTclTkLib = rb_const_get(rb_cObject, rb_intern("TclTkLib")); + ID_split_tklist = rb_intern("_split_tklist"); + ID_toUTF8 = rb_intern("_toUTF8"); + ID_fromUTF8 = rb_intern("_fromUTF8"); + + /* --------------------- */ rb_define_singleton_method(cTK, "new", tk_s_new, -1); + + /* --------------------- */ + rb_global_variable(&TK_None); + TK_None = rb_obj_alloc(rb_cObject); + rb_define_const(mTK, "None", TK_None); + rb_define_singleton_method(TK_None, "to_s", tkNone_to_s, 0); + rb_define_singleton_method(TK_None, "inspect", tkNone_to_s, 0); + OBJ_FREEZE(TK_None); + + /* --------------------- */ + rb_global_variable(&CALLBACK_TABLE); + CALLBACK_TABLE = rb_hash_new(); + + /* --------------------- */ + rb_define_singleton_method(mTK, "eval_cmd", tk_eval_cmd, -1); + rb_define_singleton_method(mTK, "callback", tk_do_callback, -1); + rb_define_singleton_method(mTK, "install_cmd", tk_install_cmd, -1); + rb_define_singleton_method(mTK, "uninstall_cmd", tk_uninstall_cmd, 1); + rb_define_singleton_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1); + rb_define_singleton_method(mTK, "hash_kv", tk_hash_kv, -1); + rb_define_singleton_method(mTK, "_get_eval_string", + tk_get_eval_string, -1); + rb_define_singleton_method(mTK, "_get_eval_enc_str", + tk_get_eval_enc_str, 1); + + rb_define_singleton_method(mTK, "bool", tcl2rb_bool, 1); + rb_define_singleton_method(mTK, "number", tcl2rb_number, 1); + rb_define_singleton_method(mTK, "string", tcl2rb_string, 1); + rb_define_singleton_method(mTK, "num_or_str", tcl2rb_num_or_str, 1); + + rb_define_method(mTK, "_toUTF8", tk_toUTF8, -1); + rb_define_method(mTK, "_fromUTF8", tk_fromUTF8, -1); + rb_define_method(mTK, "_symbolkey2str", tk_symbolkey2str, 1); + rb_define_method(mTK, "hash_kv", tk_hash_kv, -1); + rb_define_method(mTK, "_get_eval_string", tk_get_eval_string, -1); + rb_define_method(mTK, "_get_eval_enc_str", tk_get_eval_enc_str, 1); + rb_define_method(mTK, "_conv_args", tk_conv_args, -1); + + rb_define_method(mTK, "bool", tcl2rb_bool, 1); + rb_define_method(mTK, "number", tcl2rb_number, 1); + rb_define_method(mTK, "string", tcl2rb_string, 1); + rb_define_method(mTK, "num_or_str", tcl2rb_num_or_str, 1); + + /* --------------------- */ } |