diff options
Diffstat (limited to 'ext/tk/sample/tkextlib/tkHTML')
-rw-r--r-- | ext/tk/sample/tkextlib/tkHTML/hv.rb | 48 | ||||
-rw-r--r-- | ext/tk/sample/tkextlib/tkHTML/ss.rb | 82 |
2 files changed, 65 insertions, 65 deletions
diff --git a/ext/tk/sample/tkextlib/tkHTML/hv.rb b/ext/tk/sample/tkextlib/tkHTML/hv.rb index a4d78ea5b1..920eb15f5a 100644 --- a/ext/tk/sample/tkextlib/tkHTML/hv.rb +++ b/ext/tk/sample/tkextlib/tkHTML/hv.rb @@ -5,7 +5,7 @@ # # This application is used for testing the HTML widget. It can # also server as an example of how to use the HTML widget. -# +# require 'tk' require 'tkextlib/tkHTML' @@ -51,11 +51,11 @@ show_img = TkVariable.new(1) # 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(' ') -} + [ ((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 for each form element @@ -126,7 +126,7 @@ script_cmd = proc{|*args| # This routine is called for every <APPLET> markup # -applet_cmd = proc{|w, arglist| +applet_cmd = proc{|w, arglist| # puts "AppletCmd: w=#{w} arglist=#{arglist}" TkLabel.new(w, :text=>"The Applet #{w}", :bd=>2, :relief=>raised) } @@ -134,12 +134,12 @@ applet_cmd = proc{|w, arglist| # # Construct the main HTML viewer # -html = Tk::HTML_Widget.new(:padx=>5, :pady=>9, - :formcommand=>form_cmd, - :imagecommand=>image_cmd, - :scriptcommand=>script_cmd, - :appletcommand=>applet_cmd, - :underlinehyperlinks=>0, +html = Tk::HTML_Widget.new(:padx=>5, :pady=>9, + :formcommand=>form_cmd, + :imagecommand=>image_cmd, + :scriptcommand=>script_cmd, + :appletcommand=>applet_cmd, + :underlinehyperlinks=>0, :bg=>'white', :tablerelief=>:raised) vscr = html.yscrollbar(TkScrollbar.new) hscr = html.xscrollbar(TkScrollbar.new) @@ -166,7 +166,7 @@ read_file = proc{|name| rescue ret = nil fp = nil - Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", + Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", :type=>:ok) ensure fp.close if fp @@ -221,7 +221,7 @@ html.clipping_window.bind('1', href_binding, '%x %y') html.clipping_window.bind('B1-Motion', proc{|w, x, y| w.selection_set(priv['mark'], "@#{x},#{y}") TkClipboard.clear - # avoid tkhtml0.0 errors + # avoid tkhtml0.0 errors # anyone can fix this for tkhtml0.0 begin TkClipboard.append(TkSelection.get) @@ -235,7 +235,7 @@ html.clipping_window.bind('B1-Motion', proc{|w, x, y| last_dir = Dir.pwd sel_load = proc{ filetypes = [ - ['Html Files', ['.html', '.htm']], + ['Html Files', ['.html', '.htm']], ['All Files', '*'] ] @@ -268,15 +268,15 @@ Tk::HTML_Widget::ClippingWindow.bind('Motion', proc{|w, x, y| # Setup menu # menu_spec = [ - [['File', 0], - ['Open', sel_load, 0], - ['Refresh', refresh, 0], + [['File', 0], + ['Open', sel_load, 0], + ['Refresh', refresh, 0], '---', - ['Exit', proc{exit}, 1]], + ['Exit', proc{exit}, 1]], - [['View', 0], - ['Underline Hyperlinks', ul_hyper], - ['Show Table Structure', show_tbl], + [['View', 0], + ['Underline Hyperlinks', ul_hyper], + ['Show Table Structure', show_tbl], ['Show Images', show_img]] ] @@ -285,7 +285,7 @@ mbar = Tk.root.add_menubar(menu_spec) # # Setup trace # -ul_hyper.trace('w', proc{ +ul_hyper.trace('w', proc{ html[:underlinehyperlinks] = ul_hyper.value refresh.call }) diff --git a/ext/tk/sample/tkextlib/tkHTML/ss.rb b/ext/tk/sample/tkextlib/tkHTML/ss.rb index 1c13d7ac34..45d4d87d69 100644 --- a/ext/tk/sample/tkextlib/tkHTML/ss.rb +++ b/ext/tk/sample/tkextlib/tkHTML/ss.rb @@ -2,7 +2,7 @@ # # This script implements the "ss" application. "ss" implements # a presentation slide-show based on HTML slides. -# +# require 'tk' require 'tkextlib/tkHTML' @@ -45,18 +45,18 @@ EOD @key_block = false - Tk::HTML_Widget::ClippingWindow.bind('1', - proc{|w, ksym| key_press(w, ksym)}, + 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)}, + 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)}, + 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)}, + Tk::HTML_Widget::ClippingWindow.bind('KeyPress', + proc{|w, ksym| key_press(w, ksym)}, '%W %K') ############################################ @@ -64,37 +64,37 @@ EOD # 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], + [['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, + @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| + }, + :hyperlinkcommand=>proc{|*args| hyper_cmd(*args) - }, + }, :fontcommand=>proc{|*args| pick_font(*args) - }, + }, :appletcommand=>proc{|*args| run_applet('small', *args) - }, + }, :bg=>'white', :tablerelief=>:raised) @html.token_handler('meta', proc{|*args| meta(@html, *args)}) @@ -127,9 +127,9 @@ EOD # 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 =~ /fixed/)? 'courier': 'charter'), + (12 * (1.2**(size.to_f - 4.0))).to_i, + ((attrs =~ /italic/)? 'italic': 'roman'), ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ') end @@ -139,9 +139,9 @@ EOD baseFontSize = 24 # puts "FontCmd: #{size} #{attrs}" - [ ((attrs =~ /fixed/)? 'courier': 'charter'), - (baseFontSize * (1.2**(size.to_f - 4.0))).to_i, - ((attrs =~ /italic/)? 'italic': 'roman'), + [ ((attrs =~ /fixed/)? 'courier': 'charter'), + (baseFontSize * (1.2**(size.to_f - 4.0))).to_i, + ((attrs =~ /italic/)? 'italic': 'roman'), ((attrs =~ /bold/)? 'bold': 'normal') ].join(' ') end @@ -244,7 +244,7 @@ EOD # def sel_load filetypes = [ - ['Html Files', ['.html', '.htm']], + ['Html Files', ['.html', '.htm']], ['All Files', '*'] ] @@ -280,7 +280,7 @@ EOD rescue ret = nil fp = nil - Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", + Tk.messageBox(:icon=>'error', :message=>"fail to open '#{name}'", :type=>:ok) ensure fp.close if fp @@ -371,32 +371,32 @@ EOD width = @root.winfo_screenwidth height = @root.winfo_screenheight - @fswin = TkToplevel.new(:overrideredirect=>true, + @fswin = TkToplevel.new(:overrideredirect=>true, :geometry=>"#{width}x#{height}+0+0") - @html_fs = Tk::HTML_Widget.new(@fswin, :padx=>5, :pady=>9, + @html_fs = Tk::HTML_Widget.new(@fswin, :padx=>5, :pady=>9, :formcommand=>proc{|*args| form_cmd(*args) }, - :imagecommand=>proc{|*args| + :imagecommand=>proc{|*args| image_cmd(0, *args) - }, + }, :scriptcommand=>proc{|*args| script_cmd(*args) - }, + }, :appletcommand=>proc{|*args| applet_cmd(*args) - }, - :hyperlinkcommand=>proc{|*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, + }, + :bg=>'white', :tablerelief=>:raised, :cursor=>:tcross) { pack(:fill=>:both, :expand=>true) token_handler('meta', proc{|*args| meta(self, *args)}) |