Class: TkHTML_File_Viewer
- Includes:
- TkComm
- Defined in:
- sample/tkextlib/tkHTML/ss.rb
Constant Summary collapse
- @@biggray =
These are images to use with the actual image specified in a "
" markup can't be found.
TkPhotoImage.new(:data=>" R0lGODdhPAA+APAAALi4uAAAACwAAAAAPAA+AAACQISPqcvtD6OctNqLs968+w+G4kiW5omm\n 6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNFgsAO///\n")
- @@smgray =
TkPhotoImage.new(:data=>" R0lGODdhOAAYAPAAALi4uAAAACwAAAAAOAAYAAACI4SPqcvtD6OctNqLs968+w+G4kiW5omm\n 6sq27gvH8kzX9m0VADv/\n")
Constants included from TkComm
TkComm::GET_CONFIGINFO_AS_ARRAY, TkComm::GET_CONFIGINFOwoRES_AS_ARRAY, TkComm::TkExtlibAutoloadModule, TkComm::Tk_CMDTBL, TkComm::Tk_IDs, TkComm::Tk_WINDOWS, TkComm::USE_TCLs_LIST_FUNCTIONS, TkComm::WidgetClassNames
Constants included from TkUtil
TkUtil::None, TkUtil::RELEASE_DATE
Instance Method Summary collapse
-
#applet_cmd(w, arglist) ⇒ Object
This routine is called for every
-
#clear_screen ⇒ Object
Clear the screen.
- #form_cmd(n, cmd, *args) ⇒ Object
-
#fullscreen ⇒ Object
Go from window mode to full-screen mode.
-
#fullscreen_off ⇒ Object
Go from full-screen mode back to window mode.
-
#href_binding(w, x, y) ⇒ Object
This binding fires when there is a click on a hyperlink.
- #hyper_cmd(*args) ⇒ Object
- #image_cmd(hs, *args) ⇒ Object
-
#initialize(file = nil) ⇒ TkHTML_File_Viewer
constructor
A new instance of TkHTML_File_Viewer.
- #key_press(w, keysym) ⇒ Object
-
#load_file(name) ⇒ Object
Load a file into the HTML widget.
-
#meta(w, tag, alist) ⇒ Object
This routine is called whenever a "" markup is seen.
- #move_big_image(b) ⇒ Object
-
#pick_font(size, attrs) ⇒ Object
A font chooser routine.
-
#pick_font_fs(size, attrs) ⇒ Object
This routine is called to pick fonts for the fullscreen view.
-
#process_url(url) ⇒ Object
Process the given URL.
-
#read_file(name) ⇒ Object
Read a file.
-
#refresh(*args) ⇒ Object
Refresh the current file.
-
#run_applet(size, w, arglist) ⇒ Object
This routine is called to run an applet.
-
#script_cmd(*args) ⇒ Object
This routine is called for every
Returns a new instance of TkHTML_File_Viewer.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
# File 'sample/tkextlib/tkHTML/ss.rb', line 27 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 # = [ [['File', 0], ['Open', proc{sel_load()}, 0], ['Full Screen', proc{fullscreen()}, 0], ['Refresh', proc{refresh()}, 0], '---', ['Exit', proc{exit}, 1]] ] = @root.() @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) @html.token_handler('meta', proc{|*args| (@html, *args)}) vscr = @html.(.new) hscr = @html.(.new) 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) ############################################ @html.clipwin.focus # If an arguent was specified, read it into the HTML widget. # Tk.update if file && file != "" load_file(file) end end