home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Komunikace
/
Comanche
/
comanche.exe
/
lib
/
iwidgets2.2.0
/
scripts
/
scrolledhtml.itk
< prev
next >
Wrap
Text File
|
1999-02-24
|
61KB
|
1,899 lines
# Scrolledhtml
# ----------------------------------------------------------------------
# Implements a scrolled html text widget by inheritance from scrolledtext
# Import reads from an html file, while export still writes plain text
# Also provides a render command, to display html text passed in as an
# argument.
#
# WISH LIST:
# This section lists possible future enhancements.
#
# 1) make images scroll smoothly off top like they do off bottom.
# 2) support color of 'none' in images
# 3) support for imagemaps
# 4) add ability to get non-local URLs
# 5) keep track of visited links
# 6) add html 2.0 and 3.0 support (there are a few features supported now)
# 7) add java applets support
#
# ----------------------------------------------------------------------
# AUTHOR: Kris Raney EMAIL: kraney@spd.dsccc.com
#
# @(#) $Id: scrolledhtml.itk,v 1.2 1998/08/11 14:46:41 welch Exp $
# ----------------------------------------------------------------------
# Copyright (c) 1996 DSC Technologies Corporation
# ======================================================================
# Permission to use, copy, modify, distribute and license this software
# and its documentation for any purpose, and without fee or written
# agreement with DSC, is hereby granted, provided that the above copyright
# notice appears in all copies and that both the copyright notice and
# warranty disclaimer below appear in supporting documentation, and that
# the names of DSC Technologies Corporation or DSC Communications
# Corporation not be used in advertising or publicity pertaining to the
# software without specific, written prior permission.
#
# DSC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, AND NON-
# INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE
# AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. IN NO EVENT SHALL
# DSC BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS ACTION,
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
# ======================================================================
# Acknowledgements:
#
# Special thanks go to Sam Shen(SLShen@lbl.gov), as this code is based on his
# tkhtml.tcl code from tk inspect. The original code is copyright 1995
# Lawrence Berkeley Laboratory.
#
# This software is copyright (C) 1995 by the Lawrence Berkeley Laboratory.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that: (1) source code distributions
# retain the above copyright notice and this paragraph in its entirety, (2)
# distributions including binary code include the above copyright notice and
# this paragraph in its entirety in the documentation or other materials
# provided with the distribution, and (3) all advertising materials mentioning
# features or use of this software display the following acknowledgement:
# ``This product includes software developed by the University of California,
# Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
# the University nor the names of its contributors may be used to endorse
# or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# This code is based on Angel Li's (angel@flipper.rsmas.miami.edu) HTML
#
# Default resources.
#
option add *Scrolledhtml.borderWidth 2 widgetDefault
option add *Scrolledhtml.relief sunken widgetDefault
option add *Scrolledhtml.scrollMargin 3 widgetDefault
option add *Scrolledhtml.width 500 widgetDefault
option add *Scrolledhtml.height 600 widgetDefault
option add *Scrolledhtml.visibleItems 80x24 widgetDefault
option add *Scrolledhtml.vscrollMode static widgetDefault
option add *Scrolledhtml.hscrollMode static widgetDefault
option add *Scrolledhtml.labelPos n widgetDefault
option add *Scrolledhtml.wrap word widgetDefault
#
# Usual options.
#
itk::usual Scrolledhtml {
keep -fontname -fontsize -fixedfont -link -linkhighlight \
-activebackground -activerelief -background -borderwidth -cursor \
-elementborderwidth -foreground -highlightcolor -highlightthickness \
-insertbackground -insertborderwidth -insertofftime -insertontime \
-insertwidth -jump -labelfont -selectbackground -selectborderwidth \
-selectforeground -textbackground -textfont -troughcolor -unknownimage
}
# ------------------------------------------------------------------
# SCROLLEDHTML
# ------------------------------------------------------------------
class ::iwidgets::Scrolledhtml {
inherit ::iwidgets::Scrolledtext
constructor {args} {}
itk_option define -feedback feedBack FeedBack {}
itk_option define -linkcommand linkCommand LinkCommand {}
itk_option define -fontname fontname FontName times
itk_option define -fixedfont fixedFont FixedFont courier
itk_option define -fontsize fontSize FontSize medium
itk_option define -link link Link blue
itk_option define -linkhighlight linkhighlight LinkHighLight red
itk_option define -unknownimage unknownimage File {}
itk_option define -textbackground textBackground Background {}
public method import {args}
public method clear {}
public method render {html {wd .}}
public method title {} {return $_title}
public method pwd {} {return $_cwd}
protected method _setup {}
protected method _set_tag {}
protected method _reconfig_tags {}
protected method _append_text {text}
protected method _definefont {name foundry family weight slant registry}
protected method _peek {instack}
protected method _push {instack value}
protected method _pop {instack}
protected method _parse_fields {array_var string}
protected method _href_click {cmd href}
protected method _feedback {{val "next"}}
private variable _fbmax 0
private variable _fbcount 0
protected method _header {level args}
protected method _/header {level}
protected method _entity_a {args}
protected method _entity_/a {}
protected method _entity_address {}
protected method _entity_/address {}
protected method _entity_b {}
protected method _entity_/b {}
protected method _entity_base {{args {}}}
protected method _entity_big {}
protected method _entity_/big {}
protected method _entity_blockquote {}
protected method _entity_/blockquote {}
protected method _entity_body {{args {}}}
protected method _entity_/body {}
protected method _entity_br {{args {}}}
protected method _entity_center {}
protected method _entity_/center {}
protected method _entity_cite {}
protected method _entity_/cite {}
protected method _entity_code {}
protected method _entity_/code {}
protected method _entity_dir {{args {}}}
protected method _entity_/dir {}
protected method _entity_dl {{args {}}}
protected method _entity_/dl {}
protected method _entity_dt {}
protected method _entity_dd {}
protected method _entity_dfn {}
protected method _entity_/dfn {}
protected method _entity_em {}
protected method _entity_/em {}
protected method _entity_h1 {{args {}}}
protected method _entity_/h1 {}
protected method _entity_h2 {{args {}}}
protected method _entity_/h2 {}
protected method _entity_h3 {{args {}}}
protected method _entity_/h3 {}
protected method _entity_h4 {{args {}}}
protected method _entity_/h4 {}
protected method _entity_h5 {{args {}}}
protected method _entity_/h5 {}
protected method _entity_h6 {{args {}}}
protected method _entity_/h6 {}
protected method _entity_hr {{args {}}}
protected method _entity_i {}
protected method _entity_/i {}
protected method _entity_img {args}
protected method _entity_kbd {}
protected method _entity_/kbd {}
protected method _entity_li {}
protected method _entity_listing {}
protected method _entity_/listing {}
protected method _entity_menu {{args {}}}
protected method _entity_/menu {}
protected method _entity_ol {{args {}}}
protected method _entity_/ol {}
protected method _entity_p {{args {}}}
protected method _entity_pre {{args {}}}
protected method _entity_/pre {}
protected method _entity_samp {}
protected method _entity_/samp {}
protected method _entity_small {}
protected method _entity_/small {}
protected method _entity_sub {}
protected method _entity_/sub {}
protected method _entity_sup {}
protected method _entity_/sup {}
protected method _entity_strong {}
protected method _entity_/strong {}
protected method _entity_title {}
protected method _entity_/title {}
protected method _entity_tt {}
protected method _entity_/tt {}
protected method _entity_u {}
protected method _entity_/u {}
protected method _entity_ul {{args {}}}
protected method _entity_/ul {}
protected method _entity_var {}
protected method _entity_/var {}
protected variable _title {} ;# The title of the html document
protected variable _listyle bullet ;# list element style
protected variable _lipic {} ;# picture to use as bullet
protected variable _color black ;# current text color
protected variable _bgcolor #d9d9d9 ;# current background color
protected variable _link blue ;# current link color
protected variable _smallpoints "60 80 100 120 140 180 240" ;# font point
protected variable _mediumpoints "80 100 120 140 180 240 360" ;# sizes for
protected variable _largepoints "100 120 140 180 240 360 480" ;# various
protected variable _hugepoints "120 140 180 240 360 480 640" ;# fontsizes
protected variable _font times ;# name of current font
protected variable _rulerheight 6 ;#
protected variable _indentincr 4 ;# increment to indent by
protected variable _counter -1 ;# counter to give unique numbers
protected variable _left 0 ;# initial left margin
protected variable _left2 0 ;# subsequent left margin
protected variable _right 0 ;# right margin
protected variable _justify L ;# text justification
protected variable _offset 0 ;# text offset (super/subscript)
protected variable _textweight 0 ;# boldness of text
protected variable _textslant 0 ;# whether to use italics
protected variable _underline 0 ;# whether to use underline
protected variable _verbatim 0 ;# whether to skip formatting
protected variable _pre 0 ;# preformatted text
protected variable _intitle 0 ;# in <title>...</title>
protected variable _anchorcount 0 ;# number of anchors
protected variable _stack ;# array of stacks
protected variable _pointsndx 2 ;#
protected variable _fontnames ;# list of accepted font names
protected variable _fontinfo ;# array of font info given font name
protected variable _tag ;#
protected variable _tagl ;#
protected variable _tagfont ;#
protected variable _cwd . ;# base directory of current page
protected variable _anchor ;# array of indexes by anchorname
protected variable _defaulttextbackground;# default text background
private variable _initialized 0
private variable _defUnknownImg [image create photo -data {
R0lGODdhHwAgAPQAAP///wAAAMzMzC9PT76+vvnTogCR/1WRVaoAVf//qvT09OKdcWlcx19f
X9/f339/f8vN/J2d/aq2qoKCggAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
ACwAAAAAHwAgAAAF/iAgjqRDnmiKmqOkqsTaToDjvudTttLjOITJbTQhGI+iQE0xMvZqQIDw
NAEiAcqRVdKAGh0NyVCkuyqZBEmwofgRrFIxSaI0JmuA9KTrthIicWMTAQ8xWHgSe15AVgcJ
eVMjDwECOkome22Mb0cHCzEPOiQPgwGXCjomakedA0VgY1IPDZcuP3l5YkcRDwMHqDQoEzq2
Pz8IQkK7Bw8HDg+xO26PCAgRDcpGswEK2Dh9ItUMDdirPYUKwTKMjwDV1gHlR2oCkSmcI9UE
BabYrGnQoolgBCGckX7yWJWDYaUMAYSRFECAwMXeiU1BHpKTB4CBR4+oBOb5By1UNgUfXj0C
8HaP079sBCCkZIAKWst/OGPOhNBNHQmXOeftJBASRVCcEiIojQDBwIOeRo+SpGXKFFGbP6Xi
nLWxEMsmWpEOC9XDYtigYtKSwsH2xdq2cEfRmFS1rt27eE09CAEAOw==
}]
}
#
# Provide a lowercased access method for the Scrolledhtml class.
#
proc ::iwidgets::scrolledhtml {pathName args} {
uplevel ::iwidgets::Scrolledhtml $pathName $args
}
# ------------------------------------------------------------------
# CONSTRUCTOR
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::constructor {args} {
# define the fonts we're going to use
set _fontnames ""
_definefont helvetica adobe helvetica "medium bold" "r o" iso8859
_definefont courier adobe courier "medium bold" "r o" iso8859
_definefont times adobe times "medium bold" "r i" iso8859
_definefont symbol adobe symbol "medium medium" "r r" adobe
$itk_component(text) configure -state disabled
eval itk_initialize $args
set _initialized 1
}
# ------------------------------------------------------------------
# OPTIONS
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# OPTION: -fontsize
#
# Set the general size of the font.
# ------------------------------------------------------------------
configbody iwidgets::Scrolledhtml::fontsize {
switch $itk_option(-fontsize) {
small { }
medium { }
large { }
huge { }
default {
error "bad fontsize option\
\"$itk_option(-fontsize)\": should\
be small, medium, large, or huge"
}
}
_reconfig_tags
}
# ------------------------------------------------------------------
# OPTION: -fixedfont
#
# Set the fixed font name
# ------------------------------------------------------------------
configbody iwidgets::Scrolledhtml::fixedfont {
if {[lsearch -exact $_fontnames $itk_option(-fixedfont)] == -1} {
error "Invalid font name \"$itk_option(-fixedfont)\". Must be one of \
$_fontnames"
}
}
# ------------------------------------------------------------------
# OPTION: -fontname
#
# Set the default font name
# ------------------------------------------------------------------
configbody iwidgets::Scrolledhtml::fontname {
if {[lsearch -exact $_fontnames $itk_option(-fontname)] == -1} {
error "Invalid font name \"$itk_option(-fontname)\". Must be one of \
$_fontnames"
}
}
# ------------------------------------------------------------------
# OPTION: -textbackground
#
# Set the default text background
# ------------------------------------------------------------------
configbody iwidgets::Scrolledhtml::textbackground {
set _defaulttextbackground $itk_option(-textbackground)
}
# ------------------------------------------------------------------
# METHODS
# ------------------------------------------------------------------
# ------------------------------------------------------------------
# METHOD: clear
#
# Clears the text out
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::clear {} {
$itk_component(text) config -state normal
$itk_component(text) delete 1.0 end
_setup
$itk_component(text) config -state disabled
}
# ------------------------------------------------------------------
# METHOD import ?-link? filename?#anchorname?
#
# read html text from a file (import filename) if the keyword link is present,
# pathname is relative to last page, otherwise it is relative to current
# directory. This allows the user to use a linkcommand of
# "<widgetname> import -link"
#
# if '#anchorname' is appended to the filename, the page is displayed starting
# at the anchor named 'anchorname' If an anchor is specified without a filename,
# the current page is assumed.
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::import {args} {
set len [llength $args]
if {$len != 1 && $len != 2} {
error "wrong # args: should be \
\"$itk_component(hull) import ?-link? filename\""
}
set linkname [lindex $args [expr $len - 1]]
#
# Seperate filename#anchorname
#
if ![regexp {(.*)#(.*)} $linkname dummy filename anchorname] {
set filename $linkname
}
if {$filename!=""} {
#
# Check for -link option
#
switch -- $len {
1 {
#
# open file & set cwd to that file's directory
#
set f [open $filename r]
set _cwd [file dirname $filename]
}
2 {
switch -- [lindex $args 0] {
-link {
#
# got -link, so set path relative to current locale, if path
# is a relative pathname
#
if {[string compare "." [file dirname $filename]] == 0} {
set f [open [file join $_cwd $filename] r]
} else {
if {[string index [file dirname $filename] 0] != "/" &&\
[string index [file dirname $filename] 0] != "~"} {
set f [open [file join $_cwd $filename] r]
set _cwd [file join _cwd [file dirname $filename]]
} else {
set f [open $filename r]
set _cwd [file dirname $filename]
}
}
}
default {
# got something other than -link
error "invalid format: should be \
\"$itk_component(hull) import ?-link? filename\""
}
}
}
}
set txt [read $f]
close $f
render $txt $_cwd
}
#
# if an anchor was requested, move that anchor into view
#
if [ info exists anchorname] {
if {$anchorname!=""} {
if [info exists _anchor($anchorname)] {
$itk_component(text) see $_anchor($anchorname)
}
} else {
$itk_component(text) see 0.0
}
}
}
# ------------------------------------------------------------------
# METHOD: render text ?wd?
#
# Clear the text, then render html formatted text. Optional wd argument
# sets the base directory for any links or images.
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::render {html {wd .}} {
#
# blank text and reset all state variables
#
clear
set _cwd $wd
_set_tag
#
# Convert the text from something like this:
# Put <strong>bold</strong> text in {}'s.
#
# to something like this:
# _append_text {Put }
# catch {_entity_[string tolower {strong}]}
# _append_text {bold}
# catch {_entity_[string tolower {/strong}]}
# _append_text { text in &bl;&br;'s.}
#
# But first, convert all of the <p> markers to
# "&pp;" so we can count them and substitute
# them back later, like this:
#
# _entity_p
# _feedback next
#
regsub -all \{ $html {\&bl;} html
regsub -all \} $html {\&br;} html
regsub -all {\\} $html {\&bs;} html
set html "_append_text {$html}"
_feedback [regsub -nocase -all "<p>" $html {\&pp;} html]
regsub -all "&pp;" $html "\}\n_entity_p\n_feedback next\n_append_text \{" html
regsub -all {<([^> ]*) *([^>]*)>} $html \
"\}\ncatch \{_entity_\[string tolower \{\\1\}\] \\2\}\n_append_text \{" html
$itk_component(text) config -state normal
eval $html
$itk_component(text) config -state disabled
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _setup
#
# Reset all state variables to prepare for a new page.
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_setup {} {
set _font $itk_option(-fontname)
set _left 0
set _left2 0
set _right 0
set _justify L
set _textweight 0
set _textslant 0
set _underline 0
set _verbatim 0
set _pre 0
set _title {}
set _intitle 0
set _anchorcount 0
set _stack(font) {}
set _stack(color) {}
set _stack(justify) {}
set _stack(listyle) {}
set _stack(lipic) {}
set _stack(href) {}
set _stack(pointsndx) {}
set _stack(left) {}
set _stack(left2) {}
set _stack(offset) {}
set _pointsndx 2
set _bgcolor $_defaulttextbackground
set _color $itk_option(-foreground)
set _link $itk_option(-link)
config -textbackground $_bgcolor
foreach x [array names _anchor] { unset _anchor($x) }
$itk_component(text) tag config hr -relief sunken -borderwidth 2 \
-font -*-*-*-*-*-*-$_rulerheight-*-*-*-*-*-*-*
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _definefont name foundry family weight slant registry
#
# define font information used to generate font value from font name
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_definefont \
{name foundry family weight slant registry} {
if {[lsearch -exact $_fontnames $name] == -1 } {
lappend _fontnames $name
}
set _fontinfo($name) \
[list $foundry $family $weight $slant $registry]
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _append_text text
#
# append text in the format described by the state variables
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_append_text {text} {
if {$text == ""} {
return
}
regsub -nocase -all "&?" $text {\&} text
regsub -nocase -all "<?" $text "<" text
regsub -nocase -all ">?" $text ">" text
regsub -nocase -all ""?" $text "\"" text
regsub -nocase -all "&bl;?" $text "\{" text
regsub -nocase -all "&br;?" $text "\}" text
regsub -nocase -all "&bs;?" $text {\\} text
if !$_verbatim {
if !$_pre {
set text [string trim $text "\n\r"]
regsub -all "\[ \n\r\t\]+" $text " " text
}
if ![string length $text] return
}
if {!$_pre && !$_intitle} {
set p [$itk_component(text) get "end - 2c"]
set n [string index $text 0]
if {$n == " " && $p == " "} {
set text [string range $text 1 end]
}
$itk_component(text) insert end $text $_tag
return
}
if {$_pre && !$_intitle} {
$itk_component(text) insert end $text $_tag
return
}
append _title $text
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _set_tag
#
# generate a tag
# ------------------------------------------------------------------
# a tag is constructed as: font?B?I?U?Points-LeftLeft2RightColorJustify
body iwidgets::Scrolledhtml::_set_tag {} {
set i -1
foreach var {foundry family weight slant registry} {
set $var [lindex $_fontinfo($_font) \
[incr i]]
}
set x_font "-$foundry-$family-"
set _tag $_font
set args {}
if {$_textweight > 0} {
append _tag "B"
append x_font [lindex $weight 1]-
} else {
append x_font [lindex $weight 0]-
}
if {$_textslant > 0} {
append _tag "I"
append x_font [lindex $slant 1]-
} else {
append x_font [lindex $slant 0]-
}
if {$_underline > 0} {
append _tag "U"
append args " -underline 1"
}
switch $_justify {
L { append args " -justify left" }
R { append args " -justify right" }
C { append args " -justify center" }
}
append args " -offset $_offset"
set pts [lindex [set [format "_%spoints" $itk_option(-fontsize)]] \
$_pointsndx]
append _tag $_pointsndx - $_left \
$_left2 $_right \
$_color $_justify
append x_font "normal-*-*-$pts-*-*-*-*-$registry-*"
if $_anchorcount {
set href [_peek href]
set href_tag href[incr _counter]
set tags [list $_tag $href_tag]
if { $itk_option(-linkcommand)!= {} } {
$itk_component(text) tag bind $href_tag <1> \
[list uplevel #0 $itk_option(-linkcommand) $href]
}
$itk_component(text) tag bind $href_tag <Enter> \
[list $itk_component(text) tag configure $href_tag \
-foreground $itk_option(-linkhighlight)]
$itk_component(text) tag bind $href_tag <Leave> \
[list $itk_component(text) tag configure $href_tag \
-foreground $_color]
} else {
set tags $_tag
}
if {![info exists _tagl($_tag)]} {
set _tagfont($_tag) 1
eval $itk_component(text) tag configure $_tag \
-foreground $_color \
-lmargin1 ${_left}m \
-lmargin2 ${_left2}m $args
if [catch {eval $itk_component(text) tag configure $_tag \
-font $x_font} err] {
_definefont $_font * $family $weight $slant *
regsub \$foundry $x_font * x_font
regsub \$registry $x_font * x_font
catch {eval $itk_component(text) tag configure $_tag -font $x_font}
}
}
if [info exists href_tag] {
$itk_component(text) tag raise $href_tag $_tag
}
set _tag $tags
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _reconfig_tags
#
# reconfigure tags following a configuration change
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_reconfig_tags {} {
if $_initialized {
foreach tag [$itk_component(text) tag names] {
foreach efont $_fontnames {
if [regexp "${efont}(B?)(I?)(U?)(\[1-9\]\[0-9\]*)-" $tag t b i u points] {
set j -1
set _font $efont
foreach var {foundry family weight slant registry} {
set $var [lindex $_fontinfo($_font) [incr j]]
}
set x_font "-$foundry-$family-"
if {$b == "B"} {
append x_font [lindex $weight 1]-
} else {
append x_font [lindex $weight 0]-
}
if {$i == "I"} {
append x_font [lindex $slant 1]-
} else {
append x_font [lindex $slant 0]-
}
set pts [lindex [set [format \
"_%spoints" $itk_option(-fontsize)]] $points]
append x_font "normal-*-*-$pts-*-*-*-*-$registry-*"
$itk_component(text) tag config $tag -font $x_font
break
}
}
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _push instack value
#
# push value onto stack(instack)
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_push {instack value} {
lappend _stack($instack) $value
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _pop instack
#
# pop value from stack(instack)
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_pop {instack} {
set n [expr [llength $_stack($instack)]-1]
if {$n < 0} {
return ""
}
set val [lindex $_stack($instack) $n]
set _stack($instack) [lreplace $_stack($instack) $n $n]
return $val
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _peek instack
#
# peek at top value on stack(instack)
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_peek {instack} {
return [lindex $_stack($instack) end]
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _parse_fields array_var string
#
# parse fields from a href or image tag. At the moment, doesn't support
# spaces in field values. (e.g. alt="not avaliable")
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_parse_fields {array_var string} {
upvar $array_var array
if {$string != "{}" } {
regsub -all "( *)=( *)" $string = string
regsub -all {\\\"} $string \" string
while {$string != ""} {
if ![regexp "(\[^ \n\r=\]+)=\"(\[^\"\n\r\t\]*)(.*)" $string \
dummy field value newstring] {
if ![regexp "(\[^ \n\r=\]+)=(\[^\n\r\t \]*)(.*)" $string \
dummy field value newstring] {
if ![regexp "(\[^ \n\r\]+)(.*)" $string dummy field newstring] {
error "malformed command field; field = \"$string\""
continue
}
set value ""
}
}
set array([string tolower $field]) $value
set string "$newstring"
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _href_click
#
# process a click on an href
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_href_click {cmd href} {
uplevel #0 $cmd $href
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _feedback ?val?
#
# Called from time to time while the text is being rendered to
# handle feedback via the "-feedback" option. If "val" is "next",
# then the counter is incremented and the feedback command is
# executed. Otherwise, "val" is taken as the maximum counter
# value, and the counter is reset.
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_feedback {{val "next"}} {
if {$val == "next"} {
incr _fbcount
if {$itk_option(-feedback) != ""} {
uplevel #0 $itk_option(-feedback) $_fbcount $_fbmax
}
} elseif {[catch {expr 1*$val}] != 0} {
error "bad value \"$val\": should be a number"
} else {
set _fbmax $val
set _fbcount 0
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _header level
#
# generic entity to set state for <hn> tag
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_header {level args} {
eval _parse_fields ar $args
_push justify $_justify
if [info exists ar(align)] {
_entity_p align=$ar(align)
} else {
_entity_p
}
if [info exists ar(src)] {
_entity_img src=$ar(src)
}
_push pointsndx $_pointsndx
set _pointsndx [expr 7-$level]
incr _textweight
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _/header level
#
# generic entity to set state for </hn> tag
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_/header {level} {
set _justify [_pop justify]
set _pointsndx [_pop pointsndx]
incr _textweight -1
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_a
#
# add an anchor. Accepts arguments of the form ?href=filename#anchorpoint?
# ?name=anchorname?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_a {args} {
_parse_fields ar $args
_push color $_color
if [info exists ar(href)] {
_push href $ar(href)
incr _anchorcount
set _color $_link
_entity_u
} else {
_push href {}
}
if [info exists ar(name)] {
set _anchor($ar(name)) [$itk_component(text) index end]
}
if [info exists ar(id)] {
set _anchor($ar(id)) [$itk_component(text) index end]
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/a
#
# End anchor
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/a {} {
set href [_pop href]
if {$href != {}} {
incr _anchorcount -1
set _color [_pop color]
_entity_/u
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_address
#
# display an address
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_address {} {
_entity_br
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/address
#
# change state back from address display
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/address {} {
_entity_/i
_entity_br
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_b
#
# Change current font to bold
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_b {} {
incr _textweight
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/b
#
# change current font back from bold
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/b {} {
incr _textweight -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_big
#
# Change current font to a bigger size
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_big {} {
_push pointsndx $_pointsndx
if {[incr _pointsndx 2] > 6} {
set _pointsndx 6
}
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/big
#
# change current font back from bigger size
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/big {} {
set _pointsndx [_pop pointsndx]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_base
#
# set the cwd of the document
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_base {{args {}}} {
_parse_fields ar $args
if [info exists ar(href)] {
set cwd [file dirname $ar(href)]
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_blockquote
#
# display a block quote
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_blockquote {} {
_entity_p
_push left $_left
incr _left $_indentincr
_push left2 $_left2
set _left2 $_left
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/blockquote
#
# change back from blockquote
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/blockquote {} {
_entity_p
set _left [_pop left]
set _left2 [_pop left2]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_body
#
# begin body text. Takes argument of the form ?bgcolor=<color>? ?text=<color>?
# ?link=<color>?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_body {{args {}}} {
_parse_fields ar $args
if [info exists ar(bgcolor)] {
set _bgcolor $ar(bgcolor)
set temp $itk_option(-textbackground)
config -textbackground $_bgcolor
set _defaulttextbackground $temp
}
if [info exists ar(text)] {
set _color $ar(text)
}
if [info exists ar(link)] {
set _link $ar(link)
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/body
#
# end body text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/body {} {
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_br
#
# line break
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_br {{args {}}} {
if {[$itk_component(text) get end-2c] != "\n"} {
$itk_component(text) insert end "\n"
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_center
#
# change justification to center
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_center {} {
_push justify $_justify
set _justify C
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/center
#
# change state back from center
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/center {} {
set _justify [_pop justify]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_cite
#
# display citation
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_cite {} {
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/cite
#
# change state back from citation
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/cite {} {
_entity_/i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_code
#
# display code listing
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_code {} {
_entity_pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/code
#
# end code listing
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/code {} {
_entity_/pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dir
#
# display dir list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_dir {{args {}}} {
_entity_ul plain $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/dir
#
# end dir list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/dir {} {
_entity_/ul
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dl
#
# begin definition list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_dl {{args {}}} {
if $_left {
_entity_br
} else {
_entity_p
}
_push left $_left
_push left2 $_left2
if {$_left2 == $_left } {
incr _left2 [expr $_indentincr+3]
} else {
incr _left2 $_indentincr
}
incr _left $_indentincr
_push listyle $_listyle
set _listyle none
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/dl
#
# end definition list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/dl {} {
set _left [_pop left]
set _left2 [_pop left2]
set _listyle [_pop listyle]
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dt
#
# definition term
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_dt {} {
set _left [expr $_left2 - 3]
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dd
#
# definition definition
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_dd {} {
set _left $_left2
_set_tag
_entity_br
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_dfn
#
# display defining instance of a term
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_dfn {} {
_entity_i
_entity_b
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/dfn
#
# change state back from defining instance of term
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/dfn {} {
_entity_/b
_entity_/i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_em
#
# display emphasized text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_em {} {
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/em
#
# change state back from emphasized text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/em {} {
_entity_/i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h1
#
# display header level 1.
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_h1 {{args {}}} {
_header 1 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h1
#
# change state back from header 1
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/h1 {} {
_/header 1
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h2
#
# display header level 2
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_h2 {{args {}}} {
_header 2 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h2
#
# change state back from header 2
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/h2 {} {
_/header 2
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h3
#
# display header level 3
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_h3 {{args {}}} {
_header 3 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h3
#
# change state back from header 3
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/h3 {} {
_/header 3
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h4
#
# display header level 4
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_h4 {{args {}}} {
_header 4 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h4
#
# change state back from header 4
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/h4 {} {
_/header 4
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h5
#
# display header level 5
# Accepts argument of the form ?align=[left,right,center]? ?src=<image pname>?
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_h5 {{args {}}} {
_header 5 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h5
#
# change state back from header 5
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/h5 {} {
_/header 5
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_h6
#
# display header level 6
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_h6 {{args {}}} {
_header 6 $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/h6
#
# change state back from header 6
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/h6 {} {
_/header 6
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_hr
#
# Add a horizontal rule
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_hr {{args {}}} {
_parse_fields ar $args
$itk_component(text) tag config hr[incr _counter] -relief sunken \
-borderwidth 2 \
-font -*-*-*-*-*-*-2-*-*-*-*-*-*-*
if [info exists ar(size)] {
$itk_component(text) tag config hr$_counter -font \
-*-*-*-*-*-*-$ar(size)-*-*-*-*-*-*-*
}
if [info exists ar(width)] {
}
if [info exists ar(noshade)] {
$itk_component(text) tag config hr$_counter -relief flat \
-background black
}
# if [info exists ar(align)] {
# $itk_component(text) tag config hr$_counter -justify $ar(align)
# }
_entity_p
$itk_component(text) insert end " \n" hr$_counter
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_i
#
# display italicized text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_i {} {
incr _textslant
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/i
#
# change state back from italicized text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/i {} {
incr _textslant -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_img
#
# display an image. takes argument of the form img=<filename>
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_img {args} {
_parse_fields ar $args
set alttext "<image>"
#
# If proper argument exists
#
if [info exists ar(src)] {
#
# if this is an anchor
#
if $_anchorcount {
# create link colored border
set imgframe $itk_component(text).img[incr _counter]
frame $imgframe -borderwidth 2 -background $_link
bind $imgframe <Enter> \
[list $imgframe configure -background $itk_option(-linkhighlight)]
bind $imgframe <Leave> \
[list $imgframe configure -background $_link]
} else {
# create plain frame
set imgframe $itk_component(text).img[incr _counter]
frame $imgframe -borderwidth 0 -background $_color
}
#
# try to load image
#
set file [file join $_cwd $ar(src)]
if [catch {set img [image create photo -file $file]} err] {
# got an error. Check for width & height suggestions.
if {[info exists ar(width)] && [info exists ar(height)] } {
# suggestions exist, so make frame appropriate size and add a border
$imgframe configure -width $ar(width) -height $ar(height) -borderwidth 2
pack propagate $imgframe false
}
#
# If alt text is specified, display that
#
if [info exists ar(alt)] {
set win $imgframe.text
# add a border
$imgframe configure -borderwidth 2
label $win -text "$ar(alt)" -background $_bgcolor \
-foreground $_color
pack $win -expand true -fill both
} else {
#
# Load 'unknown image'
#
if {$itk_option(-unknownimage) != {}} {
set uki $itk_option(-unknownimage)
if [catch { set img [image create photo -file $uki] } err] {
error "Couldn't create image $uki:\n$err\nUnknown image not found"
}
} else {
set img $_defUnknownImg
}
set win $imgframe.$img
#
# make label containing image
#
label $win -image $img -borderwidth 0 -background $_bgcolor
pack $win -expand true -fill both
}
} else { ;# no error loading image
set win $imgframe.$img
#
# make label containing image
#
label $win -image $img -borderwidth 0
}
pack $win
#
# set alignment
#
set align bottom
if [info exists ar(align)] {
switch $ar(align) {
middle {
set align center
}
default {
set align [string tolower $ar(align)]
}
}
}
#
# create window in text to display image
#
$itk_component(text) window create end -window \
$imgframe -align $align
#
# set tag for window
#
$itk_component(text) tag add $_tag $imgframe
if $_anchorcount {
set href [_peek href]
set href_tag href[incr _counter]
set tags [list $_tag $href_tag]
if { $itk_option(-linkcommand)!= {} } {
bind $win <1> [list uplevel #0 $itk_option(-linkcommand) $href]
}
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_kbd
#
# Display keyboard input
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_kbd {} {
incr _textweight
_entity_tt
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/kbd
#
# change state back from displaying keyboard input
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/kbd {} {
_entity_/tt
incr _textweight -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_li
#
# begin new list entry
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_li {} {
_entity_br
switch -exact $_listyle {
bullet {
set old_font $_font
set _font symbol
_set_tag
$itk_component(text) insert end "\xb7" $_tag
set _font $old_font
_set_tag
}
none {
}
picture {
_entity_img src="$_lipic"
}
default {
incr _listyle
_entity_b
$itk_component(text) insert end "$_listyle) " $_tag
_entity_/b
}
}
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_listing
#
# diplay code listing
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_listing {} {
_entity_pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/listing
#
# end code listing
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/listing {} {
_entity_/pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_menu
#
# diplay menu list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_menu {{args {}}} {
_entity_ul plain $args
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/menu
#
# end menu list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/menu {} {
_entity_/ul
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_ol
#
# begin ordered list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_ol {{args {}}} {
if $_left {
_entity_br
} else {
_entity_p
}
_push left $_left
_push left2 $_left2
if {$_left2 == $_left } {
incr _left2 [expr $_indentincr+3]
} else {
incr _left2 $_indentincr
}
incr _left $_indentincr
_push listyle $_listyle
set _listyle 0
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/ol
#
# end ordered list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/ol {} {
set _left [_pop left]
set _left2 [_pop left2]
set _listyle [_pop listyle]
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_p
#
# paragraph break
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_p {{args {}}} {
_parse_fields ar $args
if [info exists ar(align)] {
switch [string tolower $ar(align)] {
center {
set _justify C
}
left {
set _justify L
}
right {
set _justify R
}
default {}
}
}
_set_tag
if [info exists ar(id)] {
set _anchor($ar(id)) [$itk_component(text) index end]
}
set x [$itk_component(text) get end-3c]
set y [$itk_component(text) get end-2c]
if {$x == "" && $y == ""} return
if {$y == ""} {
$itk_component(text) insert end "\n\n"
return
}
if {$x == "\n" && $y == "\n"} return
if {$y == "\n"} {
$itk_component(text) insert end "\n"
return
}
$itk_component(text) insert end "\n\n"
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_pre
#
# display preformatted text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_pre {{args {}}} {
_entity_tt
_entity_br
incr _pre
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/pre
#
# change state back from preformatted text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/pre {} {
_entity_/tt
set _pre 0
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_samp
#
# display sample text.
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_samp {} {
_entity_kbd
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/samp
#
# switch back to non-sample text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/samp {} {
_entity_/kbd
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_small
#
# Change current font to a smaller size
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_small {} {
_push pointsndx $_pointsndx
if {[incr _pointsndx -2] < 0} {
set _pointsndx 0
}
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/small
#
# change current font back from smaller size
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/small {} {
set _pointsndx [_pop pointsndx]
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_sub
#
# display subscript
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_sub {} {
_push offset $_offset
incr _offset -2
_entity_small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/sub
#
# switch back to non-subscript
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/sub {} {
set _offset [_pop offset]
_entity_/small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_sup
#
# display superscript
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_sup {} {
_push offset $_offset
incr _offset 4
_entity_small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/sup
#
# switch back to non-superscript
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/sup {} {
set _offset [_pop offset]
_entity_/small
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_strong
#
# display strong text. (i.e. make font bold)
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_strong {} {
incr _textweight
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/strong
#
# switch back to non-strong text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/strong {} {
incr _textweight -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_title
#
# begin title of document
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_title {} {
set _intitle 1
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/title
#
# end title
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/title {} {
set _intitle 0
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_tt
#
# Show typewriter text, using the font given by -fixedfont
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_tt {} {
_push font $_font
set _font $itk_option(-fixedfont)
set _verbatim 1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/tt
#
# Change back to non-typewriter mode to display text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/tt {} {
set _font [_pop font]
set _verbatim 0
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_u
#
# display underlined text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_u {} {
incr _underline
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/u
#
# change back from underlined text
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/u {} {
incr _underline -1
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_ul
#
# begin unordered list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_ul {{args {}}} {
_parse_fields ar $args
if $_left {
_entity_br
} else {
_entity_p
}
if [info exists ar(id)] {
set _anchor($ar(id)) [$itk_component(text) index end]
}
_push left $_left
_push left2 $_left2
if {$_left2 == $_left } {
incr _left2 [expr $_indentincr+3]
} else {
incr _left2 $_indentincr
}
incr _left $_indentincr
_push listyle $_listyle
if [info exists ar(plain)] {
set _listyle none
} {
set _listyle bullet
}
if [info exists ar(dingbat)] {
set ar(src) $ar(dingbat)
}
_push lipic $_lipic
if [info exists ar(src)] {
set _listyle picture
set _lipic $ar(src)
}
_set_tag
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/ul
#
# end unordered list
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/ul {} {
set _left [_pop left]
set _left2 [_pop left2]
set _listyle [_pop listyle]
set _lipic [_pop lipic]
_set_tag
_entity_p
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_var
#
# Display variable
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_var {} {
_entity_i
}
# ------------------------------------------------------------------
# PRIVATE METHOD: _entity_/var
#
# change state back from variable display
# ------------------------------------------------------------------
body iwidgets::Scrolledhtml::_entity_/var {} {
_entity_/i
}