diff options
author | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-03-30 08:44:19 +0000 |
---|---|---|
committer | nagai <nagai@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-03-30 08:44:19 +0000 |
commit | 11974f26b347c59c4cea15f3631cc632481dd4c3 (patch) | |
tree | 760e0cf10c7c7083f6f784f16b602dd562214dd6 /ext/tk/sample/tkextlib | |
parent | a07bc1123aeb0bd3a1548338053d44047d20b509 (diff) |
* ext/tk/tcltklib.c: add TclTkIp#_create_console() method to create
a Tcl/Tk's console window.
* ext/tk/lib/multi-tk.rb: support TclTkIp#_create_console() method.
* ext/tk/lib/remote-tk.rb: ditto.
* ext/tk/lib/tk/console.rb: ditto.
* ext/tk/lib/tk.rb: update RELEASE_DATE
* ext/tk/sample/demo-*/check2.rb: use 'return' in the Proc object.
* ext/tk/sample/tkextlib/**: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/sample/tkextlib')
-rw-r--r-- | ext/tk/sample/tkextlib/bwidget/tree.rb | 2 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tkHTML/hv.rb | 85 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tkHTML/ss.rb | 682 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tktable/basic.rb | 4 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tktable/command.rb | 4 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tktable/debug.rb | 2 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tktable/maxsize.rb | 2 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/treectrl/demo.rb | 1 |
8 files changed, 410 insertions, 372 deletions
diff --git a/ext/tk/sample/tkextlib/bwidget/tree.rb b/ext/tk/sample/tkextlib/bwidget/tree.rb index 2b33962fa6..e1fcaa774f 100644 --- a/ext/tk/sample/tkextlib/bwidget/tree.rb +++ b/ext/tk/sample/tkextlib/bwidget/tree.rb @@ -119,7 +119,7 @@ module DemoTree Tk.root.bind_remove('Unmap') Tk.root.bind_remove('Map') Tk.root.bind_remove('Configure') - return true + true }) end diff --git a/ext/tk/sample/tkextlib/tkHTML/hv.rb b/ext/tk/sample/tkextlib/tkHTML/hv.rb index d9f3ea7d7c..a4d78ea5b1 100644 --- a/ext/tk/sample/tkextlib/tkHTML/hv.rb +++ b/ext/tk/sample/tkextlib/tkHTML/hv.rb @@ -78,38 +78,43 @@ big_imgs = {} hotkey = {} move_big_image = proc{|b| - return unless big_imgs.key?(b) - b.copy(big_imgs[b]) - big_imgs[b].delete - big_imgs.delete(b) - Tk.update + if big_imgs.key?(b) + b.copy(big_imgs[b]) + big_imgs[b].delete + big_imgs.delete(b) + Tk.update + end } image_cmd = proc{|*args| - return smgray unless show_img.bool - fn = args[0] - if old_imgs.key?(fn) - images[fn] = old_imgs[fn] - old_imgs.delete(fn) - return images[fn] - end + if show_img.bool + smgray + else + fn = args[0] - begin - img = TkPhotoImage.new(:file=>fn) - rescue - return smgray - end + if old_imgs.key?(fn) + images[fn] = old_imgs[fn] + old_imgs.delete(fn) + images[fn] - if img.width * img.height > 20000 - b = TkPhotoImage.new(:width=>img.width, :height=>img.height) - big_imgs[b] = img - img = b - Tk.after_idle(proc{ move_big_image.call(b) }) + else + begin + img = TkPhotoImage.new(:file=>fn) + rescue + smgray + else + if img.width * img.height > 20000 + b = TkPhotoImage.new(:width=>img.width, :height=>img.height) + big_imgs[b] = img + img = b + Tk.after_idle(proc{ move_big_image.call(b) }) + end + + images[fn] = img + img + end + end end - - images[fn] = img - - img } # @@ -183,12 +188,13 @@ clear_screen = proc{ # Load a file into the HTML widget # load_file = proc{|name| - return unless (doc = read_file.call(name)) - clear_screen.call - last_file = name - html.configure(:base=>name) - html.parse(doc) - old_imgs.clear + if (doc = read_file.call(name)) + clear_screen.call + last_file = name + html.configure(:base=>name) + html.parse(doc) + old_imgs.clear + end } href_binding = proc{|x, y| @@ -196,15 +202,16 @@ href_binding = proc{|x, y| html.selection_clear priv['mark'] = "@#{x},#{y}" lst = html.href(x, y) - return if lst.size.zero? - lnk, target = lst + unless lst.size.zero? + lnk, target = lst - if lnk != "" - if lnk =~ /^#{last_file}#(.*)$/ - html.yview($1) - else - load_file.call(lnk) + if lnk != "" + if lnk =~ /^#{last_file}#(.*)$/ + html.yview($1) + else + load_file.call(lnk) + end end end } diff --git a/ext/tk/sample/tkextlib/tkHTML/ss.rb b/ext/tk/sample/tkextlib/tkHTML/ss.rb index 3dbb7ec716..1c13d7ac34 100644 --- a/ext/tk/sample/tkextlib/tkHTML/ss.rb +++ b/ext/tk/sample/tkextlib/tkHTML/ss.rb @@ -6,401 +6,431 @@ require 'tk' require 'tkextlib/tkHTML' -root = TkRoot.new(:title=>'HTML File Viewer', :iconname=>'HV') -fswin = nil - -html = nil -html_fs = nil - -hotkey = {} - file = ARGV[0] +class TkHTML_File_Viewer + include TkComm # These are images to use with the actual image specified in a # "<img>" markup can't be found. # -biggray = TkPhotoImage.new(:data=><<'EOD') +@@biggray = TkPhotoImage.new(:data=><<'EOD') R0lGODdhPAA+APAAALi4uAAAACwAAAAAPAA+AAACQISPqcvtD6OctNqLs968+w+G4kiW5omm 6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNFgsAO/// EOD -smgray = TkPhotoImage.new(:data=><<'EOD') +@@smgray = TkPhotoImage.new(:data=><<'EOD') R0lGODdhOAAYAPAAALi4uAAAACwAAAAAOAAYAAACI4SPqcvtD6OctNqLs968+w+G4kiW5omm 6sq27gvH8kzX9m0VADv/ EOD + def initialize(file = nil) + @root = TkRoot.new(:title=>'HTML File Viewer', :iconname=>'HV') + @fswin = nil + + @html = nil + @html_fs = nil + + @hotkey = {} + + @applet_arg = TkVarAccess.new_hash('AppletArg') + + @images = {} + @old_imgs = {} + @big_imgs = {} + + @last_dir = Dir.pwd + + @last_file = '' + + @key_block = false + + Tk::HTML_Widget::ClippingWindow.bind('1', + proc{|w, ksym| key_press(w, ksym)}, + '%W Down') + Tk::HTML_Widget::ClippingWindow.bind('3', + proc{|w, ksym| key_press(w, ksym)}, + '%W Up') + Tk::HTML_Widget::ClippingWindow.bind('2', + proc{|w, ksym| key_press(w, ksym)}, + '%W Down') + + Tk::HTML_Widget::ClippingWindow.bind('KeyPress', + proc{|w, ksym| key_press(w, ksym)}, + '%W %K') + + ############################################ + # + # Build the half-size view of the page + # + menu_spec = [ + [['File', 0], + ['Open', proc{sel_load()}, 0], + ['Full Screen', proc{fullscreen()}, 0], + ['Refresh', proc{refresh()}, 0], + '---', + ['Exit', proc{exit}, 1]] + ] + + mbar = @root.add_menubar(menu_spec) + + @html = Tk::HTML_Widget.new(:width=>512, :height=>384, + :padx=>5, :pady=>9, + :formcommand=>proc{|*args| form_cmd(*args)}, + :imagecommand=>proc{|*args| + image_cmd(1, *args) + }, + :scriptcommand=>proc{|*args| + script_cmd(*args) + }, + :appletcommand=>proc{|*args| + applet_cmd(*args) + }, + :hyperlinkcommand=>proc{|*args| + hyper_cmd(*args) + }, + :fontcommand=>proc{|*args| + pick_font(*args) + }, + :appletcommand=>proc{|*args| + run_applet('small', *args) + }, + :bg=>'white', :tablerelief=>:raised) -# -# A font chooser routine. -# -# html[:fontcommand] = pick_font -pick_font = proc{|size, attrs| - # puts "FontCmd: #{size} #{attrs}" - [ ((attrs =~ /fixed/)? 'courier': 'charter'), - (12 * (1.2**(size.to_f - 4.0))).to_i, - ((attrs =~ /italic/)? 'italic': 'roman'), - ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ') -} - -# This routine is called to pick fonts for the fullscreen view. -# -baseFontSize = 24 -pick_font_fs = proc{|size, attrs| - # puts "FontCmd: #{size} #{attrs}" - [ ((attrs =~ /fixed/)? 'courier': 'charter'), - (baseFontSize * (1.2**(size.to_f - 4.0))).to_i, - ((attrs =~ /italic/)? 'italic': 'roman'), - ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ') -} + @html.token_handler('meta', proc{|*args| meta(@html, *args)}) -# -# -hyper_cmd = proc{|*args| - puts "HyperlinkCommand: #{args.inspect}" -} + vscr = @html.yscrollbar(TkScrollbar.new) + hscr = @html.xscrollbar(TkScrollbar.new) -# This routine is called to run an applet -# -applet_arg = TkVarAccess.new_hash('AppletArg') -run_applet = proc{|size, w, arglist| - applet_arg.value = Hash[*simplelist(arglist)] + Tk.grid(@html, vscr, :sticky=>:news) + Tk.grid(hscr, :sticky=>:ew) + @root.grid_columnconfigure(0, :weight=>1) + @root.grid_columnconfigure(1, :weight=>0) + @root.grid_rowconfigure(0, :weight=>1) + @root.grid_rowconfigure(1, :weight=>0) - return unless applet_arg.key?('src') + ############################################ - src = html.remove(applet_arg['src']) + @html.clipwin.focus - applet_arg['window'] = w - applet_arg['fontsize'] = size + # If an arguent was specified, read it into the HTML widget. + # + Tk.update + if file && file != "" + load_file(file) + end + end - begin - Tk.load_tclscript(src) - rescue => e - puts "Applet error: #{e.message}" + # + # A font chooser routine. + # + # html[:fontcommand] = pick_font + def pick_font(size, attrs) + # puts "FontCmd: #{size} #{attrs}" + [ ((attrs =~ /fixed/)? 'courier': 'charter'), + (12 * (1.2**(size.to_f - 4.0))).to_i, + ((attrs =~ /italic/)? 'italic': 'roman'), + ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ') end -} -# -# -form_cmd = proc{|n, cmd, *args| -} + # This routine is called to pick fonts for the fullscreen view. + # + def pick_font_fs(size, attrs) + baseFontSize = 24 -# -# -images = {} -old_imgs = {} -big_imgs = {} + # puts "FontCmd: #{size} #{attrs}" + [ ((attrs =~ /fixed/)? 'courier': 'charter'), + (baseFontSize * (1.2**(size.to_f - 4.0))).to_i, + ((attrs =~ /italic/)? 'italic': 'roman'), + ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ') + end -# -# -move_big_image = proc{|b| - return unless big_imgs.key?(b) - b.copy(big_imgs[b]) - big_imgs[b].delete - big_imgs.delete(b) -} - -image_cmd = proc{|hs, *args| - fn = args[0] - - if old_imgs.key?(fn) - return (images[fn] = old_imgs.delete(fn)) + # + # + def hyper_cmd(*args) + puts "HyperlinkCommand: #{args.inspect}" end - begin - img = TkPhotoImage.new(:file=>fn) - rescue - return ((hs)? smallgray: biggray) + # This routine is called to run an applet + # + def run_applet(size, w, arglist) + applet_arg.value = Hash[*simplelist(arglist)] + + return unless @applet_arg.key?('src') + + src = @html.remove(@applet_arg['src']) + + @applet_arg['window'] = w + @applet_arg['fontsize'] = size + + begin + Tk.load_tclscript(src) + rescue => e + puts "Applet error: #{e.message}" + end end - if hs - img2 = TkPhotoImage.new - img2.copy(img, :subsample=>[2,2]) - img.delete - img = img2 + # + # + def form_cmd(n, cmd, *args) + # p [n, cmd, *args] end - if img.width * img.height > 20000 - b = TkPhotoImage.new(:width=>img.width, :height=>img.height) - big_imgs[b] = img - img = b - Tk.after_idle(proc{ move_big_image.call(b) }) + # + # + def move_big_image(b) + return unless @big_imgs.key?(b) + b.copy(@big_imgs[b]) + @big_imgs[b].delete + @big_imgs.delete(b) end - images[fn] = img + def image_cmd(hs, *args) + fn = args[0] - img -} + if @old_imgs.key?(fn) + return (@images[fn] = @old_imgs.delete(fn)) + end + begin + img = TkPhotoImage.new(:file=>fn) + rescue + return ((hs)? @@smallgray: @@biggray) + end -# -# This routine is called for every <SCRIPT> markup -# -script_cmd = proc{|*args| - # puts "ScriptCmd: #{args.inspect}" -} + if hs + img2 = TkPhotoImage.new + img2.copy(img, :subsample=>[2,2]) + img.delete + img = img2 + end -# This routine is called for every <APPLET> markup -# -applet_cmd = proc{|w, arglist| - # puts "AppletCmd: w=#{w} arglist=#{arglist}" - #TkLabel.new(w, :text=>"The Applet #{w}", :bd=>2, :relief=>raised) -} + if img.width * img.height > 20000 + b = TkPhotoImage.new(:width=>img.width, :height=>img.height) + @big_imgs[b] = img + img = b + Tk.after_idle(proc{ move_big_image(b) }) + end -# This binding fires when there is a click on a hyperlink -# -href_binding = proc{|w, x, y| - lst = w.href(x, y) - unless lst.empty? - process_url.call(lst) - end -} + @images[fn] = img -# -# -last_dir = Dir.pwd -load_file = nil - -sel_load = proc{ - filetypes = [ - ['Html Files', ['.html', '.htm']], - ['All Files', '*'] - ] - - f = Tk.getOpenFile(:initialdir=>last_dir, :filetypes=>filetypes) - if f != '' - load_file.call(f) - last_dir = File.dirname(f) + img end -} -# Clear the screen. -# -clear_screen = proc{ - if html_fs && html_fs.exist? - w = html_fs - else - w = html - end - w.clear - old_imgs.clear - big_imgs.clear - hotkey.clear - images.each{|k, v| old_imgs[k] = v } - images.clear -} - -# Read a file -# -read_file = proc{|name| - begin - fp = open(name, 'r') - ret = fp.read(File.size(name)) - rescue - ret = nil - fp = nil - Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", - :type=>:ok) - ensure - fp.close if fp + # + # This routine is called for every <SCRIPT> markup + # + def script_cmd(*args) + # puts "ScriptCmd: #{args.inspect}" end - ret -} -# Process the given URL -# -process_url = proc{|url| - case url[0] - when /^file:/ - load_file.call(url[0][5..-1]) - when /^exec:/ - Tk.ip_eval(url[0][5..-1].tr('\\', ' ')) - else - load_file.call(url[0]) + # This routine is called for every <APPLET> markup + # + def applet_cmd(w, arglist) + # puts "AppletCmd: w=#{w} arglist=#{arglist}" + #TkLabel.new(w, :text=>"The Applet #{w}", :bd=>2, :relief=>raised) end -} -# Load a file into the HTML widget -# -last_file = '' - -load_file = proc{|name| - return unless (doc = read_file.call(name)) - clear_screen.call - last_file = name - if html_fs && html_fs.exist? - w = html_fs - else - w = html + # This binding fires when there is a click on a hyperlink + # + def href_binding(w, x, y) + lst = w.href(x, y) + unless lst.empty? + process_url(lst) + end end - w.configure(:base=>name) - w.parse(doc) - w.configure(:cursor=>'top_left_arrow') - old_imgs.clear -} - -# Refresh the current file. -# -refresh = proc{|*args| - load_file.call(last_file) if last_file -} - -# This routine is called whenever a "<meta>" markup is seen. -# -meta = proc{|w, tag, alist| - v = Hash[*simplelist(alist)] - if v.kye?('key') && v.key?('href') - hotkey[v['key']] = w.resolve(v['href']) + # + # + def sel_load + filetypes = [ + ['Html Files', ['.html', '.htm']], + ['All Files', '*'] + ] + + f = Tk.getOpenFile(:initialdir=>@last_dir, :filetypes=>filetypes) + if f != '' + load_file(f) + @last_dir = File.dirname(f) + end end - if v.kye?('next') - hotkey['Down'] =v['next'] + # Clear the screen. + # + def clear_screen + if @html_fs && @html_fs.exist? + w = @html_fs + else + w = @html + end + w.clear + @old_imgs.clear + @big_imgs.clear + @hotkey.clear + @images.each{|k, v| @old_imgs[k] = v } + @images.clear end - if v.kye?('prev') - hotkey['Up'] =v['prev'] + # Read a file + # + def read_file(name) + begin + fp = open(name, 'r') + ret = fp.read(File.size(name)) + rescue + ret = nil + fp = nil + Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", + :type=>:ok) + ensure + fp.close if fp + end + ret end - if v.kye?('other') - hotkey['o'] =v['other'] + # Process the given URL + # + def process_url(url) + case url[0] + when /^file:/ + load_file(url[0][5..-1]) + when /^exec:/ + Tk.ip_eval(url[0][5..-1].tr('\\', ' ')) + else + load_file(url[0]) + end end -} -# Go from full-screen mode back to window mode. -# -fullscreen_off = proc{ - fswin.destroy - root.deiconify - Tk.update - root.raise - html.clipwin.focus - clear_screen.call - old_imgs.clear - refresh.call -} - -# Go from window mode to full-screen mode. -# -fullscreen = proc{ - if fswin && fswin.exist? - fswin.deiconify - Tk.update - fswin.raise - return + # Load a file into the HTML widget + # + def load_file(name) + return unless (doc = read_file(name)) + clear_screen() + @last_file = name + if @html_fs && @html_fs.exist? + w = @html_fs + else + w = @html + end + w.configure(:base=>name) + w.parse(doc) + w.configure(:cursor=>'top_left_arrow') + @old_imgs.clear end - width = root.winfo_screenwidth - height = root.winfo_screenheight - fswin = TkToplevel.new(:overrideredirect=>true, - :geometry=>"#{width}x#{height}+0+0") - - html_fs = Tk::HTML_Widget.new(fswin, :padx=>5, :pady=>9, - :formcommand=>form_cmd, - :imagecommand=>proc{image_cmd.call(0)}, - :scriptcommand=>script_cmd, - :appletcommand=>applet_cmd, - :hyperlinkcommand=>hyper_cmd, - :bg=>'white', :tablerelief=>:raised, - :appletcommand=>proc{|*args| - run_applet('big', *args) - }, - :fontcommand=>pick_font_fs, - :cursor=>:tcross) { - pack(:fill=>:both, :expand=>true) - token_handler('meta', proc{|*args| meta.call(self, *args)}) - } - - clear_screen.call - old_imgs.clear - refresh.call - Tk.update - html_fs.clipwin.focus -} - -# -# -key_block = false + # Refresh the current file. + # + def refresh(*args) + load_file(@last_file) if @last_file + end -key_press = proc{|w, keysym| - return if key_block - key_block = true - Tk.after(250, proc{key_block = false}) + # This routine is called whenever a "<meta>" markup is seen. + # + def meta(w, tag, alist) + v = Hash[*simplelist(alist)] - if hotkey.key?(keysym) - process_url.call(hotkey[keysym]) - end - case keysym - when 'Escape' - if fswin && fswin.exist? - fullscreen_off.call - else - fullscreen.call + if v.key?('key') && v.key?('href') + @hotkey[v['key']] = w.resolve(v['href']) end - end -} -Tk::HTML_Widget::ClippingWindow.bind('1', key_press, '%W Down') -Tk::HTML_Widget::ClippingWindow.bind('3', key_press, '%W Up') -Tk::HTML_Widget::ClippingWindow.bind('2', key_press, '%w Down') + if v.key?('next') + @hotkey['Down'] =v['next'] + end -Tk::HTML_Widget::ClippingWindow.bind('KeyPress', key_press, '%W %K') + if v.key?('prev') + @hotkey['Up'] =v['prev'] + end + if v.key?('other') + @hotkey['o'] =v['other'] + end + end -############################################ -# -# Build the half-size view of the page -# -menu_spec = [ - [['File', 0], - ['Open', sel_load, 0], - ['Full Screen', fullscreen, 0], - ['Refresh', refresh, 0], - '---', - ['Exit', proc{exit}, 1]] -] - -mbar = root.add_menubar(menu_spec) - -html = Tk::HTML_Widget.new(:width=>512, :height=>384, - :padx=>5, :pady=>9, - :formcommand=>form_cmd, - :imagecommand=>proc{|*args| - image_cmd.call(1, *args) - }, - :scriptcommand=>script_cmd, - :appletcommand=>applet_cmd, - :hyperlinkcommand=>hyper_cmd, - :fontcommand=>pick_font, - :appletcommand=>proc{|*args| - run_applet.call('small', *args) - }, - :bg=>'white', :tablerelief=>:raised) - -html.token_handler('meta', proc{|*args| meta.call(html, *args)}) - -vscr = html.yscrollbar(TkScrollbar.new) -hscr = html.xscrollbar(TkScrollbar.new) - -Tk.grid(html, vscr, :sticky=>:news) -Tk.grid(hscr, :sticky=>:ew) -Tk.root.grid_columnconfigure(0, :weight=>1) -Tk.root.grid_columnconfigure(1, :weight=>0) -Tk.root.grid_rowconfigure(0, :weight=>1) -Tk.root.grid_rowconfigure(1, :weight=>0) + # Go from full-screen mode back to window mode. + # + def fullscreen_off + @fswin.destroy + @root.deiconify + Tk.update + @root.raise + @html.clipwin.focus + clear_screen() + @old_imgs.clear + refresh() + end + # Go from window mode to full-screen mode. + # + def fullscreen + if @fswin && @fswin.exist? + @fswin.deiconify + Tk.update + @fswin.raise + return + end -############################################ + width = @root.winfo_screenwidth + height = @root.winfo_screenheight + @fswin = TkToplevel.new(:overrideredirect=>true, + :geometry=>"#{width}x#{height}+0+0") + + @html_fs = Tk::HTML_Widget.new(@fswin, :padx=>5, :pady=>9, + :formcommand=>proc{|*args| + form_cmd(*args) + }, + :imagecommand=>proc{|*args| + image_cmd(0, *args) + }, + :scriptcommand=>proc{|*args| + script_cmd(*args) + }, + :appletcommand=>proc{|*args| + applet_cmd(*args) + }, + :hyperlinkcommand=>proc{|*args| + hyper_cmd(*args) + }, + :appletcommand=>proc{|*args| + run_applet('big', *args) + }, + :fontcommand=>proc{|*args| + pick_font_fs(*args) + }, + :bg=>'white', :tablerelief=>:raised, + :cursor=>:tcross) { + pack(:fill=>:both, :expand=>true) + token_handler('meta', proc{|*args| meta(self, *args)}) + } + + clear_screen() + @old_imgs.clear + refresh() + Tk.update + @html_fs.clipwin.focus + end -html.clipwin.focus + # + # + def key_press(w, keysym) + return if @key_block + @key_block = true + Tk.after(250, proc{@key_block = false}) -# If an arguent was specified, read it into the HTML widget. -# -Tk.update -if file && file != "" - load_file.call(file) + if @hotkey.key?(keysym) + process_url(@hotkey[keysym]) + end + case keysym + when 'Escape' + if @fswin && @fswin.exist? + fullscreen_off() + else + fullscreen() + end + end + end end - ############################################ +TkHTML_File_Viewer.new(file) + Tk.mainloop diff --git a/ext/tk/sample/tkextlib/tktable/basic.rb b/ext/tk/sample/tkextlib/tktable/basic.rb index ece46b318e..0d2d48893a 100644 --- a/ext/tk/sample/tkextlib/tktable/basic.rb +++ b/ext/tk/sample/tkextlib/tktable/basic.rb @@ -29,11 +29,11 @@ table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, :rowstretchmode=>:last, :colstretchmode=>:last, :rowtagcommand=>proc{|row| row = Integer(row) - return 'OddRow' if row>0 && row%2 == 1 + (row>0 && row%2 == 1)? 'OddRow': '' }, :coltagcommand=>proc{|col| col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 + (col>0 && col%2 == 1)? 'OddCol': '' }, :selectmode=>:extended, :sparsearray=>false) diff --git a/ext/tk/sample/tkextlib/tktable/command.rb b/ext/tk/sample/tkextlib/tktable/command.rb index eb9ddffb78..bf36159ccc 100644 --- a/ext/tk/sample/tkextlib/tktable/command.rb +++ b/ext/tk/sample/tkextlib/tktable/command.rb @@ -45,11 +45,11 @@ table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :rowstretchmode=>:last, :colstretchmode=>:last, :rowtagcommand=>proc{|row| row = Integer(row) - return 'OddRow' if row>0 && row%2 == 1 + (row>0 && row%2 == 1)? 'OddRow': '' }, :coltagcommand=>proc{|col| col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 + (col>0 && col%2 == 1)? 'OddCol': '' }, :selectmode=>:extended, :flashmode=>true, :rowstretch=>:unset, :colstretch=>:unset, diff --git a/ext/tk/sample/tkextlib/tktable/debug.rb b/ext/tk/sample/tkextlib/tktable/debug.rb index 3200c1c77a..d5cd5e49ba 100644 --- a/ext/tk/sample/tkextlib/tktable/debug.rb +++ b/ext/tk/sample/tkextlib/tktable/debug.rb @@ -29,7 +29,7 @@ table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, :roworigin=>-5, :colorigin=>-2, :coltagcommand=>proc{|col| col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 + (col>0 && col%2 == 1)? 'OddCol': '' }, :selectmode=>:extended, :flashmode=>true, :rowstretch=>:unset, :colstretch=>:unset, diff --git a/ext/tk/sample/tkextlib/tktable/maxsize.rb b/ext/tk/sample/tkextlib/tktable/maxsize.rb index c9ca745ee5..aff68ff377 100644 --- a/ext/tk/sample/tkextlib/tktable/maxsize.rb +++ b/ext/tk/sample/tkextlib/tktable/maxsize.rb @@ -28,7 +28,7 @@ table = Tk::TkTable.new(:rows=>rows, :cols=>cols, :variable=>ary, :titlerows=>1, :titlecols=>1, :coltagcommand=>proc{|col| col = Integer(col) - return 'OddCol' if col>0 && col%2 == 1 + (col>0 && col%2 == 1)? 'OddCol': '' }, :selectmode=>:extended, :colstretch=>:unset, :rowstretch=>:unset, diff --git a/ext/tk/sample/tkextlib/treectrl/demo.rb b/ext/tk/sample/tkextlib/treectrl/demo.rb index 1f822a6548..92742e583c 100644 --- a/ext/tk/sample/tkextlib/treectrl/demo.rb +++ b/ext/tk/sample/tkextlib/treectrl/demo.rb @@ -111,6 +111,7 @@ class TkTreeCtrl_demo [['File']] ] if Tk::PLATFORM['platform'] != 'unix' + TkConsole.create TkConsole.eval('.console conf -height 8') menuspec[0] << ['Console', proc{ if TkComm.bool(TkConsole.eval('winfo ismapped .')) |