.TH "tkhtml" "3tcl" "Sun Nov 11 18:57:26 EST 2012" .SH "NAME" tkhtml \- Widget to render html documents. .SH "SYNOPSIS" html pathName ?options? .SH "STANDARD OPTIONS" .RS .nf \-height \-width \-xscrollcommand \-xscrollincrement \-yscrollcommand \-yscrollincrement .fi .RE See the options(n) manual entry for details on the standard options. .SH "WIDGET-SPECIFIC OPTIONS" Command-Line Name:-defaultstyle .br Database Name: defaultstyle .br Database Class: Defaultstyle .br .RS .PP This option is used to set the default style-sheet for the widget. The option value should be the entire text of the default style-sheet. The default stylesheet defines things that are "built-in" to the document \- for example the behaviour of

or tags in html. The idea behind making it flexible is to allow Tkhtml to display anything that looks roughly like an XML document. But this will not work at the moment because of other assumptions the implementation makes about the set of valid tags. Currently, only valid HTML tags are recognized. The Tkhtml package adds the [::tkhtml::htmlstyle] command to the interpreter it is loaded into. Invoking this command returns a CSS document suitable for use with Tkhml as a default stylesheet for HTML documents. If the \-quirks option is passed to [::tkhtml::htmlstyle] then the returned document includes some extra rules used when rendering legacy documents. If the value of the \-defaultstyle option is changed, the new value does not take effect until after the next call to the widget [reset] method. The default value of this option is the same as the string returned by the [::tkhtml::htmlstyle] command. .RE Command-Line Name:-fontscale .br Database Name: fontscale .br Database Class: Fontscale .br .RS .PP This option is set to a floating point number, default 1.0. After CSS algorithms are used to determine a font size, it is multiplied by the value of this option. Setting this to a value other than 1.0 breaks standards compliance. .RE Command-Line Name:-fonttable .br Database Name: fonttable .br Database Class: Fonttable .br .RS .PP This option must be set to a list of 7 integers. The first integer must be greater than 0 and each subsequent integer must be greater than or equal to its predecessor. The seven integers define the sizes of the Tk fonts (in points) used when a CSS formatted document requests font-size "xx-small", "x-small", "small", "medium", "large", "x-large" or "xx-large", respectively. The default value is {8 9 10 11 13 15 17}. .RE Command-Line Name:-forcefontmetrics .br Database Name: forcefontmetrics .br Database Class: Forcefontmetrics .br .RS .PP This is a boolean option. If true, the font-metrics returned by Tk are overridden with calculated values based on the font requested. This improves CSS compatibility, but on some systems may cause problems. The default is true. .RE Command-Line Name:-forcewidth .br Database Name: forcewidth .br Database Class: Forcewidth .br .RS .PP When determining the layout of a document, Tkhtml3 (and all other HTML/CSS engines) require as an input the width of the containing block for the whole document. For web-browsers, this is usually the width of the viewport in which the document will be displayed. If this option is true or the widget window is not mapped, Tkhtml3 uses the value of the \-width option as the initial containing block width. Otherwise, the width of the widget window is used. The default value is false. .RE Command-Line Name:-imagecache .br Database Name: imagecache .br Database Class: Imagecache .br .RS .PP This boolean option (default true) determines whether or not Tkhtml3 caches the images returned to it by the \-imagecmd callback script. If true, all images are cached until the next time the [reset] sub-command is invoked. If false, images are discarded as soon as they are not in use. For simple applications, or applications that retrieve images from local sources, false is usually a better value for this option (since it may save memory). However for web-browser applications where the background images of elements may be modified by mouseover events and so on, true is a better choice. .RE Command-Line Name:-imagecmd .br Database Name: imagecmd .br Database Class: Imagecmd .br .RS .PP As well as for replacing entire document nodes (i.e. ), images are used in several other contexts in CSS formatted documents, for example as list markers or backgrounds. If the \-imagecmd option is not set to an empty string (the default), then each time an image URI is encountered in the document, it is appended to the \-imagecmd script and the resulting list evaluated. The command should return either an empty string, the name of a Tk image, or a list of exactly two elements, the name of a Tk image and a script. If the result is an empty string, then no image can be displayed. If the result is a Tk image name, then the image is displayed in the widget. When the image is no longer required, it is deleted. If the result of the command is a list containing a Tk image name and a script, then instead of deleting the image when it is no longer required, the script is evaluated. If the size or content of the image are modified while it is in use the widget display is updated automatically. .RE Command-Line Name:-mode .br Database Name: mode .br Database Class: Mode .br .RS .PP This option may be set to "quirks", "standards" or "almost standards", to set the rendering engine mode. The default value is "standards". TODO: List the differences between the three modes in Tkhtml. .RE Command-Line Name:-parsemode .br Database Name: parsemode .br Database Class: Parsemode .br .RS .PP This option may be set to "html", "xhtml" or "xml", to set the parser mode. The default value is "html". In "html" mode, the parser attempts to mimic the tag-soup approach inherited by modern web-browsers from the bad old days. Explicit XML style self-closing tags (i.e. closing a markup tag with "/>" instead of ">") are not handled specially. Unknown tags are ignored. "xhtml" mode is the same as "html" mode except that explicit self-closing tags are recognized. "xml" mode is the same as "xhtml" mode except that unknown tag names and XML CDATA sections are recognized. .RE Command-Line Name:-shrink .br Database Name: shrink .br Database Class: Shrink .br .RS .PP This boolean option governs the way the widgets requested width and height are calculated. If it is set to false (the default), then the requested width and height are set by the \-width and \-height options as per usual. If this option is set to true, then the widgets requested width and height are determined by the current document. Each time the document layout is calculated, the widgets requested height and width are set to the size of the document layout. If the widget is unmapped when the layout is calculated, then the value of the \-width option is used to determine the width of the initial containing block for the layout. Otherwise, the current window width is used. .RE Command-Line Name:-zoom .br Database Name: zoom .br Database Class: Zoom .br .RS .PP This option may be set to any floating point number. Before the document layout is calculated, all lengths and sizes specified in the HTML document or CSS style configuration, implicit or explicit, are multiplied by this value. The default value is 1.0. .RE Command-Line Name:-logcmd .br Database Name: logcmd .br Database Class: Logcmd .br .RS .PP This option is used for debugging the widget. It is not part of the official interface and may be modified or removed at any time. Don"t worry about it. .RE Command-Line Name:-timercmd .br Database Name: timercmd .br Database Class: Timercmd .br .RS .PP This option is used for debugging the widget. It is not part of the official interface and may be modified or removed at any time. Don"t worry about it. .RE Command-Line Name:-layoutcache .br Database Name: layoutcache .br Database Class: Layoutcache .br .RS .PP This option is used for debugging the widget. It is not part of the official interface and may be modified or removed at any time. Don"t worry about it. If this boolean option is set to true, then Tkhtml caches layout information to improve performance when the layout of a document must be recomputed. This can happen in a variety of situations, for example when extra text is appended to the document, a new style is applied to the document, a dynamic CSS selector (i.e. :hover) is activated, the widget window is resized, or when the size of an embedded image or Tk window changes. Layout caching consumes no extra memory or significant processing cycles, so in an ideal world there is no real reason to turn it off. But it can be a source of layout bugs, hence this option. The default value is true. .RE .SH "DESCRIPTION" The [html] command creates a new window (given by the pathName argument) and makes it into an html widget. The html command returns its pathName argument. At the time this command is invoked, there must not exist a window named pathName, but pathName"s parent must exist. .SH "WIDGET COMMAND" The [html] command creates a new Tcl command whose name is pathName. This command may be used to invoke various operations on the widget as follows: pathName bbox nodeHandle .br .RS If node nodeHandle generates content, this command returns a list of four integers that define the bounding-box of the generated content, relative to the top-left hand corner of the rendered document. The first two integers are the x and y coordinates of the top-left corner of the bounding-box, the later two are the x and y coordinates of the bottom-right corner of the same box. If the node does not generate content, then an empty string is returned. .RE pathName cget option .br .RS Returns the current value of the configuration option given by option. Option may have any of the values accepted by the [html] command. .RE pathName configure ?option? ?value? .br .RS Query or modify the configuration options of the widget. If no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for information on the format of this list). If option is specified with no value, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if no option is specified). If one or more option-value pairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string. Option may have any of the values accepted by the [html] command. .RE pathName fragment html-text .br .RS TODO: Document this command. .RE pathName handler node tag script .br pathName handler attribute tag script .br pathName handler script tag script .br pathName handler parse tag script .br .RS This command is used to define "handler" scripts \- Tcl callback scripts that are invoked by the widget when document elements of specified types are encountered. The widget supports two types of handler scripts: "node" and "script". For a "node" handler script, whenever a document element having the specified tag type (e.g. "p" or "link") is encountered during parsing, then the node handle for the node is appended to script and the resulting list evaluated as a Tcl command. See the section "NODE COMMAND" for details of how a node handle may be used to query and manipulate a document node. A node handler is called only after the subtree rooted at the node has been completely parsed. If the handler script is a "script" handler, whenever a document node of type tag is parsed, two arguments are appended to the specified script before it is evaluated. The first argument is a key-value list (suitable for passing to the [array set] command containing the HTML attributes that were part of the element declaration. The second argument is the literal text that appears between the start and end tags of the element. Elements for which a "script" handler is evaluated are not included in the parsed form of the HTML document. Instead, the result of the script handler evaluation is substituted into the document and parsed. For example, to handle the following embedded javascript: .RS .nf .fi .RE a script handler that returns the string "

A paragraph

" must be configured for nodes of type "SCRIPT". Unlike node or script handlers, a "parse" handler may be associated with a specific opening tag, a closing tag or with text tags (by specifying an empty string as the tag type). Whenever such a tag is encountered the parse handler script is invoked with two arguments, the node handle for the created node and the character offset of the in the parsed document. For a closing tag (i.e. "/form") an empty string is passed instead of a node handle. TODO: Describe "attribute" handlers. TODO: The offset values passed to parse handler scripts currently have problems. See http://tkhtml.tcl.tk/cvstrac/tktview?tn=126 Handler callbacks are always made from within [pathName parse] commands. The callback for a given node is made as soon as the node is completely parsed. This can happen because an implicit or explicit closing tag is parsed, or because there is no more document data and the \-final switch was passed to the [pathName parse] command. TODO: Return values of handler scripts? If an exception occurs in a handler script? .RE pathName image .br .RS This command returns the name of a new Tk image containing the rendered document. Where Tk widgets would be mapped in a live display, the image contains blank space. The returned image should be deleted when the script has finished with it, for example: .RS .nf set img [.html image] # ... Use $img ... image delete $img .fi .RE This command is included mainly for automated testing and should be used with care, as large documents can result in very large images that take a long time to create and use vast amounts of memory. Currently this command is not available on windows. On that platform an empty string is always returned. .RE pathName node ? ?-index? x y? .br .RS This command is used to retrieve one or more document node handles from the current document. If the x and y parameters are omitted, then the handle returned is the root-node of the document, or an empty string if the document has no root-node (i.e. an empty document). If the x and y arguments are present, then a list of node handles is returned. The list contains one handle for each node that generates content currently located at viewport coordinates (x, y). Usually this is only a single node, but floating boxes and other overlapped content can cause this command to return more than one node. If no content is located at the specified coordinates or the widget window is not mapped, then an empty string is returned. If the \-index option is specified along with the x and y coordinates, then instead of a list of node handles, a list of two elements is returned. The first element of the list is the node-handle associated with the generated text closest to the specified (x, y) coordinates. The second list value is a byte (not character) offset into the text obtainable by [nodeHandle text] for the character closest to coordinates (x, y). The index may be used with the [pathName tag] commands. The document node can be queried and manipulated using the interface described in the "NODE COMMAND" section. .RE pathName parse ?-final? html-text .br .RS Append extra text to the end of the (possibly empty) document currently stored by the widget. If the \-final option is present, this indicates that the supplied text is the last of the document. Any subsequent call to [pathName parse] before a call to [pathName reset] will raise an error. If the \-final option is not passed to [pathName parse] along with the final part of the document text, node handler scripts for any elements closed implicitly by the end of the document will not be executed. It is not an error to specify an empty string for the html-text argument. .RE pathName preload uri .br .RS This command is only useful if the \-imagecache option is set to true and an \-imagecmd script is defined. It causes the widget to invoke the \-imagecmd script to retrieve the image at URI uri. Assuming \-imagecache is true, the returned image is then stored in the image-cache. This command may be useful when implementing scripting environments that support "preloading" of images. .RE pathName reset .br .RS This is used to clear the internal contents of the widget prior to parsing a new document. The widget is reset such that the document tree is empty (as if no calls to [pathName parse] had ever been made) and no stylesheets except the default stylesheet are loaded (as if no invocations of [pathName style] had occured). .RE pathName search selector .br .RS The selector argument passed to this command must be a valid CSS selector, for example "h1" or "a[href]". This command returns a list of node-handles corresponding to the set of document nodes that match the supplied selector. .RE pathName style ?options? stylesheet-text .br .RS Add a stylesheet to the widgets internal configuration. The stylesheet-text argument should contain the text of a complete stylesheet. Incremental parsing of stylesheets is not supported, although of course multiple stylesheets may be added to a single widget. The following options are supported: .RS .nf Option Default Value \-------------------------------------- \-id "author" \-importcmd