1 # -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
3 # $Id: Myhtml1.tcl,v 1.6 2002-09-14 17:25:34 mikeclarkson Exp $
5 ###### Myhtml1.tcl ######
6 ############################################################
7 # Netmath Copyright (C) 1998 William F. Schelter #
8 # For distribution under GNU public License. See COPYING. #
9 ############################################################
11 defTag
eval -alter {family fixed Cnowrap nowrap adjust
0} \
13 set paramList
[xHMsplitParams
$params]
14 if { [xHMextract_param
$paramList program
""] } {
15 set wvar
(evalPushed
) "Teval"
16 xHMpushConstantTag
$win Teval
17 foreach { k val
} $paramList {
18 if { "$k" == "doinsert" } {
20 if { "$doinsert" != "[defaultInsertMode $program]" } {
21 lappend wvar
(evalPushed
) [list Targs
-doinsert $doinsert]
22 xHMpushConstantTag
$win [list Targs
-doinsert $doinsert]
26 xHMpushConstantTag
$win $tem
27 lappend wvar
(evalPushed
) $tem
32 catch {foreach v
$wvar(evalPushed
) { xHMpopConstantTag
$win $v } }
36 defTag result
-alter {family fixed weight bold adjust
0} -body {
37 set paramList
[xHMsplitParams
$params]
38 set wvar
(resultPushed
) Tresult
39 set taglist
(Tresult
) 1
40 if { [xHMextract_param
$paramList modified
""] } {
41 lappend wvar
(resultPushed
) Tmodified
42 set taglist
(Tmodified
) 1
44 if { [xHMextract_param
$paramList name
""] } {
45 lappend wvar
(resultPushed
) result
:$name
46 set taglist
(result
:$name) 1
49 catch {foreach v
$wvar(resultPushed
) { xHMpopConstantTag
$win $v } }
52 defTag netmath
-body {
53 set paramList
[xHMsplitParams
$params]
55 if { [xHMextract_param
$paramList version
""] } {
57 if { [clock scan $version] > [clock scan $maxima_priv(date
)] } {
59 xHMextract_param
$paramList oldversion
""
60 append oldversion
$text
64 # swallow the following text if the browser is netmath enabled...
65 if { [xHMextract_param
$paramList swallow
] } {
73 set paramList
[xHMsplitParams
$params]
74 upvar #0 xHMtaglist$win taglist
75 global xHMpriv maxima_default
77 if { [xHMextract_param
$paramList display
] } {
78 set pre
{$\displaystyle
}
82 set wc
$win.c
[incr xHMpriv
(counter
)]
83 canvas $wc -background [$win cget
-background] -highlightthickness 0 -borderwidth 0
85 set si
[expr {[lindex $wvar(size
) end
] + [lindex $wvar(adjust
) end
]}]
86 if { [xHMextract_param
$paramList size
] } {
87 catch { incr si
$size }
89 set si
[expr {($si < 1 ?
1 : ($si > 7 ?
7 : $si))}]
91 set ptsize
$maxima_default([lindex $wvar(family
) end
],$si)
92 if { [regexp & $text] } {
93 set text [xHMconvert_ampersand
$text]
95 if { [catch { set it
[ $wc create stext
0 0 \
96 -anchor nw
-stext "$pre $text \$" -pointsize $ptsize \
98 xHMpushConstantTag
$win "center"
99 xHMtextInsert
$win $text
100 xHMpopConstantTag
$win "center"
105 set dims
[$wc bbox
$it]
106 $wc config
-width [lindex $dims 2] -height [lindex $dims 3]
107 xHMpushConstantTag
$win "center"
108 xHMtextInsert
$win " "
109 $win window create
$wvar(W_insert
) -window $wc -padx 1 -pady 1
110 xHMpopConstantTag
$win "center"
114 proc getDim
{ dim max
} {
115 if { [regexp {([0-9.
]+)%$} $dim junk amt
] } {
116 return [expr {round
($amt * .01 * $max) }]
117 } elseif
{ $dim < 0 } {
125 set paramList
[xHMsplitParams
$params]
126 xHMextract_param
$paramList width
-1
127 # allow for things like 50%
128 set width
[getDim
[set width
] [expr {.95 * [winfo width
$win]}]]
129 xHMextract_param
$paramList height
-1
130 set height
[getDim
[set height
] [expr {.95 * [winfo height
$win]}]]
131 set ewin
[makeEmbedWin
$win $width $height]
132 $win window create
$wvar(W_insert
) -window $ewin -padx 1 -pady 1
133 set slave
[oget
$ewin slave
]
134 if { [ xHMextract_param
$paramList src
] } {
135 set data
[HMgetURL
$win $src text]
136 interp eval $slave $data
141 proc HMgetURL
{ textwin url type
} {
142 set currentUrl
[oget
$textwin currentUrl
]
143 catch { set currentUrl
[decodeURL
[oget
$textwin baseurl
]] }
144 set new
[resolveURL
$url $currentUrl ]
145 return [uplevel 1 getURL
[list $new] type
]
149 ## endsource "myhtml1.tcl"