BrowseX  Check-in [670e7a35d4]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:init
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:670e7a35d4aba107472ac7d72ab355163cee87dfeff15a7cff29305c9627162f
User & Date: pmacdona 2018-06-02 20:13:14
Context
2018-06-02
21:34
Del check-in: 681769af63 user: pmacdona tags: trunk
20:13
init check-in: 670e7a35d4 user: pmacdona tags: trunk
20:04
initial empty check-in check-in: 0acb88c176 user: pmacdona tags: trunk
Changes

Added API.html.

























































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<!-- Generated by TML 2.0   copyright 2000-2001 Peter MacDonald -->
<!-- Best viewed with BrowseX          http://BrowseX.com -->





<TABLE NAME="top" ><TR>
<TD width=123 ><DIV align=left ><IMG SRC=logo64.gif  width=43 height=64 ></IMG></DIV></TD>
<TD><CENTER><IMG SRC=browsexb.gif  alt="BrowseX" width=430 height=74 ></IMG></CENTER></TD>
<TD width=123 NAME="TOPROW" ><DIV align=right >
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=27901" width="88"
height="31"
border="0" alt="SourceForge Logo"></A>
</DIV></TD>

</TR></TABLE>
<BODY  BGCOLOR="#FFFFFF" LINK="#066e28" >
<TABLE bgcolor="#FFFFFF" border="0" width=600>
<TR valign=top bgcolor=#FFFFFF><TD>
<font size="2" >
<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>BrowseX</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html">Home</A></TD></TR>
<TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html#updates">News</A></TD></TR>
<TR><TD>&nbsp;<A HREF="Install.html">Download</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Features.html">Features</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Demos.html">Demos</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="API.html">API</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="SQLite.html">SQLite</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TML.html">TML</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="dballoc.html">Dballoc</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Javascript.html">Javascript</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mail.html">Mailer</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Address.html">Address</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mime.html">Mimetypes</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="portal.html">Portal</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="gdup.html">DynDNS</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="talk.html">Talk</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="ZipView.html">ZipView</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TDB.html">TDB</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Packaging.html">Packaging</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Passman.html">Passman</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Thin.html">Thin</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="Press.html">Press</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Doc.html">Docs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Bugs.html">Bugs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="FAQ.html">FAQ</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Sell.html">Pros</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Why.html">Why</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="copyright.html">License</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Contacts.html">Contacts</A><BR></TD></TR>
</table></td></tr></table>
<p>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Search</b></font></td></tr>
  <CENTER><TR><TD><FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
</TD></TR></CENTER></table></td></tr></table>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Links</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://dev.scriptics.com">Scriptics</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.postgresql.org">Postgres</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.openssl.org">OpenSSL</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://members1.chello.nl/~j.nijtmans/img.html">Img</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.baremetal.com">Baremetal</A><BR></TD></TR>
</table></td></tr></table>

<P>
<B>Contact</B></FONT><BR>
<A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
</font>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP" BGCOLOR="white">




<A NAME=sect1></A><H1>Application Extension: The API</H1>

<A NAME=sect2></A><H2>browsex.ini: The Init File</H2>

<FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; can now easily be extended, without changing <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp;
source code.  Just put your own Tcl in <i>browsex.ini</i> in the <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp;
home directory <i>(~/.brx/browsex.ini under unix)</i>.   As of version 1.6,
this file will get sourced automatically at browser startup.
New users will be given a default version of this file which looks
something like:

 <font color=steelblue><pre>
  # Tcl user extension script for BrowseX.
  # This is sourced at startup and lets you hook in your own Tcl.

  # Comment out the following "return" for an simple App that displays Urls.
  return

  toplevel [set m .myapp]
  wm geom $m 200x200
  pack [text $m.t]
  $m.t insert end "Here is my Url Displayer extension\n"
  
  # Event handler for "urlget"
  proc My_urlget {v url arg} {
    $::m.t insert end $url\n
    return 1
  }
  
  # Add an event handler to get control when a "urlget" event occurs.
  brx::ApiAddHandler 0 urlget My_urlget
  
  # See http://browsex.com/API.html for details of Api calls.

</pre></font>

Alternatively, you can specify a script file with the <b>-i</b> command line
argument.
The above simple example runs if you remove or comment out the <b>return</b> on 
line 5.  It pops up a window which displays each URL you visit.
Not spectacular, but it demonstrates
how easy it is to extend <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp;.  Used in conjunction with
<A HREF="SQLite.html">SQLite</A> also builtin to <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp;, it gives a fair
degree of power and flexibility.  
<P>
 <p><hr><p>

<A NAME=sect3></A><H2>API Details</H2>

Any procedure within <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; can be called directly.  Commonly used
ones include:

 <font color=steelblue><pre>
 set v [brx::ViewNew -1 0 {-url http://my.url.com/}]
 brx::UrlView $v http://my.url.com/ 

</pre></font>

<ul><li><i>ViewNew</i> opens a new browser window and returns the handle <b>v</b>.<BR></li>
<li><i>UrlView</i> displays the URL in the window identifed by the handle <b>v</b></li>
</ul>

The problem is, <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; can and does change.  Thus the API tries
to reduce this risk.
<P>
The main goal is to allow programs to get control at various
stages of the browsing process.
There are three areas to the API.  The first and simplest lets you
define <b>Event Handlers</b> that let you get control at various events 
in the browsing process.  The more extreme lets you <b>Morph the View</b>
to do pretty much whatever you like.  Lastly, you can even take control
at startup.
 <p><hr><p>
<A NAME=sect4></A><H2>Event Handlers</H2>

The following 3 functions allow getting/setting your own event handlers.
<i>(We're talking about BrowseX events here, not Tcl events.)</i> <P>

<BLOCKQUOTE><TABLE cellpadding=1 cellspacing=0><tr><td colspan=2 valign=top><B>ApiAddHandler {v event cmd}</B></td><td valign=top> Set an event handler and returns token</td></tr>
<tr><td colspan=2 valign=top><B>ApiDelHandler {v event token}</B></td><td valign=top> Delete an event handler</td></tr>
<tr><td colspan=2 valign=top><B>ApiUpdHandler {v event cmd var}</B></td><td valign=top> Add/del handler and puts token in var</td></tr>
</TABLE></BLOCKQUOTE>

Valid events are:  <b>authget parse unktype cancel arghandler urlget formsubmit</b>
<BR>
<P>
In practice you probably need only the last function, <i>ApiUpdHandler</i> 
using a <i>cmd</i> of {} to remove handlers. 
<P>
The <b>token</b> is just an integer denoting the place in the queue.
Multiple event handlers can be added, and they will be
executed in order of addition <i>(but watch it, deleting creates empty slots
that the next add will grab)</i>.
<P>
Lets say you've defined handlers for your Foo_ project.
The <b>cmd</b> called must take exactly these parameters.

<BLOCKQUOTE><TABLE cellpadding=1 cellspacing=0>
<tr><td colspan=2 valign=top><B>Foo_authget {v epass realm}</B></td><td valign=top> Authorization request</td></tr>
<tr><td colspan=2 valign=top><B>Foo_parse {v url arg}</B></td><td valign=top> A document parse</td></tr>
<tr><td colspan=2 valign=top><B>Foo_unktype {v ltyp data}</B></td><td valign=top> Unknown mime type</td></tr>
<tr><td colspan=2 valign=top><B>Foo_cancel {v msg}</B></td><td valign=top> A cancel was issued</td></tr>
<tr><td colspan=2 valign=top><B>Foo_arghandler {flag arg}</B></td><td valign=top> Parse command line argument</td></tr>
<tr><td colspan=2 valign=top><B>Foo_urlget {v url arg}</B></td><td valign=top> A urlget issue</td></tr>
<tr><td colspan=2 valign=top><B>Foo_formsubmit {v n a url qargs}</B></td><td valign=top> Form is about to submit</td></tr>
</TABLE></BLOCKQUOTE>

In the case of urlget and formsubmit a  <b>return 1</b> is required
for continuation.  Finally, be aware that the function will
be in the brx:: namespace.  If you are outside that
use ::foo::Foo_parse, etc.

 <p><hr><p>
<A NAME=sect5></A><H2>View Morphing</H2>
If you actually need complete control to
change or wrap <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; to customize the browser, use this interface.
Choose a unique suffix/prefix, say <b>Foo_</b>.  Then you would
call the view create function <b>ViewNew</b> thus:
<P>
<b>::brx::ViewNew -1 Foo_</b>
<P>
This creates a new view of type Foo_, plus
the following are
functions in the brx:: namespace that let you get control when:

<BLOCKQUOTE><TABLE cellpadding=1 cellspacing=0>
<tr><td colspan=2 valign=top><B>AppInitFoo_ {v ov a args}</B></td><td valign=top>view is to be created </td></tr>
<tr><td colspan=2 valign=top><B>AppMainFoo_ {v w}</B></td><td valign=top> Html widget is about to be created</td></tr>
<tr><td colspan=2 valign=top><B>AppDisplayItFoo_ v </B></td><td valign=top> End of view creation</td></tr>
<tr><td colspan=2 valign=top><B>MenuDoDefFoo_ {v m}</B></td><td valign=top> popup menu is appearing.</td></tr>
<tr><td colspan=2 valign=top><B>HrefFoo_{v x y f}</B></td><td valign=top> User has clicked in Html view.</td></tr>
</TABLE></BLOCKQUOTE>

Note the per-view v parameter to each. Here is a sample definition.

 <font color=steelblue><pre>
  proc ::brx::AppInitFoo_  {v ov a args} {
    variable pc
    upvar brx::pd$v pv
    return [AppInit0 $v $ov $a $args]
  }

</pre></font>

The <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; default type is <b>0</b>, so we just chained to it.
The <b>pc</b> variable contains the global program state.
The <b>upvar</b> statement that connects you the <b>pv</b> per-view variable.

<P>
If you would like to see a reference implementation, look
in mailer.tcl which demonstrates how the <b>Mailer</b>
takes complete control and encapsulates Browser views.

 <p><hr><p>
<A NAME=sect6></A><H2>Startup Control and Command Line Arguments</H2>
You can get control at startup by adding the following file to 
the brx.zip as the file name: <b>/custapp.tcl</b>

 <font color=steelblue><pre>
# custapp.tcl
namespace eval ::brx {
  set pc(deftype) Foo_
  set pc(hook:arghandler) brx::foo_arghandler
}
if [catch {source $argv0} src] {
  tobe_bgerror $src
}

</pre></font>

The pc(deftype) assignment instructs <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; to look for the file 
<b>appmain.tcl</b> in the directory <b>Foo_</b>
and source it at startup.   Arghandler lets you get control
of the command line arguments that are not already in use.

 <font color=steelblue><pre>
proc ::brx::foo_arghandler {flag arg} {
  switch -- $flag {
    -fooroot {
       set pc(foo_:root) $arg
       return 2
    }
  }
  return 0;
}

</pre></font>

By specifing Foo_ above, you instructed BrowseX to look for the following

 <p><hr><p>
<A NAME=sect7></A><H2>Table of Contents</H2>
<UL>
<LI><A HREF=#sect2>browsex.ini: The Init File</A>
<LI><A HREF=#sect3>API Details</A>
<LI><A HREF=#sect4>Event Handlers</A>
<LI><A HREF=#sect5>View Morphing</A>
<LI><A HREF=#sect6>Startup Control and Command Line Arguments</A>
<LI><A HREF=#sect7>Table of Contents</A></UL></OL>

</TD></TR></TABLE> <CENTER ALIGN=right><P><IMG SRC=browsex.gif>  <I>Copyright &copy; 1999-2001 &nbsp; <a href="mailto:peter@browsex.com">Browsex Systems Inc</a> &nbsp;  <a href="http://BrowseX.com">http://BrowseX.com</a></I></CENTER><P>&nbsp;<P>
<HR >

Added Address.html.











































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
<!-- Generated by TML 2.0   copyright 2000-2001 Peter MacDonald -->
<!-- Best viewed with BrowseX          http://BrowseX.com -->





<TABLE NAME="top" ><TR>
<TD width=123 ><DIV align=left ><IMG SRC=logo64.gif  width=43 height=64 ></IMG></DIV></TD>
<TD><CENTER><IMG SRC=browsexb.gif  alt="BrowseX" width=430 height=74 ></IMG></CENTER></TD>
<TD width=123 NAME="TOPROW" ><DIV align=right >
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=27901" width="88"
height="31"
border="0" alt="SourceForge Logo"></A>
</DIV></TD>

</TR></TABLE>
<BODY  BGCOLOR="#FFFFFF" LINK="#066e28" >
<TABLE bgcolor="#FFFFFF" border="0" width=600>
<TR valign=top bgcolor=#FFFFFF><TD>
<font size="2" >
<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>BrowseX</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html">Home</A></TD></TR>
<TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html#updates">News</A></TD></TR>
<TR><TD>&nbsp;<A HREF="Install.html">Download</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Features.html">Features</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Demos.html">Demos</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="API.html">API</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="SQLite.html">SQLite</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TML.html">TML</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="dballoc.html">Dballoc</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Javascript.html">Javascript</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mail.html">Mailer</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Address.html">Address</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mime.html">Mimetypes</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="portal.html">Portal</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="gdup.html">DynDNS</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="talk.html">Talk</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="ZipView.html">ZipView</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TDB.html">TDB</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Packaging.html">Packaging</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Passman.html">Passman</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Thin.html">Thin</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="Press.html">Press</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Doc.html">Docs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Bugs.html">Bugs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="FAQ.html">FAQ</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Sell.html">Pros</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Why.html">Why</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="copyright.html">License</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Contacts.html">Contacts</A><BR></TD></TR>
</table></td></tr></table>
<p>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Search</b></font></td></tr>
  <CENTER><TR><TD><FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
</TD></TR></CENTER></table></td></tr></table>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Links</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://dev.scriptics.com">Scriptics</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.postgresql.org">Postgres</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.openssl.org">OpenSSL</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://members1.chello.nl/~j.nijtmans/img.html">Img</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.baremetal.com">Baremetal</A><BR></TD></TR>
</table></td></tr></table>

<P>
<B>Contact</B></FONT><BR>
<A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
</font>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP" BGCOLOR="white">



<TITLE>BrowseX Address Book</TITLE>
<A NAME=sect1></A><H1>BrowseX Address Book</H1>
The <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; <B>Address Book</B> applet maintains lists of email
addresses and is integrated for use with the mail
composer.  It has two modes: Edit and Lookup.
Lookup mode is used mostly from the mail composer window
to lookup mail addresses to send to.  Edit mode is available
when you start <b>Address Book</b> from the <b>Apps</b> menu.
<P>
In Edit mode you can add, change or delete entries.
No changes take effect until you click <b>Done</b> to commit.
New entries can be added just by clicking <b>New</b> and
typing a new <b>Name</b> in the popup dialog. 
Then update the other fields and click <b>Done</b>.
<P>
<b>Address Book</b> is very simple an currently contains
only the following fields:
<BLOCKQUOTE><TABLE cellpadding=1 cellspacing=0><tr><td colspan=2 valign=top><B>Name</B></td><td valign=top> The name of the person (this is the key field)</td></tr>
<tr><td colspan=2 valign=top><B>Email</B></td><td valign=top> One or more email addresses.  Can contain aliases</td></tr>
<tr><td colspan=2 valign=top><B>Alias</B></td><td valign=top> An alias that can be used in mail composer</td></tr>
<tr><td colspan=2 valign=top><B>Phone</B></td><td valign=top> Telephone number</td></tr>
<tr><td colspan=2 valign=top><B>FAX</B></td><td valign=top> Fax number</td></tr>
<tr><td colspan=2 valign=top><B>URL</B></td><td valign=top> Url for the user</td></tr>
<tr><td colspan=2 valign=top><B>Title</B></td><td valign=top> A persons title</td></tr>
<tr><td colspan=2 valign=top><B>Org</B></td><td valign=top> Company</td></tr>
<tr><td colspan=2 valign=top><B>Comment</B></td><td valign=top> Miscellaneous</td></tr>
</TABLE></BLOCKQUOTE>

Of the above, only the first three fields are currently used
in <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp;.  Future extensions may make use of the others.

</TD></TR></TABLE> <CENTER ALIGN=right><P><IMG SRC=browsex.gif>  <I>Copyright &copy; 1999-2001 &nbsp; <a href="mailto:peter@browsex.com">Browsex Systems Inc</a> &nbsp;  <a href="http://BrowseX.com">http://BrowseX.com</a></I></CENTER><P>&nbsp;<P>
<HR >




Added Bugs.html.

























































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!-- Generated by TML 2.0   copyright 2000-2001 Peter MacDonald -->
<!-- Best viewed with BrowseX          http://BrowseX.com -->





<TABLE NAME="top" ><TR>
<TD width=123 ><DIV align=left ><IMG SRC=logo64.gif  width=43 height=64 ></IMG></DIV></TD>
<TD><CENTER><IMG SRC=browsexb.gif  alt="BrowseX" width=430 height=74 ></IMG></CENTER></TD>
<TD width=123 NAME="TOPROW" ><DIV align=right >
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=27901" width="88"
height="31"
border="0" alt="SourceForge Logo"></A>
</DIV></TD>

</TR></TABLE>
<BODY  BGCOLOR="#FFFFFF" LINK="#066e28" >
<TABLE bgcolor="#FFFFFF" border="0" width=600>
<TR valign=top bgcolor=#FFFFFF><TD>
<font size="2" >
<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>BrowseX</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html">Home</A></TD></TR>
<TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html#updates">News</A></TD></TR>
<TR><TD>&nbsp;<A HREF="Install.html">Download</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Features.html">Features</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Demos.html">Demos</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="API.html">API</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="SQLite.html">SQLite</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TML.html">TML</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="dballoc.html">Dballoc</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Javascript.html">Javascript</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mail.html">Mailer</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Address.html">Address</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mime.html">Mimetypes</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="portal.html">Portal</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="gdup.html">DynDNS</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="talk.html">Talk</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="ZipView.html">ZipView</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TDB.html">TDB</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Packaging.html">Packaging</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Passman.html">Passman</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Thin.html">Thin</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="Press.html">Press</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Doc.html">Docs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Bugs.html">Bugs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="FAQ.html">FAQ</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Sell.html">Pros</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Why.html">Why</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="copyright.html">License</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Contacts.html">Contacts</A><BR></TD></TR>
</table></td></tr></table>
<p>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Search</b></font></td></tr>
  <CENTER><TR><TD><FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
</TD></TR></CENTER></table></td></tr></table>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Links</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://dev.scriptics.com">Scriptics</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.postgresql.org">Postgres</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.openssl.org">OpenSSL</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://members1.chello.nl/~j.nijtmans/img.html">Img</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.baremetal.com">Baremetal</A><BR></TD></TR>
</table></td></tr></table>

<P>
<B>Contact</B></FONT><BR>
<A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
</font>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP" BGCOLOR="white">




<TITLE>Status/Bug Reports</TITLE>

<A NAME=sect1></A><H1><CENTER><B>BrowseX</B>&nbsp; Status/Bug Reports</CENTER></H1>
<P><HR ><P>

<A NAME=sect2></A><H2><CENTER>BUGS THAT ARE ACTUALLY FEATURES</CENTER></H2>
<UL><LI>new window gets click history of parent</LI> </UL>

<A NAME=sect3></A><H2><CENTER>FEATURES IN-PROGRESS</CENTER></H2>
<UL><LI>implement pg_connect filtering by domain</LI>
<LI>printing to postscript: needs margin space</LI>
<LI>bookmark editor</LI>
<LI>search-shortcut editor: save last 10, launch on site-select</LI>
<LI>SSL certificate mgmt/not-valid-signed cert reporting</LI>
<LI>mail check every N minutes</LI>
<LI>mail handling of large messages is slow.</LI>
<LI>mail features/content type handling</LI>
<LI>application helpers: xdvi, uudecode viewer etc.</LI>
<LI>ftp: download with redirect may be broken</LI>
</UL>

<A NAME=sect4></A><H2><CENTER>MAJOR IMPORTANCE</CENTER></H2>
<UL><LI>focus after close view</LI>
<LI>cleanup "redirect" code</LI>
<LI>complete cookies to RFC spec: private cache, etc</LI>
<LI>back not properly preserve form values for redirects</LI>
<LI>frames could be faster and sometimes gets confused</LI>
<LI>frames resizing and interactive resizing of individual frames</LI>
<LI>bind in form validation demo script not cleaned up</LI>
<LI>cache size limit is not yet enforced</LI>
<LI>Changing def lang encoding</LI>
<LI>If a dialog is open, and you exit, it can dump core</LI>
</UL>

<A NAME=sect5></A><H2><CENTER>LESSER IMPORTANCE</CENTER></H2>
<UL><LI>Option to animate gifs only in the active window</LI>
<LI>cookies need cleanup of old/expired</LI>
<LI>Bug in initial table layout, is correct on refresh (salon) </LI>
<LI>Down arrow in text windows goes to bottom (left over from insert)</LI>
<LI>Esc should close search, dialogs, etc</LI>
<LI>frame sizings may sometimes be off a bit?</LI>
<LI>back/forward sometimes gets confused.</LI>
<LI>highlighting in find is intermitantly off by one and/or horizontal.</LI>
<LI>Compensate when text color is same as background.</LI>
<LI>Gray out pref menu items not in force.</LI>
<LI>On resize the bgimage does not expand to fill screen??</LI>
<LI>file upload unimplemented: rfc1867.txt</LI>
<LI>Visited links are not always updated (ie. for file?)</LI>
<LI>font sizes could be better chosen</LI>
<LI>HTTP 1.1 socket no-close (is this is really even desirable?)</LI>
<LI>reset to default options affects email id, etc</LI>
<LI>truetype fonts</LI>
<LI>resizable/dragable in frame pages</LI>
<LI>resizing a frames page should re-layout</LI>
<LI>invalidated main page should invalidate all cached sub-gifs?</LI>
<LI>add max cookie size dialog (also delete/view cookies/delete auth?)</LI>
<LI>cookie "size=0" </LI>
<LI>implement a -nocache option?</LI>
<LI>max embed toplevels/slave setting</LI>
<LI>secure web should not cache html to disk??</LI>
<LI>corrupted gifs may hang in the image code (rare?).</LI>
<LI>Allow multiple mailer windows, but lock/reserve active folder.</LI>
<LI>Popup menu over/near/in form not working?</LI>
</UL>

<A NAME=sect6></A><H2><CENTER>NICE-TO-HAVE FEATURES</CENTER></H2>
<UL><LI>Grok .tcl files</LI>
<LI>menu option to save BG image</LI>
<LI>word docs should use catdoc to strip to text</LI>
<LI>mail should support the tnef decoder</LI>
</UL>

</TD></TR></TABLE> <CENTER ALIGN=right><P><IMG SRC=browsex.gif>  <I>Copyright &copy; 1999-2001 &nbsp; <a href="mailto:peter@browsex.com">Browsex Systems Inc</a> &nbsp;  <a href="http://BrowseX.com">http://BrowseX.com</a></I></CENTER><P>&nbsp;<P>


Added CTML.html.













>
>
>
>
>
>
1
2
3
4
5
6
[H1 C-TML Copyright]
[TITLE C-TML Copyright]

C-TML is copyright [B BrowseX Systems Inc].  All rights reserved.


Added ChangeLog.html.

















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
<!-- Generated by TML 2.0   copyright 2000-2001 Peter MacDonald -->
<!-- Best viewed with BrowseX          http://BrowseX.com -->





<TABLE NAME="top" ><TR>
<TD width=123 ><DIV align=left ><IMG SRC=logo64.gif  width=43 height=64 ></IMG></DIV></TD>
<TD><CENTER><IMG SRC=browsexb.gif  alt="BrowseX" width=430 height=74 ></IMG></CENTER></TD>
<TD width=123 NAME="TOPROW" ><DIV align=right >
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=27901" width="88"
height="31"
border="0" alt="SourceForge Logo"></A>
</DIV></TD>

</TR></TABLE>
<BODY  BGCOLOR="#FFFFFF" LINK="#066e28" >
<TABLE bgcolor="#FFFFFF" border="0" width=600>
<TR valign=top bgcolor=#FFFFFF><TD>
<font size="2" >
<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>BrowseX</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html">Home</A></TD></TR>
<TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html#updates">News</A></TD></TR>
<TR><TD>&nbsp;<A HREF="Install.html">Download</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Features.html">Features</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Demos.html">Demos</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="API.html">API</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="SQLite.html">SQLite</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TML.html">TML</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="dballoc.html">Dballoc</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Javascript.html">Javascript</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mail.html">Mailer</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Address.html">Address</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mime.html">Mimetypes</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="portal.html">Portal</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="gdup.html">DynDNS</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="talk.html">Talk</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="ZipView.html">ZipView</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TDB.html">TDB</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Packaging.html">Packaging</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Passman.html">Passman</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Thin.html">Thin</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="Press.html">Press</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Doc.html">Docs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Bugs.html">Bugs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="FAQ.html">FAQ</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Sell.html">Pros</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Why.html">Why</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="copyright.html">License</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Contacts.html">Contacts</A><BR></TD></TR>
</table></td></tr></table>
<p>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Search</b></font></td></tr>
  <CENTER><TR><TD><FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
</TD></TR></CENTER></table></td></tr></table>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Links</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://dev.scriptics.com">Scriptics</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.postgresql.org">Postgres</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.openssl.org">OpenSSL</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://members1.chello.nl/~j.nijtmans/img.html">Img</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.baremetal.com">Baremetal</A><BR></TD></TR>
</table></td></tr></table>

<P>
<B>Contact</B></FONT><BR>
<A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
</font>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP" BGCOLOR="white">



<TITLE>BrowseX Home Page</TITLE>


<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="580"><tr><td><table width="580" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>ChangeLog</b></font></td></tr>
  <TR><TD><BR>&nbsp;<BR> <BLOCKQUOTE>
<A NAME=sect1></A><H2>TODO</H2>
<UL><li>fix cancel</li>
<li>enforce cache size limit and implement cache cleanup: LRU</li>
<li>table layout bug: http://www.wissenschaft.de/</li>
<li>fix caching of error conditions</li>
<li>black on black bgimage (a bad-gif bug??): http://www.gattrix.de/ </li>
<li>bgcolor on form els shouldn't inherit bgcolor unless in table???</li>
<li>in Thtml fix HtmlResolveUri() to stop chopping at space char</li>
<li>fix busy with frames</li>
<li>implement Regexp class in JS</li>
<li>scaled animations??</li>
<li>change multi-q to max at 2-3 then roundrobin add</li>
<li>fix nslookup to handle multiple addresses</li>
<li>fix onchange</li>
<li>implement edit html to update page</li>
<li>implement multi dns addr lookup in dns cache</li>
<li>reload of local TML file not working</li>
<li>last word in file with no trailing space not parsed (and first?)</li>
<li>go-back goes back two links</li>
<li>grabbed selection won't release to other apps</li>
<li>printing of Text sources (like email) should offer print text only</li>
<li>redirects not going to cache (bug?)</li>
<li>fix hang of some emails</li>
</UL>

<A NAME=sect2></A><H2>Release 2.0.0: Mar 6, 2002</H2>
<UL><li>add notebook tab support to browsex</li>
<li>major update for tml: support for remote apps</li>
<li>add tktable option to tkhtml to intercept html TABLEs</li>
<li>fix background image bug for transparent gifs not clearing screen.</li>
<li>fix listbox (select multiple) to take focus</li>
<li>html/text pages now all go in cache/0</li>
<li>added a search cache option to BRX menu</li>
<li>location pulldown is now sorted by most recent first, with dups removed</li>
<li>limit location pulldown to 150 most recent on startup</li>
<li>dynamic config can now save/restore: unfinished</li>
<li>simple mail filters started</li>
<li>fixed tml AE links in file:</li>
<li>recursive CacheDeref check</li>
<li>fix add to address book from mail reader</li>
<li>fix to/from address formatting in mail reader</li>
<li>fix web portal server bugs</li>
<li>add cgi and gif support to portal</li>
<li>change -urlget to always check net</li>
<li>show url in title and view lists if title=={}</li>
</UL>

<A NAME=sect3></A><H2>Release 1.6.0: Aug 26, 2001</H2>
<UL><li>support extensions: add browsex.ini init script and -i arg</li>
<li>windows version now includes sqlite</li>
<li>updated to sqlite version 2.0.1</li>
<li>swap font fixed/variable in preferences</li>
<li>fixed GDUP (dynamic DNS) password bug</li>
<li>add bell when new mail comes in</li>
<li>fix meta encoding bug (windows only?)</li>
<li>fix bad dns addr prompts once for each gif</li>
<li>fix base address missing slash bug</li>
<li>failed chmod resolver.sh now disables external</li>
</UL>

<A NAME=sect4></A><H2>Release 1.5.0: June 16, 2001</H2>
<UL><li>fix form encoding of UTF8 chars</li>
<li>set textarea default bg to white and add scrollbars</li>
<li>fix checkbox form bug</li>
<li>TML: major update (2.0): prepend % to names plus cleanup code</li>
<li>TML: add loop control constructs and implement inline refs</li>
<li>fix long-line > 2000 chars hang/runaway memory alloc</li>
<li>ignore 404 return code if data was returned</li>
<li>hide image balloon at either click or Leave events</li>
<li>elminate show page top  when Tkhtml parses #label url (added -ypos to parse)</li>
</UL>

<A NAME=sect5></A><H2>Release 1.4.4: May 25, 2001</H2>
<UL><li>implement background= image support for table cells</li>
<li>implement Cut&Paste of html</li>
<li>implement building option menus from JS</li>
<li>implement <b>button</b> form item: JS attached actions</li>
<li>fix memory overwrite bug that caused JS crash</li>
<li>display broken image for missing gifs</li>
<li>fix image alt balloon display, broken by brx::toplevel</li>
<li>add clear screen to external programs with leading pipe</li>
<li>fix form reset</li>
<li>fix dir browser option</li>
<li>change cache init to not be after 1000</li>
<li>Tkhtml now translates % width/height for images sizes</li>
<li>Changed default browser string to be Mozilla prefix (server blowup)</li>
<li>rolled back form select option value="" fix in 1.4.3.  Was correct.</li>
<li>add a cancel to UrlView</li>
<li>fix pipeline queue depth check</li>
<li>change http bad-servers to set q-depth to 1, instead of sep. sockets</li>
<li>encode form image button with name.x in submit</li>
<li>do update select multiple and add scrollbar to if > 10 items</li>
<li>change SELECT OPTION to copy text if value= missing</li>
<li>failed connection now deletes dns addr from dns cache</li>
<li>fix JS FormSubmit from looping</li>
<li>fix bug in tkhtml "token attr" when previously were zero attrs</li>
</UL>

<A NAME=sect6></A><H2>Release 1.4.3: May 2, 2001</H2>
<UL><li>Change form items to seperate creation from color setting</li>
<li>add a 1ms delay in pipeline between requests</li>
<li>round delay parameter to int in meta redirect</li>
<li>fix form post bug with select: was substituting Text when value=""</li>
<li>fix some form items not appearing (js related)</li>
<li>fixed scaled transparent gifs from losing transparency: BLT fix</li>
<li>make large cached gifs (>2000p) scheduled and add "update" to render text</li>
<li>change cursor to hand when over submit buttons</li>
<li>implement run command on image file in cache</li>
<li>fix go to invalid page breaks relative links on current page</li>
<li>change form items to be active: uses overrelief or bind</li>
</UL>

<A NAME=sect7></A><H2>Release 1.4.2: Apr 30, 2001</H2>
<UL><li>fixed http pipeline hanging on gifs upon reconnect</li>
<li>major cleanup of the image handling code in image.tcl</li>
<li>compile blt and vu into binary to get image scaling and tiling</li>
<li>implement scalable images (except for animations)</li>
<li>fix <b>to</b> address in mailer message body display</li>
<li>make image cache work with scaled images of diff sizes</li>
<li>add gamma correction image option</li>
<li>fix image popup</li>
<li>resize browser window now does a relayout for frames</li>
<li>fix refresh in framed pages</li>
<li>have JS window size not replace browser window size (add -subtype)</li>
<li>misc javascript fixes</li>
<li>suspend PRE tag when see start of TABLE</li>
<li>defer set location until after UrlGet</li>
<li>change prefs reset to restore prior to session</li>
<li>fix checkbox form elements all being checked on load</li>
<li>implement onload=javascript:...</li>
</UL>

<A NAME=sect8></A><H2>Release 1.4.1: Apr 26, 2001</H2>
<UL><li>clear selection after setting breakpoint: distraction</li>
<li>fix tdb cmdline running</li>
<li>enhance widconf to include pack/place config, + fix combobox sel bug</li>
<li>add WebLogic to list of bad pipeline servers</li>
<li>add http:badservers option to let users blacklist other servers</li>
<li>add mail option to mail force server to be 8bit</li>
<li>fixed PRE formatting inside TD so it doesn't become 1 long line</li>
<li>added DDE and Registry into the link for Windows</li>
</UL>

<A NAME=sect9></A><H2>Release 1.4.0: Apr 24, 2001</H2>
<UL><li>fixed bug with javascript embedded inside a forms defn</li>
<li>fixed Popup Image hang</li>
<li>truncate colors at 12 digits</li>
<li>rollback part of double-parse fix: broke go-back to redirect pages</li>
<li>change browsex button to use UrlView to clear frames</li>
<li>fix embedded tcl applets</li>
<li>extend compiled tcl support to include embeded tcl applet</li>
<li>set bgcolor now applies to all app bgcolors: tk_setPallete</li>
<li>fixed redirects causing frames-clear to fail</li>
<li>implement universal widget option settable via Shift-Control-B1</li>
<li>fix location url entry and go-back with frames</li>
<li>reduce http pipeline to 6 from 7 to eliminate gif stalls</li>
<li>fix bug with Http::Disband popping up an error</li>
<li>fix page status bug and always show DL time</li>
<li>fix gif viewer</li>
<li>always redirect stdout/stderr to debug log</li>
<li>add an option to disable error tracebacks</li>
<li>add an option to set trace level in mailer</li>
</UL>

<A NAME=sect10></A><H2>Release 1.3.8: Apr 21, 2001</H2>
<UL><li>fix serious pipeline bug that caused some gifs never to show up</li>
<li>implement incremental updating of screen every .5 secs as gifs come in</li>
<li>fix bugs with history/cache window</li>
</UL>

<A NAME=sect11></A><H2>Release 1.3.7: Apr 20, 2001</H2>
<UL><li>in mailto: add support for ?subject=&cc=&bcc=</li>
<li>update status line for progress in mail body search</li>
<li>change and also parameterize some mailer colors</li>
<li>make focus go to location open new view</li>
<li>fix goto #label (again)</li>
<li>stop slide with #label from going to network</li>
<li>improve location bar updating</li>
<li>broaden keybindings to work also in entry forms and location bar</li>
<li>fixed another frames getsize bug</li>
<li>map out backslash in urls</li>
<li>set cursor-busy when sending/receiving mail</li>
<li>fixed form select-multiple</li>
<li>add mailto ?subject support for inside mailer window to</li>
<li>fix frames size calculation</li>
<li>fix encoding to include /</li>
<li>exclude unnamed fields from form submits</li>
<li>fixed JS form problem by adding update before script eval in parse</li>
<li>fixed font lists so variable only shows variable fonts, etc</li>
<li>support colors given as integers</li>
<li>run through procheck and fixed some bugs</li>
<li>add support for sourcing compiled Tcl using Tclpro procomp</li>
</UL>

<A NAME=sect12></A><H2>Release 1.3.6: Apr 12, 2001</H2>
<UL><li>form layout cleanup: spacing, fonts and colors should now be much better</li>
<li>fix overall color/font, esp. fontoverride and coloroverride</li>
<li>fix cursor stuck busy (cause was redirects)</li>
<li>eliminate redundent radio elements in form submit</li>
<li>sort cookies in outgoing headers</li>
<li>boost browser colors (for non-image) from 16 to 64</li>
<li>fix duplicate form item: double parse caused by broken redirects</li>
<li>implemented download image on click when download is off</li>
<li>stop mail SaveAs from popping up new view</li>
<li>file:/ now supports globbing like *.html in directory lists</li>
</UL>

<A NAME=sect13></A><H2>Release 1.3.5: Apr 9, 2001</H2>
<UL><li>fixed huge memory leak for background gifs: images not released</li>
<li>fixed URL redirect loop problem ala www.faz.net</li>
<li>fix nowrap TD option not taking width (eg. hotmail.com)</li>
<li>fix bgcolor="" causing black on black text problem (eg. sourceforge</li>
<li>fix table layout bug in http://www.spiegel.de/ (cause: HR SIZE=-1)</li>
<li>fix embedded tcl (frink broke it)</li>
<li>fix table width= causing too narrow columns</li>
<li>add paste URL support to browser body window</li>
<li>pipeline default enabled again, but not for Netscape servers</li>
<li>fix alt-o open when used from frames</li>
<li>redirects that are in cache don't go out to network</li>
<li>add more header info to Page-Info.</li>
<li>TDB: fixed paste in cmd window</li>
<li>TDB: change to use an command entry box</li>
</UL>

<A NAME=sect14></A><H2>Release 1.3.4: Apr 3, 2001</H2>
<UL><li>release TDB debugger</li>
<li>fixed console in TOBE (stdout still hooped on exec)</li>
<li>ran code through frink to format and bracket all <b>if</b>s</li>
<li>fixed bug in frames with pv(locvar) undefined</li>
</UL>

<A NAME=sect15></A><H2>Release 1.3.3: Mar 1, 2001</H2>
<UL><li>disable pipeline http by default: some web servers barf</li>
<li>javascript support for forms is now mostly done</li>
</UL>

<A NAME=sect16></A><H2>Release 1.3.2: Mar , 2001</H2>
<UL><li>release code to pipeline http requests</li>
<li>more javascript support</li>
<li>added German and French language bindings</li>
</UL>

<A NAME=sect17></A><H2>Release 1.3.1: Mar , 2001</H2>
<UL><li>change all http fetches to now go directly to disk/cache</li>
<li>user defined mimetypes support is now done</li>
<li>redid history to use tktable (just mail left now with mclistbox)</li>
<li>rewrote forms to be zero not one based</li>
<li>run through dmalloc to eliminate leaks</li>
</UL>

<A NAME=sect18></A><H2>Release 1.3.0: Feb , 2001</H2>
<UL><li>initial release with new javascript</li>
</UL>

<A NAME=sect19></A><H2>Release 1.2.4: Jan 9, 2001</H2>
<UL><li>cache speedup, no longer "flush"es writes.</li>
<li>mailer now supports multiple open mail reading views</li>
<li>slide back/forward should now correctly remember page scroll position</li>
<li>fixed Tcl embedded apps</li>
<li>fixed malformed index bug</li>
<li>prefs/encoding now applies to pages, not Tcl system encoding</li>
<li>zipview restrictions removed</li>
<li>frames in mail window now work</li>
<li>chg external dnslookup fails to not use server address</li>
</UL>

<A NAME=sect20></A><H2>Release 1.2.3: Jan 3, 2001</H2>
<UL><li>Fixed bug in editor startup</li>
<li>Change portal password to not use passman</li>
<li>Disabled passman by default</li>
<li>Enabled support for builtin mail via portal</li>
<li></li>
</UL>
<A NAME=sect21></A><H2>Release 1.2.2: Jan 2, 2001</H2>
<UL><li>Option to disable images in printing (was crashing windows)</li>
<li>Ignore background images less than 4x4: slows us down to a crawl</li>
<li>Fixed Auth problem</li>
<li>Fixed Duplicate parse</li>
<li></li>
</UL>
<A NAME=sect22></A><H2>Release 1.2.1: Jan 1, 2001</H2>
The following are new features.
<UL><li>Support for Dynamic DNS</li>
<li>Web portal/server (http and https)</li>
<li>Portal builtin commands like read bookmarks, mail, and exec commands</li>
<li>Address Book</li>
<li></li>
</UL>
<A NAME=sect23></A><H2>Release 1.1.2: Nov 24, 2000</H2>
The following are bug fixes.
<UL><li>nested table widths were too wide</li>
<li>multiple <BR> tags were not doing <P></li>
<li>broken links no longer added to Url list</li>
<li>reload was being ignored sometimes</li>
<li>eliminate NULL byte from display (my.yahoo.com)</li>
<li></li>
</UL>

<A NAME=sect24></A><H2>Release 1.1.1: Oct 29, 2000</H2>
<UL><li>Fixed SSL which was broken by the new packaging.</li>
<li>Fixed Urls where path was empty (eg. "?some=stuff")</li>
<li>Reduced size of license screen so it fits into 640x480.</li>
<li>Reorganized Preferences to fit in 640x480.</li>
<li>Fixed hang: recursive call to encoding.</li>
<li>Changed external DNS lookup to use sh script.</li>
<li>Fixed directory display breakage.</li>
</UL>

<A NAME=sect25></A><H2>Release 1.1.0: Oct 24, 2000</H2>

<ul><li>Focusing to location no longer grabs the selection.</li>
<li>Fixed offline mode.  Cachecmp=never now tries cache first.</li>
<li>Fixed history so it comes from cache.</li>
<li>Eliminate network down hang.</li>
<li>Limit checks on number of redirects.</li>
<li>Fixed frame=100%,* bug.</li>
<li>Fixed ftp download bug.</li>
<li>Proxy now working properly.</li>
<li>Tclhtml: modified Tkhtml to compile subset without Tk.</li>
<li>Packaged as a single standalone binary</li>
<li>Can view a zip archive of html content: html, gifs. (ala PDF)</li>
<li>Netscape bookmarks import (in File/Util menu).</li>
<li>Config option for changing Meta key to <b>Control</b> from <b>Alt</b>. There is
still no general keymap editor.</li>
<li>Option to set a limit on the max number of images.</li>
<li>Long menus, multi-columned menus and cascades.  Fixed menu key shortcuts.</li>
<li>filter URLs by href option for http.</li>
<li>filter Image by href option for http (eg. Ads like doubleclick).</li>
<li>Dialog to change selection/find background color.</li>
<li><A HREF="Passman.html">Passman</A>:
a password manager for logins.
This option caches userid/passwords in an encrypted file
and automatically substituting them when you type the PassMan
password.</li>
<li>A simple editor with Undo, and support
for encrypted files (ie. so you can edit the PassMan file). </li>
<li>Encryption options include either DES, or XOR (aperiodic).</li>
<li>The NGS <A HREF="Javascript.html">Javascript</A> compiler is now included with <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp;</li>
<li>An initial Tcl outline of a DOM has been implemented, but
is too slow to be practical, so a faster C version is in the works.
ie. Javascript is not working, yet.</li>
</ul>

<A NAME=sect26></A><H2>Release 1.0.x: Sept 29, 2000</H2>

Beta Release.  Package renamed to <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp;.  Everything changed.

<A NAME=sect27></A><H2>PDQ Alpha 1.09</H2>
<UL><LI>NEW: take snapshot to directory of current page and images</LI>
<LI>NEW: windows alpha version release</LI>
<LI>NEW: buggy expand replaced by TML</LI>
<LI>screen refresh was intermittently broken</LI>
<LI>cursor was stuck as a hand</LI>
<LI>printing to postscript</LI>
<LI>images use size hint so screen rearrange required less often</LI>
<LI>redirected images were not always appearing (ie. doubleclick.net)</LI>
<LI>cookies were broken for deep subdomains</LI>
<LI>frame target= in base tag now working</LI>
<LI>animate gif was broken for some gifs</LI>
</UL>

<P>
Comments?  Send mail to <A HREF="mailto:peter@browsex.com">peter@browsex.com</A>.
</BLOCKQUOTE></TD></TR></table></td></tr></table>
</TD></TR></TABLE> <CENTER ALIGN=right><P><IMG SRC=browsex.gif>  <I>Copyright &copy; 1999-2001 &nbsp; <a href="mailto:peter@browsex.com">Browsex Systems Inc</a> &nbsp;  <a href="http://BrowseX.com">http://BrowseX.com</a></I></CENTER><P>&nbsp;<P>
<HR >

Added Changes.html.





































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
<!-- Generated by TML 2.0   copyright 2000-2001 Peter MacDonald -->
<!-- Best viewed with BrowseX          http://BrowseX.com -->





<TABLE NAME="top" ><TR>
<TD width=123 ><DIV align=left ><IMG SRC=logo64.gif  width=43 height=64 ></IMG></DIV></TD>
<TD><CENTER><IMG SRC=browsexb.gif  alt="BrowseX" width=430 height=74 ></IMG></CENTER></TD>
<TD width=123 NAME="TOPROW" ><DIV align=right >
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=27901" width="88"
height="31"
border="0" alt="SourceForge Logo"></A>
</DIV></TD>

</TR></TABLE>
<BODY  BGCOLOR="#FFFFFF" LINK="#066e28" >
<TABLE bgcolor="#FFFFFF" border="0" width=600>
<TR valign=top bgcolor=#FFFFFF><TD>
<font size="2" >
<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>BrowseX</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html">Home</A></TD></TR>
<TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html#updates">News</A></TD></TR>
<TR><TD>&nbsp;<A HREF="Install.html">Download</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Features.html">Features</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Demos.html">Demos</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="API.html">API</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="SQLite.html">SQLite</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TML.html">TML</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="dballoc.html">Dballoc</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Javascript.html">Javascript</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mail.html">Mailer</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Address.html">Address</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mime.html">Mimetypes</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="portal.html">Portal</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="gdup.html">DynDNS</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="talk.html">Talk</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="ZipView.html">ZipView</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TDB.html">TDB</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Packaging.html">Packaging</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Passman.html">Passman</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Thin.html">Thin</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="Press.html">Press</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Doc.html">Docs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Bugs.html">Bugs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="FAQ.html">FAQ</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Sell.html">Pros</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Why.html">Why</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="copyright.html">License</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Contacts.html">Contacts</A><BR></TD></TR>
</table></td></tr></table>
<p>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Search</b></font></td></tr>
  <CENTER><TR><TD><FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
</TD></TR></CENTER></table></td></tr></table>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Links</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://dev.scriptics.com">Scriptics</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.postgresql.org">Postgres</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.openssl.org">OpenSSL</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://members1.chello.nl/~j.nijtmans/img.html">Img</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.baremetal.com">Baremetal</A><BR></TD></TR>
</table></td></tr></table>

<P>
<B>Contact</B></FONT><BR>
<A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
</font>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP" BGCOLOR="white">




<TITLE>BrowseX Change Log</TITLE>

<A NAME=sect1></A><H1><CENTER><FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; Change Log</CENTER></H1>
<P><HR ><P>

<A NAME=sect2></A><H2><CENTER>Fixed in <FONT COLOR=#00420c><B>BrowseX</B></FONT>&nbsp; Alpha 1.09</CENTER></H2>
<UL><LI>NEW: take snapshot to directory of current page and images</LI>
<LI>NEW: windows alpha version release</LI>
<LI>NEW: buggy expand replaced by TML</LI>
<LI>screen refresh was intermittently broken</LI>
<LI>cursor was stuck as a hand</LI>
<LI>printing to postscript</LI>
<LI>images use size hint so screen rearrange required less often</LI>
<LI>redirected images were not always appearing (ie. doubleclick.net)</LI>
<LI>cookies were broken for deep subdomains</LI>
<LI>frame target= in base tag now working</LI>
<LI>animate gif was broken for some gifs</LI>
</UL>

<A NAME=sect3></A><H2>Change Summary</H2>
<A NAME=sect4></A><H3>TML Macro Language</H3>
TML is designed to allow access to Tcl procedures as a Macro Language 
from within HTML pages.
The previous macro-language (Expand) was implemented entirely in Tcl and so 
had some nasty limitations with nested macro invocations that 
made it unsuitable for the task at hand.  
TML is written in C, is more efficient and is designed to do the right thing.
Moreover, there is now a complementary program for converting
HTML into TML.  The TML specification has been created
to facilitate this bidirectional transformation.

</TD></TR></TABLE> <CENTER ALIGN=right><P><IMG SRC=browsex.gif>  <I>Copyright &copy; 1999-2001 &nbsp; <a href="mailto:peter@browsex.com">Browsex Systems Inc</a> &nbsp;  <a href="http://BrowseX.com">http://BrowseX.com</a></I></CENTER><P>&nbsp;<P>

Added Coding.html.

























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!-- Generated by TML 2.0   copyright 2000-2001 Peter MacDonald -->
<!-- Best viewed with BrowseX          http://BrowseX.com -->
<PRE>- Avoid unnecessary syntax.  ie. '"' and ';' are often best avoided. eg.
  Use:
     set b &lt;Somewhere&gt;/n
  not
     set b "&lt;Somewhere&gt;/n";
  Both work as long as there is no imbedded space, but start to cause trouble 
  in some situations.
  
- Avoid the use of quotations marks, in particular when using variables and [].
  Use [list ...] instead.  Why?  Because it can cause undesirable evaluations.
  Also nested quotes become messy.
  Use:
     set b [list a $real list is best]
  not
     set b "a $real list is best"

- A list is the safe way to build up a command for use with eval. ie:
    set cmd $c a b c $d
    eval $cmd
  But if c is a list you want expanded, use:
    set cmd [concat $c a b c $d]
    eval $cmd

- Passing variables by reference is sometimes required, and in Tcl we
  play with the variable scope to implement. eg.
    proc foo a { upvar 1 $a arg; set arg 5 }
    

- Similar to above is using upvar with an array in a namespace to sort of 
  emulate passing a pointer to a struct.  eg:
    proc bar::foo n { upvar bar::$n a; set a(dog) 1 }

- Try to use catch as little as possible.  When things go wrong,
  you will be looking at everywhere you used catch.


ANSWERS TO STUMPERS

- If $foo derefs a var foo, how do you double dereference?
  set x [set $foo]
</PRE>

Added Contact.html.

















































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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



<TABLE> <TR> 
<TD width=123> <DIV align=left> <IMG SRC= linux.gif ></IMG></DIV></TD>
<TD> <CENTER> <IMG SRC=browsexb.gif  alt="BrowseX"></IMG></CENTER></TD>
<TD width=123><DIV align=right> <IMG SRC= logo64.gif ></IMG></DIV></TD>
</TR></TABLE>
<BODY  BGCOLOR="#FFFFFF" LINK="#066e28" >
<TABLE bgcolor="white" border="0" width=600>
<TR valign=top bgcolor=white><TD>
<font size="2">

<table cellspacing="0" cellpadding="1" bgcolor="black"
border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
align="center"><font color="white">
<b>BrowseX</b></font></td></tr>

<TR><TD>&nbsp; <A HREF="http://BrowseX.com/index.html">Home Page</A></TD></TR>
<TR><TD>&nbsp; <A HREF="Install.html">Download</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Features.html">Features</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Demo/index.html">Demos</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Tml.html">Tml</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Thin.html">Thin</A><BR></TD></TR>
<TR><TD>&nbsp; <hr></TD></TR>
<TR><TD>&nbsp; <A HREF="Doc.html">Docs</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Bugs.html">Bugs</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="FAQ.html">FAQ</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Sell.html">Pros</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Why.html">Why</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="copyright.html">License</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="Contact.html">Contact</A><BR></TD></TR>
</table></td></tr></table>
<p>

<table cellspacing="0" cellpadding="1" bgcolor="black"
border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
align="center"><font color="white">
<b>Search</b></font></td></tr>

<CENTER>
<TR> <TD>
<FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
</TD></TR></CENTER></table></td></tr></table>

<table cellspacing="0" cellpadding="1" bgcolor="black"
border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
align="center"><font color="white">
<b>Links</b></font></td></tr>

<TR><TD>&nbsp; <A HREF="http://dev.scriptics.com">Scriptics</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="http://www.postgresql.org">Postgres</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="http://www.openssl.org">OpenSSL</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="http://members1.chello.nl/~j.nijtmans/img.html">Img</A><BR></TD></TR>
<TR><TD>&nbsp; <A HREF="http://www.baremetal.com">Baremetal</A><BR></TD></TR>
</table></td></tr></table>

<P>
<B> Contact</B></FONT><BR>
<A HREF="mailto:sales@browsex.com">sales@browsex.com</A>
</font>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP" BGCOLOR="white">


<TITLE> PDQ Contacts</TITLE>

Information on <B> C-Tml</B>, the C-version of Tml and Support Contract
rates is available <A HREF="Sales.html">Here</A>.
<P>
If you like what you see, and would like to see it continue,
feel free to make a contribution.
<P>
<FONT size=4> <b> Phone Number</b>&nbsp;&nbsp;&nbsp;  250-744-7121</FONT>

<A NAME=sect1><H2> Postal Address</H2>
<PRE>
  BrowseX Systems Inc
  3527 Redwood Ave
  Victoria, BC, Canada
  V8P-4Z6
</PRE>
<P>
<A NAME=sect2><H2> Email Addresses</H2>
<UL>
<LI> <B> Reporting A Bug:</B> <BR> If you think you've found a bug that is not in the <A HREF="Bugs.html">Known Problems</A> list, send email to <A HREF="mailto:bugs@browsex.com">bugs@browsex.com</A>
<P>
<LI> <B> Technical Support:</B> <BR> For clients with a support contract: <A HREF="mailto:support@browsex.com">support@browsex.com</A>
<P>
<li> <b> For everything else:</b> <A HREF="mailto:sales@browsex.com">sales@browsex.com</A></li>
</UL>

</TD></TR></TABLE> <CENTER ALIGN=right><P><IMG SRC=browsex.gif>  <I>Copyright &copy; 1999, 2000 &nbsp; <a href="mailto:sales@browsex.com">Browsex Systems Inc</a> &nbsp;  <a href="http://BrowseX.com">http://BrowseX.com</a></I></CENTER><P>&nbsp;<P>


Added Contacts.html.



















































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
<!-- Generated by TML 2.0   copyright 2000-2001 Peter MacDonald -->
<!-- Best viewed with BrowseX          http://BrowseX.com -->





<TABLE NAME="top" ><TR>
<TD width=123 ><DIV align=left ><IMG SRC=logo64.gif  width=43 height=64 ></IMG></DIV></TD>
<TD><CENTER><IMG SRC=browsexb.gif  alt="BrowseX" width=430 height=74 ></IMG></CENTER></TD>
<TD width=123 NAME="TOPROW" ><DIV align=right >
<A href="http://sourceforge.net">
<IMG src="http://sourceforge.net/sflogo.php?group_id=27901" width="88"
height="31"
border="0" alt="SourceForge Logo"></A>
</DIV></TD>

</TR></TABLE>
<BODY  BGCOLOR="#FFFFFF" LINK="#066e28" >
<TABLE bgcolor="#FFFFFF" border="0" width=600>
<TR valign=top bgcolor=#FFFFFF><TD>
<font size="2" >
<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>BrowseX</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html">Home</A></TD></TR>
<TR><TD>&nbsp;<A HREF="http://BrowseX.com/index.html#updates">News</A></TD></TR>
<TR><TD>&nbsp;<A HREF="Install.html">Download</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Features.html">Features</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Demos.html">Demos</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="API.html">API</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="SQLite.html">SQLite</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TML.html">TML</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="dballoc.html">Dballoc</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Javascript.html">Javascript</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mail.html">Mailer</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Address.html">Address</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Mime.html">Mimetypes</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="portal.html">Portal</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="gdup.html">DynDNS</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="talk.html">Talk</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="ZipView.html">ZipView</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="TDB.html">TDB</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Packaging.html">Packaging</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Passman.html">Passman</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Thin.html">Thin</A><BR></TD></TR>
<TR><TD>&nbsp;<hr></TD></TR>
<TR><TD>&nbsp;<A HREF="Press.html">Press</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Doc.html">Docs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Bugs.html">Bugs</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="FAQ.html">FAQ</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Sell.html">Pros</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Why.html">Why</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="copyright.html">License</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="Contacts.html">Contacts</A><BR></TD></TR>
</table></td></tr></table>
<p>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Search</b></font></td></tr>
  <CENTER><TR><TD><FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
</TD></TR></CENTER></table></td></tr></table>

<table cellspacing="0" cellpadding="1" bgcolor="black"
  border=1 width="123"><tr><td><table width="123" bgcolor="#c0d9d9"
  cellspacing="0" cellpadding="1" border=0><tr><td bgcolor="#247852"
  align="center"><font color="white">
  <b>Links</b></font></td></tr>
  <TR><TD>&nbsp;<A HREF="http://dev.scriptics.com">Scriptics</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.postgresql.org">Postgres</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.openssl.org">OpenSSL</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://members1.chello.nl/~j.nijtmans/img.html">Img</A><BR></TD></TR>
<TR><TD>&nbsp;<A HREF="http://www.baremetal.com">Baremetal</A><BR></TD></TR>
</table></td></tr></table>

<P>
<B>Contact</B></FONT><BR>
<A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
</font>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP" BGCOLOR="white">



<TITLE>BrowseX Contacts</TITLE>

If you like what you see, and would like to see it continue,
feel free to make a contribution.
<P>
<FONT size=4 ><b>Phone Number</b>&nbsp;&nbsp;&nbsp;  250-744-7121</FONT><BR>
<FONT size=4 ><b>Alternate Number</b>&nbsp;&nbsp;&nbsp;  250-595-5998</FONT>

<A NAME=sect1></A><H2>Postal Address</H2>
<PRE>  BrowseX Systems Inc
  3527 Redwood Ave
  Victoria, BC, Canada
  V8P-4Z6
</PRE>
<P>
<A NAME=sect2></A><H2>Email Addresses</H2>
<UL><LI> <B>Reporting A Bug:</B> <BR> If you think you've found a bug that is not in the <A HREF="Bugs.html">Known Problems</A> list, send email to <A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
<P>
<LI> <B>Technical Support:</B> <BR> For clients with a support contract: <A HREF="mailto:peter@browsex.com">peter@browsex.com</A>
<P>
</UL>

</TD></TR></TABLE> <CENTER ALIGN=right><P><IMG SRC=browsex.gif>  <I>Copyright &copy; 1999-2001 &nbsp; <a href="mailto:peter@browsex.com">Browsex Systems Inc</a> &nbsp;  <a href="http://BrowseX.com">http://BrowseX.com</a></I></CENTER><P>&nbsp;<P>


Added Demo/Alpha.html.















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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

<BODY BGCOLOR=#FFFFFF>
<CENTER><IMG SRC=http://www.pdqi.com/pdqlogo.gif ></CENTER>
<TABLE>
<TR><TD BGCOLOR=#8cc8fe WIDTH="130" ALIGN=LEFT VALIGN="TOP">
<FONT SIZE=2><H2>PDQ Innovations<BR></H2>
<A HREF="http://www.pdqi.com/index.html">Home</A><BR>
<A HREF="Features.html">Features</A><BR>
<A HREF="Doc.html">Documentation</A><BR>
<A HREF="Alpha.html">Alpha Test</A><BR>
<A HREF="Download.html">Download</A><BR>
<A HREF="Demo/index.html">Demos</A><BR>
<A HREF="FAQ.html">FAQ</A><BR>
<A HREF="Bugs.html">Status</A><BR>
<A HREF="Contact.html">Contacts</A><BR>
<P>
<FONT SIZE=3>
<FORM method=GET action=http://www.google.com/custom>
<INPUT TYPE=text name=q size=10 maxlength=255 value="">
<INPUT type=submit name=sa VALUE="Search">
<INPUT type=hidden name=cof VALUE="T:Black;LW:600;L:http://www.pdqi.com/pdqlogo.gif;LH:100;BGC:White;AH:center;AWFID:73475c2a7a72a198;">
</FORM>
<B>Links</B><P>
<A HREF="http://www.pdqi.com">PDQI</A><BR>
<A HREF="http://www.google.com">Google</A><BR>
<A HREF="http://www.scriptics.com">Scriptics</A><BR>
<A HREF="http://www.openssl.org">OpenSSL</A><BR>
<A HREF="http://www.hwaci.com/sw/tkhtml/index.html">Tkhtml</A><BR>
<A HREF="http://tix.mne.com/">Tix</A><BR>
<A HREF="http://www.tcltk.com/blt/">Blt</A><BR>
<A HREF="http://www.purl.org/net/hobbs/tcl/capp/">Tktable...</A><BR>
<A HREF="http://www.postgresql.org">Postgres</A><BR>
<A HREF="http://www.baremetal.com">Baremetal</A><BR>
<P>
<B>Contact</B></FONT><BR>
<A HREF="mailto:devel@pdqi.com">devel@pdqi.com</A>
</FONT>
</TD>
</TD><TD WIDTH="455" COLSPAN="2" VALIGN="TOP">


<A NAME=sect1><H1>Alpha Test</H1>
<I>This area is under construction!</I>
<P>
The initial release of <B>PDQ</B> is being presented to a limited audience for
evaluation and testing.
<P>
Please do <B>NOT</B> use the Alpha <B>PDQ</B> in critical or important
situations, like doing your Banking.  All pages are currently
cached to disk, including https:!  <B>PDQ</B> Innovations assumes no liability
for loss or damages.
<P>
At this time, we are also asking that <B>PDQ</B> not be redistributed.
<A NAME=sect2><H2>Downloading</H2>
For the Alpha test, there is currently no installation script.
The following 3 packages are required for the initial installation.
Subsequent upgrades will probably require only the last.
<UL>
<LI><A HREF="download/tcltk8_3.tgz">tcltk8_3.tgz: <I>1.3M</I> - The Tcl 8.3 distribution</A></LI>
<LI><A HREF="download/pdqlibs1_0.tgz">pdqlibs1_0.tgz: <I>1.5M</I> - Support libraries</A></LI>
<LI><A HREF="download/pdq1_0_7.tgz">pdq1_0_7.tgz: <I>.25M</I> - The Browser</A></LI>
</UL>
<BR>
<A NAME=sect3><H2>Installation</H2>
After downloading the packages install as follows (assumes
packages are in /tmp):

<UL>
<LI>cd /usr/lib
<LI>tar -xzpvf /tmp/tcltk8_3.tgz
<LI>tar -xzpvf /tmp/pdqlibs_1.0.tgz
<LI>tar -xzpvf /tmp/pdq1_0.tgz
<LI>mv wish8.3 ../bin/
<LI>ln -s /usr/lib/pdq1.0/pdq.bin /usr/bin/pdq
</UL>

<P>
That's it!
Note: the current install is not yet sophisticated.  The
above will install Tcl/Tk/Tix/Blt/Tktable and various other
runtimes and libraries in /usr/lib.  Be warned:
This may overwrite existing files.
<P>
After installation, type <B>pdq</B> and go to the <A HREF="Demo">Demo</A> page.

</TD></TR></TABLE>

Added Demo/Applets/Maler.tcl.

































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# Author: Achim Lehmkuhl
# Copyright 1997


. configure -borderwidth 3 -relief ridge
set farbe black
set staerke 2
set recht 0

proc freihand {oldx oldy farbe staerke} {
      bind .malfeld <B1-Motion> {
      .malfeld create line $oldx $oldy %x %y -fill $farbe -width $staerke
     set oldx %x
     set oldy %y
  } 
} 

proc radieren {oldx oldy} {
      bind .malfeld <B1-Motion> {
      .malfeld create line $oldx $oldy %x %y -fill white -width 10
     set oldx %x
     set oldy %y
  } 
} 

proc l {oldx oldy farbe staerke} { 
            global set recht 0    
            bind .malfeld <B1-Motion> { 
               set ax %x
               set ay %y
               if { $recht != 0} {
               .malfeld delete $recht }
               set recht [ .malfeld create line $oldx $oldy $ax $ay -fill $farbe -width $staerke ] 
               }
               bind .malfeld <ButtonRelease> {
              .malfeld create line $oldx $oldy %x %y -fill $farbe -width $staerke } 
} 


proc r {oldx oldy farbe staerke} { 
            global set recht 0    
            bind .malfeld <B1-Motion> { 
               set ax %x
               set ay %y
               if { $recht != 0} {
               .malfeld delete $recht }
               set recht [ .malfeld create rectangle $oldx $oldy $ax $ay -outline $farbe -width $staerke ] 
               }
               bind .malfeld <ButtonRelease> {
              .malfeld create rectangle $oldx $oldy %x %y -outline $farbe -width $staerke } 
} 

proc rf {oldx oldy farbe staerke} { 
            global set recht 0    
            bind .malfeld <B1-Motion> { 
               set ax %x
               set ay %y
               if { $recht != 0} {
               .malfeld delete $recht }
               set recht [ .malfeld create rectangle $oldx $oldy $ax $ay -outline $farbe -fill $farbe -width $staerke ] 
               }
               bind .malfeld <ButtonRelease> {
              .malfeld create rectangle $oldx $oldy %x %y -outline $farbe -fill $farbe -width $staerke } 
} 



proc k {oldx oldy farbe staerke} { 
            global set recht 0    
            bind .malfeld <B1-Motion> { 
               set ax %x
               set ay %y
               if { $recht != 0} {
               .malfeld delete $recht }
               set recht [ .malfeld create oval $oldx $oldy $ax $ay -outline $farbe -width $staerke ] 
               }
               bind .malfeld <ButtonRelease> {
              .malfeld create oval $oldx $oldy %x %y -outline $farbe -width $staerke } 
} 


proc kf {oldx oldy farbe staerke} { 
            global set recht 0    
            bind .malfeld <B1-Motion> { 
               set ax %x
               set ay %y
               if { $recht != 0} {
               .malfeld delete $recht }
               set recht [ .malfeld create oval $oldx $oldy $ax $ay -outline $farbe -fill $farbe -width $staerke ] 
               }
               bind .malfeld <ButtonRelease> {
              .malfeld create oval $oldx $oldy %x %y -outline $farbe -fill $farbe -width $staerke } 
} 


proc b {oldx oldy farbe staerke} {
            bind .malfeld <B1-Motion> {
               if { $staerke == 2 } {set staerke 3 }
               .malfeld create oval %x %y [expr %x+$staerke] [expr %y+$staerke] -outline $farbe -fill $farbe 
               set oldx %x
               set oldy %y
               }
}

image create photo stift -data {R0lGODlhGQAZAIAAAAAAAP///yH5BAEAAAEALAAAAAAZABkAAAJNjI+py+0O4oMgxDqTPDtb/IVZ
R4JNyXUMakimwoovEm8qDbJ3yrfY7rvoZr2W73jSXJCrmY2Ic4pOQo1lIlQBYdnsqLttLj1KKPm8
KAAAOw==
}

image create photo radier -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAJOjI+py+0N4nOxgqmq0XjLY3Vf
wlEXdDLjsmYp2yKxHLqvG8Ql7JEzmNpZbj2gL9cq6YAfJTE5NMJeNaSJGvwxi0ji1NrteJrex7CM
2SkKADs=
}
image create photo breit -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAIojI+py+0Po5y02huB3rzz5IXi
IZaeYaYaqppkO77wh9X2jef6zvdKAQA7
}
image create photo mittel -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAIkjI+py+0Po5y02ost2Lz7nnzi
eIzmZ5zqVq5kBsfyTNf2jWcFADs=
}
image create photo duenn -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAIcjI+py+0Po5y02ouz3vyAD4ai
2JXmiabqyrZLAQA7
}
image create photo recht -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAI5jI+py+0PgZy0UiUhAphr422h
NoLlc2ZfkJ5Ou7JdDK/1d5OzveO9nlD5gq5Gy4K8EJPMmPMJZRQAADs=
}
image create photo rechtf -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAIyjI+py+0PA5i0Wrqutnn77mlg
yCmkaJ5loq5IW42trNKnTeKh/qUwwNsEUZGi8YhMMgoAOw==
}
image create photo kreis -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAJAjI+py+0HopwPzQsqxLLS9YGR
0zGlOSrnswZt075oZqWebcgineg53gMGeSpdqCj8JYccjbLp5Pic1Kr1is1CCgA7
}
image create photo kreisf -data {R0lGODdhGQAbAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABsAAAI4jI+py+0PozSg2gsk3nD73Hwi
I35kyS1oiqxm67JUjCV0Dd+Vre+KfqIFYyHXgxh5TZbMpvNpKAAAOw==
}
image create photo blasen -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAJFjI+py80AnQSHylcvNlYr2H2g
9yGhdwbpVDpUpLZbTJtuxlnwXZPV6MNxgr1ibmUM7XbC5in1tMmc0sQKBLUSo1sssVEAADs=
}
image create photo linie -data {R0lGODdhGQAZAIAAAAAAAP///yH5BAEAAAAALAAAAAAZABkAAAInjI+py+0Po5xgsmoVzmhz430h
N2aldVJftx6p9EYxND+1c7f6zlsFADs=
}
image create photo loesch -data {R0lGODdhGQAZAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4O
Dg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEh
ISIiIiMjIyQkJCUlJSYmJicnJygoKCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0
NDU1NTY2Njc3Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZGRkdH
R0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVVVVZWVldXV1hYWFlZWVpa
WltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2RkZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1t
bW5ubm9vb3BwcHFxcXJycnNzc3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CA
gIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGRkZKSkpOT
k5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6CgoKGhoaKioqOjo6SkpKWlpaam
pqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5
ubq6uru7u7y8vL29vb6+vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zM
zM3Nzc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc3N3d3d7e3t/f
3+Dg4OHh4eLi4uPj4+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr6+zs7O3t7e7u7u/v7/Dw8PHx8fLy
8vPz8/T09PX19fb29vf39/j4+Pn5+fr6+vv7+/z8/P39/f7+/v///ywAAAAAGQAZAAAI/gD3CfTn
rx9Bg/amRTsCgECANdTq+eNnkN8+fBMN9uu3TxcjAgIEBAggoIAAR6lQRePnT2A/ivtankIEgMUQ
AQBwChhAAJAVP/v4UcQXkx+xU1uQeGC0oqGHOAFyiruxRx9Fiv7+qRjz5wGABR4GjDwgRg0BAEYc
/SEYM98+FSpYqFgBl66LFS3wsjhgD1zGgi9ZvOT3r9+/ghT1vewXR5qVfRwnWqRk+J/lyy9jbvRH
zcpmxZLpEL5s2eA+xY2+iSnm797Gflb9schK+p/rev3yWZGm4jTHxRSNiKt9OCjBOduc5NbnLx+/
fBypVSHONh+1cLdyFyR4sF9n4v8sofL7o2qFZqzc/8EzlhXfYcNFyatgmb52rkiQAXP3lw6eNfCk
qbLHRURJxo8pgUxBDYCXFXMKPhVZ5A8+qvSBxTQMWubPLtIYdJg+Vk3DyynmZHiYH6oIdFiB/LAi
TGUM+kOeQQf5s40Kfryzj4kEwZHCCyvIBVcc9JnIkXEvFaYfjAC2FBuNG8U2WoySORmTP/pAR1uM
+DwJGWz8MKdPbQEBADs=
}

canvas .malfeld -width 550p -height 360p  -borderwidth 3 -relief ridge -bg white
frame .buttonleiste -width 80 -borderwidth 3 -relief ridge
frame .farbleiste -height 40 -borderwidth 3 -relief ridge
canvas .farbleiste.aktuell -width 30 -height 16 -borderwidth 2 -relief ridge -bg $farbe 
canvas .farbleiste.rot -width 16 -height 16 -relief sunken -borderwidth 3 -bg red1
canvas .farbleiste.hellrot -width 16 -height 16 -relief sunken -borderwidth 3 -bg red2
canvas .farbleiste.orange -width 16 -height 16 -relief sunken -borderwidth 3 -bg orange
canvas .farbleiste.gelb -width 16 -height 16 -relief sunken -borderwidth 3 -bg yellow
canvas .farbleiste.hegruen -width 16 -height 16 -relief sunken -borderwidth 3 -bg green1
canvas .farbleiste.gruen -width 16 -height 16 -relief sunken -borderwidth 3 -bg green4
canvas .farbleiste.hiblau -width 16 -height 16 -relief sunken -borderwidth 3 -bg lightskyblue
canvas .farbleiste.heblau -width 16 -height 16 -relief sunken -borderwidth 3 -bg lightsteelblue
canvas .farbleiste.blau -width 16 -height 16 -relief sunken -borderwidth 3 -bg blue
canvas .farbleiste.violett -width 16 -height 16 -relief sunken -borderwidth 3 -bg violetred2
canvas .farbleiste.braun -width 16 -height 16 -relief sunken -borderwidth 3 -bg brown3
canvas .farbleiste.dbraun -width 16 -height 16 -relief sunken -borderwidth 3 -bg brown4
canvas .farbleiste.schwarz -width 16 -height 16 -relief sunken -borderwidth 3 -bg black
canvas .farbleiste.weiss -width 16 -height 16 -relief sunken -borderwidth 3 -bg white
button .farbleiste.breit  -image breit -command { set staerke 10 }
button .farbleiste.mittel  -image mittel -command { set staerke 5 }
button .farbleiste.duenn  -image duenn -command { set staerke 2}

pack .farbleiste -side bottom
pack .farbleiste.aktuell .farbleiste.breit .farbleiste.mittel .farbleiste.duenn .farbleiste.rot .farbleiste.hellrot .farbleiste.orange .farbleiste.gelb .farbleiste.hegruen .farbleiste.gruen .farbleiste.hiblau .farbleiste.heblau .farbleiste.blau .farbleiste.violett .farbleiste.braun .farbleiste.dbraun .farbleiste.schwarz .farbleiste.weiss -side left -fill x -expand y
pack .buttonleiste -side left

button .buttonleiste.stift -image stift -bg grey -command {bind .malfeld <Button-1> {  
   set oldx %x
   set oldy %y
   freihand $oldx $oldy $farbe $staerke} }

button .buttonleiste.radier -image radier -command  {bind .malfeld <Button-1> {  
   set oldx %x
   set oldy %y
   radieren $oldx $oldy } }

button .buttonleiste.linie -image linie -command  {bind .malfeld <Button-1> {  
   set oldx %x
   set oldy %y
   l $oldx $oldy $farbe $staerke} }


button .buttonleiste.recht -image recht -command  {bind .malfeld <Button-1> {  
   set oldx %x
   set oldy %y
   r $oldx $oldy $farbe $staerke} }

button .buttonleiste.rechtf -image rechtf -command  {bind .malfeld <Button-1> {  
   set oldx %x
   set oldy %y
   rf $oldx $oldy $farbe $staerke } }

button .buttonleiste.kreis -image kreis -command  {bind .malfeld <Button-1> {  
   set oldx %x
   set oldy %y
   k $oldx $oldy $farbe $staerke } }

button .buttonleiste.kreisf -image kreisf  -command  {bind .malfeld <Button-1> {  
   set oldx %x
   set oldy %y
   kf $oldx $oldy $farbe $staerke } }

button .buttonleiste.blasen -image blasen -command {bind .malfeld <Button-1> {
   set oldx %x
   set oldy %y
   b $oldx $oldy $farbe $staerke }}

button .buttonleiste.loeschen -image loesch -command {destroy .malfeld
   canvas .malfeld -width 550p -height 360p -borderwidth 3 -relief raised -bg white
   pack .malfeld -side right
   bind .malfeld <Any-Enter> { .malfeld configure -cursor crosshair }
   bind .malfeld <Any-Leave> {.malfeld configure -cursor arrow }
} 


pack .buttonleiste.stift .buttonleiste.linie \
.buttonleiste.blasen .buttonleiste.recht .buttonleiste.rechtf \
.buttonleiste.kreis .buttonleiste.kreisf .buttonleiste.radier .buttonleiste.loeschen -side top -expand y

pack .malfeld -side left 

bind .malfeld <Any-Enter> { .malfeld configure -cursor crosshair }
bind .malfeld <Any-Leave> {.malfeld configure -cursor arrow }
bind .farbleiste.rot <Any-Enter> { .farbleiste.rot  configure  -relief raised  }
bind .farbleiste.rot <Any-Leave> { .farbleiste.rot configure -relief sunken }
bind .farbleiste.rot <Button-1> { set farbe red1
                                                          .farbleiste.aktuell configure -bg $farbe}
bind .farbleiste.hellrot <Any-Enter> { .farbleiste.hellrot  configure  -relief raised  }
bind .farbleiste.hellrot <Any-Leave> { .farbleiste.hellrot configure -relief sunken }
bind .farbleiste.hellrot <Button-1> { set farbe red2
                                                          .farbleiste.aktuell configure -bg $farbe  }
bind .farbleiste.orange <Any-Enter> { .farbleiste.orange  configure  -relief raised  }
bind .farbleiste.orange <Any-Leave> { .farbleiste.orange configure -relief sunken }
bind .farbleiste.orange <Button-1> { set farbe orange
                                                          .farbleiste.aktuell configure -bg $farbe  }
bind .farbleiste.gelb <Any-Enter> { .farbleiste.gelb  configure  -relief raised  }
bind .farbleiste.gelb <Any-Leave> { .farbleiste.gelb configure -relief sunken }
bind .farbleiste.gelb <Button-1> { set farbe yellow
                                                          .farbleiste.aktuell configure -bg $farbe  }
bind .farbleiste.hegruen <Any-Enter> { .farbleiste.hegruen  configure  -relief raised  }
bind .farbleiste.hegruen <Any-Leave> { .farbleiste.hegruen configure -relief sunken }
bind .farbleiste.hegruen <Button-1> { set farbe green1
                                                          .farbleiste.aktuell configure -bg $farbe  }
bind .farbleiste.gruen <Any-Enter> { .farbleiste.gruen  configure  -relief raised  }
bind .farbleiste.gruen <Any-Leave> { .farbleiste.gruen configure -relief sunken }
bind .farbleiste.gruen <Button-1> { set farbe green4 
                                                          .farbleiste.aktuell configure -bg $farbe }
bind .farbleiste.hiblau <Any-Enter> { .farbleiste.hiblau  configure  -relief raised  }
bind .farbleiste.hiblau <Any-Leave> { .farbleiste.hiblau configure -relief sunken }
bind .farbleiste.hiblau <Button-1> { set farbe lightskyblue 
                                                          .farbleiste.aktuell configure -bg $farbe }
bind .farbleiste.heblau <Any-Enter> { .farbleiste.heblau  configure  -relief raised  }
bind .farbleiste.heblau <Any-Leave> { .farbleiste.heblau configure -relief sunken }
bind .farbleiste.heblau <Button-1> { set farbe lightsteelblue 
                                                          .farbleiste.aktuell configure -bg $farbe }
bind .farbleiste.blau <Any-Enter> { .farbleiste.blau  configure  -relief raised  }
bind .farbleiste.blau <Any-Leave> { .farbleiste.blau configure -relief sunken }
bind .farbleiste.blau <Button-1> { set farbe blue 
                                                          .farbleiste.aktuell configure -bg $farbe }
bind .farbleiste.violett <Any-Enter> { .farbleiste.violett  configure  -relief raised  }
bind .farbleiste.violett <Any-Leave> { .farbleiste.violett configure -relief sunken }
bind .farbleiste.violett <Button-1> { set farbe violetred2
                                                          .farbleiste.aktuell configure -bg $farbe  }
bind .farbleiste.braun <Any-Enter> { .farbleiste.braun  configure  -relief raised  }
bind .farbleiste.braun <Any-Leave> { .farbleiste.braun configure -relief sunken }
bind .farbleiste.braun <Button-1> { set farbe brown3 
                                                          .farbleiste.aktuell configure -bg $farbe }
bind .farbleiste.dbraun <Any-Enter> { .farbleiste.dbraun  configure  -relief raised  }
bind .farbleiste.dbraun <Any-Leave> { .farbleiste.dbraun configure -relief sunken }
bind .farbleiste.dbraun <Button-1> { set farbe brown4
                                                          .farbleiste.aktuell configure -bg $farbe  }
bind .farbleiste.schwarz <Any-Enter> { .farbleiste.schwarz  configure  -relief raised  }
bind .farbleiste.schwarz <Any-Leave> { .farbleiste.schwarz configure -relief sunken }
bind .farbleiste.schwarz <Button-1> { set farbe black
                                                                   .farbleiste.aktuell configure -bg $farbe  }
bind .farbleiste.weiss <Any-Enter> { .farbleiste.weiss configure  -relief raised  }
bind .farbleiste.weiss <Any-Leave> { .farbleiste.weiss configure -relief sunken }
bind .farbleiste.weiss <Button-1> { set farbe white 
                                                          .farbleiste.aktuell configure -bg $farbe }

Added Demo/Applets/backg.html.















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
<script language=Tcl width=473 height=415>
#
#	backgammon tclet
#
#	Backgammon
#	by Ignaz KOHLBECKER
#	ignaz@fujita3.iis.u-tokyo.ac.jp
#
#	Distribution and modifications of this program and its associated
#	files are possible under the conditions of the
#	GNU Public License (GPL).
#
#	History:
#
#	97/08/13	first edit.
#	97/08/25	V1.0 last edit version 1.0.
#	98/01/11	V1.1 jot and rand()
#	98/01/30	tclet version: no exec, toplevel, wm, tkwait, @;
#			instead vwait, bitmap->image, bitmap data inline
#	98/01/31	no puts, trash unnecessary stuff
#


#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	Game Procedures
#


#-------------------------------------------------------------------
proc gameinit {} {
    global progname bp bop avmove diceexpr
    global c totturns dice1 dice2 undook
    set checkerinit {6 6 6 6 6 8 8 8 13 13 13 13 13 24 24}

    set progname "Phi's Backgammon Tclet V1.1"

    # The points on the board are numbered 1 to 24.
    # Player  1 moves from 24 downward to  1.
    # Player -1 moves from  1 upward   to 24.
    # Bar      for player 1 is 25, for player -1 is  0.
    # Bear-off for player 1 is  0, for player -1 is 25.

    set bp(1)  25 ;# bar position
    set bp(-1)  0 ;# bar position
    set bop(1)   0 ;# bear off position
    set bop(-1) 25 ;# bear off position

    # The average outcome of two dices with doubling in case of two equals:
    # 2 * 1/6 * Sum[i,{i,1,6}] + 1/36 * Sum[2i,{i,1,6}] = 8 1/6
    set avmove 8.167

    # The expression to throw a dice
    set diceexpr {expr {1 + int(6 * rand())}}

    for {set level 0} {$level <= 4} {incr level} {
	for {set p 0} {$p <= 25} {incr p} {
	    set c(1,$level,$p) 0
	    set c(-1,$level,$p) 0
	}
	
	foreach number $checkerinit {
	    incr c(1,$level,$number)
	    incr c(-1,$level,[expr 25 - $number])
	}
    }
    set totturns 0
    set dice1 0
    set dice2 0
    set undook 0
}

#-------------------------------------------------------------------
proc restart {} {
    global restartrequest dice1 dice2 turn noturn bar nobar undook
    global playerdone c bp totturns compwon playerwon
    global diceexpr

    # Put all checkers in start position
    gameinit
    showcheckers 0
    
    # Throw dices unil two different numbers
    while {[set dice1 [eval $diceexpr]] == [set dice2 [eval $diceexpr]]} {}
    # Decide who begins the game.
    if {$dice1 > $dice2} {
	# Computer begins
	set turn 1
	set noturn -1
    } else {
	# Player begins
	set turn -1
	set noturn 1
    }
    
    while {!$restartrequest && !$compwon && !$playerwon} {
	set bar [set bp($turn)]
	set nobar [set bp($noturn)]
	set dice1 [expr $turn * $dice1]
	set dice2 [expr $turn * $dice2]
	showdices
	
	incr totturns
	if {$turn == 1} {
	    # Computers move
	    compmove $dice1 $dice2
	    
	    if {[set c(1,0,$nobar)] == 15} {
		# The computer won.
		#puts "Backgammon: Computer won in $totturns turns."
		set compwon 1
	    }
	} else {
	    # Players move
	    thinker 0

	    # Store game in level 4 for Undo
	    copylevel 0 4 {}
	    # Enable the Undo-Button
	    set undook 1
	    
	    set playerdone 0
	    # Wait for the player to do his moves and
	    # return control by pressing "Go"
	    vwait playerdone
	    
	    if {[set c(-1,0,$nobar)] == 15} {
		# The player won.
		#puts "Backgammon: Player won in $totturns turns."
		set playerwon 1
	    }
	    # Disable the Undo-Button
	    set undook 0
	    
	    thinker -1
	}
	# Flip turn; get new dices
	set h $turn
	set turn $noturn
	set noturn $h
	set dice1 [eval $diceexpr]
	set dice2 [eval $diceexpr]
	
	update
    }
    # done|quit|won
}

#-------------------------------------------------------------------
proc compmove {d1 d2} {
    global allmoves maxmovelen

    set allmoves {}
    set maxmovelen 0
    thinker 1
    if {$d1 == $d2} {
	deep 0 $d1 $d1 $d1 $d1 {} 0
    } else {
	deep 0 $d1 $d2 0 0 {} 0
    }

    set pickmove [select 0]
    # puts "$pickmove"
    foreach m [lindex $pickmove 0] {copylevel 0 0 $m}
    
    showcheckers 0
    thinker -1
}

#-------------------------------------------------------------------
proc copylevel {fromlevel tolevel move} {
    global c turn noturn bar nobar allmoves

    if {$fromlevel != $tolevel} {
	for {set i 0} {$i <= 25} {incr i} {
	    foreach ii [list $turn $noturn] {
		set c($ii,$tolevel,$i)   [set c($ii,$fromlevel,$i)]	
	    }
	}
    }

    if {$move != {}} {
	set from [lindex $move 0]
	# Remove the checker from where it was
	incr c($turn,$tolevel,$from) -1

	set to [expr $from - [lindex $move 1]]
	
	if {($to > 0) && ($to < 25)} {
	    # blot might be possible
	    if {[set c($noturn,$tolevel,$to)] == 1} {
		# blot! remove the noturn's checker
		set c($noturn,$tolevel,$to) 0
		# kick the noturn's checker on the bar
		incr c($noturn,$tolevel,$nobar) 
	    }
	    # Put the checker at the new point
	    incr c($turn,$tolevel,$to)
	} else {
	    # Put the checker to bearoff
	    incr c($turn,$tolevel,$nobar)
	}
    }
}

#-------------------------------------------------------------------
proc deep {level d1 d2 d3 d4 movelist kickout} {
    global c turn noturn bar nobar allmoves maxmovelen
    global white black

    # make a list of all possible start points
    if {[set c($turn,$level,$bar)] > 0} {
	# at least one checker is on the bar; try to get it in 
	# only bar is a possible start point
	set plist [list $bar]
    } else {
	# bar is empty
	# get all points with turn's checkers, 
	# from highest to lowest point (important!)
	set plist {}
	for {set p $bar} {$p != $nobar} {incr p [expr -$turn]} {
	    if {[set c($turn,$level,$p)] > 0} {
		# at least one checker is on the point
		lappend plist $p
	    }
	}
    }
    

    # bearoffok indicates that all ckeckers are in the homeboard
    set bearoffok 1

    # block indicates that no move at current level was found
    set block 1

    # firstinplist is 1 only for the highest point in plist.
    # That is the only point from where not exact bearing off is allowed.
    set firstinplist 1

    # loop over all points with turn's checkers,
    # descending from bar towards bear-off.
    foreach p $plist {

	# dicetry monitors the dice permutations
	#  1     - {d1 d2 d3 d4}
	#  2     - {d2 d1 d3 d4}
	#  other - end condition for while loop
	# try with d1 first:
	set dicetry 1
	while {$dicetry == 1 || $dicetry == 2} {
	    set to [expr $p - $d1]
	    set tohomeboard [expr abs($nobar - $to) <= 6]
	    set tobearoffexact [expr $turn * ($nobar - $to) == 0]
	    set tobearoff      [expr $turn * ($nobar - $to) >= 0]
	    if {($to -$nobar) *$turn < 0} {set to $nobar}
	    
	    if {abs($nobar - $p) > 6} {
		# The first point outside the homeboard
		# switches bearoffok off.
		# For this to work properly it was important to
		# have elements in plist descend from bar to bearoff.
		set bearoffok 0
	    }

	    if {($bearoffok && \
		    ($tobearoffexact || ($tobearoff && $firstinplist))) || \
		    (!$tobearoff && ([set c($noturn,$level,$to)] <= 1))} {
		# move from p with d1 ok.
		if {($to -$nobar) *$turn < 0} {
		    set move [list $p [expr $nobar -$p]]
		} else {
		    set move [list $p $d1]
		}
		# as at least this move is possible,
		# the situation is not blocked.
		set block 0

		# nextmovelist is movelist with the new move appended.
		# A seperate variable is necessary to preserve movelist
		# for the next p.
		set nextmovelist $movelist
		lappend nextmovelist $move

		set nextkickout [expr $kickout +($nobar +$turn *$p) *\
			([set c($noturn,$level,$to)] == 1)]

		# Create the potential situation which would be there
		# if move applied.
		set nextlevel [expr $level + 1]
		copylevel $level $nextlevel $move
		
		if {$d2 == 0} {
		    # All dices used. A valid move sequence has been found.

		    # Evaluate the potential final situation.
		    set evaluation [evalsituation $nextlevel $nextkickout]

		    # Add the move sequence to allmoves 
		    lappend allmoves [list $nextmovelist $evaluation]

		    # Check for new maximum length.
		    set nextmovelen [llength $nextmovelist]
		    if {$nextmovelen > $maxmovelen} {
			set maxmovelen $nextmovelen
		    }
		} else {
		    # more dices; try to use them, too.
		    deep $nextlevel $d2 $d3 $d4 0 $nextmovelist $nextkickout
		}
	    }
	    
	    # Permutation of the dices
	    # if d2 is different from d1 and not 0,
	    # and d1 and d2 had not been flipped before,
	    # flip d1 and d2 and try again.
	    if {$d2 != 0 && $d2 != $d1 && $dicetry == 1} {
		set h $d2
		set d2 $d1
		set d1 $h
		set dicetry 2
	    } else {
		# no more tries. get out of the while loop.
		set dicetry 0
	    }
	} 
	# while try dice permutations
	set firstinplist 0
	update
    } 
    # foreach p in plist

    if {$block} {
	# Neither move with d1 nor with d2 was possible.
	# If any move sequence so far, add it to allmoves 
	set movelen [llength $movelist]
	if {$movelen > 0} {

	    # Evaluate the situation.
	    set evaluation [evalsituation $level $kickout]

	    # Add the move sequence to allmoves 
	    lappend allmoves [list $movelist $evaluation]

	    # Check for new maximum length.
	    if {$movelen > $maxmovelen} {
		set maxmovelen $movelen
	    }
	}
    }
    update
    thinker 1
}

#-------------------------------------------------------------------
proc evalsituation {level kickout} {
    global turn noturn c bp bar nobar avmove

    set kickoutrisk 0
    set singlecnt   0

    # Overlap init
    set overlap 0
    # Upward moving player's checkers on the bar.
    # Pending until we know there are checkers from the
    # downward moving player higher than this point.
    set olpending [set c(-1,$level,0)]
    # The overlap starts only after the first checker of
    # the upward moving player was found.
    set olstart [expr $olpending > 0]

    foreach eturn [list $turn $noturn] {
	set single($eturn) 0
	set pvalue($eturn) [expr 25 * [set c($eturn,$level,[set bp($eturn)])]]
	set pnumber($eturn) 0
	set reenter($eturn) 0
	set outhome($eturn) [set pvalue($eturn)]
    }

    for {set pe 1} {$pe <= 24} {incr pe} {
	# overlap
	if {([set c(1,$level,$pe)] > 0) && $olstart} {
	    # Downward moving player's checker found.
	    # The pending overlaps become real ones.
	    # Also add the checkers of the downward moving player.
	    incr overlap [expr $olpending +[set c(1,$level,$pe)]]
	    set olpending 0
	}
	incr olpending [set c(-1,$level,$pe)]
	set olstart [expr $olstart || ([expr $olpending > 0])]

	# for current player and for counterpart player do
	foreach eturn [list $turn $noturn] {
	    set noeturn [expr -$eturn]
	    set minehere [set c($eturn,$level,$pe)]
	    set pvaluehere [expr [set bp($noeturn)] + $eturn *$pe]
	    incr pvalue($eturn) [expr $pvaluehere *$minehere]
	    incr pnumber($eturn) [expr $minehere > 0]
	    incr reenter($noeturn) [expr ($minehere > 1) && ($pvaluehere <= 6)]
	    if {$pvaluehere > 6} {
		incr outhome($eturn) [expr $pvaluehere *$minehere]
	    }

	    if {$minehere == 1} {
		# a single!
		incr singlecnt
		set h 0
		set limit [expr abs([set bp($noeturn)] -$pe)]
		for {set d1 1} {($d1 <= 6) && ($d1 < $limit)} {incr d1} {
		    set pos1 [expr $pe -$eturn *$d1]
		    if {[set c($noeturn,$level,$pos1)] > 0} {
			incr h 6
		    } elseif {[set c($eturn,$level,$pos1)] > 0} {
			for {set d2 1} {($d2 <= 6) && ($d1 +$d2 < $limit)} \
				{incr d1} {
			    set pos2 [expr $pos1 -$eturn *$d2]
			    incr h [expr [set c($noeturn,$level,$pos2)] > 0]
			}
		    }
		}
		set kickoutrisk \
			[expr $kickoutrisk +double($h)/36.0 *\
			([set bp($eturn)] -$eturn *$pe)]
	    }
	    # end if a single
	}
	# end each player
    }
    # for all points from 1 to 24

    # Complete the kickout risk calculation
    set kickoutrisk \
	    [expr $kickoutrisk +$singlecnt *\
	    double([set reenter($turn)])/6.0 *$avmove]

    # Kickout gain is the number of points the counterpart looses by kickout
    # plus the number of kicked out checkers
    # times the probability of not being able to get them in
    # times the average points per move.
    set kickoutgain [expr $kickout +[set c($noturn,$level,$nobar)] *\
	    double([set reenter($noturn)])/6.0 *$avmove]

    # return the evaluation:
    #  0: overlap
    #  1: kickout risk
    #  2: kickout gain
    #  3: self  reenter
    #  4: other reenter
    #  5: self  outside home
    #  6: other outside home
    #  7: self  bearoff
    #  8: other bearoff
    #  9: self  point value
    # 10: other point value
    # 11: self  point number
    # 12: other point number
    return [list $overlap\
	    $kickoutrisk\
	    $kickoutgain\
	    [set reenter($turn)]\
	    [set reenter($noturn)]\
	    [set outhome($turn)]\
	    [set outhome($noturn)]\
	    [set c($turn,$level,$nobar)]\
	    [set c($noturn,$level,$bar)]\
	    [set pvalue($turn)]\
	    [set pvalue($noturn)]\
	    [set pnumber($turn)]\
	    [set pnumber($noturn)]]
}

#-------------------------------------------------------------------
proc select {level} {
    global c turn noturn allmoves bp
   
    # This is the strategy part.

    # Allmoves contains all legal moves plus maybe some move that are
    # shorter than maximum possible in the current situation.
    # As a rule of the game, we must choose only from those moves of
    # maximum length. This is realized by making move length the
    # highest order selection criterion.

    # The strategy is based on a hierarchy of selection criteria.
    # It compares all moves, searching for maximum gain.
    # It selects all moves with maximum value at the highest order selection
    # criterion,
    # among them all with maximum value at the second to highest
    # selection criterion, and so on.
    # If no more criteria, it simply takes the first in the list of
    # selected moves.
    # If the list is empty, no legal move is possible in this situation
    # and the computer can't make any move.

    # Get the point values of the current situation.
    # This is needed for the aggressivity calculation.
    set pvalue($turn) 0
    set pvalue($noturn) 0
    foreach eturn [list $turn $noturn] {
	for {set pe 1} {$pe <= 24} {incr pe} {
	    set minehere [set c($eturn,$level,$pe)]
	    set pvaluehere [expr [set bp([expr -$eturn])] + $eturn *$pe]
	    incr pvalue($eturn) [expr $pvaluehere *$minehere]
	}
    }

    # The aggressivity:
    # Based on how much the player is behind or ahead of the counterpart,
    # set the behavior on a scale from defensive (-1) to aggressive (1).
    # Be more defensive when more ahead of the counterpart,
    # Be more aggressive when more behind of the counterpart.
    set a [set pvalue($turn)]
    set b [set pvalue($noturn)]
    if {$a *$b} {
	# Neither one is 0
	if {$a > $b} {
	    # Counterpart is ahead. Be more aggressive.
	    set agg [expr double($a -$b) / double($a)]
	} else {
	    # Player is ahead. Be more defensive.
	    set agg [expr double($a -$b) / double($b)]
	}
	# puts "Aggressivity: $agg"
    } else {
	puts "Backgammon: Program error: Game should be over."
    }

    # The selection criteria:
    set overlap 0
    set kickoutrisk 1
    set kickoutgain 2
    set selfreenter 3
    set otherreenter 4
    set selfoutsidehome 5
    set otheroutsidehome 6
    set selfbearoff 7
    set otherbearoff 8
    set selfpointvalue 9
    set otherpointvalue 10
    set selfpointnumber 11
    set otherpointnumber 12

    set criterion(1) {$candlen}
    set criterion(2) {[lindex $cand $overlap] > 0}
    set criterion(3) {([lindex $cand $overlap] > 0) *\
	    ([lindex $cand $kickoutgain] -[lindex $cand $kickoutrisk])}
    set criterion(4) {-[lindex $cand $selfoutsidehome]}
    set criterion(5) {[lindex $cand $selfbearoff]}
    set criterion(6) {-[lindex $cand $selfpointvalue]}
    set criterion(7) {[lindex $cand $selfpointnumber]}
    set criterion(8) {-[lindex $cand $otherreenter]}

    # The selection algorithm.
    set bestmove [lindex $allmoves 0]
    set besteval [lindex $bestmove 1]
    set bestlen  [llength [lindex $bestmove 0]]
    # puts "Initial best: $bestmove"
    foreach compmove $allmoves {
	set compeval [lindex $compmove 1]
	set complen  [llength [lindex $compmove 0]]
	set h 0
	set best 0
	set comp 0
	while {($best == $comp) && ($h < 8)} {
	    # Same value at this hierarchy. Try next hierarchy.
	    incr h

	    set cand $besteval
	    set candlen $bestlen
	    set best [expr [set criterion($h)]]

	    set cand $compeval
	    set candlen $complen
	    set comp [expr [set criterion($h)]]
	}
	if {$comp > $best} {
	    # found a new maximum
	    # puts "At criterion $h, comp=$comp > best=$best"
	    # puts "    New best: $compmove"

	    set bestmove $compmove
	    set besteval $compeval
	}
	thinker 1
    }

    # puts ""
    # Return the best move
    return $bestmove
}


#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	GUI Procedures
#


#-------------------------------------------------------------------
proc undocmd {} {
    global undook
    
    if {$undook} {
	copylevel 4 0 {}
	showcheckers 0
    }
}


#-------------------------------------------------------------------
proc showboard {style} {
    global boardlist boardstyle
    global s s2 x0 x1 x2 x3 y0 y1 y2 fcol fbcol

    # style: -1 - plain, 0 - toggle style

    if {$style == 0} {
	set boardstyle [expr -$boardstyle]
    } else {
	set boardstyle $style
    }

    foreach boardelem $boardlist {.c delete $boardelem}
    set boardlist {}

    set xx1 [expr $x0 +$x1]
    set xx2 [expr $x0 +$x2]
    set xx3 [expr $x0 +$x3]
    set yy1 [expr $y0 +$y1]
    set yy2 [expr $y0 +$y2]
    set xm1 [expr $x0 -$x1]
    set xm2 [expr $x0 -$x2]
    set xm3 [expr $x0 -$x3]
    set ym1 [expr $y0 -$y1]
    set ym2 [expr $y0 -$y2]
    
    set rectfill grey
    set polyw 2

    lappend boardlist [.c create rect $xm3 $yy2 $xm2 $ym2 \
	    -width 4 -fill $rectfill]
    lappend boardlist [.c create rect $xm1 $yy2 $xx1 $ym2 \
	    -width 4 -fill $rectfill]
    lappend boardlist [.c create rect $xx3 $yy2 $xx2 $ym2 \
	    -width 4 -fill $rectfill]

    for {set i 0} {$i < 12} {incr i} {
	set pox1 [expr $xm2 + $s * ($i + $i / 6)]
	set pox2 [expr $pox1 + $s2]
	set pox3 [expr $pox1 + $s]

	set pox4 [expr $xx2 - $s * ($i + $i / 6)]
	set pox5 [expr $pox4 - $s2]
	set pox6 [expr $pox4 - $s]

	set imod [expr $i % 2]

	lappend boardlist [.c create polygon $pox1 $yy2 $pox2 $yy1 $pox3 $yy2 \
		-fill [set fcol($boardstyle,$imod)] \
		-outline [set fbcol($boardstyle,$imod)] -width $polyw]
	lappend boardlist [.c create polygon $pox4 $ym2 $pox5 $ym1 $pox6 $ym2 \
		-fill [set fcol($boardstyle,$imod)] \
		-outline [set fbcol($boardstyle,$imod)] -width $polyw]
    }   

    foreach boardelem $boardlist {.c lower $boardelem}
}
 

#-------------------------------------------------------------------
proc showcheckers {showlevel} {
    global c checkerlist white black posx posy boposx boposy 
    global s s2 bp col xori pcol x0 y0 checkertag

    foreach checker $checkerlist {.c delete $checker}
    set checkerlist {}

    for {set p 0} {$p <= 25} {incr p} {
	foreach player [list 1 -1] {
	    set pp [expr [set bp([expr -$player])] +$player * $p]
	    for {set ch 1} {$ch <= [set c($player,$showlevel,$pp)]} {incr ch} {
		set x [expr $x0 +$xori * [set posx($p,$ch)]]
		set y [expr $y0 -$player * [set posy($p,$ch)]]

		set item [.c create oval [expr $x -$s2] [expr $y -$s2] \
			[expr $x +$s2] [expr $y +$s2] \
			-fill [set col([expr $player * $pcol],1)] \
			-outline [set col([expr $player * $pcol],2)] -width 2]
		.c addtag [set checkertag($player)] withtag $item
		lappend checkerlist $item
	    }
	}
    }
    update
}


#-------------------------------------------------------------------
proc showdices {} {
    global dice1 dice2 dicelist x0 y0 dicex dicecol pcol
    
    if {$dice1 && $dice2} {
	foreach dicebmp $dicelist {.c delete $dicebmp}
	set dicelist {}
	set d1 [expr abs($dice1)]
	set d2 [expr abs($dice2)]
	set dsign [expr $dice1 / abs($dice1)]
	
	set item [.c create image [expr $x0 - $dsign * $dicex(1)] $y0 \
		-image dice($d1) \
		-anchor c]
	dice($d1) configure -background [set dicecol([expr $dsign * $pcol])]

	lappend dicelist $item
	set item [.c create image [expr $x0 - $dsign * $dicex(2)] $y0 \
		-image dice($d2) \
		-anchor c]
	dice($d2) configure -background [set dicecol([expr $dsign * $pcol])]

	lappend dicelist $item
	update
    }
}


#-------------------------------------------------------------------
proc thinker {mode} {
    global thinkerlist thinkercnt
    global thinknot think
    # modes: 0 "watch on", 1 "think", -1 "off"
    
    foreach thinkerbmp $thinkerlist {.c delete $thinkerbmp}
    set thinkerlist {}

    if {$mode == 0} {
	lappend thinkerlist [.c create image 80 14 \
		-image thinknot \
		-anchor nw]
    } elseif {$mode == 1} {
	set thinkercnt [expr ([incr thinkercnt]) % 8 + 1]
	lappend thinkerlist [.c create image 80 14 \
		-image think($thinkercnt) \
		-anchor nw]
    }
}


#-------------------------------------------------------------------
# grabchecker --
# This procedure is invoked when the mouse is pressed over one of the
# data points.  It sets up state to allow the point to be dragged.
#
# Arguments:
# w -		The canvas window.
# x, y -	The coordinates of the mouse press.

proc grabchecker {w x y} {
    global lastX lastY x0 x3 s2 s y0 y1 y2 mapxy2p mapp2x fromP toP xori
     
    $w dtag selected
    $w addtag selected withtag current
    $w raise current

    set snapx $x
    if {$snapx <= ($x0 -$x3)} {set snapx [expr $x0 -$x3 +1]}
    if {$snapx >= ($x0 +$x3)} {set snapx [expr $x0 +$x3 -1]}
    set gridx [expr ($snapx -$x0 +$s2) / $s]
    
    set snapy [expr abs($y0 -$y)]
    set yminus [expr $y0 < $y]
    if {$snapy < $y1 +$s2} {set snapy [expr $y1 +$s2]}
    if {$snapy > $y2 -$s2} {set snapy [expr $y2 -$s2]}
    set snapy [expr $y0 +($yminus *2 -1) *$snapy]

    set fromP [lindex [lindex $mapxy2p $yminus] [expr $xori *$gridx +7]]
    set toP $fromP
    set snapx [expr $x0 +$s * $xori *[lindex $mapp2x $fromP]]

    set lastX $snapx
    set lastY $snapy
}


#-------------------------------------------------------------------
# movechecker --
# This procedure is invoked during mouse motion events.  It drags the
# current item.
#
# Arguments:
# w -		The canvas window.
# x, y -	The coordinates of the mouse.

proc movechecker {w x y} {
    global lastX lastY x0 x3 s2 s y0 y1 y2 mapxy2p mapp2x xori toP

    set snapx $x
    if {$snapx <= ($x0 -$x3)} {set snapx [expr $x0 -$x3 +1]}
    if {$snapx >= ($x0 +$x3)} {set snapx [expr $x0 +$x3 -1]}
    set gridx [expr ($snapx -$x0 +$s2) / $s]
    
    set snapy [expr abs($y0 -$y)]
    set yminus [expr $y0 < $y]
    if {$snapy < $y1 +$s2} {set snapy [expr $y1 +$s2]}
    if {$snapy > $y2 -$s2} {set snapy [expr $y2 -$s2]}
    set snapy [expr $y0 +($yminus *2 -1) *$snapy]

    set toP [lindex [lindex $mapxy2p $yminus] [expr $xori *$gridx +7]]
    set snapx [expr $x0 +$s * $xori *[lindex $mapp2x $toP]]
    $w move selected [expr $snapx -$lastX] [expr $snapy -$lastY]

    set lastX $snapx
    set lastY $snapy
}


#-------------------------------------------------------------------
# releasechecker --
# This procedure is invoked when the mouse is relased.
#
# Arguments:
# w -		The canvas window.
# x, y -	The coordinates of the mouse.

proc releasechecker {w x y} {
    global fromP toP c

    $w dtag selected

    # 1: Computer, -1: Player
    if {[set c(1,0,$toP)] <= 1} {
	incr c(-1,0,$fromP) -1
	incr c(-1,0,$toP)

	if {([set c(1,0,$toP)] == 1) && ($toP < 25)} {
	    incr c(1,0,$toP) -1
	    incr c(1,0,25)
	}
    }
    showcheckers 0
}


#-------------------------------------------------------------------
# GUI Inits
proc guiinit {} {
    global checkerlist dicelist boardlist thinkerlist thinkercnt
    global boardstyle xori pcol totturn plot checkertag
    global s2 os x0 y0 brown col fcol fbcol dicecol
    global plotFont miniFont largeFont mapxy2p mapp2x
    global s x1 x2 x3 y1 y2 posx posy
    global px1 py1 cx1 cy1 px2 px3 dicex
    global data thinknot think dice

    set checkerlist {}
    set dicelist {}
    set boardlist {}
    set thinkerlist {}
    set thinkercnt 0

    set boardstyle -1 ;# plain style
    set xori 1
    set pcol 1
    set totturn -2
    set plot(lastX) 0
    set plot(lastY) 0
    set checkertag(1)  compckecker
    set checkertag(-1) playerchecker


    # Graphic parameters

    set s2 15		;# half size of a checker
    set os 4		;# displacement of piled up checkers
    set x0 [expr $s2 *15 +10]		;# center of the board
    set y0 [expr $s2 *11 +40]		;# center of the board

    set brown "brown"
    set col(1,1) white	;# white checkers
    set col(1,2) black	;# border of white checkers
    set col(1,3) grey	;# when mouse enters white checkers
    set col(-1,2) $brown	;# border of black checkers
    set col(-1,1) black	;# black checkers
    set col(-1,3) dimgrey	;# when mouse enters black checkers

    set fcol(1,0) ""
    set fcol(1,1) ""
    set fbcol(1,0) $brown
    set fbcol(1,1) white
    set fcol(-1,0) $brown
    set fcol(-1,1) white
    set fbcol(-1,0) black
    set fbcol(-1,1) black

    set dicecol(1)  white
    set dicecol(-1) $brown

    set plotFont {-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*}
    set miniFont {-*-Helvetica-Medium-R-Normal--*-80-*-*-*-*-*-*}
    set largeFont {-*-times-bold-r-normal-*-40-400-*-*-*-*-*-*}


    set mapxy2p {{1  1  2  3  4  5  6  0  7  8  9 10 11 12 12} \
	    {25 24 23 22 21 20 19 19 18 17 16 15 14 13 13}}
    set mapp2x {0 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 6 5 4 3 2 1\
	    -1 -2 -3 -4 -5 -6 -7}


    # Graphic variables

    set s [expr 2 * $s2]
    set x1 $s2
    set x2 [expr $s2 + 6 * $s]
    set x3 [expr $s2 + 7 * $s]
    set y1 $s2
    set y2 [expr $s2 + 5 * $s]

    # Bear off coordinates
    for {set py 1} {$py <= 15} {incr py} {
	set posx(0,$py) [expr -7 * $s]
	set posy(0,$py) [expr 5 * $s -$os * ($py - 1)]
    }

    # Bar coordinates
    for {set py 1} {$py <= 15} {incr py} {
	set posx(25,$py) 0
	set posy(25,$py) [expr -$s -$os * ($py - 1)]
    }

    # All other coordinates
    for {set px 0} {$px <= 5} {incr px} {
	for {set py 0} {$py <= 14} {incr py} {
	    # First board
	    set px1 [expr $px + 1]
	    set py1 [expr $py + 1]
	    set cx1 [expr ($px - 6) * $s + $os * ($py / 5)]
	    set cy1 [expr (5 - ($py % 5)) * $s - $os * ($py / 5)]
	    set posx($px1,$py1) $cx1
	    set posy($px1,$py1) $cy1

	    # Second board
	    set px2 [expr $px + 7]
	    set posx($px2,$py1) [expr $cx1 + 7 * $s]
	    set posy($px2,$py1) $cy1

	    # Third board
	    set px3 [expr $px + 13]
	    set posx($px3,$py1) [expr -$cx1]
	    set posy($px3,$py1) [expr -$cy1]

	    # Fourth board
	    set px3 [expr $px + 19]
	    set posx($px3,$py1) [expr -$cx1 - 7 * $s]
	    set posy($px3,$py1) [expr -$cy1]
	}
    }

    # Dice coordinates
    set dicex(1) [expr 3 * $s]
    set dicex(2) [expr 4 * $s]

    # Create the bitmap images
    image create bitmap thinknot -data $data(think.bmp)
    thinknot configure -background ""

    for {set thinkercnt 0} {$thinkercnt <= 8} {incr thinkercnt} {
	image create bitmap think($thinkercnt) \
		-data [set data(think${thinkercnt}.bmp)]
	think($thinkercnt) configure -background ""
    }

    for {set dicecnt 1} {$dicecnt <= 6} {incr dicecnt} {
	image create bitmap dice($dicecnt) \
		-data [set data(dice${dicecnt}.bmp)]
	# dice($dicecnt) configure -background ""
    }
}


#-------------------------------------------------------------------
# Buttons: Quit, Undo, Go, Restart, Board
proc makebuttons {} {
    frame .buttons
    pack .buttons -side bottom -fill x -pady 2m
    button .buttons.restart -text Start \
	    -command "set restartrequest 1; set playerdone 1"
    button .buttons.undo -text Undo -command "undocmd"
    button .buttons.go -text " Go " -command "set playerdone 1"
    button .buttons.side -text Side -command {set xori [expr -$xori]; \
	    showcheckers 0; showdices}
    button .buttons.color -text Color -command {set pcol [expr -$pcol]; \
	    showcheckers 0; showdices}
    pack .buttons.restart .buttons.undo .buttons.go \
	    .buttons.side .buttons.color -side left -expand 1 -fill x
}


#-------------------------------------------------------------------
# Canvas graphic elements
proc makecanvas {} {
    global x0 y2 plotFont brown x2 y2 y0 col pcol 

    canvas .c -relief raised -width [expr 2 * $x0] -height [expr 2 * $y2 + 40]
    pack .c -side top -fill x

    .c create text $x0 20 -text "Phi's Backgammon" \
	    -font $plotFont -fill $brown
    .c create rect [expr $x0 -$x2] [expr $y0 -$y2] \
	    [expr $x0 +$x2] [expr $y0 +$y2] -width 4

    .c bind compckecker <Any-Enter> {.c itemconfig current \
	    -fill [set col($pcol,3)]}
    .c bind playerchecker <Any-Enter> {.c itemconfig current \
	    -fill [set col([expr -$pcol],3)]}
    .c bind compckecker <Any-Leave> {.c itemconfig current \
	    -fill [set col($pcol,1)]}
    .c bind playerchecker <Any-Leave> {.c itemconfig current \
	    -fill [set col([expr -$pcol],1)]}
    .c bind playerchecker <1> "grabchecker .c %x %y"
    .c bind playerchecker <ButtonRelease-1> "releasechecker .c %x %y"
    .c bind playerchecker <B1-Motion> "movechecker .c %x %y"
}


#-------------------------------------------------------------------
# Init
proc init {} {
    global boardstyle

    gameinit
    bitmapdata
    guiinit
    makecanvas
    makebuttons

    # Create the board
    showboard $boardstyle
    showcheckers 0
}


#-------------------------------------------------------------------
# Main loop
proc main {} {
    global restartrequest compwon playerwon 
    global x0 y0 largeFont totturns

    set compwon 0
    set playerwon 0
    while 1 {
	# Wait for pressing "Start"
	set restartrequest 0
	vwait restartrequest

	# Start a new game
	if $playerwon {.c delete $won}
	if $compwon {.c delete $lost}
	set compwon 0
	set playerwon 0

	while {!$compwon && !$playerwon} {
	    set restartrequest 0
	    restart
	}

	if $playerwon {
	    set won [.c create text $x0 $y0 \
		    -text "You won in $totturns turns!" \
		    -font $largeFont -fill red -anchor center]
	}
	if $compwon {
	    set lost [.c create text $x0 $y0 \
		    -text "You lost in $totturns turns!" \
		    -font $largeFont -fill red -anchor center]
	}
    }
}

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	The picdata (machine generated)
#

proc bitmapdata {} {
    global data

set data(dice1.bmp) {
   #define dice1_width 27
   #define dice1_height 27
   static unsigned char dice1_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x70, 0x00, 0x06,
      0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06,
      0x03, 0x70, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice2.bmp) {
   #define dice2_width 27
   #define dice2_height 27
   static unsigned char dice2_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x00, 0x06,
      0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06,
      0xc3, 0x01, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x1c, 0x06,
      0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06,
      0x03, 0x00, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice3.bmp) {
   #define dice3_width 27
   #define dice3_height 27
   static unsigned char dice3_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x00, 0x06,
      0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06,
      0xc3, 0x01, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x70, 0x00, 0x06,
      0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06,
      0x03, 0x70, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x1c, 0x06,
      0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06,
      0x03, 0x00, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice4.bmp) {
   #define dice4_width 27
   #define dice4_height 27
   static unsigned char dice4_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice5.bmp) {
   #define dice5_width 27
   #define dice5_height 27
   static unsigned char dice5_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x70, 0x00, 0x06,
      0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06,
      0x03, 0x70, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice6.bmp) {
   #define dice6_width 27
   #define dice6_height 27
   static unsigned char dice6_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(think.bmp) {
   #define think_width 23
   #define think_height 15
   static unsigned char think_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x60, 0x30, 0x00, 0x10, 0x40, 0x00,
      0x08, 0x80, 0x00, 0x08, 0x80, 0x00, 0x08, 0x9b, 0x00, 0x04, 0x9b, 0x00,
      0x73, 0x40, 0x00, 0xde, 0x3f, 0x00, 0x00, 0x00, 0x00};
}
set data(think0.bmp) {
   #define think1_width 23
   #define think1_height 15
   static unsigned char think1_bits[] = {
      0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x60, 0x30, 0x00, 0x10, 0x40, 0x00,
      0x50, 0x60, 0x00, 0x88, 0x99, 0x00, 0x08, 0x89, 0x00, 0x08, 0x80, 0x00,
      0x08, 0x89, 0x00, 0x08, 0x80, 0x00, 0x08, 0x40, 0x00, 0x04, 0x40, 0x00,
      0x73, 0x30, 0x00, 0xde, 0x1f, 0x00, 0x00, 0x00, 0x00};
}
set data(think1.bmp) {
   #define think2_width 23
   #define think2_height 15
   static unsigned char think2_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xc0, 0x60, 0x00,
      0x20, 0x80, 0x00, 0x90, 0x40, 0x01, 0x10, 0x33, 0x01, 0x10, 0x12, 0x01,
      0x10, 0x00, 0x01, 0x10, 0x12, 0x01, 0x10, 0x80, 0x00, 0x08, 0x80, 0x00,
      0xe6, 0x60, 0x00, 0xbc, 0x3f, 0x00, 0x00, 0x00, 0x00};
}
set data(think2.bmp) {
   #define think3_width 23
   #define think3_height 15
   static unsigned char think3_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x83, 0x01, 0x80, 0x00, 0x02,
      0x80, 0x02, 0x03, 0x40, 0xcc, 0x04, 0x40, 0x48, 0x04, 0x40, 0x00, 0x04,
      0x40, 0x48, 0x04, 0x40, 0x00, 0x04, 0x40, 0x00, 0x02, 0x20, 0x00, 0x02,
      0x98, 0x83, 0x01, 0xf0, 0xfe, 0x00, 0x00, 0x00, 0x00};
}
set data(think3.bmp) {
   #define think4_width 23
   #define think4_height 15
   static unsigned char think4_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x06, 0x03,
      0x00, 0x01, 0x04, 0x80, 0x04, 0x0a, 0x80, 0x98, 0x09, 0x80, 0x90, 0x08,
      0x80, 0x00, 0x08, 0x80, 0x90, 0x08, 0x80, 0x00, 0x04, 0x40, 0x00, 0x04,
      0x30, 0x07, 0x03, 0xe0, 0xfd, 0x01, 0x00, 0x00, 0x00};
}
set data(think4.bmp) {
   #define think6_width 23
   #define think6_height 15
   static unsigned char think6_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x06, 0x03, 0x00, 0x01, 0x04,
      0x00, 0x03, 0x05, 0x80, 0xcc, 0x08, 0x80, 0x48, 0x08, 0x80, 0x00, 0x08,
      0x80, 0x48, 0x08, 0x80, 0x00, 0x08, 0x00, 0x01, 0x08, 0x00, 0x01, 0x10,
      0x00, 0x06, 0x67, 0x00, 0xfc, 0x3d, 0x00, 0x00, 0x00};
}
set data(think5.bmp) {
   #define think7_width 23
   #define think7_height 15
   static unsigned char think7_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x01, 0x01,
      0x80, 0x00, 0x02, 0x40, 0x81, 0x04, 0x40, 0x66, 0x04, 0x40, 0x24, 0x04,
      0x40, 0x00, 0x04, 0x40, 0x24, 0x04, 0x80, 0x00, 0x04, 0x80, 0x00, 0x08,
      0x00, 0x83, 0x33, 0x00, 0xfe, 0x1e, 0x00, 0x00, 0x00};
}
set data(think6.bmp) {
   #define think8_width 23
   #define think8_height 15
   static unsigned char think8_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xc0, 0x60, 0x00, 0x20, 0x80, 0x00,
      0x60, 0xa0, 0x00, 0x90, 0x19, 0x01, 0x10, 0x09, 0x01, 0x10, 0x00, 0x01,
      0x10, 0x09, 0x01, 0x10, 0x00, 0x01, 0x20, 0x00, 0x01, 0x20, 0x00, 0x02,
      0xc0, 0xe0, 0x0c, 0x80, 0xbf, 0x07, 0x00, 0x00, 0x00};
}
set data(think7.bmp) {
   #define think9_width 23
   #define think9_height 15
   static unsigned char think9_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x20, 0x20, 0x00,
      0x10, 0x40, 0x00, 0x28, 0x90, 0x00, 0xc8, 0x8c, 0x00, 0x88, 0x84, 0x00,
      0x08, 0x80, 0x00, 0x88, 0x84, 0x00, 0x10, 0x80, 0x00, 0x10, 0x00, 0x01,
      0x60, 0x70, 0x06, 0xc0, 0xdf, 0x03, 0x00, 0x00, 0x00};
}
set data(think8.bmp) {
   #define think9_width 23
   #define think9_height 15
   static unsigned char think9_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x20, 0x20, 0x00,
      0x10, 0x40, 0x00, 0x28, 0x90, 0x00, 0xc8, 0x8c, 0x00, 0x88, 0x84, 0x00,
      0x08, 0x80, 0x00, 0x88, 0x84, 0x00, 0x10, 0x80, 0x00, 0x10, 0x00, 0x01,
      0x60, 0x70, 0x06, 0xc0, 0xdf, 0x03, 0x00, 0x00, 0x00};
}


}

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	Call init and main
#

init
main

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------
</script>

Added Demo/Applets/backgammon.html.































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<HTML>
<HEAD>
   <TITLE>Phi's Backgammon Tclet</TITLE>
</HEAD>
<BODY>

<center>
<embed src=backgammon.tcl width=473 height=415>
</center>

<HR SIZE=4 NOSHADE WIDTH="100%">
<P>
You need the <A HREF="http://sunscript.sun.com/">Tcl Plugin</A> to play the backgammon game on this page.
</P>

<P>
Download full versions
 (You need <A HREF="http://sunscript.sun.com/">Tcl/Tk</A> to run them):<BR>
<A HREF="backgammon1.1.tgz">backgammon1.1.tgz</A>, 
<A HREF="backgammon1.1.zip">backgammon1.1.zip</A> 
 (Version 1.1, 1998/01/11)<BR>
<A HREF="backgammon1.0.tgz">backgammon1.0.tgz</A>,
<A HREF="backgammon1.0.zip">backgammon1.0.zip</A>
 (former version 1.0)
</P>

<P>
Tired of playing in front of the computer?<BR>
Have your next backgammon match in real life in the relaxed atmoshere of<BR>
<A HREF="http://www.belizecaye.com"><IMG SRC="pic/caye.gif" BORDER=0></A>
</P>

<HR SIZE=4 NOSHADE WIDTH="100%">
<I>
Last modified : 22.05.98<BR>
First edit: 31.01.98
</I>

<ADDRESS><A HREF="http://www.fujita3.iis.u-tokyo.ac.jp~/ignaz/">Veit Ignaz Kohlbecker</A>,
 <I><A HREF="mailto:ignaz@fujita3.iis.u-tokyo.ac.jp">ignaz@fujita3.iis.u-tokyo.ac.jp</A></I>
</ADDRESS>

<HR SIZE=4 NOSHADE WIDTH="100%">

</BODY>
</HTML>
]

Added Demo/Applets/backgammon.tcl.









































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
#
#	backgammon tclet
#
#	Backgammon
#	by Ignaz KOHLBECKER
#	ignaz@fujita3.iis.u-tokyo.ac.jp
#
#	Distribution and modifications of this program and its associated
#	files are possible under the conditions of the
#	GNU Public License (GPL).
#
#	History:
#
#	97/08/13	first edit.
#	97/08/25	V1.0 last edit version 1.0.
#	98/01/11	V1.1 jot and rand()
#	98/01/30	tclet version: no exec, toplevel, wm, tkwait, @;
#			instead vwait, bitmap->image, bitmap data inline
#	98/01/31	no puts, trash unnecessary stuff
#


#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	Game Procedures
#


#-------------------------------------------------------------------
proc gameinit {} {
    global progname bp bop avmove diceexpr
    global c totturns dice1 dice2 undook
    set checkerinit {6 6 6 6 6 8 8 8 13 13 13 13 13 24 24}

    set progname "Phi's Backgammon Tclet V1.1"

    # The points on the board are numbered 1 to 24.
    # Player  1 moves from 24 downward to  1.
    # Player -1 moves from  1 upward   to 24.
    # Bar      for player 1 is 25, for player -1 is  0.
    # Bear-off for player 1 is  0, for player -1 is 25.

    set bp(1)  25 ;# bar position
    set bp(-1)  0 ;# bar position
    set bop(1)   0 ;# bear off position
    set bop(-1) 25 ;# bear off position

    # The average outcome of two dices with doubling in case of two equals:
    # 2 * 1/6 * Sum[i,{i,1,6}] + 1/36 * Sum[2i,{i,1,6}] = 8 1/6
    set avmove 8.167

    # The expression to throw a dice
    set diceexpr {expr {1 + int(6 * rand())}}

    for {set level 0} {$level <= 4} {incr level} {
	for {set p 0} {$p <= 25} {incr p} {
	    set c(1,$level,$p) 0
	    set c(-1,$level,$p) 0
	}
	
	foreach number $checkerinit {
	    incr c(1,$level,$number)
	    incr c(-1,$level,[expr 25 - $number])
	}
    }
    set totturns 0
    set dice1 0
    set dice2 0
    set undook 0
}

#-------------------------------------------------------------------
proc restart {} {
    global restartrequest dice1 dice2 turn noturn bar nobar undook
    global playerdone c bp totturns compwon playerwon
    global diceexpr

    # Put all checkers in start position
    gameinit
    showcheckers 0
    
    # Throw dices unil two different numbers
    while {[set dice1 [eval $diceexpr]] == [set dice2 [eval $diceexpr]]} {}
    # Decide who begins the game.
    if {$dice1 > $dice2} {
	# Computer begins
	set turn 1
	set noturn -1
    } else {
	# Player begins
	set turn -1
	set noturn 1
    }
    
    while {!$restartrequest && !$compwon && !$playerwon} {
	set bar [set bp($turn)]
	set nobar [set bp($noturn)]
	set dice1 [expr $turn * $dice1]
	set dice2 [expr $turn * $dice2]
	showdices
	
	incr totturns
	if {$turn == 1} {
	    # Computers move
	    compmove $dice1 $dice2
	    
	    if {[set c(1,0,$nobar)] == 15} {
		# The computer won.
		#puts "Backgammon: Computer won in $totturns turns."
		set compwon 1
	    }
	} else {
	    # Players move
	    thinker 0

	    # Store game in level 4 for Undo
	    copylevel 0 4 {}
	    # Enable the Undo-Button
	    set undook 1
	    
	    set playerdone 0
	    # Wait for the player to do his moves and
	    # return control by pressing "Go"
	    vwait playerdone
	    
	    if {[set c(-1,0,$nobar)] == 15} {
		# The player won.
		#puts "Backgammon: Player won in $totturns turns."
		set playerwon 1
	    }
	    # Disable the Undo-Button
	    set undook 0
	    
	    thinker -1
	}
	# Flip turn; get new dices
	set h $turn
	set turn $noturn
	set noturn $h
	set dice1 [eval $diceexpr]
	set dice2 [eval $diceexpr]
	
	update
    }
    # done|quit|won
}

#-------------------------------------------------------------------
proc compmove {d1 d2} {
    global allmoves maxmovelen

    set allmoves {}
    set maxmovelen 0
    thinker 1
    if {$d1 == $d2} {
	deep 0 $d1 $d1 $d1 $d1 {} 0
    } else {
	deep 0 $d1 $d2 0 0 {} 0
    }

    set pickmove [select 0]
    # puts "$pickmove"
    foreach m [lindex $pickmove 0] {copylevel 0 0 $m}
    
    showcheckers 0
    thinker -1
}

#-------------------------------------------------------------------
proc copylevel {fromlevel tolevel move} {
    global c turn noturn bar nobar allmoves

    if {$fromlevel != $tolevel} {
	for {set i 0} {$i <= 25} {incr i} {
	    foreach ii [list $turn $noturn] {
		set c($ii,$tolevel,$i)   [set c($ii,$fromlevel,$i)]	
	    }
	}
    }

    if {$move != {}} {
	set from [lindex $move 0]
	# Remove the checker from where it was
	incr c($turn,$tolevel,$from) -1

	set to [expr $from - [lindex $move 1]]
	
	if {($to > 0) && ($to < 25)} {
	    # blot might be possible
	    if {[set c($noturn,$tolevel,$to)] == 1} {
		# blot! remove the noturn's checker
		set c($noturn,$tolevel,$to) 0
		# kick the noturn's checker on the bar
		incr c($noturn,$tolevel,$nobar) 
	    }
	    # Put the checker at the new point
	    incr c($turn,$tolevel,$to)
	} else {
	    # Put the checker to bearoff
	    incr c($turn,$tolevel,$nobar)
	}
    }
}

#-------------------------------------------------------------------
proc deep {level d1 d2 d3 d4 movelist kickout} {
    global c turn noturn bar nobar allmoves maxmovelen
    global white black

    # make a list of all possible start points
    if {[set c($turn,$level,$bar)] > 0} {
	# at least one checker is on the bar; try to get it in 
	# only bar is a possible start point
	set plist [list $bar]
    } else {
	# bar is empty
	# get all points with turn's checkers, 
	# from highest to lowest point (important!)
	set plist {}
	for {set p $bar} {$p != $nobar} {incr p [expr -$turn]} {
	    if {[set c($turn,$level,$p)] > 0} {
		# at least one checker is on the point
		lappend plist $p
	    }
	}
    }
    

    # bearoffok indicates that all ckeckers are in the homeboard
    set bearoffok 1

    # block indicates that no move at current level was found
    set block 1

    # firstinplist is 1 only for the highest point in plist.
    # That is the only point from where not exact bearing off is allowed.
    set firstinplist 1

    # loop over all points with turn's checkers,
    # descending from bar towards bear-off.
    foreach p $plist {

	# dicetry monitors the dice permutations
	#  1     - {d1 d2 d3 d4}
	#  2     - {d2 d1 d3 d4}
	#  other - end condition for while loop
	# try with d1 first:
	set dicetry 1
	while {$dicetry == 1 || $dicetry == 2} {
	    set to [expr $p - $d1]
	    set tohomeboard [expr abs($nobar - $to) <= 6]
	    set tobearoffexact [expr $turn * ($nobar - $to) == 0]
	    set tobearoff      [expr $turn * ($nobar - $to) >= 0]
	    if {($to -$nobar) *$turn < 0} {set to $nobar}
	    
	    if {abs($nobar - $p) > 6} {
		# The first point outside the homeboard
		# switches bearoffok off.
		# For this to work properly it was important to
		# have elements in plist descend from bar to bearoff.
		set bearoffok 0
	    }

	    if {($bearoffok && \
		    ($tobearoffexact || ($tobearoff && $firstinplist))) || \
		    (!$tobearoff && ([set c($noturn,$level,$to)] <= 1))} {
		# move from p with d1 ok.
		if {($to -$nobar) *$turn < 0} {
		    set move [list $p [expr $nobar -$p]]
		} else {
		    set move [list $p $d1]
		}
		# as at least this move is possible,
		# the situation is not blocked.
		set block 0

		# nextmovelist is movelist with the new move appended.
		# A seperate variable is necessary to preserve movelist
		# for the next p.
		set nextmovelist $movelist
		lappend nextmovelist $move

		set nextkickout [expr $kickout +($nobar +$turn *$p) *\
			([set c($noturn,$level,$to)] == 1)]

		# Create the potential situation which would be there
		# if move applied.
		set nextlevel [expr $level + 1]
		copylevel $level $nextlevel $move
		
		if {$d2 == 0} {
		    # All dices used. A valid move sequence has been found.

		    # Evaluate the potential final situation.
		    set evaluation [evalsituation $nextlevel $nextkickout]

		    # Add the move sequence to allmoves 
		    lappend allmoves [list $nextmovelist $evaluation]

		    # Check for new maximum length.
		    set nextmovelen [llength $nextmovelist]
		    if {$nextmovelen > $maxmovelen} {
			set maxmovelen $nextmovelen
		    }
		} else {
		    # more dices; try to use them, too.
		    deep $nextlevel $d2 $d3 $d4 0 $nextmovelist $nextkickout
		}
	    }
	    
	    # Permutation of the dices
	    # if d2 is different from d1 and not 0,
	    # and d1 and d2 had not been flipped before,
	    # flip d1 and d2 and try again.
	    if {$d2 != 0 && $d2 != $d1 && $dicetry == 1} {
		set h $d2
		set d2 $d1
		set d1 $h
		set dicetry 2
	    } else {
		# no more tries. get out of the while loop.
		set dicetry 0
	    }
	} 
	# while try dice permutations
	set firstinplist 0
	update
    } 
    # foreach p in plist

    if {$block} {
	# Neither move with d1 nor with d2 was possible.
	# If any move sequence so far, add it to allmoves 
	set movelen [llength $movelist]
	if {$movelen > 0} {

	    # Evaluate the situation.
	    set evaluation [evalsituation $level $kickout]

	    # Add the move sequence to allmoves 
	    lappend allmoves [list $movelist $evaluation]

	    # Check for new maximum length.
	    if {$movelen > $maxmovelen} {
		set maxmovelen $movelen
	    }
	}
    }
    update
    thinker 1
}

#-------------------------------------------------------------------
proc evalsituation {level kickout} {
    global turn noturn c bp bar nobar avmove

    set kickoutrisk 0
    set singlecnt   0

    # Overlap init
    set overlap 0
    # Upward moving player's checkers on the bar.
    # Pending until we know there are checkers from the
    # downward moving player higher than this point.
    set olpending [set c(-1,$level,0)]
    # The overlap starts only after the first checker of
    # the upward moving player was found.
    set olstart [expr $olpending > 0]

    foreach eturn [list $turn $noturn] {
	set single($eturn) 0
	set pvalue($eturn) [expr 25 * [set c($eturn,$level,[set bp($eturn)])]]
	set pnumber($eturn) 0
	set reenter($eturn) 0
	set outhome($eturn) [set pvalue($eturn)]
    }

    for {set pe 1} {$pe <= 24} {incr pe} {
	# overlap
	if {([set c(1,$level,$pe)] > 0) && $olstart} {
	    # Downward moving player's checker found.
	    # The pending overlaps become real ones.
	    # Also add the checkers of the downward moving player.
	    incr overlap [expr $olpending +[set c(1,$level,$pe)]]
	    set olpending 0
	}
	incr olpending [set c(-1,$level,$pe)]
	set olstart [expr $olstart || ([expr $olpending > 0])]

	# for current player and for counterpart player do
	foreach eturn [list $turn $noturn] {
	    set noeturn [expr -$eturn]
	    set minehere [set c($eturn,$level,$pe)]
	    set pvaluehere [expr [set bp($noeturn)] + $eturn *$pe]
	    incr pvalue($eturn) [expr $pvaluehere *$minehere]
	    incr pnumber($eturn) [expr $minehere > 0]
	    incr reenter($noeturn) [expr ($minehere > 1) && ($pvaluehere <= 6)]
	    if {$pvaluehere > 6} {
		incr outhome($eturn) [expr $pvaluehere *$minehere]
	    }

	    if {$minehere == 1} {
		# a single!
		incr singlecnt
		set h 0
		set limit [expr abs([set bp($noeturn)] -$pe)]
		for {set d1 1} {($d1 <= 6) && ($d1 < $limit)} {incr d1} {
		    set pos1 [expr $pe -$eturn *$d1]
		    if {[set c($noeturn,$level,$pos1)] > 0} {
			incr h 6
		    } elseif {[set c($eturn,$level,$pos1)] > 0} {
			for {set d2 1} {($d2 <= 6) && ($d1 +$d2 < $limit)} \
				{incr d1} {
			    set pos2 [expr $pos1 -$eturn *$d2]
			    incr h [expr [set c($noeturn,$level,$pos2)] > 0]
			}
		    }
		}
		set kickoutrisk \
			[expr $kickoutrisk +double($h)/36.0 *\
			([set bp($eturn)] -$eturn *$pe)]
	    }
	    # end if a single
	}
	# end each player
    }
    # for all points from 1 to 24

    # Complete the kickout risk calculation
    set kickoutrisk \
	    [expr $kickoutrisk +$singlecnt *\
	    double([set reenter($turn)])/6.0 *$avmove]

    # Kickout gain is the number of points the counterpart looses by kickout
    # plus the number of kicked out checkers
    # times the probability of not being able to get them in
    # times the average points per move.
    set kickoutgain [expr $kickout +[set c($noturn,$level,$nobar)] *\
	    double([set reenter($noturn)])/6.0 *$avmove]

    # return the evaluation:
    #  0: overlap
    #  1: kickout risk
    #  2: kickout gain
    #  3: self  reenter
    #  4: other reenter
    #  5: self  outside home
    #  6: other outside home
    #  7: self  bearoff
    #  8: other bearoff
    #  9: self  point value
    # 10: other point value
    # 11: self  point number
    # 12: other point number
    return [list $overlap\
	    $kickoutrisk\
	    $kickoutgain\
	    [set reenter($turn)]\
	    [set reenter($noturn)]\
	    [set outhome($turn)]\
	    [set outhome($noturn)]\
	    [set c($turn,$level,$nobar)]\
	    [set c($noturn,$level,$bar)]\
	    [set pvalue($turn)]\
	    [set pvalue($noturn)]\
	    [set pnumber($turn)]\
	    [set pnumber($noturn)]]
}

#-------------------------------------------------------------------
proc select {level} {
    global c turn noturn allmoves bp
   
    # This is the strategy part.

    # Allmoves contains all legal moves plus maybe some move that are
    # shorter than maximum possible in the current situation.
    # As a rule of the game, we must choose only from those moves of
    # maximum length. This is realized by making move length the
    # highest order selection criterion.

    # The strategy is based on a hierarchy of selection criteria.
    # It compares all moves, searching for maximum gain.
    # It selects all moves with maximum value at the highest order selection
    # criterion,
    # among them all with maximum value at the second to highest
    # selection criterion, and so on.
    # If no more criteria, it simply takes the first in the list of
    # selected moves.
    # If the list is empty, no legal move is possible in this situation
    # and the computer can't make any move.

    # Get the point values of the current situation.
    # This is needed for the aggressivity calculation.
    set pvalue($turn) 0
    set pvalue($noturn) 0
    foreach eturn [list $turn $noturn] {
	for {set pe 1} {$pe <= 24} {incr pe} {
	    set minehere [set c($eturn,$level,$pe)]
	    set pvaluehere [expr [set bp([expr -$eturn])] + $eturn *$pe]
	    incr pvalue($eturn) [expr $pvaluehere *$minehere]
	}
    }

    # The aggressivity:
    # Based on how much the player is behind or ahead of the counterpart,
    # set the behavior on a scale from defensive (-1) to aggressive (1).
    # Be more defensive when more ahead of the counterpart,
    # Be more aggressive when more behind of the counterpart.
    set a [set pvalue($turn)]
    set b [set pvalue($noturn)]
    if {$a *$b} {
	# Neither one is 0
	if {$a > $b} {
	    # Counterpart is ahead. Be more aggressive.
	    set agg [expr double($a -$b) / double($a)]
	} else {
	    # Player is ahead. Be more defensive.
	    set agg [expr double($a -$b) / double($b)]
	}
	# puts "Aggressivity: $agg"
    } else {
	puts "Backgammon: Program error: Game should be over."
    }

    # The selection criteria:
    set overlap 0
    set kickoutrisk 1
    set kickoutgain 2
    set selfreenter 3
    set otherreenter 4
    set selfoutsidehome 5
    set otheroutsidehome 6
    set selfbearoff 7
    set otherbearoff 8
    set selfpointvalue 9
    set otherpointvalue 10
    set selfpointnumber 11
    set otherpointnumber 12

    set criterion(1) {$candlen}
    set criterion(2) {[lindex $cand $overlap] > 0}
    set criterion(3) {([lindex $cand $overlap] > 0) *\
	    ([lindex $cand $kickoutgain] -[lindex $cand $kickoutrisk])}
    set criterion(4) {-[lindex $cand $selfoutsidehome]}
    set criterion(5) {[lindex $cand $selfbearoff]}
    set criterion(6) {-[lindex $cand $selfpointvalue]}
    set criterion(7) {[lindex $cand $selfpointnumber]}
    set criterion(8) {-[lindex $cand $otherreenter]}

    # The selection algorithm.
    set bestmove [lindex $allmoves 0]
    set besteval [lindex $bestmove 1]
    set bestlen  [llength [lindex $bestmove 0]]
    # puts "Initial best: $bestmove"
    foreach compmove $allmoves {
	set compeval [lindex $compmove 1]
	set complen  [llength [lindex $compmove 0]]
	set h 0
	set best 0
	set comp 0
	while {($best == $comp) && ($h < 8)} {
	    # Same value at this hierarchy. Try next hierarchy.
	    incr h

	    set cand $besteval
	    set candlen $bestlen
	    set best [expr [set criterion($h)]]

	    set cand $compeval
	    set candlen $complen
	    set comp [expr [set criterion($h)]]
	}
	if {$comp > $best} {
	    # found a new maximum
	    # puts "At criterion $h, comp=$comp > best=$best"
	    # puts "    New best: $compmove"

	    set bestmove $compmove
	    set besteval $compeval
	}
	thinker 1
    }

    # puts ""
    # Return the best move
    return $bestmove
}


#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	GUI Procedures
#


#-------------------------------------------------------------------
proc undocmd {} {
    global undook
    
    if {$undook} {
	copylevel 4 0 {}
	showcheckers 0
    }
}


#-------------------------------------------------------------------
proc showboard {style} {
    global boardlist boardstyle
    global s s2 x0 x1 x2 x3 y0 y1 y2 fcol fbcol

    # style: -1 - plain, 0 - toggle style

    if {$style == 0} {
	set boardstyle [expr -$boardstyle]
    } else {
	set boardstyle $style
    }

    foreach boardelem $boardlist {.c delete $boardelem}
    set boardlist {}

    set xx1 [expr $x0 +$x1]
    set xx2 [expr $x0 +$x2]
    set xx3 [expr $x0 +$x3]
    set yy1 [expr $y0 +$y1]
    set yy2 [expr $y0 +$y2]
    set xm1 [expr $x0 -$x1]
    set xm2 [expr $x0 -$x2]
    set xm3 [expr $x0 -$x3]
    set ym1 [expr $y0 -$y1]
    set ym2 [expr $y0 -$y2]
    
    set rectfill grey
    set polyw 2

    lappend boardlist [.c create rect $xm3 $yy2 $xm2 $ym2 \
	    -width 4 -fill $rectfill]
    lappend boardlist [.c create rect $xm1 $yy2 $xx1 $ym2 \
	    -width 4 -fill $rectfill]
    lappend boardlist [.c create rect $xx3 $yy2 $xx2 $ym2 \
	    -width 4 -fill $rectfill]

    for {set i 0} {$i < 12} {incr i} {
	set pox1 [expr $xm2 + $s * ($i + $i / 6)]
	set pox2 [expr $pox1 + $s2]
	set pox3 [expr $pox1 + $s]

	set pox4 [expr $xx2 - $s * ($i + $i / 6)]
	set pox5 [expr $pox4 - $s2]
	set pox6 [expr $pox4 - $s]

	set imod [expr $i % 2]

	lappend boardlist [.c create polygon $pox1 $yy2 $pox2 $yy1 $pox3 $yy2 \
		-fill [set fcol($boardstyle,$imod)] \
		-outline [set fbcol($boardstyle,$imod)] -width $polyw]
	lappend boardlist [.c create polygon $pox4 $ym2 $pox5 $ym1 $pox6 $ym2 \
		-fill [set fcol($boardstyle,$imod)] \
		-outline [set fbcol($boardstyle,$imod)] -width $polyw]
    }   

    foreach boardelem $boardlist {.c lower $boardelem}
}
 

#-------------------------------------------------------------------
proc showcheckers {showlevel} {
    global c checkerlist white black posx posy boposx boposy 
    global s s2 bp col xori pcol x0 y0 checkertag

    foreach checker $checkerlist {.c delete $checker}
    set checkerlist {}

    for {set p 0} {$p <= 25} {incr p} {
	foreach player [list 1 -1] {
	    set pp [expr [set bp([expr -$player])] +$player * $p]
	    for {set ch 1} {$ch <= [set c($player,$showlevel,$pp)]} {incr ch} {
		set x [expr $x0 +$xori * [set posx($p,$ch)]]
		set y [expr $y0 -$player * [set posy($p,$ch)]]

		set item [.c create oval [expr $x -$s2] [expr $y -$s2] \
			[expr $x +$s2] [expr $y +$s2] \
			-fill [set col([expr $player * $pcol],1)] \
			-outline [set col([expr $player * $pcol],2)] -width 2]
		.c addtag [set checkertag($player)] withtag $item
		lappend checkerlist $item
	    }
	}
    }
    update
}


#-------------------------------------------------------------------
proc showdices {} {
    global dice1 dice2 dicelist x0 y0 dicex dicecol pcol
    
    if {$dice1 && $dice2} {
	foreach dicebmp $dicelist {.c delete $dicebmp}
	set dicelist {}
	set d1 [expr abs($dice1)]
	set d2 [expr abs($dice2)]
	set dsign [expr $dice1 / abs($dice1)]
	
	set item [.c create image [expr $x0 - $dsign * $dicex(1)] $y0 \
		-image dice($d1) \
		-anchor c]
	dice($d1) configure -background [set dicecol([expr $dsign * $pcol])]

	lappend dicelist $item
	set item [.c create image [expr $x0 - $dsign * $dicex(2)] $y0 \
		-image dice($d2) \
		-anchor c]
	dice($d2) configure -background [set dicecol([expr $dsign * $pcol])]

	lappend dicelist $item
	update
    }
}


#-------------------------------------------------------------------
proc thinker {mode} {
    global thinkerlist thinkercnt
    global thinknot think
    # modes: 0 "watch on", 1 "think", -1 "off"
    
    foreach thinkerbmp $thinkerlist {.c delete $thinkerbmp}
    set thinkerlist {}

    if {$mode == 0} {
	lappend thinkerlist [.c create image 80 14 \
		-image thinknot \
		-anchor nw]
    } elseif {$mode == 1} {
	set thinkercnt [expr ([incr thinkercnt]) % 8 + 1]
	lappend thinkerlist [.c create image 80 14 \
		-image think($thinkercnt) \
		-anchor nw]
    }
}


#-------------------------------------------------------------------
# grabchecker --
# This procedure is invoked when the mouse is pressed over one of the
# data points.  It sets up state to allow the point to be dragged.
#
# Arguments:
# w -		The canvas window.
# x, y -	The coordinates of the mouse press.

proc grabchecker {w x y} {
    global lastX lastY x0 x3 s2 s y0 y1 y2 mapxy2p mapp2x fromP toP xori
     
    $w dtag selected
    $w addtag selected withtag current
    $w raise current

    set snapx $x
    if {$snapx <= ($x0 -$x3)} {set snapx [expr $x0 -$x3 +1]}
    if {$snapx >= ($x0 +$x3)} {set snapx [expr $x0 +$x3 -1]}
    set gridx [expr ($snapx -$x0 +$s2) / $s]
    
    set snapy [expr abs($y0 -$y)]
    set yminus [expr $y0 < $y]
    if {$snapy < $y1 +$s2} {set snapy [expr $y1 +$s2]}
    if {$snapy > $y2 -$s2} {set snapy [expr $y2 -$s2]}
    set snapy [expr $y0 +($yminus *2 -1) *$snapy]

    set fromP [lindex [lindex $mapxy2p $yminus] [expr $xori *$gridx +7]]
    set toP $fromP
    set snapx [expr $x0 +$s * $xori *[lindex $mapp2x $fromP]]

    set lastX $snapx
    set lastY $snapy
}


#-------------------------------------------------------------------
# movechecker --
# This procedure is invoked during mouse motion events.  It drags the
# current item.
#
# Arguments:
# w -		The canvas window.
# x, y -	The coordinates of the mouse.

proc movechecker {w x y} {
    global lastX lastY x0 x3 s2 s y0 y1 y2 mapxy2p mapp2x xori toP

    set snapx $x
    if {$snapx <= ($x0 -$x3)} {set snapx [expr $x0 -$x3 +1]}
    if {$snapx >= ($x0 +$x3)} {set snapx [expr $x0 +$x3 -1]}
    set gridx [expr ($snapx -$x0 +$s2) / $s]
    
    set snapy [expr abs($y0 -$y)]
    set yminus [expr $y0 < $y]
    if {$snapy < $y1 +$s2} {set snapy [expr $y1 +$s2]}
    if {$snapy > $y2 -$s2} {set snapy [expr $y2 -$s2]}
    set snapy [expr $y0 +($yminus *2 -1) *$snapy]

    set toP [lindex [lindex $mapxy2p $yminus] [expr $xori *$gridx +7]]
    set snapx [expr $x0 +$s * $xori *[lindex $mapp2x $toP]]
    $w move selected [expr $snapx -$lastX] [expr $snapy -$lastY]

    set lastX $snapx
    set lastY $snapy
}


#-------------------------------------------------------------------
# releasechecker --
# This procedure is invoked when the mouse is relased.
#
# Arguments:
# w -		The canvas window.
# x, y -	The coordinates of the mouse.

proc releasechecker {w x y} {
    global fromP toP c

    $w dtag selected

    # 1: Computer, -1: Player
    if {[set c(1,0,$toP)] <= 1} {
	incr c(-1,0,$fromP) -1
	incr c(-1,0,$toP)

	if {([set c(1,0,$toP)] == 1) && ($toP < 25)} {
	    incr c(1,0,$toP) -1
	    incr c(1,0,25)
	}
    }
    showcheckers 0
}


#-------------------------------------------------------------------
# GUI Inits
proc guiinit {} {
    global checkerlist dicelist boardlist thinkerlist thinkercnt
    global boardstyle xori pcol totturn plot checkertag
    global s2 os x0 y0 brown col fcol fbcol dicecol
    global plotFont miniFont largeFont mapxy2p mapp2x
    global s x1 x2 x3 y1 y2 posx posy
    global px1 py1 cx1 cy1 px2 px3 dicex
    global data thinknot think dice

    set checkerlist {}
    set dicelist {}
    set boardlist {}
    set thinkerlist {}
    set thinkercnt 0

    set boardstyle -1 ;# plain style
    set xori 1
    set pcol 1
    set totturn -2
    set plot(lastX) 0
    set plot(lastY) 0
    set checkertag(1)  compckecker
    set checkertag(-1) playerchecker


    # Graphic parameters

    set s2 15		;# half size of a checker
    set os 4		;# displacement of piled up checkers
    set x0 [expr $s2 *15 +10]		;# center of the board
    set y0 [expr $s2 *11 +40]		;# center of the board

    set brown "brown"
    set col(1,1) white	;# white checkers
    set col(1,2) black	;# border of white checkers
    set col(1,3) grey	;# when mouse enters white checkers
    set col(-1,2) $brown	;# border of black checkers
    set col(-1,1) black	;# black checkers
    set col(-1,3) dimgrey	;# when mouse enters black checkers

    set fcol(1,0) ""
    set fcol(1,1) ""
    set fbcol(1,0) $brown
    set fbcol(1,1) white
    set fcol(-1,0) $brown
    set fcol(-1,1) white
    set fbcol(-1,0) black
    set fbcol(-1,1) black

    set dicecol(1)  white
    set dicecol(-1) $brown

    set plotFont {-*-Helvetica-Medium-R-Normal--*-180-*-*-*-*-*-*}
    set miniFont {-*-Helvetica-Medium-R-Normal--*-80-*-*-*-*-*-*}
    set largeFont {-*-times-bold-r-normal-*-40-400-*-*-*-*-*-*}


    set mapxy2p {{1  1  2  3  4  5  6  0  7  8  9 10 11 12 12} \
	    {25 24 23 22 21 20 19 19 18 17 16 15 14 13 13}}
    set mapp2x {0 -6 -5 -4 -3 -2 -1 1 2 3 4 5 6 6 5 4 3 2 1\
	    -1 -2 -3 -4 -5 -6 -7}


    # Graphic variables

    set s [expr 2 * $s2]
    set x1 $s2
    set x2 [expr $s2 + 6 * $s]
    set x3 [expr $s2 + 7 * $s]
    set y1 $s2
    set y2 [expr $s2 + 5 * $s]

    # Bear off coordinates
    for {set py 1} {$py <= 15} {incr py} {
	set posx(0,$py) [expr -7 * $s]
	set posy(0,$py) [expr 5 * $s -$os * ($py - 1)]
    }

    # Bar coordinates
    for {set py 1} {$py <= 15} {incr py} {
	set posx(25,$py) 0
	set posy(25,$py) [expr -$s -$os * ($py - 1)]
    }

    # All other coordinates
    for {set px 0} {$px <= 5} {incr px} {
	for {set py 0} {$py <= 14} {incr py} {
	    # First board
	    set px1 [expr $px + 1]
	    set py1 [expr $py + 1]
	    set cx1 [expr ($px - 6) * $s + $os * ($py / 5)]
	    set cy1 [expr (5 - ($py % 5)) * $s - $os * ($py / 5)]
	    set posx($px1,$py1) $cx1
	    set posy($px1,$py1) $cy1

	    # Second board
	    set px2 [expr $px + 7]
	    set posx($px2,$py1) [expr $cx1 + 7 * $s]
	    set posy($px2,$py1) $cy1

	    # Third board
	    set px3 [expr $px + 13]
	    set posx($px3,$py1) [expr -$cx1]
	    set posy($px3,$py1) [expr -$cy1]

	    # Fourth board
	    set px3 [expr $px + 19]
	    set posx($px3,$py1) [expr -$cx1 - 7 * $s]
	    set posy($px3,$py1) [expr -$cy1]
	}
    }

    # Dice coordinates
    set dicex(1) [expr 3 * $s]
    set dicex(2) [expr 4 * $s]

    # Create the bitmap images
    image create bitmap thinknot -data $data(think.bmp)
    thinknot configure -background ""

    for {set thinkercnt 0} {$thinkercnt <= 8} {incr thinkercnt} {
	image create bitmap think($thinkercnt) \
		-data [set data(think${thinkercnt}.bmp)]
	think($thinkercnt) configure -background ""
    }

    for {set dicecnt 1} {$dicecnt <= 6} {incr dicecnt} {
	image create bitmap dice($dicecnt) \
		-data [set data(dice${dicecnt}.bmp)]
	# dice($dicecnt) configure -background ""
    }
}


#-------------------------------------------------------------------
# Buttons: Quit, Undo, Go, Restart, Board
proc makebuttons {} {
    frame .buttons
    pack .buttons -side bottom -fill x -pady 2m
    button .buttons.restart -text Start \
	    -command "set restartrequest 1; set playerdone 1"
    button .buttons.undo -text Undo -command "undocmd"
    button .buttons.go -text " Go " -command "set playerdone 1"
    button .buttons.side -text Side -command {set xori [expr -$xori]; \
	    showcheckers 0; showdices}
    button .buttons.color -text Color -command {set pcol [expr -$pcol]; \
	    showcheckers 0; showdices}
    pack .buttons.restart .buttons.undo .buttons.go \
	    .buttons.side .buttons.color -side left -expand 1 -fill x
}


#-------------------------------------------------------------------
# Canvas graphic elements
proc makecanvas {} {
    global x0 y2 plotFont brown x2 y2 y0 col pcol 

    canvas .c -relief raised -width [expr 2 * $x0] -height [expr 2 * $y2 + 40]
    pack .c -side top -fill x

    .c create text $x0 20 -text "Phi's Backgammon" \
	    -font $plotFont -fill $brown
    .c create rect [expr $x0 -$x2] [expr $y0 -$y2] \
	    [expr $x0 +$x2] [expr $y0 +$y2] -width 4

    .c bind compckecker <Any-Enter> {.c itemconfig current \
	    -fill [set col($pcol,3)]}
    .c bind playerchecker <Any-Enter> {.c itemconfig current \
	    -fill [set col([expr -$pcol],3)]}
    .c bind compckecker <Any-Leave> {.c itemconfig current \
	    -fill [set col($pcol,1)]}
    .c bind playerchecker <Any-Leave> {.c itemconfig current \
	    -fill [set col([expr -$pcol],1)]}
    .c bind playerchecker <1> "grabchecker .c %x %y"
    .c bind playerchecker <ButtonRelease-1> "releasechecker .c %x %y"
    .c bind playerchecker <B1-Motion> "movechecker .c %x %y"
}


#-------------------------------------------------------------------
# Init
proc init {} {
    global boardstyle

    gameinit
    bitmapdata
    guiinit
    makecanvas
    makebuttons

    # Create the board
    showboard $boardstyle
    showcheckers 0
}


#-------------------------------------------------------------------
# Main loop
proc main {} {
    global restartrequest compwon playerwon 
    global x0 y0 largeFont totturns

    set compwon 0
    set playerwon 0
    while 1 {
	# Wait for pressing "Start"
	set restartrequest 0
	vwait restartrequest

	# Start a new game
	if $playerwon {.c delete $won}
	if $compwon {.c delete $lost}
	set compwon 0
	set playerwon 0

	while {!$compwon && !$playerwon} {
	    set restartrequest 0
	    restart
	}

	if $playerwon {
	    set won [.c create text $x0 $y0 \
		    -text "You won in $totturns turns!" \
		    -font $largeFont -fill red -anchor center]
	}
	if $compwon {
	    set lost [.c create text $x0 $y0 \
		    -text "You lost in $totturns turns!" \
		    -font $largeFont -fill red -anchor center]
	}
    }
}

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	The picdata (machine generated)
#

proc bitmapdata {} {
    global data

set data(dice1.bmp) {
   #define dice1_width 27
   #define dice1_height 27
   static unsigned char dice1_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x70, 0x00, 0x06,
      0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06,
      0x03, 0x70, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice2.bmp) {
   #define dice2_width 27
   #define dice2_height 27
   static unsigned char dice2_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x00, 0x06,
      0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06,
      0xc3, 0x01, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x1c, 0x06,
      0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06,
      0x03, 0x00, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice3.bmp) {
   #define dice3_width 27
   #define dice3_height 27
   static unsigned char dice3_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x00, 0x06,
      0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06, 0xe3, 0x03, 0x00, 0x06,
      0xc3, 0x01, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x70, 0x00, 0x06,
      0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06,
      0x03, 0x70, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x1c, 0x06,
      0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06, 0x03, 0x00, 0x3e, 0x06,
      0x03, 0x00, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice4.bmp) {
   #define dice4_width 27
   #define dice4_height 27
   static unsigned char dice4_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice5.bmp) {
   #define dice5_width 27
   #define dice5_height 27
   static unsigned char dice5_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x70, 0x00, 0x06,
      0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06, 0x03, 0xf8, 0x00, 0x06,
      0x03, 0x70, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(dice6.bmp) {
   #define dice6_width 27
   #define dice6_height 27
   static unsigned char dice6_bits[] = {
      0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06, 0xc3, 0x01, 0x1c, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06, 0x03, 0x00, 0x00, 0x06,
      0xc3, 0x01, 0x1c, 0x06, 0xe3, 0x03, 0x3e, 0x06, 0xe3, 0x03, 0x3e, 0x06,
      0xe3, 0x03, 0x3e, 0x06, 0xc3, 0x01, 0x1c, 0x06, 0x03, 0x00, 0x00, 0x06,
      0x03, 0x00, 0x00, 0x06, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x07};
}
set data(think.bmp) {
   #define think_width 23
   #define think_height 15
   static unsigned char think_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
      0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x60, 0x30, 0x00, 0x10, 0x40, 0x00,
      0x08, 0x80, 0x00, 0x08, 0x80, 0x00, 0x08, 0x9b, 0x00, 0x04, 0x9b, 0x00,
      0x73, 0x40, 0x00, 0xde, 0x3f, 0x00, 0x00, 0x00, 0x00};
}
set data(think0.bmp) {
   #define think1_width 23
   #define think1_height 15
   static unsigned char think1_bits[] = {
      0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x60, 0x30, 0x00, 0x10, 0x40, 0x00,
      0x50, 0x60, 0x00, 0x88, 0x99, 0x00, 0x08, 0x89, 0x00, 0x08, 0x80, 0x00,
      0x08, 0x89, 0x00, 0x08, 0x80, 0x00, 0x08, 0x40, 0x00, 0x04, 0x40, 0x00,
      0x73, 0x30, 0x00, 0xde, 0x1f, 0x00, 0x00, 0x00, 0x00};
}
set data(think1.bmp) {
   #define think2_width 23
   #define think2_height 15
   static unsigned char think2_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xc0, 0x60, 0x00,
      0x20, 0x80, 0x00, 0x90, 0x40, 0x01, 0x10, 0x33, 0x01, 0x10, 0x12, 0x01,
      0x10, 0x00, 0x01, 0x10, 0x12, 0x01, 0x10, 0x80, 0x00, 0x08, 0x80, 0x00,
      0xe6, 0x60, 0x00, 0xbc, 0x3f, 0x00, 0x00, 0x00, 0x00};
}
set data(think2.bmp) {
   #define think3_width 23
   #define think3_height 15
   static unsigned char think3_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x83, 0x01, 0x80, 0x00, 0x02,
      0x80, 0x02, 0x03, 0x40, 0xcc, 0x04, 0x40, 0x48, 0x04, 0x40, 0x00, 0x04,
      0x40, 0x48, 0x04, 0x40, 0x00, 0x04, 0x40, 0x00, 0x02, 0x20, 0x00, 0x02,
      0x98, 0x83, 0x01, 0xf0, 0xfe, 0x00, 0x00, 0x00, 0x00};
}
set data(think3.bmp) {
   #define think4_width 23
   #define think4_height 15
   static unsigned char think4_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x06, 0x03,
      0x00, 0x01, 0x04, 0x80, 0x04, 0x0a, 0x80, 0x98, 0x09, 0x80, 0x90, 0x08,
      0x80, 0x00, 0x08, 0x80, 0x90, 0x08, 0x80, 0x00, 0x04, 0x40, 0x00, 0x04,
      0x30, 0x07, 0x03, 0xe0, 0xfd, 0x01, 0x00, 0x00, 0x00};
}
set data(think4.bmp) {
   #define think6_width 23
   #define think6_height 15
   static unsigned char think6_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x06, 0x03, 0x00, 0x01, 0x04,
      0x00, 0x03, 0x05, 0x80, 0xcc, 0x08, 0x80, 0x48, 0x08, 0x80, 0x00, 0x08,
      0x80, 0x48, 0x08, 0x80, 0x00, 0x08, 0x00, 0x01, 0x08, 0x00, 0x01, 0x10,
      0x00, 0x06, 0x67, 0x00, 0xfc, 0x3d, 0x00, 0x00, 0x00};
}
set data(think5.bmp) {
   #define think7_width 23
   #define think7_height 15
   static unsigned char think7_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x01, 0x01,
      0x80, 0x00, 0x02, 0x40, 0x81, 0x04, 0x40, 0x66, 0x04, 0x40, 0x24, 0x04,
      0x40, 0x00, 0x04, 0x40, 0x24, 0x04, 0x80, 0x00, 0x04, 0x80, 0x00, 0x08,
      0x00, 0x83, 0x33, 0x00, 0xfe, 0x1e, 0x00, 0x00, 0x00};
}
set data(think6.bmp) {
   #define think8_width 23
   #define think8_height 15
   static unsigned char think8_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0xc0, 0x60, 0x00, 0x20, 0x80, 0x00,
      0x60, 0xa0, 0x00, 0x90, 0x19, 0x01, 0x10, 0x09, 0x01, 0x10, 0x00, 0x01,
      0x10, 0x09, 0x01, 0x10, 0x00, 0x01, 0x20, 0x00, 0x01, 0x20, 0x00, 0x02,
      0xc0, 0xe0, 0x0c, 0x80, 0xbf, 0x07, 0x00, 0x00, 0x00};
}
set data(think7.bmp) {
   #define think9_width 23
   #define think9_height 15
   static unsigned char think9_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x20, 0x20, 0x00,
      0x10, 0x40, 0x00, 0x28, 0x90, 0x00, 0xc8, 0x8c, 0x00, 0x88, 0x84, 0x00,
      0x08, 0x80, 0x00, 0x88, 0x84, 0x00, 0x10, 0x80, 0x00, 0x10, 0x00, 0x01,
      0x60, 0x70, 0x06, 0xc0, 0xdf, 0x03, 0x00, 0x00, 0x00};
}
set data(think8.bmp) {
   #define think9_width 23
   #define think9_height 15
   static unsigned char think9_bits[] = {
      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x20, 0x20, 0x00,
      0x10, 0x40, 0x00, 0x28, 0x90, 0x00, 0xc8, 0x8c, 0x00, 0x88, 0x84, 0x00,
      0x08, 0x80, 0x00, 0x88, 0x84, 0x00, 0x10, 0x80, 0x00, 0x10, 0x00, 0x01,
      0x60, 0x70, 0x06, 0xc0, 0xdf, 0x03, 0x00, 0x00, 0x00};
}


}

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

#
#	Call init and main
#

init
main

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------

Added Demo/Applets/bertspel.html.

























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
   <TITLE></TITLE>
   <META NAME="GENERATOR" CONTENT="Mozilla/3.0Gold (X11; I; HP-UX A.09.05 9000/712) [Netscape]">
<link rel=stylesheet href="/~vannoord/vn.css" type="text/css">

</HEAD>
<BODY>

<H2>Bert Bos Puzzle</H2>

<P>The objective of the game is to make all buttons red. If you click on
a button its color will change, but its neighbors will also change color.
Have fun.</P>

<P><EMBED 
       src="bertspel.tcl"
       pluginspage="http://www.sunlabs.com/tcl/plugin/"
       width=400 
       height=400></P>

<P>I (<A href="http://www.let.rug.nl/~vannoord">Gertjan van Noord</A> heard of this puzzle via Bert Bos. He explains it as follows: </P>

<P>The puzzle consists of a square of n x n blue tiles. The back side of
each tile is red. The object of the puzzle is to turn every tile, so that
the whole square becomes red. </P>

<P>However, when a tile is turned, its four neigbours also turn. With every
turn, therefore, five tiles swap colour. </P>

<P>Tho object of this program is to find all possible patterns of tiles
to turn for a given n, so that the result is a red square. The following
observations can be made: </P>

<OL>
<LI>the order of turning tiles is immaterial </LI>

<LI>no tile need to be turned twice </LI>

<LI>all solutions can be mirrored in several ways </LI>

<LI>selecting a top row determines all other rows </LI>
</OL>

<P>Observation 4 is due to Harry Bos and it is what makes this program
possible. The program views the top row as a sequence of n bits. There
are 2**n possibilities, which can be specified with the number corresponding
to the bit pattern: 0--2**n-1. These 2**m possibilities include all mirrored
solutions. </P>

<P>Bert Bos <A HREF="mailto:bert@let.rug.nl">bert@let.rug.nl</A> 15 May
1995 </P>

<P>The <A HREF="bertspel.tcl">source of the script is here.</A>
</P>

</BODY>
</HTML>
]

Added Demo/Applets/bertspel.tcl.























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
proc spel {{size 10}} {
    global spel
    catch {destroy .frame}

#    toplevel $w
#    wm title $w {Bert Bos Puzzle}
#    wm iconname $w {Bert Bos Puzzle}
    frame .frame
    pack .frame -fill both -expand 1 -fill both
    set col $size
    while {$col > 0} {
	frame .frame.t$col
	pack .frame.t$col -expand 1 -fill both
	set row 1
	while {$row <= $size} {
	    set vrij($col,$row) blue
	    button .frame.t$col.$row -width 1 -height 1 -relief raised \
		-borderwidth 1 -padx 0 -pady 0 -bg $vrij($col,$row) \
		-command "press $row $col $size"
	    pack .frame.t$col.$row -side left -fill both -expand 1
	    set row [expr $row + 1]
	}
	set col [expr $col - 1]
    }
    frame .frame.tok
    set new 3
    while {$new < 14} {
	button .frame.tok.$new -command "spel $new" -text $new
	pack .frame.tok.$new -side left -fill both -expand 1
	set new [expr $new + 1]
    }
    frame .frame.stok
    while {$new < 24} {
	button .frame.stok.$new -command "spel $new" -text $new
	pack .frame.stok.$new -side left -fill both -expand 1
	set new [expr $new + 1]
    }
    button .frame.quit -command "destroy ." -text Quit
    pack  .frame.tok .frame.stok  .frame.quit  -fill both -expand 1
}

proc press {col row size} {
    swap $col $row $size
    swap [expr $col+1] [expr $row] $size
    swap [expr $col-1] [expr $row] $size
    swap [expr $col] [expr $row+1] $size
    swap [expr $col] [expr $row-1] $size
}

proc swap {col row size} {
    if { $col > 0 && $row > 0 && $col <= $size && $row <= $size } {
	set color [lindex [.frame.t$row.$col configure -bg] 4] 
	if {$color == "blue"} {
	    .frame.t$row.$col configure -bg red 
	} { .frame.t$row.$col configure -bg blue }
    }
}

spel 6

Added Demo/Applets/bike.html.

































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<Html>
<Head>
<Title>Tcl Plugin Demo: Bike Gears Calculator</Title>
<!-- Author: bwelch -->
</Head>
<Body bgcolor=white text=black>



<h1>A Bike Gear Ratio Calculator</h1>
<h3>[<a HREF="../">My Home</a> | <a HREF="http://sunscript.sun.com/">Tcl Home</a> | <a HREF="http://sunscript.sun.com/plugin/">Tcl
Plugin</a> | <a HREF="http://sunscript.sun.com/plugin/applets.html">Demos</a>]</h3>
<p>
<hr>
<p>
This application computes the effect of different gear combinations.
One way to visualize this is to think of replacing your modern bicycle
with an old fashioned "ordinary" bike that has a large diameter front
wheel and the pedals connected right to the front axel. In those bikes,
the mechanical advantage comes from the wheel diameter. The larger
the wheel the more power, but the harder it is to pedal. 
<p>
The graph displays the effective wheel diameter for each gear combination.
The horizontal lines correspond to the different gears up front (at
the pedals). The points on each line correspond to each gear in the
gear cluster at the back wheel. The values are the effective wheel
diameter. 
<p>
To use the application, just enter numbers and press the Recompute
button. Just pressing Return in a text entry causes the graph to update,
too. If you move the mouse over the graph, the specific values for
the point under the mouse cursor are displayed.
<br>
<embed src=bike.tcl width=400 height=300
PLUGINSPAGE=http://redsonja.sunlabs.com/research/tcl/plugin/license.html
>
<br>
 
<p>
The graph tells you the shift sequence that lets you use your gears
effectively. As you ride along, if a hill becomes steeper, you want
to know the derailleur positions for the next lower gear. Similarly,
if the hill starts to level out, you want to know the positions for
the next higher gear. In the initial chart displayed when you load
(or reload) this page, the combination of the middle front sprocket
and the smallest rear gear give you an effective wheel diameter of
83 inches (move the mouse cursor over the rightmost point on the middle
line to check this out). The next lower gear is 79 inches, which you
get by using the <i>large</i> front sprocket and the third smallest
rear gear. The next lower gear doesn't use the middle sprocket! 
<p>
The gear ratio graph also makes it easy to tell how well spaced out
your gears are. Notice in the initial chart that several derailleur
positions have the same or nearly the same gearing. This 18 speed bike
really has about 13 gears. You can buy real gear clusters and front
sprockets to space out the gears more evenly. The gear chart application
makes it easy for you to experiment with different gear combinations.


<h2>The Code</h2>

<pre>

# bike.tcl
# This program computes the effective wheel diameter of a bike given its
# gear setup.  For example, if the effective diameter is 100 inches, it is
# as if you have an old-fashioned bike with a 100 inch diameter front wheel
# and the pedals are connected right to its axle.  The bigger the diameter
# the harder it is to pedal.

option add *Entry.width 2
option add *background gray75
option add *highlightBackground gray75
. config -borderwidth 10 -bg gray75

if [info exists embed_args] {
    # Don't resize within plugin
    grid propagate . false
    set maxwidth $embed_args(width)
} else {
    set maxwidth 400
}
message .msg -text "Bicycle Gear Ratios" -aspect 2000

# Every text entry widget can be associated with a Tcl variable.  In these cases
# front(n) and back(n) are the number of gears at the front and back of the bike.
entry .efront -textvariable front(n)
entry .eback -textvariable back(n)

label .lfront -text "# front gears"
label .lback -text "# back gears"

entry .size -textvariable size
label .lsize -text "Wheel diameter"
set size 27

# Hitting Return in a text entry recomputes the graph.
foreach e {.size .efront .eback} {
    bind $e &lt;Return&gt; UpdateRatios
}
button .doit -text Recompute -command UpdateRatios

# The grid geometry manager is used for the main arrangement of widgets
grid .msg  -columnspan 3        -sticky news
grid .lfront .efront		-sticky w
grid .lback  .eback		-sticky w
grid .lsize  .size .doit	-sticky w
grid .doit 			-sticky e

# When the number of gears is changed, the set of entries for each gear is re-created.
trace variable front(n) w UpdateFront
trace variable back(n) w UpdateBack

proc UpdateFront {args} {
    UpdateBoxes .front 1 front ff0000 110000
}
proc UpdateBack {args} {
    UpdateBoxes .back 2 back 0000ff 000011
}
proc UpdateBoxes {frame row varName color dColor} {
    # upvar creates a local name alias for a global variable (absolute scope #0)
    # In this case, 'var' is an alias for 'front' or 'back'
    upvar #0 $varName var
    catch {destroy $frame}
    if ![NumberOk var(n) 1 10] {
	return
    }
    # Make a horizontal stack of a label and several entries, using the packer
    frame $frame
    label $frame.teeth -text "# teeth"
    pack $frame.teeth -side left
    for {set i 0} {$i < $var(n)} {incr i} {
	entry $frame.$i -textvariable $varName\($i) -foreground #$color
	# Fade the text color from bright to black
	set color [format %06x [expr 0x$color - 0x$dColor]]
	pack $frame.$i -side left
	bind $frame.$i &lt;Return&gt; UpdateRatios
    }
    # Position the horizontal stack in the main grid of widgets
    grid $frame -column 2 -row $row -sticky w
}
# Validate a number.  Returns 0 if there isn't a number in the variable.
proc NumberOk {varName min max} {
    upvar $varName var
    if {([string length [string trim $var]] == 0)} {
	return 0
    }
    if {[catch {expr $var}]} {
	set var ""
	return 0
    }
    if {$var < $min} {
	set var $min
    }
    if {$var > $max} {
	set var $max
    }
    return 1
}

# Set default values for the front and back gear configuration.
array set front {
    0 27
    1 40 
    2 50
}

set front(n) [expr [array size front] -1]
array set back {
    0 27
    1 21
    2 19
    3 17
    4 15
    5 13
} 
set back(n) [expr [array size back] -1]

# UpdateRatios displays a graph of the effective wheel diameter.
proc UpdateRatios {} {
    global front back
    # Find the minimum and maximum gear sizes in front and back.
    foreach name {front back} {
	# Here upvar creates an alias for a local variable (scope 0 frames up)
	upvar 0 $name array
	catch {unset array(max)}
	catch {unset array(min)}
	for {set n 0} {$n < $array(n)} {incr n} {
	    if {([string length [string trim $array($n)]] == 0) ||
		[catch {expr $array($n)}]} {
		    continue
	    }
	    if {![info exists array(min)] || ($array($n) < $array(min)) } {
		set array(min) $array($n)
	    }
	    if {![info exists array(max)] || ($array($n) > $array(max)) } {
		set array(max) $array($n)
	    }
	}
	if {![info exists array(max)] || ![info exists array(min)]} {
	    return
	}
    }
    # Find the bounds of the graph, rounded to 5
    set min [expr [Gearage $front(min) $back(max)]/5 * 5]
    set max [expr ([Gearage $front(max) $back(min)]+5)/5 * 5]
    set span [expr $max - $min]

    if [winfo exists .c] {
	.c delete all
    } else {
	canvas .c
    }
    global maxwidth
    set y 10
    set xoff 20
    set xscale [expr double($maxwidth-$xoff-35)/$span]
    set fcolor ff0000
    set df     110000
    for {set f 0} {$f < $front(n)} {incr f} {
	if ![NumberOk front($f) 3 1000] {
	    continue
	}
	# Create a horizontal line for each front gear, same color as text entry.
	.c create text 0 $y -text $front($f) -fill #$fcolor
	.c create line $xoff $y [expr $xscale*$span + $xoff] $y -fill #$fcolor
	set fcolor [format %06x [expr 0x$fcolor - 0x$df]]

	set bcolor 0000ff
	for {set b 0} {$b < $back(n)} {incr b} {
	    if ![NumberOk back($b) 3 1000] {
		continue
	    }
	    if [catch {Gearage $front($f) $back($b)} g] {
		continue
	    }
	    # Plot the points in the same color as rear wheel text.
	    set x [expr $xscale *($g-$min) +$xoff]
	    set id [.c create oval [expr $x-3] [expr $y-3] [expr $x+3] [expr $y+3] \
		-fill #$bcolor -tags "gearage=$g f=$f b=$b"]
	    set bcolor [format %06x [expr 0x$bcolor - 0x11]]
	}
	incr y 20
    }
    bind .c &lt;ButtonPress-1&gt; [list FeedbackOn %x %y]
    bind .c &lt;Motion&gt; [list FeedbackOn %x %y]
    bind .c &lt;ButtonRelease-1&gt; [list FeedbackOff]
    .c create text $xoff $y -text $min -anchor w
    .c create text [expr $xscale*$span+$xoff] $y -text $max -anchor e
    .c create text [expr ($xscale*$span+$xoff)/2] $y \
	-text "Effective Wheel Diameter" -anchor c
    # Size the canvas to fit the plot
    .c move all 10 10
    foreach {x1 y1 x2 y2} [.c bbox all] {}
    .c config -width [expr $x2 + 0] -height [expr $y2 +0]
    grid .c -row 4 -column 0 -columnspan 3
}
proc Gearage {f b} {
    global size
    expr round($f.0 / $b.0 * $size)
} 
# As the mouse moves over the plot, display the exact value for each point it crosses.
proc FeedbackOn {x y} {
    global feedback
    foreach id [.c find overlapping [expr $x-2] [expr $y-2] [expr $x+2] [expr $y+2]] {
	if [regexp {gearage=([0-9]+) f=([0-9]+) b=([0-9]+)} [.c itemconfigure $id -tags] junk g f b] {
	    FeedbackOff
	    foreach {x1 y1 x2 y2} [.c coords $id] {}
	    set feedback [.c create text $x1 $y1 -text $g -fill blue -anchor s]
	    .front.$f config -bg white
	    .back.$b config -bg white
	    lappend feedback $f $b
	    break
	}
    }
}
proc FeedbackOff {} {
    global feedback
    catch {.c delete [lindex $feedback 0]}
    catch {.front.[lindex $feedback 1] config -bg grey75}
    catch {.back.[lindex $feedback 2] config -bg grey75}
}
update	;# So auto-sizing works ok
UpdateRatios
</pre>
</Body>
</Html>

Added Demo/Applets/bike.tcl.



























































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# bike.tcl
# This program computes the effective wheel diameter of a bike given its
# gear setup.  For example, if the effective diameter is 100 inches, it is
# as if you have an old-fashioned bike with a 100 inch diameter front wheel
# and the pedals are connected right to its axle.  The bigger the diameter
# the harder it is to pedal.

option add *Entry.width 2
option add *background gray75
option add *highlightBackground gray75
. config -borderwidth 10 -bg gray75

if [info exists embed_args] {
    # Don't resize within plugin
    grid propagate . false
    set maxwidth $embed_args(width)
} else {
    set maxwidth 400
}
message .msg -text "Bicycle Gear Ratios" -aspect 2000

# Every text entry widget can be associated with a Tcl variable.  In these cases
# front(n) and back(n) are the number of gears at the front and back of the bike.
entry .efront -textvariable front(n)
entry .eback -textvariable back(n)

label .lfront -text "# front gears"
label .lback -text "# back gears"

entry .size -textvariable size
label .lsize -text "Wheel diameter"
set size 27

# Hitting Return in a text entry recomputes the graph.
foreach e {.size .efront .eback} {
    bind $e <Return> UpdateRatios
}
button .doit -text Recompute -command UpdateRatios

# The grid geometry manager is used for the main arrangement of widgets
grid .msg  -columnspan 3        -sticky news
grid .lfront .efront		-sticky w
grid .lback  .eback		-sticky w
grid .lsize  .size .doit	-sticky w
grid .doit 			-sticky e

# When the number of gears is changed, the set of entries for each gear is re-created.
trace variable front(n) w UpdateFront
trace variable back(n) w UpdateBack

proc UpdateFront {args} {
    UpdateBoxes .front 1 front ff0000 110000
}
proc UpdateBack {args} {
    UpdateBoxes .back 2 back 0000ff 000011
}
proc UpdateBoxes {frame row varName color dColor} {
    # upvar creates a local name alias for a global variable (absolute scope #0)
    # In this case, 'var' is an alias for 'front' or 'back'
    upvar #0 $varName var
    catch {destroy $frame}
    if ![NumberOk var(n) 1 10] {
	return
    }
    # Make a horizontal stack of a label and several entries, using the packer
    frame $frame
    label $frame.teeth -text "# teeth"
    pack $frame.teeth -side left
    for {set i 0} {$i < $var(n)} {incr i} {
	entry $frame.$i -textvariable $varName\($i) -foreground #$color
	# Fade the text color from bright to black
	set color [format %06x [expr 0x$color - 0x$dColor]]
	pack $frame.$i -side left
	bind $frame.$i <Return> UpdateRatios
    }
    # Position the horizontal stack in the main grid of widgets
    grid $frame -column 2 -row $row -sticky w
}
# Validate a number.  Returns 0 if there isn't a number in the variable.
proc NumberOk {varName min max} {
    upvar $varName var
    if {([string length [string trim $var]] == 0)} {
	return 0
    }
    if {[catch {expr $var}]} {
	set var ""
	return 0
    }
    if {$var < $min} {
	set var $min
    }
    if {$var > $max} {
	set var $max
    }
    return 1
}

# Set default values for the front and back gear configuration.
array set front {
    0 27
    1 40 
    2 50
}

set front(n) [expr [array size front] -1]
array set back {
    0 27
    1 21
    2 19
    3 17
    4 15
    5 13
} 
set back(n) [expr [array size back] -1]

# UpdateRatios displays a graph of the effective wheel diameter.
proc UpdateRatios {} {
    global front back
    # Find the minimum and maximum gear sizes in front and back.
    foreach name {front back} {
	# Here upvar creates an alias for a local variable (scope 0 frames up)
	upvar 0 $name array
	catch {unset array(max)}
	catch {unset array(min)}
	for {set n 0} {$n < $array(n)} {incr n} {
	    if {([string length [string trim $array($n)]] == 0) ||
		[catch {expr $array($n)}]} {
		    continue
	    }
	    if {![info exists array(min)] || ($array($n) < $array(min)) } {
		set array(min) $array($n)
	    }
	    if {![info exists array(max)] || ($array($n) > $array(max)) } {
		set array(max) $array($n)
	    }
	}
	if {![info exists array(max)] || ![info exists array(min)]} {
	    return
	}
    }
    # Find the bounds of the graph, rounded to 5
    set min [expr [Gearage $front(min) $back(max)]/5 * 5]
    set max [expr ([Gearage $front(max) $back(min)]+5)/5 * 5]
    set span [expr $max - $min]

    if [winfo exists .c] {
	.c delete all
    } else {
	canvas .c
    }
    global maxwidth
    set y 10
    set xoff 20
    set xscale [expr double($maxwidth-$xoff-35)/$span]
    set fcolor ff0000
    set df     110000
    for {set f 0} {$f < $front(n)} {incr f} {
	if ![NumberOk front($f) 3 1000] {
	    continue
	}
	# Create a horizontal line for each front gear, same color as text entry.
	.c create text 0 $y -text $front($f) -fill #$fcolor
	.c create line $xoff $y [expr $xscale*$span + $xoff] $y -fill #$fcolor
	set fcolor [format %06x [expr 0x$fcolor - 0x$df]]

	set bcolor 0000ff
	for {set b 0} {$b < $back(n)} {incr b} {
	    if ![NumberOk back($b) 3 1000] {
		continue
	    }
	    if [catch {Gearage $front($f) $back($b)} g] {
		continue
	    }
	    # Plot the points in the same color as rear wheel text.
	    set x [expr $xscale *($g-$min) +$xoff]
	    set id [.c create oval [expr $x-3] [expr $y-3] [expr $x+3] [expr $y+3] \
		-fill #$bcolor -tags "gearage=$g f=$f b=$b"]
	    set bcolor [format %06x [expr 0x$bcolor - 0x11]]
	}
	incr y 20
    }
    bind .c <ButtonPress-1> [list FeedbackOn %x %y]
    bind .c <Motion> [list FeedbackOn %x %y]
    bind .c <ButtonRelease-1> [list FeedbackOff]
    .c create text $xoff $y -text $min -anchor w
    .c create text [expr $xscale*$span+$xoff] $y -text $max -anchor e
    .c create text [expr ($xscale*$span+$xoff)/2] $y \
	-text "Effective Wheel Diameter" -anchor c
    # Size the canvas to fit the plot
    .c move all 10 10
    foreach {x1 y1 x2 y2} [.c bbox all] {}
    .c config -width [expr $x2 + 0] -height [expr $y2 +0]
    grid .c -row 4 -column 0 -columnspan 3
}
proc Gearage {f b} {
    global size
    expr round($f.0 / $b.0 * $size)
} 
# As the mouse moves over the plot, display the exact value for each point it crosses.
proc FeedbackOn {x y} {
    global feedback
    foreach id [.c find overlapping [expr $x-2] [expr $y-2] [expr $x+2] [expr $y+2]] {
	if [regexp {gearage=([0-9]+) f=([0-9]+) b=([0-9]+)} [.c itemconfigure $id -tags] junk g f b] {
	    FeedbackOff
	    foreach {x1 y1 x2 y2} [.c coords $id] {}
	    set feedback [.c create text $x1 $y1 -text $g -fill blue -anchor s]
	    .front.$f config -bg white
	    .back.$b config -bg white
	    lappend feedback $f $b
	    break
	}
    }
}
proc FeedbackOff {} {
    global feedback
    catch {.c delete [lindex $feedback 0]}
    catch {.front.[lindex $feedback 1] config -bg grey75}
    catch {.back.[lindex $feedback 2] config -bg grey75}
}
update	;# So auto-sizing works ok
UpdateRatios

Added Demo/Applets/exp.tcl.



































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
<HTML>
<BODY BGCOLOR="#F0F0F0">
<CENTER>
<TABLE CELLPADDING=10 BORDER=8><TR><TD BGCOLOR="#60C0FF">
<BR>
<H3><FONT COLOR="#FF4000">Astronomical tclet</FONT></H3>
</TD></TR></TABLE>
<HR SIZE=12>
</CENTER>

<FONT COLOR="#404000">
<P>This is an example of real working (for several years)
scientific application.
The tclets are one of the various tools provided by
<B><I><A HREF="http://www.astro.spbu.ru/Clusters.html">Data Base of Radio
Sources in Galaxy's Clusters</A></I></B>. The <B>DB</B> has been creating in
<A HREF="http://www.astro.spbu.ru">Astromomical Institute</A>
(<A HREF="http://www.pu.ru">Saint-Petersburg University</A>, Russia). This tool
used to work with wish-interpreter. Now it works with
tcl/tk-plugin as well.
Such tclets are generated on fly by CGI module if requested.
The tclet displays the field of the sky where the inquired Cluster
of galaxies from Abell catalog is located. Well, the scheme of field
is displayed.</P>
<HR>
<P>Two windows are created: Control window contains some buttons
and Field window contains a picture.</P>
<P>Three type of object are present on the picture:
<UL>
<LI><TABLE CELLPADDING=0 CELLSPACING=0><TR><TD>the galaxies
from <B>APM</B> optical data (blue colored
objects</TD><TD BGCOLOR="#60C0FF">&nbsp;&nbsp;</TD><TD>),</TD></TR></TABLE></LI>
<LI><TABLE><TR><TD>the radio sources from <B>FIRST</B> catalogue
(brown colored objects</TD><TD
BGCOLOR="#C06000">&nbsp;&nbsp;</TD><TD>) and</TD></TR></TABLE></LI>
<LI><TABLE><TR><TD>the radio sources from <B>NVSS</B> catalogue
(green objects</TD><TD
BGCOLOR="#00C000">&nbsp;&nbsp;</TD><TD>).</TD></TR></TABLE></LI></UL>
The galaxies are shown as ovals with axis getting from real catalogue.
The radio sources are shown as crosses.
When mouse is over the object the info is displayd at bottom of the
field window: the coordinates of object, the size (a and b axis),
the positional angle of a-axis, star magnitude (for galaxy) or
flux density at frequency 1400MHz.</P>
<HR>
<P>The tclet supplies some useful actions.
The picture usually contains several hundreds of objects.
So some objects lay over another one.<BR>
<B>To place</B> the current object under
all other click on left mouse button.<BR>
<B>To remove</B> the object click on right one.<BR>
<B>To scale</B> the picture with some scale factor click
on middle mouse button (3-button mouse desirable).<BR>
<B>To restore</B> scale click the middle button once more.</P>

<P>You can <B>switch off/on</B> all objects of some type by clicking on
the Control window buttons: "Galaxies", "FIRST&nbsp;radio&nbsp;objects" or
"NVSS&nbsp;radio&nbsp;objects".<BR>
If you had removed some objects you can <B>restore</B> them by clicking the
"Objects&nbsp;restore" button.<BR>
You can <B>change</B> scale factor by clicking on appropriate button with number
"2", "3" or "10".</P>
<HR>
<P>These tclets are used to solve some real astronomical problems such as
the identifying of radio sources.
In a while we intend to add extra features to our tclets.</P>
<HR SIZE=5>
<CENTER>
<embed src=A1081exp.tcl width=645 height=545>
</CENTER>
<HR SIZE=3>

<P>The breif information about this this tclets you can get clicking
on "About" button. Second clicking will remove this info.</P>
<P>Detailed information may be asked by E-mail
<A HREF=mailto:tit@astro.spbu.ru> tit@astro.spbu.ru</A>
</P>
</font>
</BODY>
</HTML>
]

Added Demo/Applets/impress.tar.gz.

cannot compute difference between binary files

Added Demo/Applets/impress.tcl.









































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
#!/bin/sh
#
# Copyright  1996,1997,1998,1999 Christopher Jay Cox, All rights reserved.
#
# $Header: /home/ccox/impress/RCS/impress.tcl,v 1.10 1999/01/02 22:26:21 ccox Exp ccox $
# restart trick \
exec wish "$0" "$@"
option add *Radiobutton*borderWidth 1
option add *Button*borderWidth 1

global Group GroupNo
global Global

set Global(PointsInch) [winfo fpixels . 1i]

set Global(FontList) {
	{-adobe-avantgarde-demi-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-avantgarde-demi-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-avantgarde-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-avantgarde-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-cheq-medium-r-normal--*-240-72-72-m-0-adobe-fontspecific}
	{-adobe-courier-bold-i-normal--*-240-72-72-m-0-iso8859-1}
	{-adobe-courier-bold-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-courier-bold-r-normal--*-240-72-72-m-0-iso8859-1}
	{-adobe-courier-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-courier-medium-i-normal--*-240-72-72-m-0-iso8859-1}
	{-adobe-courier-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-courier-medium-r-normal--*-240-72-72-m-0-iso8859-1}
	{-adobe-courier-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-helvetica-bold-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-helvetica-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-helvetica-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-helvetica-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-lubalingraph-demi-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-lubalingraph-demi-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-lubalingraph-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-lubalingraph-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-newcenturyschlbk-bold-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-newcenturyschlbk-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-newcenturyschlbk-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-newcenturyschlbk-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-souvenir-demi-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-souvenir-demi-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-souvenir-light-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-souvenir-light-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-symbol-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-adobe-times-bold-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-times-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-times-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-times-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-utopia-bold-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-utopia-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-utopia-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-utopia-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-adobe-zapfdingbats-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-bitstream-charter-black-i-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-charter-black-r-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-charter-bold-i-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-charter-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-charter-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-charter-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-charter-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-charter-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-bitstream-courier-bold-i-normal--*-240-72-72-m-0-iso8859-1}
	{-bitstream-courier-bold-i-normal--*-240-72-72-m-0-iso8859-1}
	{-bitstream-courier-bold-r-normal--*-240-72-72-m-0-iso8859-1}
	{-bitstream-courier-bold-r-normal--*-240-72-72-m-0-iso8859-1}
	{-bitstream-courier-medium-i-normal--*-240-72-72-m-0-iso8859-1}
	{-bitstream-courier-medium-i-normal--*-240-72-72-m-0-iso8859-1}
	{-bitstream-courier-medium-r-normal--*-240-72-72-m-0-iso8859-1}
	{-bitstream-courier-medium-r-normal--*-240-72-72-m-0-iso8859-1}
	{-brecher-shalomoldstyle-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-brecher-shalomscript-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-brecher-shalomstick-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-fontbank-muriel-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-fontbank-roostheavy-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-meit-goodcitymodern-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-meit-goodcitymodern-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-agate-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-agate-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-agate-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-arnoldboecklin-extrabold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-baskerville-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-baskerville-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-baskerville-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-becker-medium-r-normal-medium-*-240-72-72-p-0-iso8859-1}
	{-paradise-blippo-heavy-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-bodoni-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-bodoni-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-bodoni-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-cooper-heavy-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-eras-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-eras-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-erasblack-demibold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-eraslight-light-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-erasmedium-medium-r-normal-medium-*-240-72-72-p-0-iso8859-1}
	{-paradise-erasultrablk-heavy-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-garamond-medium-i-normal-medium-*-240-72-72-p-0-iso8859-1}
	{-paradise-goudyoldstyle-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-goudyoldstyle-medium-i-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-goudyoldstyle-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-parkavenue-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-paradise-slogan-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-rakowski-ann-medium-r-normal-stone-*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-crackling-medium-r-normal-fire-*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-davysbigkeycaps-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-davysdingbats-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-davysotherdingbats-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-dobkin-medium-r-normal-script-*-240-72-72-p-0-iso8859-1}
	{-rakowski-dragonwick-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-elizabeth-medium-r-normal-alternate-*-240-72-72-p-0-iso8859-1}
	{-rakowski-green-medium-r-normal-caps-*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-polosemiscript-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-rechtman-medium-r-normal-script-*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-rudelsberg-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-salter-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-shohl-medium-r-normal-fold-*-240-72-72-p-0-iso8859-1}
	{-rakowski-tempofont-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-tribeca-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-upperwestside-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-rakowski-zaleskicaps-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-southern-tekton display ssi-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-southern-victoriana display ssi-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown--medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown--medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown--medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-blackforest-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-bodidlybold-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-braillehc-medium-r-normal--*-240-72-72-m-0-iso8859-1}
	{-unknown-brushstroke-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-burgundian-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-caligula-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-carrickcaps-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-cartwright-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-classicheavy-light-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-comicscartoon-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-coronet-demibold-i-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-crillee-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-cuneifont-light-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-duncan-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-engraver-light-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-florence-light-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-frizquadrata-bold-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-frizquadrata-thin-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-futura_poster-light-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-genoaitalic-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-genoaroman-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-igloolaser-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-lauramccrary-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-linotext-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-luxembourg-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-manzanita-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-mazama-medium-r-normal-plain-*-240-72-72-p-0-iso8859-1}
	{-unknown-mesozoicgothic-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-oldtown-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-oswaldblack-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-perrygothic-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-postantiqua-regular-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-romeodn-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-sharktooth-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-sinaloa-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-spooky-medium-r-normal-plain-*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-sumdumgoi-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-tempofontitalic-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-unknown-westernslant-medium-r-normal--*-240-72-72-p-0-iso8859-1}
	{-unknown-windsordemi-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-urw-oldtown-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-urw-oldtowncnd-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
	{-urw-oldtownext-medium-r-normal--*-240-72-72-p-0-adobe-fontspecific}
}

image create bitmap stripe -data "
#define stripe4_width 4
#define stripe4_height 4
static char stripe4_bits[] = {
   0x09, 0x0c, 0x06, 0x03};
"

set Global(ArrowW) 3
set Global(ArrowP) 8
set Global(ArrowD) 10
set Global(ViewScale) 1
set Global(CacheSlides) 0
set Global(SlideScale) 0
set Global(HistSize) 10
set Global(TagId) 0
set Global(Undo) ""
set Global(StreamType) FIFO
set Global(Timeout) 40000
set Global(sbg) ""
set Global(F_Outline) ""
set Global(F_Fill) ""
set Global(F_SlideBG) ""
set Global(colortypeSave) Outline
set Global(PSColor) color
set Global(Circulate) 1
set Global(EmbedPage) 1
set Global(CoordFactorX) 1
set Global(CoordFactorY) 1
set Global(Xpos) 0
set Global(Ypos) 0
set Global(CurrentPageId) 1
set Global(curline) ""
set Global(colortype) Outline
set Global(selectnum) 0
set Global(CurrentPage) ""
set Global(FixedAspect) True
set Global(Grid) 0
set Global(GridX) .25i
set Global(GridY) .25i
set Global(UnitX) i
set Global(UnitY) i
set Global(ScreenH) [winfo screenheight .]
set Global(ScreenW) [winfo screenwidth .]
set Global(Start) ""
set Global(top_left_corner) bottom_right_corner
set Global(top_side) bottom_side
set Global(top_right_corner) bottom_left_corner
set Global(right_side) left_side
set Global(bottom_right_corner) top_left_corner
set Global(bottom_side) top_side
set Global(bottom_left_corner) top_right_corner
set Global(left_side) right_side
set Global(Duplicate) ""
set Global(Cut) ""
set Global(Copy) ""
set Global(Message) "Select"
set Global(Smooth) 0
set Global(Msg_Smooth) "Switch to Smooth Lines"
set Global(Msg_miter) "Miter Line Joints"
set Global(Msg_round) "Round Line Joints"
set Global(Msg_bevel) "Bevel Line Joints"
set Global(Msg_first) "Arrow at First Point"
set Global(Msg_last) "Arrow at Last Point"
set Global(Msg_both) "Arrow at Both Ends"
set Global(Msg_none) "No Arrows"
set Global(Msg_Rounded_Rectangle) "Rounded Rectangle"
set Global(Msg_Flip_Vert) "Flip Vertical"
set Global(Msg_Flip_Horiz) "Flip Horizontal"
set Global(Msg_PageProp) "Page Properities"
set Global(Spline) 0
set Global(Sub-Cursor) ""
set Global(Fill) ""
set Global(Outline) black
set Global(Stipple) ""
set Global(OutStipple) ""
set Global(JoinStyle) miter
set Global(Arrow) none
set Global(Width) 1.0
set Global(PageWidth) 8.5i
set Global(PageHeight) 11i
set Global(Landscape) 0
set Global(PageVisX) 3i
set Global(PageVisY) 2i
set Global(PageBg) white
set Global(Units) i
set Global(ScrollDir) ""
set Global(OpenFile) ""
set Global(ParaStyle) Normal
set Global(AnchorChosen) 0
set Global(Gravity) 1
set Global(GravityVal) 30
set Global(MenuSelect) 0
set Global(Font) {-*-apollo-*-r-*-*-*-240-72-72-*-*-*-*}
set Global(PrintCmd) {lpr -Plp2}
set Global(FontScale) 1
set Global(PrivateCmap) ""
set GroupNo [clock clicks]
set Global(ButtonSize) .35i
set Global(ButtonRelief) flat
set Global(ButtonOrient) top
set Global(ButtonCount)  10
set Global(ColorWidth) 400
set Global(ColorHeight) 100
set Global(SlideBG) white
button .b
set Global(Background) [.b cget -bg]
set Global(ActiveBackground) [.b cget -activebackground]
destroy .b

set Global(DefButtonColor) [. cget -bg]
set Global(ButtonColor) DarkCyan
set Global(ButtonStipple1) gray50
set Global(ButtonStipple2) {}
set Global(Buttons) {
	{Button PageProp {
		set i [$Global(CurrentCanvas) create polygon 0.0 0.0 25.0 0.0 \
			25.0 0.0 175.073846154 0.0 175.073846154 0.0 200.073846154 0.0 \
			200.073846154 25.0 200.073846154 25.0 200.073846154 175.073846154 \
			200.073846154 175.073846154 200.073846154 200.073846154 \
			175.073846154 200.073846154 175.073846154 200.073846154 25.0 \
			200.073846154 25.0 200.073846154 0.0 200.073846154 0.0 \
			175.073846154 0.0 175.073846154 0.0 25.0 0.0 25.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 36.0 172.0 36.0 47.0 \
			61.0 22.0 161.0 22.0 161.0 172.0 \
			-fill #FFFFFFFFFFFF -outline black -smooth 0 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 36.0 47.0 61.0184615385 \
			47.0184615385 61.0184615385 22.0092307692 -arrow none \
			-arrowshape {8 10 3} -capstyle butt -fill black -joinstyle miter \
			-smooth 0 -splinesteps 12 -stipple $Global(ButtonStipple1) \
			-tags {} -width 1]
	}}
	{Button Grid {
		set i [$Global(CurrentCanvas) create polygon 0.0 0.0 25.0 0.0 25.0 \
			0.0 175.073846154 0.0 175.073846154 0.0 200.073846154 0.0 \
			200.073846154 25.0 200.073846154 25.0 200.073846154 \
			175.073846154 200.073846154 175.073846154 200.073846154 \
			200.073846154 175.073846154 200.073846154 175.073846154 \
			200.073846154 25.0 200.073846154 25.0 200.073846154 0.0 \
			200.073846154 0.0 175.073846154 0.0 175.073846154 0.0 25.0 \
			0.0 25.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 24.0092307692 \
			26.0184615385 49.0092307692 26.0184615385 49.0092307692 \
			26.0184615385 149.064615385 26.0184615385 149.064615385 \
			26.0184615385 174.064615385 26.0184615385 174.064615385 \
			51.0184615385 174.064615385 51.0184615385 174.064615385 \
			151.073846154 174.064615385 151.073846154 174.064615385 \
			176.073846154 149.064615385 176.073846154 149.064615385 \
			176.073846154 49.0092307692 176.073846154 49.0092307692 \
			176.073846154 24.0092307692 176.073846154 24.0092307692 \
			151.073846154 24.0092307692 151.073846154 24.0092307692 \
			51.0184615385 24.0092307692 51.0184615385 \
			-fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) \
			-tags Group-759492866 -width 2]
		set Group($Global(CurrentCanvas),$i) {Group-759492866}
		set i [$Global(CurrentCanvas) create line 24.0 101.0 174.064615385 \
			101.046153846 \
			-arrow none -arrowshape {8 10 3} -capstyle butt -fill black \
			-joinstyle miter -smooth 0 -splinesteps 12 -stipple {} \
			-tags Group-759492866 -width 2]
		set Group($Global(CurrentCanvas),$i) {Group-759492866}
		set i [$Global(CurrentCanvas) create line 99.0 176.0 99.036923077 \
			26.0184615385 \
			-arrow none -arrowshape {8 10 3} -capstyle butt -fill black \
			-joinstyle miter -smooth 0 -splinesteps 12 -stipple {} \
			-tags Group-759492866 -width 2]
		set Group($Global(CurrentCanvas),$i) {Group-759492866}
	}}
	{RadioButton Select {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 \
			24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 \
			24.0 171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 \
			161.0 24.0 161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 \
			-1.0 24.0 -1.0 24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 37.9541566013 \
			22.1761496591 61.9830972933 102.92577573 73.664874718 \
			69.3468499177 109.153797554 67.2150576124 \
			-fill $Global(ButtonColor) -outline #000000000000 -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 73.664874718 \
			69.3468499177 113.417382164 138.192903283 129.140948917 \
			126.289330577 \
			-fill $Global(ButtonColor) -outline #000000000000 -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width 1]
	}}
	{RadioButton Oval {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 \
			24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 \
			24.0 171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 \
			161.0 24.0 161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 \
			-1.0 24.0 -1.0 24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 83.0723583615 \
			21.1233836897 108.415159222 24.7089434403 130.701244279 \
			35.0331512701 147.242582766 50.850755345 156.044045139 \
			70.2539191706 156.044045139 90.9023348301 147.242582766 \
			110.305498656 130.701244279 126.123102731 108.415159222 \
			136.44731056 83.0723583615 140.032870311 57.7295575006 \
			136.44731056 35.4434724439 126.123102731 18.9021339567 \
			110.305498656 10.1006715836 90.9023348301 10.1006715836 \
			70.2539191706 18.9021339567 50.850755345 35.4434724439 \
			35.0331512701 57.7295575006 24.7089434403 \
			-fill $Global(ButtonColor) -outline black -smooth 1 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width 1]
	}}
	{RadioButton Rectangle {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 24.0 \
			-1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 24.0 171.0 \
			136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 161.0 24.0 161.0 \
			24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 24.0 -1.0 24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 20.0 32.0 45.0 32.0 45.0 \
			32.0 126.0 32.0 126.0 32.0 151.0 32.0 151.0 57.0 151.0 57.0 151.0 \
			104.0 151.0 104.0 151.0 129.0 126.0 129.0 126.0 129.0 45.0 129.0 \
			45.0 129.0 20.0 129.0 20.0 104.0 20.0 104.0 20.0 57.0 20.0 57.0 \
			-fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width 1]
	}}
	{RadioButton Rounded_Rectangle {
		set i [$Global(CurrentCanvas) create polygon 0.0 -1.0 25.0 -1.0 25.0 \
			-1.0 147.0 -1.0 147.0 -1.0 172.0 -1.0 172.0 24.0 172.0 24.0 172.0 \
			136.0 172.0 136.0 172.0 161.0 147.0 161.0 147.0 161.0 25.0 161.0 \
			25.0 161.0 0.0 161.0 0.0 136.0 0.0 136.0 0.0 24.0 0.0 24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 18.7164223548 \
			93.1459545703 18.7164223548 78.0842279201 18.7164223548 \
			55.4916379449 39.8880947215 32.8990479696 61.0597670883 \
			32.8990479696 110.460335944 32.8990479696 131.632008311 \
			32.8990479696 152.803680677 55.4916379449 152.803680677 \
			78.0842279201 152.803680677 93.1459545703 152.803680677 \
			115.738544546 131.632008311 138.331134521 110.460335944 \
			138.331134521 61.0597670883 138.331134521 39.8880947215 \
			138.331134521 18.7164223548 115.738544546 18.7164223548 \
			93.1459545703 \
			-fill $Global(ButtonColor) -outline black -smooth 1 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width 1]
	}}
	{RadioButton Polygon {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 24.0 \
			-1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 24.0 171.0 \
			136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 161.0 24.0 161.0 \
			24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 24.0 -1.0 24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 15.0 130.0 53.0 15.0 \
			143.0 70.0 154.0 141.0 84.0 100.0 \
			-fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width 1]
	}}
	{RadioButton Line {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 24.0 \
			-1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 24.0 171.0 \
			136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 161.0 24.0 161.0 \
			24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 24.0 -1.0 24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 49.0 135.0 116.0 23.0 \
			-arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill $Global(ButtonColor) -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 2]
	}}
	{RadioButton Draw {
		set i [$Global(CurrentCanvas) create polygon 0.0 -1.0 25.0 -1.0 25.0 \
			-1.0 147.0 -1.0 147.0 -1.0 172.0 -1.0 172.0 24.0 172.0 24.0 172.0 \
			136.0 172.0 136.0 172.0 161.0 147.0 161.0 147.0 161.0 25.0 161.0 \
			25.0 161.0 0.0 161.0 0.0 136.0 0.0 136.0 0.0 24.0 0.0 24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 33.365796242 145.814066335 \
			36.5148450736 144.251781322 42.8129427365 142.68949631 \
			50.1607233434 142.68949631 57.5085039502 142.68949631 \
			64.8562845571 142.68949631 70.1046992763 141.127211298 \
			74.3034310516 139.564926285 80.6015287147 138.002641273 \
			84.80026049 136.440356261 87.9493093215 134.878071249 \
			88.9989922654 134.096928743 92.1480410969 130.972358718 \
			92.6728825688 130.191216212 92.6728825688 129.410073706 \
			92.6728825688 127.847788693 92.1480410969 127.847788693 \
			91.0983581531 127.847788693 90.5735166811 127.066646187 \
			89.5238337373 127.066646187 88.4741507934 127.066646187 \
			87.4244678496 127.066646187 86.8996263777 127.847788693 \
			86.3747849058 127.847788693 85.8499434338 128.6289312 \
			85.8499434338 129.410073706 86.3747849058 129.410073706 \
			87.4244678496 130.191216212 91.623199625 131.753501224 \
			97.9212972879 131.753501224 104.219394951 131.753501224 \
			108.418126727 131.753501224 111.567175558 128.6289312 \
			113.666541446 125.504361175 114.71622439 120.817506139 \
			114.71622439 119.255221126 114.191382918 118.47407862 \
			111.042334086 115.349508596 107.893285255 113.787223583 \
			103.694553479 112.224938572 98.4461387599 112.224938572 \
			97.396455816 112.224938572 96.8716143441 112.224938572 \
			97.396455816 113.006081078 100.545504648 114.568366089 \
			103.694553479 117.692936114 107.893285255 119.255221126 \
			112.09201703 120.817506139 117.340431749 122.379791151 \
			122.588846468 122.379791151 127.837261188 120.817506139 \
			132.035992963 117.692936114 134.135358851 113.006081078 \
			134.660200323 111.443796066 134.135358851 109.881511053 \
			133.085675907 105.194656016 130.986310019 100.50780098 \
			127.837261188 98.9455159677 124.688212356 97.3832309552 \
			123.11368794 97.3832309552 119.964639109 98.9455159677 \
			119.439797637 99.7266584736 118.914956165 100.50780098 \
			119.439797637 101.288943486 122.588846468 105.975798522 \
			129.936627075 107.538083535 136.234724738 109.100368547 \
			140.433456514 110.662653559 148.830920064 112.224938572 \
			154.079334783 110.662653559 154.604176255 109.881511053 \
			-arrow none -arrowshape {8 10 3} -capstyle butt -fill black \
			-joinstyle miter -smooth 1 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 78.7435236121 \
			33.9985878915 78.7435236121 33.9985878915 106.368114916 \
			50.9983363864 106.368114916 50.9983363864 80.7643270484 \
			106.560014371 80.4934977219 106.39335017 67.7228533257 \
			111.976600902 55.5771996827 120.184812798 43.6815423415 \
			130.41382813 31.9733822263 143.371969751 25.7859737669 \
			150.392699215 25.7859737669 150.392699215 32.8900353314 \
			134.601266178 39.4941042931 114.768226267 41.7649040308 \
			97.1226539937 41.2024123527 84.0811802709 40.2440931973 \
			81.9978777593 40.2440931973 81.9978777593 78.7435236121 \
			33.9985878915 78.7435236121 33.9985878915 \
			-fill $Global(ButtonColor) -outline black -smooth 1 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 26.0568030934 \
			150.559363416 61.5562778913 92.87271687 \
			-arrow none -arrowshape {8 10 3} -capstyle butt -fill black \
			-joinstyle miter -smooth 1 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 67.2853597982 \
			82.9561969146 68.5915312389 84.1540647575 69.388371286 \
			85.7791073015 69.5797692697 87.6353204321 69.1426397684 \
			89.4988174513 68.1297070511 91.144833117 66.6631457534 \
			92.3748336461 64.9198448115 93.0404628225 63.1100720471 \
			93.0614359441 61.4521127656 92.4352233425 60.1459413251 \
			91.2373554997 59.3491012779 89.6123129557 59.1577032942 \
			87.756099825 59.5948327955 85.8926028059 60.6077655128 \
			84.2465871402 62.0743268104 83.016586611 63.8176277524 \
			82.3509574347 65.6274005169 82.3299843131 \
			-fill {} -outline black -smooth 1 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 79.8476739433 \
			13.3947260516 86.618407106 17.5613310748 86.618407106 \
			17.5613310748 117.222121002 36.3943857799 117.222121002 \
			36.3943857799 123.992854165 40.5609908033 119.826249142 \
			47.3317239661 119.826249142 47.3317239661 118.659599735 \
			49.2275292516 118.659599735 49.2275292516 114.492994711 \
			55.9982624145 107.722261548 51.831657391 107.722261548 \
			51.831657391 77.118547653 32.9986026859 77.118547653 \
			32.9986026859 70.3478144903 28.8319976627 74.5144195135 \
			22.0612644999 74.5144195135 22.0612644999 75.6810689201 \
			20.1654592143 75.6810689201 20.1654592143 \
			-fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 115.0 34.0 115.0 34.0 \
			135.0 6.0 135.0 6.0 92.0 6.0 92.0 6.0 87.0 16.0 87.0 16.0 \
			114.0 34.0 114.0 34.0 \
			-fill white -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple2) -tags {} -width 1]
	}}
	{RadioButton Text {
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 120.580883712 20.1519264665 112.23091983 \
			111.647154041 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 112.23091983 111.647154041 111.992824043 \
			114.033649023 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 111.992824043 114.033649023 111.815636481 \
			116.071305992 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 111.815636481 116.071305992 111.682745809 \
			117.760124947 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 123.498941382 \
			129.604006076 125.857750807 129.653840078 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 121.433598856 \
			129.471115404 123.498941382 129.604006076 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 119.661723232 \
			129.24409384 121.433598856 129.471115404 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 118.172240285 \
			128.922941383 119.661723232 129.24409384 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 116.976224238 \
			128.518732256 118.172240285 128.922941383 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 115.962932865 \
			128.014855125 116.976224238 128.518732256 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 115.962932865 \
			128.014855125 124.960738772 132.654954418 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 115.038235273 \
			127.411309991 115.962932865 128.014855125 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 114.202131463 \
			126.713633963 115.038235273 127.411309991 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 113.454621434 \
			125.921827043 114.202131463 126.713633963 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 112.795705186 \
			125.03035212 113.454621434 125.921827043 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 112.358273391 \
			124.288379202 112.795705186 125.03035212 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 112.0205096 \
			123.419052723 112.358273391 124.288379202 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.776876701 \
			122.427909796 112.0205096 123.419052723 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.627374696 \
			121.314950419 111.776876701 122.427909796 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.577540694 \
			120.080174593 111.627374696 121.314950419 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 82.5409288925 129.653840078 84.4069354098 \
			129.653840078 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 84.4069354098 129.653840078 86.439055267 \
			129.559709186 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 86.439055267 129.559709186 88.316136007 \
			129.288390731 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 88.316136007 129.288390731 90.0326405185 \
			128.834347602 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.577540694 \
			120.080174593 81.6494539688 132.654954418 90.0326405185 \
			128.834347602 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.577540694 \
			120.080174593 90.0326405185 128.834347602 91.5996430242 \
			128.197579799 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.60522625 \
			119.094568777 111.577540694 120.080174593 91.5996430242 \
			128.197579799 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 111.60522625 119.094568777 91.5996430242 \
			128.197579799 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 91.5996430242 128.197579799 93.0060693014 \
			127.383624434 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 93.0060693014 127.383624434 93.9030813364 \
			126.685948407 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 93.9030813364 126.685948407 94.7170367015 \
			125.82215904 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 94.7170367015 125.82215904 95.4479353968 \
			124.803330555 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 95.4479353968 124.803330555 96.0957774221 \
			123.618388731 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 96.0957774221 123.618388731 96.6550256661 \
			122.272870679 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 96.6550256661 122.272870679 97.0094007911 \
			120.993797962 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 111.682745809 117.760124947 97.0094007911 \
			120.993797962 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 97.0094007911 120.993797962 97.3582388047 \
			119.172088335 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 97.3582388047 119.172088335 97.6960025957 \
			116.802204687 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 97.6960025957 116.802204687 98.0337663867 \
			113.889684129 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 98.0337663867 113.889684129 98.360455955 \
			110.428989549 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 98.360455955 110.428989549 99.6561400056 \
			96.4754690041 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 99.6561400056 96.4754690041 100.303982031 \
			90.556296995 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 100.303982031 90.556296995 104.523260862 \
			47.1619555218 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 104.523260862 47.1619555218 72.6461109503 \
			90.556296995 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 72.6461109503 \
			90.556296995 100.303982031 90.556296995 99.6561400056 \
			96.4754690041 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 72.6461109503 \
			90.556296995 99.6561400056 96.4754690041 68.1887363317 \
			96.4754690041 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 72.6461109503 90.556296995 68.1887363317 \
			96.4754690041 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 68.1887363317 96.4754690041 56.9926972276 \
			111.647154041 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 56.9926972276 111.647154041 55.5807338391 \
			113.574068783 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 56.8653436671 \
			129.249630951 58.4821801747 129.520949406 59.4234891004 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 55.4699916126 \
			128.845421824 56.8653436671 129.249630951 59.4234891004 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.2961240111 \
			128.302784914 55.4699916126 128.845421824 59.4234891004 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 53.3437408628 \
			127.621720221 54.2961240111 128.302784914 59.4234891004 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 53.3437408628 \
			127.621720221 59.4234891004 132.654954418 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 52.585156611 \
			126.846524635 53.3437408628 127.621720221 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.9926856989 \
			126.015957936 52.585156611 126.846524635 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.571865238 \
			125.124483012 51.9926856989 126.015957936 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.317158117 \
			124.172099864 51.571865238 125.124483012 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.2341014471 \
			123.164345602 51.317158117 124.172099864 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.2728612264 \
			122.372538683 51.2341014471 123.164345602 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.3891405642 \
			121.558583317 51.2728612264 122.372538683 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.5829394607 \
			120.722479507 51.3891405642 121.558583317 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 51.8542579157 \
			119.869764363 51.5829394607 120.722479507 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 52.2086330407 \
			118.98382655 51.8542579157 119.869764363 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 52.7125101715 \
			117.976072289 52.2086330407 118.98382655 26.8984971629 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 26.8984971629 \
			132.654954418 27.795509198 129.653840078 30.1377072895 \
			129.415744291 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 26.8984971629 \
			132.654954418 30.1377072895 129.415744291 32.3691631544 \
			128.895255826 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 26.8984971629 \
			132.654954418 32.3691631544 128.895255826 34.4843396815 \
			128.092374684 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 26.8984971629 \
			132.654954418 34.4843396815 128.092374684 36.4887739821 \
			127.007100864 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 52.7125101715 \
			117.976072289 26.8984971629 132.654954418 36.4887739821 \
			127.007100864 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 53.4378717554 \
			116.741296463 52.7125101715 117.976072289 36.4887739821 \
			127.007100864 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 53.4378717554 116.741296463 36.4887739821 \
			127.007100864 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 36.4887739821 127.007100864 38.3769289447 \
			125.639434366 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 38.3769289447 125.639434366 40.3924374679 \
			123.784502071 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 40.3924374679 123.784502071 42.7623211161 \
			121.248505083 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 42.7623211161 121.248505083 45.4976541118 \
			118.031443402 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 45.4976541118 118.031443402 48.5928993439 \
			114.127779916 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 48.5928993439 114.127779916 52.0425197009 \
			109.537514626 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 54.395792015 \
			115.273961961 52.0425197009 109.537514626 117.745882712 \
			20.1519264665 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 120.580883712 20.1519264665 112.23091983 \
			111.647154041 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 112.23091983 111.647154041 111.992824043 \
			114.033649023 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 111.992824043 114.033649023 111.815636481 \
			116.071305992 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 111.815636481 116.071305992 111.682745809 \
			117.760124947 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 123.498941382 \
			129.604006076 125.857750807 129.653840078 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 121.433598856 \
			129.471115404 123.498941382 129.604006076 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 119.661723232 \
			129.24409384 121.433598856 129.471115404 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 118.172240285 \
			128.922941383 119.661723232 129.24409384 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 116.976224238 \
			128.518732256 118.172240285 128.922941383 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 115.962932865 \
			128.014855125 116.976224238 128.518732256 124.960738772 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 115.962932865 \
			128.014855125 124.960738772 132.654954418 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 115.038235273 \
			127.411309991 115.962932865 128.014855125 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 114.202131463 \
			126.713633963 115.038235273 127.411309991 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 113.454621434 \
			125.921827043 114.202131463 126.713633963 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 112.795705186 \
			125.03035212 113.454621434 125.921827043 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 112.358273391 \
			124.288379202 112.795705186 125.03035212 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 112.0205096 \
			123.419052723 112.358273391 124.288379202 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.776876701 \
			122.427909796 112.0205096 123.419052723 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.627374696 \
			121.314950419 111.776876701 122.427909796 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.577540694 \
			120.080174593 111.627374696 121.314950419 81.6494539688 \
			132.654954418 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 82.5409288925 129.653840078 84.4069354098 \
			129.653840078 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 84.4069354098 129.653840078 86.439055267 \
			129.559709186 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 86.439055267 129.559709186 88.316136007 \
			129.288390731 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 81.6494539688 \
			132.654954418 88.316136007 129.288390731 90.0326405185 \
			128.834347602 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.577540694 \
			120.080174593 81.6494539688 132.654954418 90.0326405185 \
			128.834347602 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.577540694 \
			120.080174593 90.0326405185 128.834347602 91.5996430242 \
			128.197579799 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.60522625 \
			119.094568777 111.577540694 120.080174593 91.5996430242 \
			128.197579799 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 111.60522625 119.094568777 91.5996430242 \
			128.197579799 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 91.5996430242 128.197579799 93.0060693014 \
			127.383624434 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 111.682745809 \
			117.760124947 93.0060693014 127.383624434 93.9030813364 \
			126.685948407 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 45.4976541118 \
			118.031443402 48.5928993439 114.127779916 48.5928993439 \
			114.127779916 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 48.5928993439 \
			114.127779916 48.5928993439 114.127779916 52.0425197009 \
			109.537514626 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 48.5928993439 \
			114.127779916 52.0425197009 109.537514626 52.0425197009 \
			109.537514626 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 52.0425197009 \
			109.537514626 52.0425197009 109.537514626 117.745882712 \
			20.1519264665 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 52.0425197009 \
			109.537514626 117.745882712 20.1519264665 117.745882712 \
			20.1519264665 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 117.745882712 20.1519264665 120.580883712 \
			20.1519264665 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 117.745882712 \
			20.1519264665 120.580883712 20.1519264665 120.580883712 \
			20.1519264665 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 104.523260862 \
			47.1619555218 104.523260862 47.1619555218 72.6461109503 \
			90.556296995 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 104.523260862 \
			47.1619555218 72.6461109503 90.556296995 72.6461109503 \
			90.556296995 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 72.6461109503 \
			90.556296995 72.6461109503 90.556296995 100.303982031 \
			90.556296995 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 72.6461109503 \
			90.556296995 100.303982031 90.556296995 100.303982031 \
			90.556296995 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 100.303982031 \
			90.556296995 100.303982031 90.556296995 104.523260862 \
			47.1619555218 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon 100.303982031 \
			90.556296995 104.523260862 47.1619555218 104.523260862 \
			47.1619555218 \
			-fill $Global(ButtonColor) -outline {} -smooth 0 \
			-splinesteps 12 -stipple {}  -width 1]
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 \
			24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 24.0 \
			171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 161.0 24.0 \
			161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 24.0 -1.0 \
			24.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
	}}
	{RadioButton Rotate {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 \
			24.0 -1.0 24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 \
			171.0 24.0 171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 \
			161.0 24.0 161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 \
			24.0 -1.0 24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			35.9696969695 95.484848484 35.9696969695 95.484848484 \
			19.4848484848 76.0909090903 19.4848484848 76.0909090903 \
			27.2424242423 76.0909090903 27.2424242423 76.0909090903 \
			30.3939393938 63.2424242419 38.8787878785 47.4848484846 \
			50.2727272723 35.8484848483 63.8484848479 27.8484848484 \
			79.8484848477 23.4848484848 96.8181818172 24.2121212121 \
			109.909090908 28.3333333333 122.272727271 35.3636363635 \
			133.18181818 46.2727272724 138.030303029 52.8181818178 \
			138.030303029 52.8181818178 119.363636362 59.848484848 \
			119.363636362 59.848484848 109.666666666 49.6666666663 \
			98.2727272718 43.8484848482 83.9696969689 41.424242424 \
			69.1818181812 44.8181818179 57.545454545 52.333333333 \
			50.0303030299 62.0303030298 46.1515151512 70.757575757 \
			44.9393939391 76.5757575751 44.9393939391 76.5757575751 \
			53.4242424238 76.5757575751 53.4242424238 76.5757575751 \
			35.9696969695 95.484848484 35.9696969695 95.484848484 -fill \
			$Global(ButtonColor) -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			32.3333333332 107.363636363 32.3333333332 107.363636363 \
			49.0606060602 101.303030302 48.8181818178 101.303030302 \
			58.2727272722 113.909090908 73.0606060599 122.393939393 \
			85.6666666659 124.333333332 100.939393938 121.181818181 \
			112.818181817 113.666666666 120.818181817 103.484848484 \
			125.181818181 93.3030303022 126.15151515 87.2424242416 \
			126.15151515 87.2424242416 118.15151515 87.2424242416 \
			118.15151515 87.2424242416 135.848484847 69.06060606 \
			135.848484847 69.06060606 152.575757574 88.2121212113 \
			152.575757574 88.2121212113 145.303030301 88.2121212113 \
			145.303030301 88.2121212113 142.15151515 103.969696969 \
			132.696969696 120.454545453 118.878787878 132.575757574 \
			104.818181817 139.606060605 87.1212121204 142.515151514 \
			69.6666666661 140.333333332 53.4242424238 132.575757574 \
			41.7878787876 122.15151515 34.9999999998 112.696969696 \
			32.3333333332 107.363636363 -fill $Global(ButtonColor) -outline \
			black -smooth 1 -splinesteps 12 -stipple $Global(ButtonStipple1) \
			-width 1]
	}}
	{Button Duplicate {
		set i [$Global(CurrentCanvas) create polygon \
			47.4759175308 12.4301808516 55.8584904465 13.4585960037 \
			63.2300013546 16.4197994153 68.7013372479 20.956626252 \
			71.61257427 26.5218682407 71.61257427 32.4442750639 68.7013372479 \
			38.0095170526 63.2300013546 42.5463438893 55.8584904465 \
			45.5075473009 47.4759175308 46.535962453 39.0933446153 \
			45.5075473009 31.7218337072 42.5463438893 26.2504978137 \
			38.0095170526 23.3392607919 32.4442750639 23.3392607919 \
			26.5218682407 26.2504978137 20.956626252 31.7218337072 \
			16.4197994153 39.0933446153 13.4585960037 -fill \
			$Global(ButtonColor) -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 47.7512995935 \
			46.535962453 47.7512995935 101.263844557 19.1115650792 \
			128.231206754 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 48.3020637188 \
			73.8999035053 87.9570807386 51.6914875788 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 47.7512995935 \
			73.5033246495 12.5023955758 59.2264858396 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 116.046051128 \
			73.8999035053 116.046051128 128.62778561 87.4063166134 \
			155.595147806 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 116.596815253 \
			129.024364466 144.685785641 153.612253528 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 116.596815253 \
			101.263844557 156.251832272 79.0554286311 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 116.046051128 \
			100.867265702 80.7971471101 86.5904268918 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 \
			24.0 -1.0 24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 \
			171.0 24.0 171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 \
			161.0 24.0 161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 \
			24.0 -1.0 24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 49.6668789479 \
			102.974072534 77.7558493372 127.561961596 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 49.6001644466 \
			30.9036809488 58.138044364 33.983196081 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 66.6193681583 \
			37.0310374934 75.1635320896 40.1128150343 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 83.6385718701 \
			43.1583940379 92.189019815 46.2424339874 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 100.657775582 \
			49.2857505826 109.21450754 52.3720529407 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 48.6957058477 \
			101.890726463 57.2335857658 104.970241595 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 65.7149095594 \
			108.018083008 74.2590734905 111.099860548 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 82.7341132712 \
			114.145439552 91.284561216 117.229479501 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 99.7533169831 \
			120.272796096 108.310048942 123.359098455 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			115.770669065 39.7941219039 124.153241981 40.822537056 \
			131.524752889 43.7837404676 136.996088783 48.3205673043 \
			139.907325804 53.885809293 139.907325804 59.8082161163 \
			136.996088783 65.3734581049 131.524752889 69.9102849416 \
			124.153241981 72.8714883532 115.770669065 73.8999035053 \
			107.38809615 72.8714883532 100.016585241 69.9102849416 \
			94.545249348 65.3734581049 91.6340123261 59.8082161163 \
			91.6340123261 53.885809293 94.545249348 48.3205673043 \
			100.016585241 43.7837404676 107.38809615 40.822537056 -fill \
			$Global(ButtonColor) -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
	}}
	{Button Flip_Horiz {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 \
			24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 24.0 \
			171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 161.0 24.0 \
			161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 24.0 -1.0 \
			24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 128.12386206 \
			92.3378232918 47.9129114389 92.3378232922 47.9129114391 \
			132.443298603 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create polygon 128.12386206 \
			65.5959036929 47.9129114388 65.5959036933 47.9129114386 \
			25.4904283825 -fill #FFFFFFFFFFFF -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create line 141.492353831 \
			78.9643954631 128.118926002 78.9841396972 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 114.75537029 \
			78.9643954632 101.372070344 78.9841396973 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 88.01838675 \
			78.9643954634 74.6252146869 78.9841396974 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 61.2814032089 \
			78.9643954635 47.8783590289 78.9841396976 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 34.5444196689 \
			78.9643954637 34.5049312009 78.9841396977 21.1315033719 \
			78.9841396977 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
	}}
	{Button Flip_Vert {
		set i [$Global(CurrentCanvas) create polygon 96.337823292 \
			36.8761379395 96.337823292 117.087088561 136.443298603 \
			117.087088561 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create polygon 69.5959036931 \
			36.8761379395 69.5959036931 117.087088561 29.4904283823 \
			117.087088561 -fill #FFFFFFFFFFFF -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create line 82.9643954634 \
			23.5076461692 82.9841396974 36.881073998 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 82.9643954634 \
			50.2446297098 82.9841396974 63.6279296555 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 82.9643954634 \
			76.9816132503 82.9841396974 90.374785313 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 82.9643954634 \
			103.718596791 82.9841396974 117.121640971 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 82.9643954634 \
			130.455580331 82.9841396974 130.495068799 82.9841396974 \
			143.868496628 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 24.0 -1.0 \
			24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 171.0 24.0 \
			171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 161.0 24.0 \
			161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 24.0 -1.0 \
			24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
	}}
	{Button Raise {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 \
			24.0 -1.0 24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 \
			171.0 24.0 171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 \
			161.0 24.0 161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 \
			24.0 -1.0 24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			24.5407392605 100.0 24.5407392605 25.0 127.76001998 25.0 \
			127.76001998 50.0 45.1845954043 50.0 45.1845954043 100.0 -fill \
			$Global(ButtonColor) -outline black -smooth 0 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			45.2913082605 50.0184615385 65.9351644043 50.0184615385 \
			65.9351644043 50.0184615385 127.90484457 50.0184615385 \
			127.90484457 50.0184615385 148.548700714 50.0184615385 \
			148.548700714 75.0184615385 148.548700714 75.0184615385 \
			148.548700714 100.046153846 148.548700714 100.046153846 \
			148.548700714 125.046153846 127.90484457 125.046153846 \
			127.90484457 125.046153846 65.9351644043 125.046153846 \
			65.9351644043 125.046153846 45.2913082605 125.046153846 \
			45.2913082605 100.046153846 45.2913082605 100.046153846 \
			45.2913082605 75.0184615385 45.2913082605 75.0184615385 -fill \
			#FFFFFFFFFFFF -outline black -smooth 0 -splinesteps 12 -stipple \
			$Global(ButtonStipple2) -tags {} -width 1]
	}}
	{Button Lower {
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 \
			24.0 -1.0 24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 \
			171.0 24.0 171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 \
			161.0 24.0 161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 \
			24.0 -1.0 24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 24.63982977 \
			25.0092307692 45.2836859138 25.0092307692 45.2836859138 \
			25.0092307692 107.253366079 25.0092307692 107.253366079 \
			25.0092307692 127.897222223 25.0092307692 127.897222223 \
			50.0092307692 127.897222223 50.0092307692 127.897222223 \
			75.036923077 127.897222223 75.036923077 127.897222223 \
			100.036923077 107.253366079 100.036923077 107.253366079 \
			100.036923077 45.2836859138 100.036923077 45.2836859138 \
			100.036923077 24.63982977 100.036923077 24.63982977 75.036923077 \
			24.63982977 75.036923077 24.63982977 50.0092307692 24.63982977 \
			50.0092307692 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create polygon \
			45.1845954043 100.0 45.1845954043 125.0 148.403876123 125.0 \
			148.403876123 50.0 127.760019979 50.0 127.760019979 100.0 \
			45.1845954043 100.0 -fill #FFFFFFFFFFFF -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create polygon -1.0 -1.0 \
			24.0 -1.0 24.0 -1.0 146.0 -1.0 146.0 -1.0 171.0 -1.0 171.0 24.0 \
			171.0 24.0 171.0 136.0 171.0 136.0 171.0 161.0 146.0 161.0 146.0 \
			161.0 24.0 161.0 24.0 161.0 -1.0 161.0 -1.0 136.0 -1.0 136.0 -1.0 \
			24.0 -1.0 24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
	}}
	{Button Group {
		set i [$Global(CurrentCanvas) create polygon 0.0 -1.0 \
			25.0 -1.0 25.0 -1.0 147.0 -1.0 147.0 -1.0 172.0 -1.0 172.0 24.0 \
			172.0 24.0 172.0 136.0 172.0 136.0 172.0 161.0 147.0 161.0 147.0 \
			161.0 25.0 161.0 25.0 161.0 0.0 161.0 0.0 136.0 0.0 136.0 0.0 \
			24.0 0.0 24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			19.4872975781 12.4155418363 38.9211441513 12.4155418363 \
			38.9211441513 12.4155418363 136.140606036 12.4155418363 \
			136.140606036 12.4155418363 155.574452609 12.4155418363 \
			155.574452609 31.8493884095 155.574452609 31.8493884095 \
			155.574452609 129.068850295 155.574452609 129.068850295 \
			155.574452609 148.502696868 136.140606036 148.502696868 \
			136.140606036 148.502696868 38.9211441513 148.502696868 \
			38.9211441513 148.502696868 19.4872975781 148.502696868 \
			19.4872975781 129.068850295 19.4872975781 129.068850295 \
			19.4872975781 31.8493884095 19.4872975781 31.8493884095 -fill {} \
			-outline black -smooth 0 -splinesteps 12 -stipple {} -tags {} \
			-width 2]
		set i [$Global(CurrentCanvas) create polygon \
			140.020199776 43.9055034438 139.429494156 46.7899733119 \
			137.675325586 49.5868000225 134.810993592 52.2110034117 \
			130.92352945 54.5828483873 126.131051794 56.6302676392 \
			120.579177629 58.2910513706 114.436597844 59.5147375074 \
			107.889951617 60.2641449661 101.138155481 60.5165033797 \
			94.3863593463 60.2641449661 87.8397131192 59.5147375074 \
			81.6971333342 58.2910513706 76.1452591699 56.6302676392 \
			71.352781513 54.5828483873 67.4653173715 52.2110034117 \
			64.6009853772 49.5868000225 62.8468168077 46.7899733119 \
			62.2561111871 43.9055034438 62.8468168077 41.0210335757 \
			64.6009853772 38.224206865 67.4653173715 35.6000034759 \
			71.352781513 33.2281585006 76.1452591699 31.1807392483 \
			81.6971333342 29.5199555171 87.8397131192 28.2962693802 \
			94.3863593463 27.5468619217 101.138155481 27.2945035079 \
			107.889951617 27.5468619217 114.436597844 28.2962693802 \
			120.579177629 29.5199555171 126.131051794 31.1807392483 \
			130.92352945 33.2281585006 134.810993592 35.6000034759 \
			137.675325586 38.224206865 139.429494156 41.0210335757 -fill \
			$Global(ButtonColor) -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags oval -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			31.8460280693 105.690829814 51.2798746425 47.389290094 \
			129.015260935 105.690829814 -fill $Global(ButtonColor) -outline \
			black -smooth 0 -splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			58.5278024676 70.7386082783 79.8302881343 70.7386082783 \
			79.8302881343 70.7386082783 122.466721601 70.7386082783 \
			122.466721601 70.7386082783 143.769207267 70.7386082783 \
			143.769207267 90.1724548516 143.769207267 90.1724548516 \
			143.769207267 109.627828147 143.769207267 109.627828147 \
			143.769207267 129.061674721 122.466721601 129.061674721 \
			122.466721601 129.061674721 79.8302881343 129.061674721 \
			79.8302881343 129.061674721 58.5278024676 129.061674721 \
			58.5278024676 109.627828147 58.5278024676 109.627828147 \
			58.5278024676 90.1724548516 58.5278024676 90.1724548516 -fill \
			#FFFFFFFFFFFF -outline black -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
	}}
	{Button UnGroup {
		set i [$Global(CurrentCanvas) create line 18.1860465116 \
			39.3023255812 18.297030412 12.1805605247 45.6327012525 \
			12.1805605247 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 72.8372093023 \
			12.1705426356 100.304042933 12.1805605247 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 127.488372093 \
			12.1705426356 154.975384616 12.1805605247 154.975384616 \
			39.3223613595 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 154.813953488 \
			66.4341085268 154.975384616 93.6059630289 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 154.813953488 \
			120.697674418 154.975384616 147.889564698 127.639713774 \
			147.889564698 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 100.162790698 \
			147.829457364 72.968372093 147.889564698 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 45.511627907 \
			147.829457364 18.297030412 147.889564698 18.297030412 \
			120.747763863 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle miter -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 18.1860465116 \
			93.5658914724 18.297030412 66.4641621941 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 0.0 -1.0 \
			25.0 -1.0 25.0 -1.0 147.0 -1.0 147.0 -1.0 172.0 -1.0 172.0 24.0 \
			172.0 24.0 172.0 136.0 172.0 136.0 172.0 161.0 147.0 161.0 147.0 \
			161.0 25.0 161.0 25.0 161.0 0.0 161.0 0.0 136.0 0.0 136.0 0.0 \
			24.0 0.0 24.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			140.020199776 43.9055034438 139.429494156 46.7899733119 \
			137.675325586 49.5868000225 134.810993592 52.2110034117 \
			130.92352945 54.5828483873 126.131051794 56.6302676392 \
			120.579177629 58.2910513706 114.436597844 59.5147375074 \
			107.889951617 60.2641449661 101.138155481 60.5165033797 \
			94.3863593463 60.2641449661 87.8397131192 59.5147375074 \
			81.6971333342 58.2910513706 76.1452591699 56.6302676392 \
			71.352781513 54.5828483873 67.4653173715 52.2110034117 \
			64.6009853772 49.5868000225 62.8468168077 46.7899733119 \
			62.2561111871 43.9055034438 62.8468168077 41.0210335757 \
			64.6009853772 38.224206865 67.4653173715 35.6000034759 \
			71.352781513 33.2281585006 76.1452591699 31.1807392483 \
			81.6971333342 29.5199555171 87.8397131192 28.2962693802 \
			94.3863593463 27.5468619217 101.138155481 27.2945035079 \
			107.889951617 27.5468619217 114.436597844 28.2962693802 \
			120.579177629 29.5199555171 126.131051794 31.1807392483 \
			130.92352945 33.2281585006 134.810993592 35.6000034759 \
			137.675325586 38.224206865 139.429494156 41.0210335757 -fill \
			$Global(ButtonColor) -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags oval -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			31.8460280693 105.690829814 51.2798746425 47.389290094 \
			129.015260935 105.690829814 -fill $Global(ButtonColor) -outline \
			black -smooth 0 -splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			58.5278024676 70.7386082783 79.8302881343 70.7386082783 \
			79.8302881343 70.7386082783 122.466721601 70.7386082783 \
			122.466721601 70.7386082783 143.769207267 70.7386082783 \
			143.769207267 90.1724548516 143.769207267 90.1724548516 \
			143.769207267 109.627828147 143.769207267 109.627828147 \
			143.769207267 129.061674721 122.466721601 129.061674721 \
			122.466721601 129.061674721 79.8302881343 129.061674721 \
			79.8302881343 129.061674721 58.5278024676 129.061674721 \
			58.5278024676 109.627828147 58.5278024676 109.627828147 \
			58.5278024676 90.1724548516 58.5278024676 90.1724548516 -fill \
			#FFFFFFFFFFFF -outline black -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
	}}
	{RadioButton Cut {
		set i [$Global(CurrentCanvas) create polygon -1.0 -2.0 \
			24.0 -2.0 24.0 -2.0 146.0 -2.0 146.0 -2.0 171.0 -2.0 171.0 23.0 \
			171.0 23.0 171.0 135.0 171.0 135.0 171.0 160.0 146.0 160.0 146.0 \
			160.0 24.0 160.0 24.0 160.0 -1.0 160.0 -1.0 135.0 -1.0 135.0 -1.0 \
			23.0 -1.0 23.0 -fill {} -outline {} -smooth 0 -splinesteps 12 \
			-stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			63.5388025603 6.9140133338 75.8988998203 77.453529439 \
			60.0668341612 70.8645988339 44.229360387 62.4943797334 \
			28.3270045365 53.8115600292 12.3008923946 46.2880351751 \
			16.6934038006 51.5511429489 21.7484124676 56.3004646424 \
			27.3362349823 60.6346877942 33.3273977037 64.6514344314 \
			39.5908844671 68.4476335052 45.9966330027 72.1213384293 \
			52.4146464512 75.7705546807 58.7146009345 79.493527403 \
			64.7661861443 83.3875800132 70.4395360295 87.5506221311 \
			75.604719127 92.080611307 80.1309673092 97.075206478 83.888414522 \
			102.632317268 86.7466850558 108.849315026 88.5755858388 \
			115.824349027 89.245120006 123.655424754 88.9390819701 \
			124.711246498 88.1899034817 125.887593214 85.0587164493 \
			126.96146656 81.9162149024 128.649961096 79.3727228435 \
			130.977178405 78.0363677075 133.967006319 78.2920498845 \
			140.948898406 81.1387372648 146.92000033 84.4369342348 \
			149.710915407 87.9357554379 151.056434961 96.8059144196 \
			146.65288348 97.7731426938 141.441699615 96.9262229088 \
			136.360148001 94.9145764852 131.356264886 92.3887367034 \
			126.377271678 90.0001253411 121.371562181 88.3979947574 \
			116.285472997 88.2334532841 111.066715874 90.1568898244 \
			105.663529798 92.6751898339 102.551502676 95.6331489542 \
			100.271569609 98.8543932576 98.94295938 102.163933398 \
			98.687533161 107.030055872 99.792335968 111.40010308 \
			101.998319533 115.425441998 104.907343727 119.257818444 \
			108.121902549 123.048795605 111.243712084 126.948590342 \
			113.873651536 131.108504223 115.613628705 135.680086862 \
			116.066281396 138.541342157 115.019730004 141.009415097 \
			113.517321311 142.827397836 111.585038474 143.738251727 \
			109.248960512 143.105776486 102.407352701 138.606045263 \
			97.510031144 135.679562378 96.215539786 132.537415684 \
			95.643488515 129.295139508  \
			95.794912928 126.06698727 96.669963826 124.073367001 \
			98.082694536 122.467101186 99.60452094 121.084832186 \
			101.270367238 119.761136598 103.11484801 90.480227109 \
			88.1028765011 88.2978844307 82.1691691271 86.838656662 \
			76.1832852353 81.4975130574 58.5542458718 76.9810262708 \
			40.4402866063 71.6667017213 22.8089161852 63.9311563203 \
			6.6264709607 63.5388025603 6.9140133338 -fill \
			$Global(ButtonColor) -outline black -smooth 0 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			126.510482112 99.782778734 125.281930984 100.886679259 \
			124.333027471 102.199358547 123.745148065 103.666993989 \
			123.600632868 105.238379854 125.004350593 108.340225379 \
			127.15512505 110.754179219 129.757078443 112.432895488 \
			132.512569926 113.328658829 134.822988095 113.179832755 \
			137.065645556 112.38032825 138.962406678 111.055058193 \
			140.234813146 109.330833488 140.765639214 108.058702627 \
			141.196281095 107.296977514 139.950422302 104.259719468 \
			137.714152321 101.738945526 134.893578486 99.754387391 \
			131.896308071 98.328000582 126.510482112 99.782778734 -fill \
			$Global(DefButtonColor) -outline $Global(DefButtonColor) -smooth \
			0 -splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 85.124365772 \
			130.833572526 83.1687403834 132.206525778 81.6843201596 \
			133.939782386 80.754074319 135.965401489 80.4586971855 \
			138.217109414 81.5139673823 141.256536376 83.2077851804 \
			143.813722859 85.3504539501 145.804108261 87.7534145098 \
			147.142298379 89.3845585661 146.918126511 91.162689649 \
			146.110525232 92.7119136198 144.93551076 93.6563363455 \
			143.609099314 94.215893959 142.435508131 94.4235737431 \
			141.936833055 94.2390419018 138.807921963 93.3440933132 \
			135.463889179 91.5789640029 132.503870659 88.7857195863 \
			130.528832913 87.1583159762 130.204785312 85.124365772 \
			130.833572526 -fill $Global(DefButtonColor) -outline \
			$Global(DefButtonColor) -smooth 0 -splinesteps 12 -stipple {} \
			-tags {} -width 1]
	}}
	{RadioButton Paste {
		set i [$Global(CurrentCanvas) create polygon 3.0 2.0 28.0 \
			2.0 28.0 2.0 152.0 2.0 152.0 2.0 177.0 2.0 177.0 27.0 177.0 27.0 \
			177.0 141.0 177.0 141.0 177.0 166.0 152.0 166.0 152.0 166.0 28.0 \
			166.0 28.0 166.0 3.0 166.0 3.0 141.0 3.0 141.0 3.0 27.0 3.0 27.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags \
			{} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			67.9240825065 39.915838224 67.9240825065 35.0770838995 \
			67.9240825065 35.0770838995 71.7703623055 35.0770838995 \
			71.7703623055 35.0770838995 74.3345488381 20.5608209258 \
			82.0271084359 6.04455795217 85.8733882348 6.04455795217 \
			93.5659478326 20.5608209258 97.4122276315 35.0770838995 \
			99.9764141641 35.0770838995 99.9764141641 35.0770838995 \
			99.9764141641 39.915838224 67.9240825065 39.915838224 -fill \
			$Global(ButtonColor) -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple2) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 69.2061757729 \
			36.0448347644 75.6417316834 37.0250919481 85.90226492 \
			37.0250919481 93.5976648475 37.0250919481 97.4453648113 \
			36.0569837599 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill $Global(ButtonColor) -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			42.5939143386 73.5625787978 50.2306882263 64.5549266551 \
			65.5042360016 61.5523759408 69.3226229455 55.5472745123 \
			99.8697184961 55.5472745123 103.68810544 61.5523759408 \
			118.961653215 64.5549266551 126.598427103 73.5625787978 -fill \
			white -outline black -smooth 1 -splinesteps 12 -stipple \
			$Global(ButtonStipple2) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 66.744924848 \
			40.5334123072 66.744924848 40.5334123072 66.744924848 \
			52.5436151642 66.744924848 52.5436151642 84.5571027282 \
			55.5461658784 102.369280608 52.5436151642 102.369280608 \
			52.5436151642 102.369280608 40.5334123072 102.369280608 \
			40.5334123072 84.5571027282 43.5359630214 66.744924848 \
			40.5334123072 66.744924848 40.5334123072 -fill \
			$Global(ButtonColor) -outline black -smooth 1 -splinesteps 12 \
			-stipple $Global(ButtonStipple2) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			45.3703113914 70.5589194493 45.3703113914 70.5589194493 \
			45.3703113914 148.62523802 45.3703113914 148.62523802 \
			84.5571027279 151.627788734 123.743894064 148.62523802 \
			123.743894064 148.62523802 123.743894064 70.5589194493 \
			123.743894064 70.5589194493 80.9946671518 73.5614701636 \
			45.3703113914 70.5589194493 45.3703113914 70.5589194493 -fill \
			white -outline black -smooth 1 -splinesteps 12 -stipple \
			$Global(ButtonStipple2) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			52.5285150975 79.5654629582 52.5285150975 79.5654629582 \
			52.5285150975 139.616477243 52.5285150975 139.616477243 \
			86.0904001986 142.619027957 115.923186955 139.616477243 \
			115.923186955 139.616477243 115.923186955 79.5654629582 \
			115.923186955 79.5654629582 86.0904001986 82.5680136724 \
			52.5285150975 79.5654629582 -fill $Global(ButtonColor) -outline \
			black -smooth 1 -splinesteps 12 -stipple $Global(ButtonStipple2) \
			-tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 70.307360424 \
			52.5436151642 70.3402444446 43.5514838991 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 73.8697960001 \
			52.5436151642 73.9039953816 43.5514838991 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			45.3703113917 148.62523802 45.3703113917 148.62523802 \
			84.5571027282 151.627788734 123.743894065 148.62523802 \
			123.743894065 148.62523802 120.181458489 154.630339448 \
			84.5571027282 157.632890163 48.9327469678 154.630339448 \
			45.3703113917 148.62523802 -fill white -outline black -smooth 1 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
	}}
	{JoinButton round {
		set i [$Global(CurrentCanvas) create polygon 0.0 0.0 \
			25.0 0.0 25.0 0.0 175.073846154 0.0 175.073846154 0.0 \
			200.073846154 0.0 200.073846154 25.0 200.073846154 25.0 \
			200.073846154 175.073846154 200.073846154 175.073846154 \
			200.073846154 200.073846154 175.073846154 200.073846154 \
			175.073846154 200.073846154 25.0 200.073846154 25.0 200.073846154 \
			0.0 200.073846154 0.0 175.073846154 0.0 175.073846154 0.0 25.0 \
			0.0 25.0 -fill {} -outline {} -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon  28.0830769234 \
			177.083076923 28.0830769234 177.083076923  29.0830769234 \
			90.0830769232 28.0830769234 89.0830769232  32.0830769234 \
			31.0830769232  90.0830769234 27.0830769232 90.0830769234 \
			27.0830769232  178.083076923 27.0830769232 178.083076923 \
			27.0830769232  178.083076923 77.0830769232 178.083076923 \
			77.0830769232  78.0830769234 77.0830769232 78.0830769234 \
			77.0830769232  78.0830769234 177.083076923 78.0830769234 \
			177.083076923  28.0830769234 177.083076923 28.0830769234 \
			177.083076923 -fill $Global(ButtonColor) -outline black -smooth 1 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create line 52.0184615385 \
			185.046153846 52.036923077 135.101538461 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 68.0646153847 \
			53.036923077 118.101538462 53.0553846155 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 52.0184615385 \
			116.046153846 52.036923077 66.101538461 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 137.064615385 \
			53.036923077 187.101538462 53.0553846155 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
	}}
	{JoinButton bevel {
		set i [$Global(CurrentCanvas) create polygon 0.0 0.0 \
			25.0 0.0 25.0 0.0 175.073846154 0.0 175.073846154 0.0 \
			200.073846154 0.0 200.073846154 25.0 200.073846154 25.0 \
			200.073846154 175.073846154 200.073846154 175.073846154 \
			200.073846154 200.073846154 175.073846154 200.073846154 \
			175.073846154 200.073846154 25.0 200.073846154 25.0 200.073846154 \
			0.0 200.073846154 0.0 175.073846154 0.0 175.073846154 0.0 25.0 \
			0.0 25.0 -fill {} -outline {} -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 52.0184615385 \
			185.046153846 52.036923077 135.101538461 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 68.0646153847 \
			53.036923077 118.101538462 53.0553846155 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 52.0184615385 \
			116.046153846 52.036923077 66.101538461 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 137.064615385 \
			53.036923077 187.101538462 53.0553846155 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 27.0092307692 \
			177.009230769 27.0092307692 77.0092307692 77.0092307692 \
			27.0092307692 177.009230769 27.0092307692 177.009230769 \
			77.0092307692 77.0092307692 77.0092307692 77.0092307692 \
			177.009230769 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width \
			1]
	}}
	{JoinButton miter {
		set i [$Global(CurrentCanvas) create polygon 0.0 0.0 \
			25.0 0.0 25.0 0.0 175.073846154 0.0 175.073846154 0.0 \
			200.073846154 0.0 200.073846154 25.0 200.073846154 25.0 \
			200.073846154 175.073846154 200.073846154 175.073846154 \
			200.073846154 200.073846154 175.073846154 200.073846154 \
			175.073846154 200.073846154 25.0 200.073846154 25.0 200.073846154 \
			0.0 200.073846154 0.0 175.073846154 0.0 175.073846154 0.0 25.0 \
			0.0 25.0 -fill {} -outline {} -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 52.0184615385 \
			185.046153846 52.036923077 135.101538461 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 68.0646153847 \
			53.036923077 118.101538462 53.0553846155 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 52.0184615385 \
			116.046153846 52.036923077 66.101538461 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 137.064615385 \
			53.036923077 187.101538462 53.0553846155 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 1 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 27.0092307692 \
			177.009230769 27.0092307692 27.0092307692 177.009230769 \
			27.0092307692 177.009230769 77.0092307692 77.0092307692 \
			77.0092307692 77.0092307692 177.009230769 -fill \
			$Global(ButtonColor) -outline black -smooth 0 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
	}}
	{ArrowButton none {
		set i [$Global(CurrentCanvas) create polygon \
			-0.852307692096 -0.935384615596 24.1476923079 -0.935384615596 \
			24.1476923079 -0.935384615596 174.221538462 -0.935384615596 \
			174.221538462 -0.935384615596 199.221538462 -0.935384615596 \
			199.221538462 24.0646153844 199.221538462 24.0646153844 \
			199.221538462 174.138461538 199.221538462 174.138461538 \
			199.221538462 199.138461538 174.221538462 199.138461538 \
			174.221538462 199.138461538 24.1476923079 199.138461538 \
			24.1476923079 199.138461538 -0.852307692096 199.138461538 \
			-0.852307692096 174.138461538 -0.852307692096 174.138461538 \
			-0.852307692096 24.0646153844 -0.852307692096 24.0646153844 -fill \
			{} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags {} \
			-width 1]
		set i [$Global(CurrentCanvas) create polygon 184.696113424 \
			18.5089433898 182.854879064 19.4099729702 182.854879064 \
			19.4099729702 14.3819350668 101.854179608 14.3819350668 \
			101.854179608 12.5407007052 102.755209189 13.0984781326 \
			103.895015236 13.0984781326 103.895015236 13.3773668463 \
			104.46491826 13.3773668463 104.46491826 13.9351442737 \
			105.604724307 15.7763786354 104.703694726 15.7763786354 \
			104.703694726 184.249322633 22.2594880885 184.249322633 \
			22.2594880885 186.090556993 21.3584585081 185.532779566 \
			20.2186524607 185.532779566 20.2186524607 185.253890852 \
			19.6487494371 185.253890852 19.6487494371 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 6.75368204265 \
			110.753682043 37.4077288844 177.011127039 40.1218892818 \
			154.978530872 59.1210120639 179.246317955 61.8351724613 \
			176.851470545 42.9957061733 152.424026968 65.0283023407 \
			154.49956139 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
	}}
	{ArrowButton first {
		set i [$Global(CurrentCanvas) create polygon \
			-0.852307692096 -0.935384615596 24.1476923079 -0.935384615596 \
			24.1476923079 -0.935384615596 174.221538462 -0.935384615596 \
			174.221538462 -0.935384615596 199.221538462 -0.935384615596 \
			199.221538462 24.0646153844 199.221538462 24.0646153844 \
			199.221538462 174.138461538 199.221538462 174.138461538 \
			199.221538462 199.138461538 174.221538462 199.138461538 \
			174.221538462 199.138461538 24.1476923079 199.138461538 \
			24.1476923079 199.138461538 -0.852307692096 199.138461538 \
			-0.852307692096 174.138461538 -0.852307692096 174.138461538 \
			-0.852307692096 24.0646153844 -0.852307692096 24.0646153844 -fill \
			{} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags {} \
			-width 1]
		set i [$Global(CurrentCanvas) create polygon 184.696113424 \
			18.5089433898 182.854879064 19.4099729702 182.854879064 \
			19.4099729702 14.3819350668 101.854179608 14.3819350668 \
			101.854179608 12.5407007052 102.755209189 13.0984781326 \
			103.895015236 13.0984781326 103.895015236 13.3773668463 \
			104.46491826 13.3773668463 104.46491826 13.9351442737 \
			105.604724307 15.7763786354 104.703694726 15.7763786354 \
			104.703694726 184.249322633 22.2594880885 184.249322633 \
			22.2594880885 186.090556993 21.3584585081 185.532779566 \
			20.2186524607 185.532779566 20.2186524607 185.253890852 \
			19.6487494371 185.253890852 19.6487494371 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 191.713913476 \
			17.2134035549 127.751393269 30.8546993336 148.971186702 \
			38.1300570825 141.695828954 59.3498505155 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 6.75368204265 \
			110.753682043 37.4077288844 177.011127039 40.1218892818 \
			154.978530872 59.1210120639 179.246317955 61.8351724613 \
			176.851470545 42.9957061733 152.424026968 65.0283023407 \
			154.49956139 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
	}}
	{ArrowButton last {
		set i [$Global(CurrentCanvas) create polygon \
			-0.852307692097 -0.935384615597 24.1476923079 -0.935384615597 \
			24.1476923079 -0.935384615597 174.221538462 -0.935384615597 \
			174.221538462 -0.935384615597 199.221538462 -0.935384615597 \
			199.221538462 24.0646153844 199.221538462 24.0646153844 \
			199.221538462 174.138461538 199.221538462 174.138461538 \
			199.221538462 199.138461538 174.221538462 199.138461538 \
			174.221538462 199.138461538 24.1476923079 199.138461538 \
			24.1476923079 199.138461538 -0.852307692097 199.138461538 \
			-0.852307692097 174.138461538 -0.852307692097 174.138461538 \
			-0.852307692097 24.0646153844 -0.852307692097 24.0646153844 -fill \
			{} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags {} \
			-width 1]
		set i [$Global(CurrentCanvas) create polygon 184.696113424 \
			18.5089433898 182.854879064 19.4099729702 182.854879064 \
			19.4099729702 14.3819350668 101.854179608 14.3819350668 \
			101.854179608 12.5407007052 102.755209189 13.0984781326 \
			103.895015236 13.0984781326 103.895015236 13.3773668463 \
			104.46491826 13.3773668463 104.46491826 13.9351442737 \
			105.604724307 15.7763786354 104.703694726 15.7763786354 \
			104.703694726 184.249322633 22.2594880885 184.249322633 \
			22.2594880885 186.090556993 21.3584585081 185.532779566 \
			20.2186524607 185.532779566 20.2186524607 185.253890852 \
			19.6487494371 185.253890852 19.6487494371 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 5.82513715908 \
			108.18025154 55.8432216805 66.0438045788 48.5678639327 \
			87.2635980128 69.7876573655 94.5389557608 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 6.75368204266 \
			110.753682043 37.4077288844 177.011127039 40.1218892818 \
			154.978530872 59.121012064 179.246317955 61.8351724614 \
			176.851470545 42.9957061733 152.424026968 65.0283023408 \
			154.49956139 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
	}}
	{ArrowButton both {
		set i [$Global(CurrentCanvas) create polygon \
			-0.852307692097 -0.935384615597 24.1476923079 -0.935384615597 \
			24.1476923079 -0.935384615597 174.221538462 -0.935384615597 \
			174.221538462 -0.935384615597 199.221538462 -0.935384615597 \
			199.221538462 24.0646153844 199.221538462 24.0646153844 \
			199.221538462 174.138461538 199.221538462 174.138461538 \
			199.221538462 199.138461538 174.221538462 199.138461538 \
			174.221538462 199.138461538 24.1476923079 199.138461538 \
			24.1476923079 199.138461538 -0.852307692097 199.138461538 \
			-0.852307692097 174.138461538 -0.852307692097 174.138461538 \
			-0.852307692097 24.0646153844 -0.852307692097 24.0646153844 -fill \
			{} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags {} \
			-width 1]
		set i [$Global(CurrentCanvas) create polygon 184.696113424 \
			18.5089433898 182.854879064 19.4099729702 182.854879064 \
			19.4099729702 14.3819350668 101.854179608 14.3819350668 \
			101.854179608 12.5407007052 102.755209189 13.0984781326 \
			103.895015236 13.0984781326 103.895015236 13.3773668463 \
			104.46491826 13.3773668463 104.46491826 13.9351442737 \
			105.604724307 15.7763786354 104.703694726 15.7763786354 \
			104.703694726 184.249322633 22.2594880885 184.249322633 \
			22.2594880885 186.090556993 21.3584585081 185.532779566 \
			20.2186524607 185.532779566 20.2186524607 185.253890852 \
			19.6487494371 185.253890852 19.6487494371 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 191.713913476 \
			17.2134035549 127.751393269 30.8546993336 148.971186702 \
			38.1300570825 141.695828954 59.3498505156 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 5.82513715908 \
			108.18025154 55.8432216805 66.0438045788 48.5678639327 \
			87.2635980128 69.7876573655 94.5389557608 -fill \
			$Global(ButtonColor) -outline $Global(ButtonColor) -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon 6.75368204266 \
			110.753682043 37.4077288844 177.011127039 40.1218892818 \
			154.978530872 59.121012064 179.246317955 61.8351724614 \
			176.851470545 42.9957061733 152.424026968 65.0283023408 \
			154.49956139 -fill $Global(ButtonColor) -outline black -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
	}}
	{Button Smooth {
		set i [$Global(CurrentCanvas) create polygon \
			-0.852307692096 -0.935384615596 24.1476923079 -0.935384615596 \
			24.1476923079 -0.935384615596 174.221538462 -0.935384615596 \
			174.221538462 -0.935384615596 199.221538462 -0.935384615596 \
			199.221538462 24.0646153844 199.221538462 24.0646153844 \
			199.221538462 174.138461538 199.221538462 174.138461538 \
			199.221538462 199.138461538 174.221538462 199.138461538 \
			174.221538462 199.138461538 24.1476923079 199.138461538 \
			24.1476923079 199.138461538 -0.852307692096 199.138461538 \
			-0.852307692096 174.138461538 -0.852307692096 174.138461538 \
			-0.852307692096 24.0646153844 -0.852307692096 24.0646153844 -fill \
			{} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags {} \
			-width 1]
		set i [$Global(CurrentCanvas) create line 86.3401486816 \
			100.316868031 115.86971549 100.360304043 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle round -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 145.312185136 \
			100.316868031 174.863526234 100.360304043 174.863526234 \
			70.9396457192 -arrow none -arrowshape {8 10 3} -capstyle butt \
			-fill black -joinstyle round -smooth 0 -splinesteps 12 -stipple \
			{} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 174.798203363 \
			70.9070687107 174.863526234 70.9396457192 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill $Global(ButtonColor) -joinstyle \
			round -smooth 0 -splinesteps 12 -stipple $Global(ButtonStipple2) \
			-tags {} -width 1]
		set Global(Smooth_Line) [$Global(CurrentCanvas) create line 25.0 \
			175.0 25.0092307692 100.036923077 100.036923077 100.036923077 \
			175.064615385 100.036923077 175.064615385 25.0092307692 -arrow \
			none -arrowshape {8 10 3} -capstyle butt -fill \
			$Global(ButtonColor) -joinstyle miter -smooth 0 -splinesteps 12 \
			-stipple $Global(ButtonStipple2) -tags {} -width 4]
		set i [$Global(CurrentCanvas) create line 25.0 125.0 \
			25.0092307692 100.036923077 50.0184615385 100.036923077 -arrow \
			none -arrowshape {8 10 3} -capstyle butt -fill black -joinstyle \
			miter -smooth 0 -splinesteps 12 -stipple {} -tags {} -width 1]
	}}
	{Button Rulers {
		set i [$Global(CurrentCanvas) create polygon 3.0 3.0 28.0 \
			3.0 28.0 3.0 150.0 3.0 150.0 3.0 175.0 3.0 175.0 28.0 175.0 28.0 \
			175.0 140.0 175.0 140.0 175.0 165.0 150.0 165.0 150.0 165.0 28.0 \
			165.0 28.0 165.0 3.0 165.0 3.0 140.0 3.0 140.0 3.0 28.0 3.0 28.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags \
			{} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			23.1891100047 21.8326710294 44.4914676605 21.8326710294 \
			44.4914676605 21.8326710294 55.1426464886 21.8326710294 \
			55.1426464886 21.8326710294 76.4450041446 21.8326710294 \
			76.4450041446 36.3892820942 76.4450041446 36.3892820942 \
			76.4450041446 134.646406785 76.4450041446 134.646406785 \
			76.4450041446 149.203017849 55.1426464886 149.203017849 \
			55.1426464886 149.203017849 44.4914676605 149.203017849 \
			44.4914676605 149.203017849 23.1891100047 149.203017849 \
			23.1891100047 134.646406785 23.1891100047 134.646406785 \
			23.1891100047 36.3892820942 23.1891100047 36.3892820942 -fill \
			$Global(ButtonColor) -outline black -smooth 0 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			150.149425814 22.2067661339 150.149425814 44.2377862974 \
			150.149425814 44.2377862974 150.149425814 55.2532963793 \
			150.149425814 55.2532963793 150.149425814 77.2843165428 \
			141.662699325 77.2843165428 141.662699325 77.2843165428 \
			84.3772955216 77.2843165441 84.3772955216 77.2843165441 \
			75.8905690324 77.2843165441 75.8905690324 55.2532963806 \
			75.8905690324 55.2532963806 75.8905690324 44.2377862985 \
			75.8905690324 44.2377862985 75.8905690324 22.206766135 \
			84.3772955216 22.2067661348 84.3772955216 22.2067661348 \
			141.662699325 22.2067661341 141.662699325 22.2067661341 -fill \
			$Global(ButtonColor) -outline black -smooth 0 -splinesteps 12 \
			-stipple $Global(ButtonStipple1) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 140.131665428 \
			77.2080834672 140.121591494 63.5149289413 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 131.037141491 \
			77.2080834672 131.023709578 49.7455413384 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 121.942617553 \
			77.2080834672 121.925827663 63.5149289413 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 112.848093615 \
			77.2080834672 112.827945747 49.7455413384 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 103.753569678 \
			77.2080834672 103.730063832 63.5149289413 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 94.65904574 \
			77.2080834672 94.632181916 49.7455413384 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 85.5645218024 \
			77.2080834672 85.5343 63.5149289413 -arrow none -arrowshape {8 10 \
			3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.4699978647 \
			77.2080834672 76.436418084 49.7455413384 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.4843170578 \
			77.2080834672 76.4253476873 49.7455413384 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			30.9204790109 63.1310306103 30.9305529451 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			40.0150029485 49.8170570746 40.0284348608 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			49.1095268862 63.1310306103 49.1263167766 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			58.2040508238 49.8170570746 58.2241986923 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			67.2985747615 63.1310306103 67.3220806079 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			76.3930986992 49.8170570746 76.4199625237 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			85.4876226368 63.1310306103 85.5178444394 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			94.5821465745 49.8170570746 94.6157263552 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			103.676670512 63.1310306103 103.713608271 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			112.77119445 49.8170570746 112.811490186 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			121.865718387 63.1310306103 121.909372102 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			130.960242325 49.8170570746 131.007254018 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
		set i [$Global(CurrentCanvas) create line 76.3712924314 \
			140.054766263 63.1310306103 140.105135933 -arrow none -arrowshape \
			{8 10 3} -capstyle butt -fill black -joinstyle miter -smooth 0 \
			-splinesteps 12 -stipple {} -tags {} -width 1]
	}}
	{Button Print {
		set i [$Global(CurrentCanvas) create polygon 4.0 2.0 29.0 \
			2.0 29.0 2.0 153.0 2.0 153.0 2.0 178.0 2.0 178.0 27.0 178.0 27.0 \
			178.0 141.0 178.0 141.0 178.0 166.0 153.0 166.0 153.0 166.0 29.0 \
			166.0 29.0 166.0 4.0 166.0 4.0 141.0 4.0 141.0 4.0 27.0 4.0 27.0 \
			-fill {} -outline {} -smooth 0 -splinesteps 12 -stipple {} -tags \
			{} -width 1]
		set i [$Global(CurrentCanvas) create polygon 18.112852546 \
			78.1413823784 29.689679783 78.1413823784 29.689679783 \
			78.1413823784 145.509246403 78.1413823784 145.509246403 \
			78.1413823784 157.08607364 78.1413823784 157.08607364 \
			92.3229957436 157.08607364 92.3229957436 157.08607364 \
			106.520317973 157.08607364 106.520317973 157.08607364 \
			120.701931339 145.509246403 120.701931339 145.509246403 \
			120.701931339 29.689679783 120.701931339 29.689679783 \
			120.701931339 18.112852546 120.701931339 18.112852546 \
			106.520317973 18.112852546 106.520317973 18.112852546 \
			92.3229957436 18.112852546 92.3229957436 -fill \
			$Global(ButtonColor) -outline #000000000000 -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple1) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create polygon \
			29.6939543042 121.928678622 34.3263950074 121.928678622 \
			34.3263950074 121.928678622 140.872531179 121.928678622 \
			140.872531179 121.928678622 145.504971882 121.928678622 \
			145.504971882 130.395811007 145.504971882 130.395811007 \
			145.504971882 134.629377198 145.504971882 134.629377198 \
			145.504971882 143.096509583 140.872531179 143.096509583 \
			140.872531179 143.096509583 34.3263950074 143.096509583 \
			34.3263950074 143.096509583 29.6939543042 143.096509583 \
			29.6939543042 134.629377198 29.6939543042 134.629377198 \
			29.6939543042 130.395811007 29.6939543042 130.395811007 -fill \
			$Global(ButtonColor) -outline #000000000000 -smooth 0 \
			-splinesteps 12 -stipple $Global(ButtonStipple2) -tags {} -width \
			1]
		set i [$Global(CurrentCanvas) create polygon \
			37.0084235148 76.6096100677 37.0084235148 76.6096100677 \
			136.511731999 76.6096100677 136.511731999 76.6096100677 \
			136.511731999 54.2857931245 148.949645559 31.9619761813 \
			148.949645559 31.9619761813 49.4463370753 31.9619761813 \
			49.4463370753 31.9619761813 37.0084235148 54.2857931245 \
			37.0084235148 76.6096100677 -fill #FFFFFFFFFFFF -outline \
			#000000000000 -smooth 1 -splinesteps 12 -stipple \
			$Global(ButtonStipple2) -tags {} -width 1]
		set i [$Global(CurrentCanvas) create polygon \
			148.978487615 31.8672316384 142.932094742 42.6870925685 \
			150.25141243 42.6870925685 -fill #FFFFFFFFFFFF -outline black \
			-smooth 0 -splinesteps 12 -stipple $Global(ButtonStipple1) -tags \
			{} -width 1]
	}}
}
 

if {[info exists embed_args] || [info exists env(PLUGIN)]} {
	set Global(Plugin) 1
	set Global(ButtonSize) 25
	set Global(ButtonOrient) left
	set Global(ButtonCount) 10
} else {
	set Global(Plugin) 0
}

proc RotateF { r x y args } {
	set newshape ""
	set count [llength $args]
	set c 0
	set sr [expr sin($r*3.14159265358979323846/180.0)]
	set cr [expr cos($r*3.14159265358979323846/180.0)]
	while {$c < $count} {
		set xc [lindex $args $c] 
		set yc [lindex $args [expr $c + 1]]
		set c [expr $c + 2]
		lappend newshape [expr ($xc - $x) * $cr - ($yc - $y) * $sr + $x] \
			[expr ($xc - $x) * $sr + ($yc - $y) * $cr + $y]
	}
	return $newshape
}
set Global(CornerUL) { 5 5 25 5 25 15 15 15 15 25 5 25 5 5 }
set Global(CornerUR) [eval RotateF 90 20 20 $Global(CornerUL)]
set Global(CornerLR) [eval RotateF 90 20 20 $Global(CornerUR)]
set Global(CornerLL) [eval RotateF 90 20 20 $Global(CornerLR)]

proc popUndo {} {
	global Global

	. configure -cursor watch
	update idletasks
	deselectAll
	eval "[lindex $Global(Undo) 0]"
	set Global(Undo) [lreplace $Global(Undo) 0 0]
	. configure -cursor ""
	update idletasks
}

proc pushUndo {cmd} {
	global Global
	
	set Global(Undo) [linsert $Global(Undo) 0 "$cmd"]
	if { [llength $Global(Undo)] > 50 } {
		set Global(Undo) [lreplace $Global(Undo) 50 end]
	}
}

proc genTag {} {
	global Global

	incr Global(TagId)
	return "T-$Global(TagId)"
}

proc getPalette {} {
	global env Global
	if [file readable $env(HOME)/.xfcolors] {
		set f [open $env(HOME)/.xfcolors r]
		while 1 {
			gets $f tv
			gets $f tvalue
			if [eof $f] {
				break
			}
			set value $tvalue
		}
		scan $value "%d %d %d" red grn blu
		set BgColor [format "%02x%02x%02x" $red $grn $blu]
		tk_setPalette "#$BgColor"
		button .b
		set Global(Background) [.b cget -bg]
		set Global(ActiveBackground) [.b cget -activebackground]
		destroy .b
	}
}
proc setTags {w reqName} {
	global windowtag reqtag CjNames

	if {[info exists CjNames($w)]} {
		set windowtag $CjNames($w)
	}
	set reqtag "$reqName"
}

proc initRequestor {name w class title trans} {
	global reqName

	toplevel $w -class $class
	tk_bindForTraversal $w
	if {$trans != "" && $trans != 0} {
		wm transient $w .
	}
	wm title $w "$title"
	wm iconname $w "$name"
	set reqName "$name"
}
 
proc bindEntry {entry type width} {
	global CjNames CjWindows CjWidth
	
	set name $CjNames($entry)
	set CjWidth($entry) $width
	switch [string tolower $type] {
		hex {
		bind $entry <Key> {
			if {[expr [string length [%W get]] + 1] > $CjWidth(%W) &&\
				"%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
				if {[%W selection present]} {
					%W icursor sel.first
					%W delete sel.first sel.last
				} else {
					break
				}
			}
			set a [string toupper "%A"]
			if { ("%A" < "0" || "%A" > "9") && ("$a" < "A" || "$a" > "F") } {
				if { "%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
					if {[%W selection present]} {
						%W icursor sel.first
						%W delete sel.first sel.last
					} else {
						break
					}
				}
			}
		}
		proc set_$name { val } "
			$entry delete 0 end
			$entry insert 0 \[format \"%0${width}X\" \$val\]
		"
		proc get_$name {} "
			set val \[$entry get\]
			scan \${val} %x tvalue
			return \$tvalue
		"
		}
		unit {
		bind $entry <Key> {
			if {[expr [string length [%W get]] + 1] > $CjWidth(%W) &&\
				"%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
				break
			}
			if { "%A" < "0" || "%A" > "9" } {
				if { "%A" == "." } {
					if {[string first "." "[%W get]"] != -1} {
						break
					}
				} elseif { "%A" == "m" } {
					if {[string first "m" "[%W get]"] != -1} {
						break
					}
				} elseif { "%A" == "c" } {
					if {[string first "c" "[%W get]"] != -1} {
						break
					}
				} elseif { "%A" == "i" } {
					if {[string first "i" "[%W get]"] != -1} {
						break
					}
				} elseif { "%A" == "p" } {
					if {[string first "p" "[%W get]"] != -1} {
						break
					}
				} elseif { "%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
					break
				}
			}
		}
		proc set_$name { val } "
			$entry delete 0 end
			$entry insert 0 \[format \$val]
		"
		proc get_$name {} "
			set val \[$entry get\]
			return \$val
		"
		}
		float {
		bind $entry <Key> {
			if {[expr [string length [%W get]] + 1] > $CjWidth(%W) &&\
				"%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
				break
			}
			if { "%A" < "0" || "%A" > "9" } {
				if { "%A" == "." } {
					if {[string first "." "[%W get]"] != -1} {
						break
					}
				} elseif { "%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
					break
				}
			}
		}
		proc set_$name { val } "
			$entry delete 0 end
			$entry insert 0 \[format \$val]
		"
		proc get_$name {} "
			set val \[$entry get\]
			return \$val
		"
		}
		int {
		bind $entry <Key> {
			if {[expr [string length [%W get]] + 1] > $CjWidth(%W) &&\
				"%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
				break
			}
			if { "%A" < "0" || "%A" > "9" } {
				if { "%A" != "{}" && "%A" >= " " && "%A" <= "~" } {
					break
				}
			}
		}
		proc set_$name { val } "
			$entry delete 0 end
			$entry insert 0 \$val
		"
		proc get_$name {} "
			set val \[$entry get\]
			return \$val
		"
		}
		text -
		default {
		proc set_$name { val } "
			$entry delete 0 end
			$entry insert 0 \$val
		"
		proc get_$name {} "
			set val \[$entry get\]
			return \$val
		"
		}
	}
}

proc createEntry {w name type width args} {
	global CjNames CjWindows
	set e [eval entry $w.${name}_e $args]
	set CjNames($e) $name
	set CjWindows($name) $e
	bindEntry $w.${name}_e $type $width
	return $e
}

proc createScale {w name args} {
	global CjNames CjWindows
	set s [eval scale $w.${name}_sc $args]

	set CjNames($s) $name
	set CjWindows($name) $s
	return $s
}

proc createComboScale {w name label scale entry} {
	global CjNames CjWindows

	frame $w.${name}_f -highlightthickness 0
	frame $w.${name}_f.top -highlightthickness 0
	frame $w.${name}_f.bottom -highlightthickness 0
	set l [label $w.${name}_l -text "$label" -highlightthickness 0]
	raise $scale
	raise $entry
	
	pack $l -in $w.${name}_f.top -anchor sw -side left
	pack $scale -in $w.${name}_f.bottom -anchor nw -side left \
		-fill x -expand true
	pack $entry -in $w.${name}_f.bottom -padx 2m -anchor sw -side right 
	pack $w.${name}_f.top $w.${name}_f.bottom -in $w.${name}_f -side top \
		-padx 2m -fill x -expand true

	set ename $CjNames($entry)
	$scale configure -command set_${ename}
	bind $entry <Key-Return> "
		set_${ename} \[get_${ename}\]
		$scale set \[get_${ename}\]
	"
	bind $entry <FocusOut> "
		if {\[$entry get\] == \"\"} {
			set_${ename} \[$scale get\]
		} else {
			set_${ename} \[get_${ename}\]
			$scale set \[get_${ename}\]
		}
	"
	set CjNames($w.${name}_f) $name
	set CjWindows($name) $w.${name}_f
	return $w.${name}_f
}

proc createButton {w name default args} {
	global CjNames CjWindows 

	set b [eval button $w.${name}_b $args]
	if {"$default" == 1} {
		bind $b <Key-Return> {
			%W invoke
		}
		focus $b
	}

	set CjNames($b) $name
	set CjWindows($name) $b
	return $b
}

proc deleteComboBox {combobox} {
	global CjNames CjWindows

	eval .$CjNames($combobox)_tflb.lb delete 0 end
}
proc insertComboBox {combobox pos args} {
	global CjNames CjWindows

	eval .$CjNames($combobox)_tflb.lb insert $pos $args
}

proc createComboBox {w name label entry button height} {
	global CjNames CjWindows 

	frame $w.${name}_fcb -highlightthickness 0
	frame $w.${name}_fcbe -highlightthickness 0
	frame $w.${name}_dummy -highlightthickness 0
	set d $w.${name}_dummy
	if { "$label" != "" } {
		set l [label $w.${name}_l -text "$label" -highlightthickness 0]
		pack $l -in $w.${name}_fcb -side top -anchor w
	}
	$button configure -command "
		set rhght \[winfo reqheight .${name}_tflb.lb\]
		set rwdth \[expr \[winfo reqwidth .${name}_tflb.lb\] + \
			\[winfo reqwidth $button\]\]
		raise .${name}_tflb
		wm geometry .${name}_tflb \
			\${rwdth}x\${rhght}+\[winfo rootx $d\]\+\[winfo rooty $d\]
		wm deiconify .${name}_tflb
		focus .${name}_tflb.lb
		set CjPriv(background) \[.${name}_tflb.lb cget -selectbackground\]
	"
	pack $entry -in $w.${name}_fcbe -side left -fill x -expand true -anchor w
	pack $button -in $w.${name}_fcbe -side right -fill both -anchor w -padx .05c
	pack $w.${name}_fcbe $d -in $w.${name}_fcb -side top -anchor w
	raise $entry
	raise $button
	
	toplevel .${name}_tflb -bd 1 -relief raised -class ComboBox \
		-highlightthickness 0
	wm overrideredirect .${name}_tflb 1
	
	listbox .${name}_tflb.lb -height $height -width [$entry cget -width] \
		-yscrollcommand ".${name}_tflb.sb set" -relief flat
	scrollbar .${name}_tflb.sb -command ".${name}_tflb.lb yview" -relief ridge
	pack .${name}_tflb.lb -in .${name}_tflb -side left -pady 2 -ipadx 1
	pack .${name}_tflb.sb -in .${name}_tflb -side right -fill y -pady 2 
	wm withdraw .${name}_tflb

	bind .${name}_tflb <Key-Escape> "
		grab release \[grab current\]
		.${name}_tflb.lb configure -selectbackground \$CjPriv(background)
		wm withdraw .${name}_tflb
		if {\[info exists tkPriv(relief)\]} {
			$button configure -relief \$tkPriv(relief)
		}
		$button configure -state normal
		if {\"$w\" != \"\"} {
			focus -lastfor $w
		} else {
			focus [focus -lastfor .]
		}
		set tkPriv(buttonWindow) \"\"
		tkCancelRepeat
		focus [focus -lastfor $w]
	"
	bind .${name}_tflb.lb <Key-Return> "
		set ${name}_e_val [$entry cget -textvariable]
		set current \[.${name}_tflb.lb curselection\]
		if {\"\$current\" != \"\"} {
			set \$${name}_e_val \[.${name}_tflb.lb get \
				\$current\] 
		}
		eval \[bind .${name}_tflb <Key-Escape>\]
	"
	bind .${name}_tflb <ButtonRelease-1> "
		if {\"%W\" != \".${name}_tflb.sb\"} {
			eval \[bind .${name}_tflb <Key-Escape>\]
			focus [focus -lastfor $w]
			break
		}
	"
	bind .${name}_tflb.lb <ButtonRelease-1> "
		eval \[bind .${name}_tflb.lb <Key-Return>\]
		set tkPriv(buttonWindow) \"\"
	"
	bind .${name}_tflb.lb <Leave> "
		if {\$tkPriv(buttonWindow) != \"\"} {
			.${name}_tflb.lb configure -selectbackground \
				\[.${name}_tflb.lb cget -background\]
		}
		focus .${name}_tflb
	"
	bind .${name}_tflb.lb <Enter> "
		.${name}_tflb.lb configure -selectbackground \
			\$CjPriv(background)
	"
	bind .${name}_tflb.lb <Any-Key> "
		.${name}_tflb.lb configure -selectbackground \$CjPriv(background)
	"
	bind $button <Key-Return> "
		tkButtonUp %W
		%W invoke
		focus .${name}_tflb.lb
		grab -global .${name}_tflb
		update
	"
	bind $button <ButtonRelease-1> {
		break
	}
	bind $button <Button-1> {
		tkButtonUp %W
		%W invoke
	}
	bind $button <Leave> "
		if {\[wm state .${name}_tflb\] == \"normal\"} {
			focus .${name}_tflb
			grab -global .${name}_tflb
			update
			break
		}
	"

	set CjNames($w.${name}_fcb) $name
	set CjNames(.${name}_tflb.lb) $name
	set CjNames(.${name}_tflb) $name
	set CjWindows($name) $w.${name}_fcb
	return $w.${name}_fcb
}

proc checkUnit {entry} {
	set value [$entry get]
	if {[regexp {^[.0-9][.0-9]*[ipcm]$} $value]} {
		if {[regexp {^[^.]*[.][^.]*[.].*$} $value]} {
			return 0
		} else {
			return 1
		}
	} else {
		return 0
	}
}

proc labeledEntry { pathname label type args} {
	frame ${pathname}_f
	label ${pathname}_l -text "$label"
	eval entry ${pathname} $args
	pack ${pathname}_l -side left -in ${pathname}_f -fill x
	pack ${pathname} -side right -in ${pathname}_f -fill x
		
	return ${pathname}_f
}

proc textLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(TextReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
}

proc propLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(PropReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
}

proc slideLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(SlideReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
	set Global(colortype) $Global(colortypeSave)
}
		
proc printLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(PrintReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
}
		
proc gridLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(GridReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
}
		
proc msgLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(MsgReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
}
		
proc msgRequestor {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	frame $w.textbottom -relief raised -bd 1
	label $w.message
	button $w.ok -text "Dismiss" -command "msgLower $w"
	pack $w.message -in $w.texttop -fill both -expand true
	pack $w.ok -in $w.textbottom -side left -padx 2m -pady 2m
	pack $w.texttop $w.textbottom -anchor sw -in $w -fill x -expand true
	pack $w.f -in $w
	if { !$Global(Plugin) } {
		wm withdraw $w
	}
}
proc msgRaise {name message} {
	global Global

	set w ${name}
	set Global(MsgReplace) $Global(CurrentCanvas)

	if {![winfo exists $name]} {
		msgRequestor $name
	}
	$w.message configure -text "$message"
	if { $Global(Plugin) } {
		pack forget [winfo parent $Global(MsgReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		focus $w
	}
}
proc textRaise {name} {
	global Global

	set w ${name}
	set Global(TextReplace) $Global(CurrentCanvas)

	if {![winfo exists $name]} {
		textRequestor $name
	}
	if { $Global(Plugin) } {
		pack forget [winfo parent $Global(TextReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
	}
	$w.text delete 1.0 end
}

proc propScaleFont {fn sc} {
	regexp {([-][^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-)([^-]*)(-.*)} $fn dummy d1 size d2;
	return "$d1[expr round($size * $sc)]$d2"
}

proc propDisplay {is sc name item} {
	global Global concmd lconcmd 

	if {[winfo exists $name.p.p]} {
		eval destroy [pack slaves $name.p.p]
	} else {
		frame $name.p.p
	}
	$Global(CurrentCanvas) dtag current
	set props [$Global(CurrentCanvas) itemconfigure $item]
	set type [$Global(CurrentCanvas) type $item]
	set i 0
	set concmd ""
	foreach prop $props {
		set propname [string range [lindex $prop 0] 1 end]
		global var${propname}
		set var${propname} [lindex $prop 4]
		frame $name.p.p.f$i
		label $name.p.p.f$i.l${propname} -text "$propname"
		if {"$type" == "text" && "$propname" == "text"} {
			set l [string length [lindex $prop 4]]
			text $name.p.p.f$i.e${propname} -width 20 -height 2
			$name.p.p.f$i.e${propname} insert 0.0 \
				[string range [lindex $prop 4] 0 [expr $l - 2]]
			set textwidget $name.p.p.f$i.e${propname}
		} else {
			entry $name.p.p.f$i.e${propname} -textvariable var${propname} \
				-width 20
		}
		pack $name.p.p.f$i.l${propname} -in $name.p.p.f$i -side left -fill x
		pack $name.p.p.f$i.e${propname} -in $name.p.p.f$i -side right
		pack $name.p.p.f$i -in $name.p.p -side top -fill x -expand true
		incr i
		set conprop " -${propname} {\$var${propname}}"
		set lconprop $conprop
		if {"$type" == "text"} {
			if {"$propname" == "font"} {
				set conprop " -${propname} {\$var${propname}}"
				set lconprop \
					" -${propname} {\[propScaleFont \$var${propname} $sc\]}"
			} elseif {"$propname" == "width"} {
				set conprop " -${propname} {\$var${propname}}"
				set lconprop " -${propname} {\[expr $sc * \$var${propname}\]}"
			} elseif {"$propname" == "text"} {
				set conprop " -${propname} {\[${textwidget} get 0.0 end\]}"
				set lconprop $conprop
			}
		}
		append concmd $conprop
		append lconcmd $lconprop
	}
;#		-command "eval \$Global(CurrentCanvas) itemconfigure $item \$concmd;
	set Ic "eval $name.c itemconfigure $is $lconcmd;"
	append Ic "proc Imp_Commit {} \"\[info body Imp_Commit\]
		\$Global(CurrentCanvas) itemconfigure $item $concmd\""
	button $name.p.p.b -text "Apply" -command "$Ic;set concmd {};set lconcmd {}"
	pack $name.p.p.b -in $name.p.p
	pack $name.p.p -in $name.p
}
proc propDraw {name sc or items index} {
	global Global

	set w ${name}
	set Global(PropDraw) ""
	eval $w.c delete [$w.c find withtag all]
	set item [lindex $items [expr $index - 1]]
	set props [getProperties $Global(CurrentCanvas) $item Esc 0]
	$w.l configure -text "Object $index of [llength $items]"
	set coords [$Global(CurrentCanvas) coords $item]
	set type [$Global(CurrentCanvas) type $item]
	append Global(PropDraw) \
		"set is \[eval $w.c create $type $coords $props -tags this\]
		eval $w.c scale this 0 0 $sc $sc;"
	if {"$type" == "text"} {
		append Global(PropDraw) \
		"set fn \[$w.c itemcget \$is -font\];
		regexp {(\[-\]\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-)(\[^-\]*)(-.*)} \$fn dummy d1 size d2;
		if {\$dummy != \"\"} {
			set nsize \[expr round(\$size * $sc\)];
			if { \$nsize < 20 } {
				set nsize 20
			}
			$w.c itemconfigure \$is -font \${d1}\${nsize}\${d2};
			set fnn \[$w.c itemcget \$is -font\];
			regexp {(\[-\]\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-\[^-\]*-)(\[^-\]*)(-.*)} \$fnn dummy d1 nsize d2;
			if {(\$sc < 1 && \$nsize < \$size) || \
				(\$sc > 1 && \$nsize > \$size)} {
				$w.c itemconfigure \$is -width \[expr \[$w.c itemcget \$is \
					-width\] * $sc\];
			} else {
				$w.c itemconfigure \$is -font \$fn;
			}
		}"
	}
	if {"$type" != ""} {
		eval $Global(PropDraw)
		propDisplay $is $sc $name $item
	}
}

proc propRaise {name items} {
	global Global
	
	set w ${name}
	set Global(PropReplace) $Global(CurrentCanvas)
	
	proc Imp_Commit {} {}

	if {![winfo exists ${name}]} {
		propRequestor $name 
	}
	set ph [winfo fpixels $Global(CurrentCanvas) $Global(PageHeight)]
	set pw [winfo fpixels $Global(CurrentCanvas) $Global(PageWidth)]
	if {$ph > $pw} {
		set pix [expr 200.0 / $ph]
	} else {
		set pix [expr 200.0 / $pw]
	}
	set ch [expr $pix * $ph]
	set cw [expr $pix * $pw]
	set sc $pix
	
	$w.c configure -width $cw -height $ch
	set or [getOrigin "$items"]
	$w.s configure -to [expr [llength $items]] \
		-command "propDraw $w $sc {$or} {$items}"
	$w.s set 1
	propDraw $w $sc "$or" "$items" 1
	if { $Global(Plugin) } {
		pack forget [winfo parent $Global(PropReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
		wm minsize $w [winfo width $w] [winfo height $w]
	}
}

proc slideRaise {name} {
	global Global

	set w ${name}

	if {![winfo exists ${name}]} {
		slideRequestor $name
	}
	set Global(F_SlideBG) $w
	if { $Global(Plugin) } {
		set Global(colortypeSave) $Global(colortype)
		set Global(colortype) SlideBG
		pack forget [winfo parent $Global(SlideReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
	}
}

proc printRaise {name} {
	global Global

	set w ${name}

	if {![winfo exists ${name}]} {
		printRequestor $name
	}
	if { $Global(Plugin) } {
		pack forget [winfo parent $Global(PrintReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
	}
}

proc gridRaise {name} {
	global Global

	set w ${name}

	set Global(GridReplace) $Global(CurrentCanvas)
	if {![winfo exists ${name}]} {
		gridRequestor $name
	}
	if { $Global(Plugin) } {
		pack forget [winfo parent $Global(GridReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
	}
}
proc gridCheck {name} {
	global Global
	set w ${name}
	if {$Global(Grid)} {
		$w.gridx configure -state normal
		$w.gridy configure -state normal
		$w.gridx configure -relief sunken -bg white
		$w.gridy configure -relief sunken -bg white
	} else {
		$w.gridx configure -state disabled
		$w.gridy configure -state disabled
		$w.gridx configure -relief flat -bg [$w cget -bg]
		$w.gridy configure -relief flat -bg [$w cget -bg]
	}
}
proc fontSel {fontl} {
	global Global

	set fsel ""
	catch {set fsel [exec tkfontsel.tcl]}
	if { "$fsel" != "" } {
		$fontl insert end $fsel
	}
}
proc textRequestor {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.top -width 5i -height 4i -borderwidth 0 -highlightthickness 0
	frame $w.topr
	frame $w.bottom -borderwidth 0 -highlightthickness 0
	
	listbox $w.fonts -relief sunken -height 3 -selectmode single \
		-yscrollcommand "$w.sb set" -relief flat
	scrollbar $w.sb -orient v -command "$w.fonts yview"
	
	foreach font $Global(FontList) {
		$w.fonts insert end $font
	}
	text $w.text -height 1 -width 20

	bind $w.fonts <Button-1> "
		set Global(Font) \[%W get \[%W nearest %y\]\]
		$w.text configure -font \$Global(Font)
	" 
	if { !$Global(Plugin) } {
		button $w.addfont -text "Add Fonts..." -command "fontSel $w.fonts"
	}
	button $w.ok -text "Ok" -command "
		regsub -all {(\[^
\])
(\[^
\])} \[$w.text get 1.0 end\] {\\1 \\2} match
		\$Global(CurrentCanvas) itemconfigure \$Global(Text) \
			-text \$match -font \$Global(Font);textLower $w"

	button $w.cancel -text "Cancel" -command "textLower $w"
	bind $w <Key-Escape> "textLower $w"
	bind $w <Key-Escape> "textLower $w"

	if { !$Global(Plugin) } {
		button $w.open -text "Open" -command "
			if { \[openFile \"\"\ \"\"] != \"\" } {
				set f \[open \$Global(OpenFile) r\]
				set in \[read -nonewline \$f\]
				$w.text insert 0.0 \$in
			}"
	}

	pack $w.sb -in $w.topr -side right -fill y
	pack $w.fonts -in $w.topr -side left -expand true -fill both
	pack $w.topr -in $w.top -expand true -side top -fill both
	pack $w.text -in $w.top -expand true -fill both
	if { !$Global(Plugin) } {
		pack $w.addfont -in $w.bottom -side left -padx 1m -pady 1m
	}
	pack $w.ok $w.cancel -in $w.bottom -side left -padx 1m -pady 1m
	if { !$Global(Plugin) } {
		pack $w.open -in $w.bottom -side right -padx 1m -pady 1m
	}
	pack $w.top -side top -expand true -fill both -in $w.f
	pack $w.bottom -side top -fill x -in $w.f
	pack $w.f -in $w -fill both -expand true

	if { !$Global(Plugin) } {
		wm withdraw $w
	}
	return $w
}

proc propRequestor {name} {
	global Global lconcmd concmd

	set w ${name}
	
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.p
	frame $w.fsel -borderwidth 0 -highlightthickness 0
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	frame $w.textbottom -relief raised -bd 1
	canvas $w.c -width 1.5i -height 1.5i -relief sunken -bd 1 -bg white
	label $w.l
	scale $w.s -orient horiz -resolution 1 -from 1 -to 1 \
        -variable Global(PropItem) -bd 2 -relief raised -highlightthickness 0 \
        -width 8 -showvalue true 

	button $w.ok -text "Ok" -command "Imp_Commit;propLower $w;set concmd {};set lconcmd {}"
	button $w.cancel -text "Cancel" -command "propLower $w;set concmd {};set lconcmd {}"
	bind $w <Key-Escape> "propLower $w;set concmd {};set lconcmd {}"

	pack $w.c -in $w.texttop
	pack $w.l -in $w.texttop -fill x
	pack $w.s -in $w.texttop -fill x
	pack $w.ok $w.cancel -in $w.textbottom -side left -padx 1m -pady 1m
	pack $w.texttop -anchor sw -in $w.fsel 
	pack $w.fsel $w.textbottom -anchor sw -in $w.f -fill x
	pack $w.f $w.p -in $w -anchor sw -side left

	if { !$Global(Plugin) } {
		wm withdraw $w
	}
	return $w
}

proc drawAnchors {c} {
	global Global

	set arrowW [expr $Global(ArrowW) * 10]
	set arrowP [expr $Global(ArrowP) * 10]
	set arrowD [expr $Global(ArrowD) * 10]

	$c create oval [expr $Global(X) - $arrowP - 5] \
		[expr $Global(Y) - 5] \
		[expr $Global(X) - $arrowP + 5] \
		[expr $Global(Y) + 5] \
		-fill red -stipple gray50 -outline white -tags arrowP
	$c create oval [expr $Global(X) - $arrowD - 5] \
		[expr $Global(Y) - $arrowW - 5] \
		[expr $Global(X) - $arrowD + 5] \
		[expr $Global(Y) - $arrowW + 5] \
		-fill red -stipple gray50 -outline white -tags arrowDW
}


proc anchorBindings {c} {
	$c bind arrowP <1> {
		set S_arrowP [%W canvasx %x 10]
	}
	$c bind arrowP <B1-Motion> {
		%W move arrowP [expr [%W canvasx %x 10] - $S_arrowP] 0
		set Global(Arrowp) [expr int($Global(Arrowp) - ([%W canvasx %x 10] \
			- $S_arrowP)/10)]
		set S_arrowP [%W canvasx %x 10]
		%W delete Arrow
		drawArrow %W
	}
	$c bind arrowDW <1> {
		set S_arrowDWx [%W canvasx %x 10]
		set S_arrowDWy [%W canvasy %y 10]
	}
	$c bind arrowDW <B1-Motion> {
		%W move arrowDW [expr [%W canvasx %x 10] - $S_arrowDWx] \
			[expr [%W canvasy %y 10] - $S_arrowDWy]
		set Global(Arrowd) [expr int($Global(Arrowd) - ([%W canvasx %x 10] \
			- $S_arrowDWx)/10)]
		set Global(Arroww) [expr int($Global(Arroww) - ([%W canvasy %y 10] \
			- $S_arrowDWy)/10)]
		set S_arrowDWx [%W canvasx %x 10]
		set S_arrowDWy [%W canvasy %y 10]
		%W delete Arrow
		drawArrow %W
	}
}

proc drawArrow {c} {
	global Global

	set arrowW [expr $Global(Arroww) * 10]
	set arrowP [expr $Global(Arrowp) * 10]
	set arrowD [expr $Global(Arrowd) * 10]

	$c create line .25i .25i .75i .75i -arrow last -arrowshape "$Global(Arrowp) $Global(Arrowd) $Global(Arroww)" -tags Arrow

	set i [$c create polygon $Global(X) $Global(Y) \
		[expr $Global(X) - $arrowD] \
		[expr $Global(Y) - $arrowW] \
		[expr $Global(X) - $arrowP] \
		$Global(Y) [expr $Global(X) - $arrowD] \
		[expr $Global(Y) + $arrowW] \
		-tags Arrow ] 
	$c lower $i
}

proc arrowRequestor {name} {
	global Global

	set w ${name}
	
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	canvas $w.c -borderwidth 0 -highlightthickness 0
	frame $w.textbottom -relief raised -bd 1
	label $w.lP -textvariable Global(Arrowp)
	label $w.lW -textvariable Global(Arroww)
	label $w.lD -textvariable Global(Arrowd)


	button $w.ok -text "Ok" -command "
		set Global(ArrowP) \$Global(Arrowp)
		set Global(ArrowD) \$Global(Arrowd)
		set Global(ArrowW) \$Global(Arroww)
		arrowLower $w
	"
	button $w.cancel -text "Cancel" -command "arrowLower $w"

	pack $w.c -fill both -expand true -in $w.texttop
	pack $w.ok $w.cancel $w.lP $w.lW $w.lD -in $w.textbottom \
		-side left -padx 1m -pady 1m
	pack $w.texttop -anchor sw -in $w -fill both -expand true
	pack $w.textbottom -anchor sw -in $w -fill x -expand true
}

proc arrowRaise {name} {
	global Global

	set w ${name}

	set Global(Arroww) $Global(ArrowW)
	set Global(Arrowp) $Global(ArrowP)
	set Global(Arrowd) $Global(ArrowD)
	set Global(X) 300
	set Global(Y) 140

	set Global(ArrowReplace) $Global(CurrentCanvas)
	if {![winfo exists ${name}]} {
		arrowRequestor $name
	}
	if { $Global(Plugin) } {
		pack forget [winfo parent $Global(ArrowReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
	}
	$w.c delete all
	drawAnchors $w.c
	drawArrow $w.c
	anchorBindings $w.c
}

proc arrowLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(ArrowReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
}
		
proc gridRequestor {name} {
	global Global GridX GridY

	set w ${name}
	
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.textleft -borderwidth 0 -highlightthickness 0
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	frame $w.gridgravf -bd 1 -relief raised
	frame $w.textbottom -relief raised -bd 1

	set gridB [checkbutton $w.gridb -variable Global(Grid) -text "Grid On"\
		-command "gridCheck $w"]
	set gridX [labeledEntry $w.gridx "Grid X:" unit  \
		-textvariable GridX -width 5 -bg #FF00FF00FF00 ]
	set gridY [labeledEntry $w.gridy "Grid Y:" unit  \
		-textvariable GridY -width 5 -bg #FF00FF00FF00 ]
	gridCheck $w

	label $w.gridgravl -text "Gravity Strength"
	scale $w.gridgrav -variable Global(GravityVal) -from 0 -to 50 \
		-showvalue true -resolution 1 -orient horiz -width 2m

	button $w.ok  -text "Ok" -command \
		"if {\[checkUnit $w.gridx\]} {
			set Global(GridX) \$GridX
			set Global(GridY) \$GridY
			gridLower $w
		} else {
			msgRaise .diagmsg \"Wrong Format: should be number followed by:
    m-(millimeters)
    c-(centimeters)
    i-(inches) or
    p-(points)\"
			if {!$Global(Plugin)} {
				wm deiconify $w
			}
			raise $w
			focus $w
		}"
	button $w.cancel -text "Cancel" -command "gridLower $w"
	bind $w <Key-Escape> "gridLower $w"

	pack $gridB $gridX $gridY -in $w.textleft -side top -padx 1m -pady 1m
	pack $w.gridgravl $w.gridgrav -in $w.gridgravf -side top -fill x
	pack $w.textleft $w.gridgravf -in $w.texttop -side top
	pack $w.ok $w.cancel -in $w.textbottom -side left -padx 1m -pady 1m
	pack $w.texttop $w.textbottom -anchor sw -in $w -fill x -expand true
	pack $w.f -in $w
	set GridX $Global(GridX)
	set GridY $Global(GridY)

	if { !$Global(Plugin) } {
		wm withdraw $w
	}
	return $w
}

proc pagePropOpenLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(PagePropReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
}

proc pagePropLower {name} {
	global Global

	set w ${name}
	if { $Global(Plugin) } {
		pack forget $w
		pack [winfo parent $Global(PagePropReplace)] -fill both -expand true
	} else {
		wm withdraw $w
	}
	set Global(colortype) $Global(colortypeSave)
}

proc pagePropRaise {name} {
	global Global pageHeight pageWidth

	set w ${name}

	set pageWidth $Global(PageWidth)
	set pageHeight $Global(PageHeight)
	set Global(PagePropReplace) $Global(CurrentCanvas)

	if {![winfo exists ${name}]} {
		pagePropRequestor $name
	}
	set Global(F_SlideBG) $w
	if { $Global(Plugin) } {
		set Global(colortypeSave) $Global(colortype)
		set Global(colortype) SlideBG
		pack forget [winfo parent $Global(PagePropReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
	}
}

proc pagePropOpenRaise {name} {
	global Global

	set w ${name}

	set Global(URL) ""
	if {![winfo exists ${name}]} {
		pagePropOpenRequestor $name
	}
	if { $Global(Plugin) } {
		pack forget [winfo parent $Global(PagePropReplace)]
		pack $w -fill both -expand true
	} else {
		wm deiconify $w
		raise $w
		focus $w
	}
}

proc pagePropOpenRequestor {name} {
	global Global

	set w ${name}

	set Global(PagePropReplace) $Global(CurrentCanvas)
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.textleft -borderwidth 0 -highlightthickness 0
	frame $w.textright -borderwidth 0 -highlightthickness 0
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	frame $w.textbottom -relief raised -bd 1

	set url [labeledEntry $w.url "URL:" unit -textvariable Global(URL) \
		-width 50 -bg #FF00FF00FF00 ]
	set tout [scale $w.tout -from 1000 -to 900000 -resolution 1000 -bd 1 \
		-orient h -showvalue true -variable Global(Timeout) \
		-label "Timeout in milliseconds"]

	button $w.ok  -text "Ok" -command "pagePropOpenLower $w;openURL"
	button $w.cancel -text "Cancel" -command "pagePropOpenLower $w"
	bind $w <Key-Escape> "pagePropOpenLower $w"

	pack $url $tout -in $w.textleft -side top -fill x -padx 1m -pady 1m
	pack $w.textleft -in $w.texttop -side top
	pack $w.ok $w.cancel -in $w.textbottom -side left -padx 1m -pady 1m
	pack $w.texttop $w.textbottom -anchor sw -in $w -fill x -expand true
	pack $w.f -in $w

	if { !$Global(Plugin) } {
		wm withdraw $w
	}
	return $w
}

proc pagePropRequestor {name} {
	global Global

	set w ${name}
	
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.textleft -borderwidth 0 -highlightthickness 0
	frame $w.textright -borderwidth 0 -highlightthickness 0
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	frame $w.textbottom -relief raised -bd 1

	set landscapeB [checkbutton $w.landscapeb -variable Global(Landscape) \
		-text "Landscape"]
	set pageW [labeledEntry $w.pagewidth "Page Width:" unit  \
		-textvariable pageWidth -width 5 -bg #FF00FF00FF00 ]
	set pageH [labeledEntry $w.pageheight "Page Height:" unit  \
		-textvariable pageHeight -width 5 -bg #FF00FF00FF00 ]

	button $w.ok  -text "Ok" -command \
		"if {\[checkUnit $w.pagewidth\]} {
			set Global(PageWidth) \$pageWidth
			set Global(PageHeight) \$pageHeight
			changePageProp 
			pagePropLower $w
		} else {
			msgRaise .diagmsg \"Wrong Format: should be number followed by:
    m-(millimeters)
    c-(centimeters)
    i-(inches) or
    p-(points)\"
			if {!$Global(Plugin)} {
				wm deiconify $w
			}
			raise $w
			focus $w
		}"
	button $w.cancel -text "Cancel" -command "pagePropLower $w"
	bind $w <Key-Escape> "pagePropLower $w"

	if {$Global(Plugin)} "
		button $w.new -text {New} -anchor w\
			-command {pagePropLower $w;clearAll saveToPlugin impSave}
		button $w.open -text {Open...} -anchor w\
			-command {pagePropLower $w;pagePropOpenRaise .pagePropOpen}
		button $w.save -text {Save As...} -anchor w\
			-command {pagePropLower $w;saveToPlugin impSave}
		frame $w.sbgf
		pack $w.new $w.open $w.save $w.sbgf -in $w.textleft -side top -expand 1 -fill x
	"
	pack $landscapeB $pageW $pageH -in $w.textright -side top -padx 1m -pady 1m
	pack $w.textleft $w.textright -in $w.texttop -side left -expand 1
	pack $w.ok $w.cancel -in $w.textbottom -side left -padx 1m -pady 1m
	pack $w.texttop $w.textbottom -anchor sw -in $w -fill x -expand true
	pack $w.f -in $w
	set pageHeight $Global(PageHeight)
	set pageWidth $Global(PageWidth)

	if { !$Global(Plugin) } {
		wm withdraw $w
	}
	return $w
}

proc slideRequestor {name} {
	global Global

	set w ${name}
	
	set Global(SlideReplace) $Global(CurrentCanvas)
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	frame $w.textbottom -relief raised -bd 1

	frame $w.sbgf
	set slideBG [radiobutton $w.sbg -value SlideBG -text "Background Color" \
		-variable Global(colortype) \
		-pady 1m -anchor sw -indicatoron false -selectcolor ""]
	set slideCirc [checkbutton $w.scirc -text "Circulate" \
		-variable Global(Circulate)]
	set slideScl [checkbutton $w.sscl -text "Fit to Content" \
		-variable Global(SlideScale)]
	set slideCache [checkbutton $w.scach -text "Cache Slides on Load" \
		-variable Global(CacheSlides)]

	bind $slideBG <Double-Button-1> "
		colorPaletteReq .colorpalette \
			{0000 3300 6600 9900 CC00 FF00} \
			{0000 3300 6600 9900 CC00 FF00} \
			{0000 3300 6600 9900 CC00 FF00} \
			.colorsp"
	set slideBGC [frame $w.f_SlideBG -bg $Global(SlideBG) -relief sunken -bd 1 -width 5m -height 5m]

	button $w.dismiss -text "Dismiss" -command "slideLower $w"
	bind $w <Key-Escape> "slideLower $w"

	pack $slideBGC $slideBG -side left -in $w.sbgf -fill x -expand true
	pack $w.sbgf $slideCirc $slideScl $slideCache -in $w.texttop \
		-anchor w -expand true
	pack $w.dismiss -in $w.textbottom -side left -padx 1m -pady 1m
	pack $w.texttop -in $w -fill x -expand true
	pack $w.textbottom -anchor sw -in $w -fill x -expand true
	pack $w.f -in $w

	if { !$Global(Plugin) } {
		wm withdraw $w
	}
	return $w
}

proc printRequestor {name} {
	global Global

	set w ${name}
	
	set Global(PrintReplace) $Global(CurrentCanvas)
	if { $Global(Plugin) } {
		frame $w -borderwidth 0
	} else {
		toplevel $w
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	}
	frame $w.f -borderwidth 0 -highlightthickness 0
	frame $w.texttop -borderwidth 0 -highlightthickness 0
	frame $w.textbottom -relief raised -bd 1

	
	set e [labeledEntry $w.e "Print Cmd:" unit -width 30 -textvariable Global(PrintCmd)]
	set landscapeB [checkbutton $w.landscapeb -variable Global(Landscape) \
		-text "Landscape"]
	set printToFileB [checkbutton $w.ptf -variable Global(ToFile) \
		-text "Print To File"]
	set printColor [radiobutton $w.pc -variable Global(PSColor) \
		-text "Color" -value {color}]
	set printGrayScale [radiobutton $w.pg -variable Global(PSColor) \
		-text "Gray Scale" -value {gray}]

	button $w.ok -text "Ok" -command "printCanvas \$Global(PrintCmd);printLower $w"
	button $w.cancel -text "Cancel" -command "printLower $w"
	bind $w <Key-Escape> "printLower $w"

	pack $e -in $w.texttop -fill both -expand true
	pack $landscapeB $printToFileB $printColor $printGrayScale -anchor w -in $w.texttop -expand true
	pack $w.ok $w.cancel -in $w.textbottom -side left -padx 1m -pady 1m
	pack $w.texttop -in $w -fill x -expand true
	pack $w.textbottom -anchor sw -in $w -fill x -expand true
	pack $w.f -in $w

	if { !$Global(Plugin) } {
		wm withdraw $w
	}
	return $w
}

proc printCanvas {cmd} {
	global Global

	if {$Global(ToFile)} {
		printToFile
	} else {
		printToStream
	}
}

proc printToFile {} {
	global Global

	set filename [tk_getSaveFile \
		-filetypes {{{Postscript} {.ps .eps}}} \
		-parent .]
	set saveit $Global(CurrentCanvas)
	if {"$filename" != ""} {
		set f [open $filename w]
		for {set page 1} {[winfo exists .can.c${page}]} {incr page} {
			set Global(CurrentCanvas) .can.c${page}
			set out [doPostscript]
			regsub -all {%%Page: [0-9][0-9]* [0-9][0-9]*} $out \
				"%%Page: $page $page" newout
			regsub -all {%%EOF} $newout {%%} newout
			if { ! [info exists f] } {
				msgRaise .diagmsg "ERROR: Cannot open $filename for writing."
				set Global(CurrentCanvas) $saveit
				return
			} else {
				puts $f $newout
			}
		}
		close $f
		set Global(CurrentCanvas) $saveit
	}
}

proc printToStream {} {
	global Global

	set saveit $Global(CurrentCanvas)
	if {"$Global(PrintCmd)" != ""} {
		switch $Global(StreamType) {
			"Blocking" {
				set tmpname "|$Global(PrintCmd)"
				set opentmpname $tmpname
				set mode "w"
			}
			"Temp" {
				set tmpname "/tmp/imp[clock clicks]"
				set opentmpname $tmpname
				set mode "w"
			}
			"FIFO" {
				set tmpname "/tmp/imp[clock clicks]"
				exec /usr/bin/mkfifo $tmpname
				set opentmpname $tmpname
				set mode "w+"
			}
		}	
		set f [open $opentmpname $mode]
		fconfigure $f -blocking false
		for {set page 1} {[winfo exists .can.c${page}]} {incr page} {
			set Global(CurrentCanvas) .can.c${page}
			set out [doPostscript]
			regsub -all {%%Page: [0-9][0-9]* [0-9][0-9]*} $out \
				"%%Page: $page $page" newout
			regsub -all {%%EOF} $newout {%%} newout
			if { ! [info exists f] } {
				msgRaise .diagmsg "ERROR: Cannot open stream for writing."
				set Global(CurrentCanvas) $saveit
				return
			} else {
				append newout2 "$newout"
			}
		}
		regsub -all {%%Pages: [0-9][0-9]*} $newout2 \
			"%%Pages: [expr $page - 1]" newout3
		puts $f $newout3
		close $f
		if {$Global(StreamType) != "Blocking"} {
			eval exec $Global(PrintCmd) <$tmpname &
		}
		set Global(CurrentCanvas) $saveit
	}
}

proc saveAsFile {prompt} {
	global Global

	if {$prompt || ! [tk_dialog .saveIt "Save File" \
		"Do you wish to save the current file?" "" "0" "Yes" "No"]} {

		set filename [tk_getSaveFile \
			-initialdir [file dirname $Global(OpenFile)] \
			-initialfile [file tail $Global(OpenFile)] \
			-filetypes {{{Tcl} {.tcl .tk}} {{ImPress} {.tki}}} \
			-parent .]
		if {"$filename" != ""} {
			set out [saveAll]
			set f [open $filename w]
			if { ! [info exists f] } {
				msgRaise .diagmsg "ERROR: Cannot open $filename for writing."
			} else {
				puts $f "$out"
				close $f
			}
			return "$filename"
		} else {
			return ""
		}
	} else {
		return ""
	}
}

proc openfile {cmd filename} {
	global Global Group
	if {"$filename" != ""} {
		if {[file readable "$filename"]} {
			set Global(OpenFile) "$filename"
			if {"$cmd" != ""} {
				. configure -cursor watch
				update idletasks
				eval $cmd "$filename"
				update idletasks
				. configure -cursor ""
				update idletasks
			}
			return $Global(OpenFile)
		} else {
			set filename ""
			msgRaise .diagmsg "ERROR: Cannot open file: $filename"
			return ""
		}
	}
}

proc openFile {cmd type} {
	global Global Group

	if {"$type" == "Tk"} {
		set ftype {{{Tcl} {.tcl .tk}} {{ImPress} {.tki}}} \
	} else {
		set ftype "$type"
	}
	set filename [tk_getOpenFile \
		-filetypes "$ftype" \
		-parent .]
	return [openfile $cmd "$filename"]
}

proc explodeList {menu list parentmenu} {
	global menu_buttons Global

	set menuname [lindex $list 0]
	set menutitle [lindex $list 1]
	set menuopts [lindex $list 2]
	set menucmd [lindex $list 3]
	set newlist [lindex $list 4]
	
	# Menubutton
	if {"${parentmenu}" == "${menu}"} {
        menubutton ${parentmenu}.${menuname}_b -text "$menutitle" \
			-menu ${parentmenu}.${menuname}_b.${menuname} -padx 4m 
		if { "$menuopts" != ""} {
			eval ${parentmenu}.${menuname}_b configure $menuopts
		}
		pack ${parentmenu}.${menuname}_b -side left -fill x
        menu ${parentmenu}.${menuname}_b.${menuname}
		lappend menu_buttons ${parentmenu}.${menuname}_b
		set menuname ${menuname}_b.${menuname}
	# MenuItem
	} elseif {"$newlist" == ""} {
		if {"${menutitle}" == ""} {
			eval ${parentmenu} add separator ${menuopts}
		} else {
			eval ${parentmenu} add command -label \"${menutitle}\" \
				-command \"${menucmd}\" ${menuopts}
		}
	# MenuCascade (subMenu)
	} else {
		eval ${parentmenu} add cascade -label \"$menutitle\" \
			-menu ${parentmenu}.${menuname} ${menuopts}
		menu ${parentmenu}.${menuname}
	}
	set len [llength "$newlist"]
	if {$len} {
		for {set i 0} {$i < $len} {incr i} {
			set l [lindex "$newlist" $i]
			explodeList "$menu" "$l" "${parentmenu}.${menuname}"
		}
	}
	return $menu_buttons
}

proc createMenu {w name menulist} {
	global Global

	frame $w.${name}_frame
	pack $w.${name}_frame -fill x

	set newlist [lindex $menulist 4]
	set len [llength "$newlist"]
	for {set i 0} {$i < $len} {incr i} {
		set l [lindex "$newlist" $i]
		set menu_buttons \
			[explodeList "$w.${name}_frame" "$l" "$w.${name}_frame"]
	}
	bind . <Any-FocusIn> "
		if {(\"%d\" == \"NotifyVirtual\") && (\"%m\" == \"NotifyNormal\")} {
			focus $w.${name}_frame
		}
	"

	return "$w.${name}_frame $menu_buttons"
}

proc handleOrigin { handle } {
	global Global

	set bbox [ $Global(CurrentCanvas) bbox \
		[ $Global(CurrentCanvas) find withtag $handle ] ]
	if { "$bbox" != "" } {
		set x1 [lindex $bbox 0]
		set y1 [lindex $bbox 1]
		set x2 [lindex $bbox 2]
		set y2 [lindex $bbox 3]
		switch "$handle" {
			"top_left_corner" {
				return "$x2 $y2"
			}
			"top_side" {
				return "[expr $x1 + 5] $y2"
			}
			"top_right_corner" {
				return "$x1 $y2"
			}
			"right_side" {
				return "$x1 [expr $y1 + 5]"
			}
			"bottom_right_corner" {
				return "$x1 $y1"
			}
			"bottom_side" {
				return "[expr $x1 + 5] $y1"
			}
			"bottom_left_corner" {
				return "$x2 $y1"
			}
			"left_side" {
				return "$x2 [expr $y1 + 5]"
			}
		}
	}
}

proc disableButton { name } {
	global Global

	$name create rectangle 0 0 $Global(ButtonSize) $Global(ButtonSize) \
		-fill $Global(Background) -stipple gray50 -outline {} -tags disabled
}
proc enableButton { name } {
	$name delete disabled
}

proc disablePaste {} {
	global Global

	if {$Global(Cut) == ""} {
		disableButton .buttons.b_Paste
	}
}

proc enablePaste {} {
	.buttons.b_Paste delete disabled
}

proc enableSelectionButtons {} {
	enableButton .buttons.b_Rotate
	enableButton .buttons.b_Cut
	enableButton .buttons.b_Duplicate
	enableButton .buttons.b_Raise
	enableButton .buttons.b_Lower
	enableButton .buttons.b_Group
	enableButton .buttons.b_UnGroup
	enableButton .buttons.b_Flip_Vert
	enableButton .buttons.b_Flip_Horiz
}

proc disableSelectionButtons {} {
	disableButton .buttons.b_Rotate
	disableButton .buttons.b_Cut
	disableButton .buttons.b_Duplicate
	disableButton .buttons.b_Raise
	disableButton .buttons.b_Lower
	disableButton .buttons.b_Group
	disableButton .buttons.b_UnGroup
	disableButton .buttons.b_Flip_Vert
	disableButton .buttons.b_Flip_Horiz
}

proc setCursor { value } {
	global Global

	set Global(Cursor) $value
	setRadioButton Global(Cursor) $value
}

proc handleBindings {} {
	global Global

	$Global(CurrentCanvas) bind top_side <Enter> {
		setCursor Scale
		%W configure -cursor top_side
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind top_side <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	} 
	$Global(CurrentCanvas) bind right_side <Enter> {
		setCursor Scale
		%W configure -cursor right_side
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind right_side <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	}
	$Global(CurrentCanvas) bind left_side <Enter> {
		setCursor Scale
		%W configure -cursor left_side
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind left_side <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	}
	$Global(CurrentCanvas) bind bottom_side <Enter> {
		setCursor Scale
		%W configure -cursor bottom_side
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind bottom_side <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	}
	$Global(CurrentCanvas) bind top_left_corner <Enter> {
		setCursor Scale
		%W configure -cursor top_left_corner
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind top_left_corner <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	}
	$Global(CurrentCanvas) bind top_right_corner <Enter> {
		setCursor Scale
		%W configure -cursor top_right_corner
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind top_right_corner <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	}
	$Global(CurrentCanvas) bind bottom_right_corner <Enter> {
		setCursor Scale
		%W configure -cursor bottom_right_corner
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind bottom_right_corner <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	}
	$Global(CurrentCanvas) bind bottom_left_corner <Enter> {
		setCursor Scale
		%W configure -cursor bottom_left_corner
		set Global(Message) Scale
	}
	$Global(CurrentCanvas) bind bottom_left_corner <Leave> {
		setCursor Select
		%W configure -cursor ""
		set Global(Message) Select
	}
}

proc unHandleBindings {} {
	$Global(CurrentCanvas) bind top_side <Enter> {}
	$Global(CurrentCanvas) bind top_side <Leave> {} 
	$Global(CurrentCanvas) bind right_side <Enter> {}
	$Global(CurrentCanvas) bind right_side <Leave> {}
	$Global(CurrentCanvas) bind left_side <Enter> {}
	$Global(CurrentCanvas) bind left_side <Leave> {}
	$Global(CurrentCanvas) bind bottom_side <Enter> {}
	$Global(CurrentCanvas) bind bottom_side <Leave> {}
	$Global(CurrentCanvas) bind top_left_corner <Enter> {}
	$Global(CurrentCanvas) bind top_left_corner <Leave> {}
	$Global(CurrentCanvas) bind top_right_corner <Enter> {}
	$Global(CurrentCanvas) bind top_right_corner <Leave> {}
	$Global(CurrentCanvas) bind bottom_right_corner <Enter> {}
	$Global(CurrentCanvas) bind bottom_right_corner <Leave> {}
	$Global(CurrentCanvas) bind bottom_left_corner <Enter> {}
	$Global(CurrentCanvas) bind bottom_left_corner <Leave> {}
}

proc bboxToCorners { coords } {
	return "[lindex $coords 0]  [lindex $coords 1]  [lindex $coords 2]  [lindex $coords 1]  [lindex $coords 2]  [lindex $coords 3]  [lindex $coords 0]  [lindex $coords 3]"
}

proc createHandles {} {
	global Global

	$Global(CurrentCanvas) delete handles
	set bb [$Global(CurrentCanvas) bbox Imp_Selected]
	if {"$bb" != ""} {
	set bboxcoords [bboxToCorners $bb]
	set x2_1 [lindex $bboxcoords 0]
	set y2_1 [lindex $bboxcoords 1] 
	set x1_1 [eval expr $x2_1 - 10]
	set y1_1 [eval expr $y2_1 - 10]
	set tlc [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_1 $y1_1 $x2_1 $y2_1"] \
		-tags \"selectorbox handles disabled Imp_Selected top_left_corner\" \
		-stipple gray50 \
		-outline white -fill black]
	set x2_2 [eval expr ([lindex $bboxcoords 2] - $x2_1)/2 + $x2_1 + 5]
	set y2_2 $y2_1
	set x1_2 [eval expr $x2_2 - 10]
	set y1_2 [eval expr $y2_2 - 10]
	set ts [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_2 $y1_2 $x2_2 $y2_2"] \
		-tags \"selectorbox handles disabled Imp_Selected top_side\" \
		-stipple gray50 \
		-outline white -fill black]
	set x2_3 [eval expr [lindex $bboxcoords 2] + 10]
	set y2_3 $y2_1
	set x1_3 [eval expr $x2_3 - 10]
	set y1_3 [eval expr $y2_3 - 10]
	set trc [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_3 $y1_3 $x2_3 $y2_3"] \
		-tags \"selectorbox handles disabled Imp_Selected top_right_corner\" \
		-stipple gray50 \
		-outline white -fill black]
	set x2_4 [eval expr $x1_3 + 10]
	set y2_4 [eval expr ([lindex $bboxcoords 5] - $y2_3)/2 + $y2_3 + 5]
	set x1_4 $x1_3
	set y1_4 [eval expr $y2_4 - 10]
	set rs [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_4 $y1_4 $x2_4 $y2_4"] \
		-tags \"selectorbox handles disabled Imp_Selected right_side\" \
		-stipple gray50 \
		-outline white -fill black]
	set x1_5 [lindex $bboxcoords 4]
	set y1_5 [lindex $bboxcoords 5]
	set x2_5 [eval expr $x1_5 + 10]
	set y2_5 [eval expr $y1_5 + 10]
	set brc [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_5 $y1_5 $x2_5 $y2_5"] \
		-tags \"selectorbox handles disabled Imp_Selected bottom_right_corner\" \
		-stipple gray50 \
		-outline white -fill black]
	set x2_6 $x1_2
	set y2_6 [eval expr $y1_5 + 10]
	set x1_6 [eval expr $x2_6 + 10]
	set y1_6 $y1_5
	set bs [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_6 $y1_6 $x2_6 $y2_6"] \
		-tags \"selectorbox handles disabled Imp_Selected bottom_side\" \
		-stipple gray50 \
		-outline white -fill black]
	set x1_7 $x1_1
	set y1_7 $y1_6
	set x2_7 [eval expr $x1_7 + 10]
	set y2_7 [eval expr $y1_7 + 10]
	set blc [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_7 $y1_7 $x2_7 $y2_7"] \
		-tags \"selectorbox handles disabled Imp_Selected bottom_left_corner\" \
		-stipple gray50 \
		-outline white -fill black]
	set x1_8 $x1_1
	set y1_8 $y1_4
	set x2_8 [eval expr $x1_8 + 10]
	set y2_8 [eval expr $y1_8 + 10]
	set ls [eval $Global(CurrentCanvas) create polygon \
		[bboxToCorners "$x1_8 $y1_8 $x2_8 $y2_8"] \
		-tags \"selectorbox handles disabled Imp_Selected left_side\" \
		-stipple gray50 \
		-outline white -fill black]
	handleBindings 
	}
}

proc doRuler { ruler len th m1 m2 step orient mark_list mastertemplate} {
	global Global
# ruler is a canvase for the ruler to reside in.
# m1 (margin left, top)
# m2 (margin right, bottom) define margin sizes on each end of the ruler.
# len  is the length of the ruler.
# th is the thickness (width) of the ruler.
# step  numerical entry at every increment of step units (e.g. 1 for every 1i).
# orient h=horizontal, v=vertical.
# mark_list specifies the breakdown of ruler (max 4).
#   (e.g. {.0625, .125, .25, .5})
# mastertemplate specifies (optional) a list of values indicating the length
#   of the hash mark at each breaddown in mark_list (percentage of th).
#   defaults to $th * .1, $th * .2, $th * .5

	regexp {(.*)(.)$} "$len" match len unit
	regexp {(.*).$} "$th" match th

	if {"$mark_list" == ""} {
		switch "$unit" {
			i {
				set mark_list {.0625 .125 .25 .5}
			}
			c { 
				set mark_list {.1 .5 1}
			}
			m {
				set mark_list {5 20}
			}
			p {
				set mark_list {50 100 200}
			}
		}
	}

	# Clear ruler
	eval $ruler delete all

	# Put down the base of ruler for size.

	if {$mastertemplate == ""} {
		# define lengths for divisions in units
		set mastertemplate \
			"[expr $th * .2] [expr $th * .3] [expr $th * .5] [expr $th * .8]"
	}
	set template [lrange $mastertemplate [expr 4 - [llength $mark_list]] end]
	set largest [lindex $mastertemplate 3]

	set ti 0
	foreach b $mark_list {
		if {"$b" == ""} {
			incr ti
			continue
		}
		set mlength [lindex $template $ti]
		for {set i 0} {$i <= $len} {set i [expr $i + $b]} {
			if {"$orient" == "h"} {
				$ruler create line [expr ${i} * $Global(ViewScale)]${unit} [expr $th - ${mlength}]i \
					[expr ${i} * $Global(ViewScale)]${unit} ${th}i
				if {$i == [expr int($i)]} {
					$ruler create text [expr ${i} * $Global(ViewScale)]${unit} [expr $th - ${largest} - \
						.05]i \
						-anchor ne -text [expr int($i)]
				}
			} else {
				$ruler create line [expr $th - ${mlength}]i [expr ${i} * $Global(ViewScale)]${unit} ${th}i \
					[expr ${i} * $Global(ViewScale)]${unit}
				if {$i == [expr int($i)]} {
					$ruler create text [expr $th - ${largest} - \
						.05]i [expr ${i} * $Global(ViewScale)]${unit} \
						-anchor sw -text [expr int($i)]
				}
			}
		}
		incr ti
	}
	if {$orient == "h"} {
    	$ruler configure -scrollregion \
			"${m1}${unit} 0i [expr ${len} - ${m2}]${unit} ${th}i"
		$ruler configure -xscrollincrement 1
		$ruler create line 0 ${th}i 0 0 -tags h -fill red
	} else {
    	$ruler configure -scrollregion \
			"0i ${m1}${unit} ${th}i [expr ${len} - ${m2}]${unit}"
		$ruler configure -yscrollincrement 1
		$ruler create line 0 0 ${th}i 0 -tags v -fill red
	}

}

proc trans { x y shape } {
	set newshape ""
	set count [llength $shape]
	set c 0
	while {$c < $count} {
		set xc [lindex $shape $c]
		set yc [lindex $shape [expr $c + 1]]
		set c [expr $c + 2]
		lappend newshape [expr $xc + $x] [expr $yc + $y]
	}
	return $newshape
}

proc doPostscript {args} {
	global Global

	deselectAll 
	if { "$args" == "" } {
		set ps [$Global(CurrentCanvas) postscript -x -0i -y -0i\
			-width $Global(PageWidth) -colormode $Global(PSColor) \
			-height $Global(PageHeight) -rotate $Global(Landscape)]
	} else {
		set ps [$Global(CurrentCanvas) postscript -channel $args -x -0i -y -0i\
			-width $Global(PageWidth) -colormode $Global(PSColor) \
			-height $Global(PageHeight) -rotate $Global(Landscape)]
	}
	return $ps
}

proc display {topname args} {
	catch {
		set f [browser::openStream $topname application/postscript]
		set out [doPostscript]
		browser::writeToStream $f $out
		browser::closeStream $f
	}
}

proc saveToPlugin {topname} {
	global Global

	if {[catch {policy javascript} errMsg]} {
		$Global(CurrentCanvas) create text 20 100 -text "$errMsg
Could not activate javascript policy.
Check tclplug config/plugin.cfg." \
			-anchor sw -tags Imp_Text -fill red \
			-font {-adobe-helvetica-bold-r-normal--*-240-72-72-p-0-iso8859-1}
		update
	} else {
		catch {
			set f [browser::openStream $topname application/impress]
			set out [saveAll]
			browser::writeToStream $f $out
			browser::closeStream $f
		}
		return "ok"
	}
	return ""
}

proc printToPlugin {topname} {
	global Global

	set saveit $Global(CurrentCanvas)
	if {"$Global(PrintCmd)" != ""} {
		catch {
			set f [browser::openStream $topname application/postscript]
			for {set page 1} {[winfo exists .can.c${page}]} {incr page} {
				set Global(CurrentCanvas) .can.c${page}
				set out [doPostscript]
				regsub -all {%%Page: [0-9][0-9]* [0-9][0-9]*} $out \
					"%%Page: $page $page" newout
				regsub -all {%%EOF} $newout {%%} newout
				if { ! [info exists f] } {
					msgRaise .diagmsg "ERROR: Cannot open stream for writing."
					set Global(CurrentCanvas) $saveit
					return
				} else {
					browser::writeToStream $f $newout
				}
			}
			browser::closeStream $f
		}
		set Global(CurrentCanvas) $saveit
	}
}

proc newOne {url mimetype lastmodified size} {
	global Global

	set Global(MessageSave) $Global(Message)
	set Global(Total) $size
	set Global(TotalSize) 0
	set Global(Message) "Loading: $Global(TotalSize) of $Global(Total)"
	update idletasks
}
proc writeOne {size data} {
	global Global

	set Global(TotalSize) [expr $Global(TotalSize) + $size]
	set Global(Message) "Loading: $Global(TotalSize) of $Global(Total)"
	update idletasks
}
proc openURL {} {
	global Global
	
	if {"$Global(URL)" != ""} {
		if {[catch {policy javascript} errMsg]} {
			$Global(CurrentCanvas) create text 20 100 -text "$errMsg
Could not activate javascript policy.
Check tclplug config/plugin.cfg." \
				-anchor sw -tags Imp_Text -fill red \
				-font {-adobe-helvetica-bold-r-normal--*-240-72-72-p-0-iso8859-1}
			update
		} else {
			if {![regexp {[^/:][^/:]*:/.*} $Global(URL) m]} {
				set Global(URL) "[getattr originHomeDirURL]$Global(URL)"
			}
			. configure -cursor watch
			update idletasks
			set Global(MessageSave) $Global(Message)
			catch {
				set url_in [browser::getURL $Global(URL) $Global(Timeout) newOne writeOne]
				set t 0
			} errcode
			if {$errcode != 0} {
				. configure -cursor {}
				set Global(Message) "URL error: $errcode"
				update idletasks
			} else {
				set Global(Message) "Rendering"
				update idletasks
				after idle "
					$url_in
					. configure -cursor {}
					set Global(Message) $Global(MessageSave)
					update idletasks"
			}
	   	}
	}
}

proc printPlugin {} {
	global Global

	if {[catch {policy javascript} errMsg]} {
		$Global(CurrentCanvas) create text 20 100 -text "$errMsg
Could not activate javascript policy.
Check tclplug config/plugin.cfg." \
			-anchor sw -tags Imp_Text -fill red \
			-font {-adobe-helvetica-bold-r-normal--*-240-72-72-p-0-iso8859-1}
		update
	} else {
		printToPlugin ""
	}
}
proc popupCanvasSet { type } {
	global Global

	setCursor "$type"
	bind .msg_e <1> {}
	bind .msg_e <Key-Return> {}
	.msg_e configure -state disabled
	set Global(undo) {}

	switch "$Global(Cursor)" {
		Rotate {
			if {[$Global(CurrentCanvas) find withtag selectorbox] != ""} {
				set Global(Message) Rotate
				$Global(CurrentCanvas) delete selectorbox
				$Global(CurrentCanvas) configure -closeenough 0.0
				eval $Global(CurrentCanvas) create polygon \
					[bboxToCorners [$Global(CurrentCanvas) bbox Imp_Selected]] \
					-tags selectorbox -stipple gray25 -outline \"\" -fill black
				.msg_e configure -state normal
				bind .msg_e <1> {
					set Global(Message) $Global(LastAngle)
				}
				bind .msg_e <Key-Return> {
					set Global(LastAngle) $Global(Message)
					$Global(CurrentCanvas) addtag [genTag] withtag Imp_selected
					set Global(undo) "$Global(CurrentCanvas) addtag \
						Imp_Selected withtag T-$Global(TagId); \
						set Global(LastAngle) [expr 0 - $Global(LastAngle)]; \
						set Global(LastX) $Global(LastX); \
						set Global(LastY) $Global(LastY); \
						rotateSelected; \
						$Global(CurrentCanvas) dtag Imp_Selected; \
						$Global(CurrentCanvas) dtag T-$Global(TagId)"
					rotateSelected
					set coords [$Global(CurrentCanvas) coords selectorbox]
					$Global(CurrentCanvas) delete selectorbox
					eval $Global(CurrentCanvas) create polygon \
						[eval RotateF $Global(LastAngle) \
						$Global(LastX) $Global(LastY) $coords] \
						-tags selectorbox \
						-stipple gray25 -outline \"\" -fill black
					pushUndo "$Global(undo)$Global(FontUndo)"
				}
			} else {
				setCursor Select
				set Global(Message) Select
				enableSelectionButtons
			}
		}
		Group {
			set Global(Message) Group
			setGroup "[$Global(CurrentCanvas) find withtag Imp_selected]"
			$Global(CurrentCanvas) addtag [genTag] withtag Imp_selected
			set Global(undo) \
				"unGroup \[$Global(CurrentCanvas) find withtag \
				T-$Global(TagId)\]
				$Global(CurrentCanvas) dtag T-$Global(TagId)"
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		UnGroup {
			set Global(Message) UnGroup
			unGroup "[$Global(CurrentCanvas) find withtag Imp_selected]"
			$Global(CurrentCanvas) addtag [genTag] withtag Imp_selected
			set Global(undo) \
				"setGroup \[$Global(CurrentCanvas) find withtag \
				T-$Global(TagId)\]
				$Global(CurrentCanvas) dtag T-$Global(TagId)"
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
			focus $Global(CurrentCanvas)
		}
		Grid {
			set Global(Message) Grid
			gridRaise .grid
		}
		PageProp {
			set Global(Message) PageProp
			pagePropRaise .pageProp
			deselectAll
			setCursor "Select"
			set Global(Message) $Global(Cursor)
			enableSelectionButtons
		}
		Raise {
			set Global(Message) Raise
			$Global(CurrentCanvas) raise Imp_selected
			$Global(CurrentCanvas) raise selectorbox
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		Lower {
			set Global(Message) Lower
			$Global(CurrentCanvas) lower Imp_selected
			catch "$Global(CurrentCanvas) raise Imp_selected Disabled"
			$Global(CurrentCanvas) raise selectorbox
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		Rulers {
			if { [$Global(CurrentCanvas) find withtag $Global(RulerX)] == "" } {
				set Global(RulerX) [$Global(CurrentCanvas) create window \
					0i .25i -anchor sw \
					-window $Global(CurrentCanvas).rulerx -tags {rulerx disabled}]
				set Global(RulerY) [$Global(CurrentCanvas) create window \
					0i 0i -anchor nw \
					-window $Global(CurrentCanvas).rulery -tags {rulery disabled}]
			}
			set Global(Message) Rulers
			$Global(CurrentCanvas) coords rulerx 0i \
				[expr [lindex [$Global(CurrentCanvas) yview] 0] * \
				[winfo fpixels $Global(CurrentCanvas) $Global(PageHeight)] + \
				[winfo fpixels $Global(CurrentCanvas) .25i] - 2]
			$Global(CurrentCanvas) coords rulery \
				[expr [lindex [$Global(CurrentCanvas) xview] 0] * \
				[winfo fpixels $Global(CurrentCanvas) $Global(PageWidth)] - 2] \
				0i
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		Cut {
			set Global(Message) Cut
			cutCopySelected Cut Imp_Selected 1
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		Paste {
			if {$Global(Cut) == ""} {
				setCursor "Select"
				set Global(Message) Select
				enableSelectionButtons
			}
		}
		Duplicate {
			set Global(Message) Duplicate
			duplicateSelected
			createHandles
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		Flip_Horiz {
			flip Imp_Selected h
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		Flip_Vert {
			flip Imp_Selected v
			setCursor "Select"
			set Global(Message) Select
			enableSelectionButtons
		}
		Smooth {
			if {$Global(Smooth)} {
				set Global(Msg_Smooth) "Switch to Smooth Lines"
			} else {
				set Global(Msg_Smooth) "Switch to Straight Lines"
			}
			set Global(Message) $Global(Msg_Smooth)
			set Global(Smooth) [expr ! $Global(Smooth)]
			.buttons.b_Smooth itemconfigure $Global(Smooth_Line) \
				-smooth $Global(Smooth)
			setCursor Select
		}
		Line -
		Oval -
		Rectangle -
		Rounded_Rectangle -
		Polygon -
		Text -
		Draw {
			set Global(Sub-Cursor) ""
			$Global(CurrentCanvas) delete Global(curline)
			$Global(CurrentCanvas) delete selector
			set Global(Message) $Global(Cursor)
			deselectAll
			disableSelectionButtons
		}
		Select {
			set Global(Message) $Global(Cursor)
			deselectAll
			enableSelectionButtons
		}
		Printt {
			.text delete 0.0 end
			set out [saveAll]
			.text insert 0.0 $out
			pack forget [winfo parent $Global(CurrentCanvas)]
			pack .textframe -fill both -expand true
			focus .text
		}
	
		Print {
			if {$Global(Plugin)} {
				printPlugin
			} else {
				printRaise .print
			}
			return
		}
	}
	if {$Global(undo) != ""} {
		pushUndo "$Global(undo)"
	}
	focus $Global(CurrentCanvas)
}
proc setGroup { items } {
	global Group GroupNo Global

	if { "$items" != "" } {
		set itemList [getGroupItems "$items"] 
		foreach item $itemList {
			if {![info exists done($item)]} {
				$Global(CurrentCanvas) addtag Group${GroupNo} withtag $item
				if {[info exists Group($Global(CurrentCanvas),$item)]} {
					set Group($Global(CurrentCanvas),$item) "Group${GroupNo} $Group($Global(CurrentCanvas),$item)"
				} else {
					set Group($Global(CurrentCanvas),$item) Group${GroupNo}
				}
				set done($item) 1
			}
		}
		set GroupNo [clock clicks]
	}
}
proc unGroup { items } {
	global Group PrevGroup Global

	if { "$items" != "" } {
		. configure -cursor watch
		update idletasks
		#		set itemList [getGroupItems "$items"]
		set itemList "$items"
		foreach item $itemList {
			if {![info exists done($item)]} {
				if {[info exists Group($Global(CurrentCanvas),$item)]} {
					$Global(CurrentCanvas) dtag $Group($Global(CurrentCanvas),$item)
					if {[lrange $Group($Global(CurrentCanvas),$item) 1 end] != ""} {
						set Group($Global(CurrentCanvas),$item) [lrange $Group($Global(CurrentCanvas),$item) 1 end]
					} else {
						unset Group($Global(CurrentCanvas),$item)
					}
				}
				set done($item) 1
			}
		}
		deselectAll 
		update idletasks
		. configure -cursor ""
		update idletasks
	}
}
proc repositionWindow { X Y } {
	global Global

	set contain [winfo containing $X $Y]
	set parent ""
	catch {set parent [winfo parent $contain]}

	switch "$contain" {
		.can.scrolly {
			set Global(ScrollDir) ".can.scrollx h 1"
			eval tkScrollByUnits $Global(ScrollDir)
		}
		.can.scrollx {
			set Global(ScrollDir) ".can.scrolly v 1"
			eval tkScrollByUnits $Global(ScrollDir)
		}
		.msg_e {
			set Global(ScrollDir) ".can.scrolly v -1"
			eval tkScrollByUnits $Global(ScrollDir)
		}
		default {
			if {"$parent" == "." && "$contain" != ".can"} {
				set Global(ScrollDir) ".can.scrolly v -1"
			}
			if {"$parent" == ".can" || \
				"$parent" == $Global(CurrentCanvas)} {
				set Global(ScrollDir) ""
			} elseif {$Global(ScrollDir) == ""} {
				set Global(ScrollDir) ".can.scrollx h -1" 
				eval tkScrollByUnits $Global(ScrollDir)
			} else {
				eval tkScrollByUnits $Global(ScrollDir)
			}
		}
	}
}
proc scaleSelected { handle1 x y X Y} {
	global Global

	repositionWindow $X $Y
	set nofontscale 0
	if { "$Global(LastSX)" == ""} {
		set last [handleOrigin $handle1]
		set Global(LastSX) [lindex "$last" 0]
		set Global(LastSY) [lindex "$last" 1]
		set origin \
			[handleOrigin $Global($handle1)]
		set Global(originx) [lindex "$origin" 0]
		set Global(originy) [lindex "$origin" 1]
	}
	if { "$handle1" == "top_side" || "$handle1" == "bottom_side" } {
		set scalex 1
		set nofontscale 1
	} else {
		set e [expr $Global(originx) - $Global(LastSX)]
		if {$e} {
			set scalex [expr ($Global(originx) - $x) / \
				$e]
		}
	}
	if { "$handle1" == "right_side" || "$handle1" == "left_side" } {
		set scaley 1
		set nofontscale 1
	} else {
		set e [expr $Global(originy) - $Global(LastSY)]
		if {$e} {
			set scaley [expr ($Global(originy) - $y) / \
				$e]
			if { "$handle1" != "top_side" && "$handle1" != "bottom_side" \
				&& $Global(FixedAspect) != ""} {
				set scalex $scaley
			}
		}
	}
	set next {set Global(LastSX) $x;set Global(LastSY) $y}
	if {$scalex > 0 && $scaley > 0} {
		set Global(TScaleX) [expr $Global(TScaleX) * [expr 1.0/$scalex]]
		set Global(TScaleY) [expr $Global(TScaleY) * [expr 1.0/$scaley]]
		$Global(CurrentCanvas) scale Imp_Selected \
			$Global(originx) $Global(originy) $scalex $scaley
		eval $next
		foreach i [$Global(CurrentCanvas) find withtag Imp_SelectedText] {
			if {$Global(FontScale) && !$nofontscale} {
				set fn [$Global(CurrentCanvas) itemcget $i -font]
				if {$Global(FUndo)} {
					$Global(CurrentCanvas) addtag [genTag] withtag $i
					append Global(FontUndo) \
					";$Global(CurrentCanvas) itemconfigure T-$Global(TagId) -font $fn;$Global(CurrentCanvas) dtag T-$Global(TagId)"
				}
				regexp \
				{([-][^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-)([^-]*)(-.*)}\
					$fn dummy d1 size d2;
				if {"$dummy" != ""} {
					set nsize [expr round($size * $scalex)]
					if {$nsize < 20} {
						set nsize 20
					}
					$Global(CurrentCanvas) itemconfigure $i \
						-font ${d1}${nsize}${d2}
					set fnn [$Global(CurrentCanvas) itemcget $i -font]
					regexp \
				{([-][^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-)([^-]*)(-.*)}\
						$fnn dummy d1 nsize d2;
					if { ($scalex < 1 && $nsize < $size ) || \
		 				($scalex > 1 && $nsize > $size) } {
						$Global(CurrentCanvas) itemconfigure $i \
							-width [expr [$Global(CurrentCanvas) itemcget $i \
							-width] * $scalex]
					} else {
						$Global(CurrentCanvas) itemconfigure $i \
							-font $fn
					}
				}
			} else {
				$Global(CurrentCanvas) itemconfigure $i \
					-width [expr [$Global(CurrentCanvas) itemcget $i \
					-width] * $scalex]
			}
		}
		set Global(FUndo) 0
		$Global(CurrentCanvas) delete handles
		createHandles
	}
}

proc deselectAll {} {
	global Global

	$Global(CurrentCanvas) delete selector
	$Global(CurrentCanvas) delete selectorbox
	$Global(CurrentCanvas) dtag Imp_selected
	$Global(CurrentCanvas) dtag Imp_Selected
	$Global(CurrentCanvas) dtag Imp_SelectedText
	$Global(CurrentCanvas) dtag Imp_SelectedPhoto
	$Global(CurrentCanvas) dtag currentImp_Selected
}

proc markSpot {x y} {
	global Global

	if {$Global(Grid)} {
		set Global(LastX) [$Global(CurrentCanvas) canvasx $x \
			$Global(GridX)]
	} else {
		set Global(LastX) [$Global(CurrentCanvas) canvasx $x \
			1]
	}
	if {$Global(Grid)} {
		set Global(LastY) [$Global(CurrentCanvas) canvasy $y \
			$Global(GridY)]
	} else {
		set Global(LastY) [$Global(CurrentCanvas) canvasy $y \
			1]
	}
	set Global(LastSX) {}
	set Global(LastSY) {}
	set Global(LastRotX) $Global(LastX)
	set Global(LastRotY) $Global(LastY)
	set Global(OrigX) $Global(LastX)
	set Global(OrigY) $Global(LastY)
	set Global(LastAngle) 0.0
	set Global(TScaleX) 1.0
	set Global(TScaleY) 1.0
	set Global(TMoveX) 0.0
	set Global(TMoveY) 0.0
	set Global(undo) {}
	set Global(FontUndo) {}
	set Global(FUndo) 1
}

proc findItemUnderCursor {} {
	global Global

	return [$Global(CurrentCanvas) find withtag current]
}

proc shadeCurrentSelected {} {
	global Global

	set bb [$Global(CurrentCanvas) bbox currentImp_Selected]
	if {"$bb" != "" && \
		[$Global(CurrentCanvas) type currentImp_Selected] != "text"} {
		eval $Global(CurrentCanvas) create polygon [bboxToCorners $bb] \
			-tags {"selectorbox Imp_Selected"} \
			-stipple gray25 -outline {""} -fill black
	}
}

proc selectAll {} {
	global Global

	popupCanvasSet Select
	. configure -cursor watch
	update idletasks
	set itemList [eval $Global(CurrentCanvas) find withtag all]
	if {[llength $itemList] > 500} {
		$Global(CurrentCanvas) addtag Imp_selected withtag all
		$Global(CurrentCanvas) addtag Imp_Selected withtag all
		$Global(CurrentCanvas) addtag currentImp_Selected withtag all
		$Global(CurrentCanvas) addtag Imp_SelectedText withtag Imp_Text 
		$Global(CurrentCanvas) addtag Imp_SelectedPhoto withtag Imp_Photo
		$Global(CurrentCanvas) dtag currentImp_Selected disabled
		$Global(CurrentCanvas) dtag Imp_Selected disabled
		$Global(CurrentCanvas) dtag Imp_SelectedText disabled
		$Global(CurrentCanvas) dtag Imp_SelectedPhoto disabled
        shadeCurrentSelected
        $Global(CurrentCanvas) dtag currentImp_Selected   
	} else {
		foreach i $itemList {
			set tags [$Global(CurrentCanvas) gettags $i]
			selectItem $i $tags All
		}
	}
	createHandles
	update idletasks
	. configure -cursor ""
	update idletasks
}

proc selectItem {item tags type} {
	global Global

	if {"$item" != "" && [lsearch -exact "$tags" "disabled"] == -1} {
		if {[lsearch -exact "$tags" "Imp_Selected"] == -1 && \
			[lsearch -exact "$tags" "Imp_SelectedText"] == -1 &&
			[lsearch -exact "$tags" "Imp_SelectedPhoto"] == -1} {
			switch $type {
				New {
					deselectAll
				}
			}
			set itemList [getGroupItems $item]
			foreach i $itemList {
				$Global(CurrentCanvas) addtag Imp_selected withtag $i
				$Global(CurrentCanvas) addtag currentImp_Selected withtag $i
				set t [$Global(CurrentCanvas) type $i]
				if {$t == "text"} {
					$Global(CurrentCanvas) addtag Imp_SelectedText withtag $i
				} elseif {$t == "image"} {
					$Global(CurrentCanvas) addtag Imp_SelectedPhoto withtag $i
				}
			}
			shadeCurrentSelected
			$Global(CurrentCanvas) addtag Imp_Selected withtag currentImp_Selected
			$Global(CurrentCanvas) dtag currentImp_Selected
		} elseif {"$type" == "Add" && \
			[lsearch -exact "$tags" "selectorbox"] != -1} {
			set itemList [eval $Global(CurrentCanvas) find enclosed \
				[$Global(CurrentCanvas) bbox $item]]
			foreach i $itemList {
				$Global(CurrentCanvas) dtag $i Imp_selected
				$Global(CurrentCanvas) dtag $i Imp_Selected
				$Global(CurrentCanvas) dtag $i Imp_SelectedText
				$Global(CurrentCanvas) dtag $i Imp_SelectedPhoto
				if {[lsearch -exact [$Global(CurrentCanvas) gettags $i] \
					"selectorbox"] != -1} {
					$Global(CurrentCanvas) delete $i
				}
			}
			$Global(CurrentCanvas) delete $item
		}
	} elseif {"$type" == "New"} {
		deselectAll
	}
}

proc selectBoundedItems {bb type} {
	global Global

	. configure -cursor watch
	update idletasks
	set itemList [eval $Global(CurrentCanvas) find enclosed $bb]
	if {[llength $itemList] > 500} {
		eval $Global(CurrentCanvas) addtag Imp_selected enclosed $bb
		eval $Global(CurrentCanvas) addtag currentImp_Selected enclosed $bb
        shadeCurrentSelected
        $Global(CurrentCanvas) addtag Imp_Selected withtag currentImp_Selected
        $Global(CurrentCanvas) dtag currentImp_Selected   
	} else {
		foreach i $itemList {
			set tags [$Global(CurrentCanvas) gettags $i]
			selectItem $i $tags $type
		}
	}
	update idletasks
	. configure -cursor ""
	update idletasks
}

proc dragBoxOrMove {item tags x y X Y} { 
	global Global

	# If we don't update the tags here, we won't see the
	# potential new selection we just made.
	set tags [$Global(CurrentCanvas) gettags $item]

	if {[lsearch -exact "$tags" "Imp_Selected"] == -1 && \
		[lsearch -exact "$tags" "Imp_SelectedText"] == -1 && \
		[lsearch -exact "$tags" "Imp_SelectedPhoto"] == -1} {
		# Drag a selection box if there is no evidence of
		# being on a Imp_Selected item.
		$Global(CurrentCanvas) delete selector
		repositionWindow $X $Y
		$Global(CurrentCanvas) create rectangle \
			$Global(LastX) $Global(LastY) $x $y \
			-tags selector -fill "" -outline black
	} else {
		# Move Imp_Selected items if we are dragging on a
		# Imp_Selected item.
		set cursor [lindex [$Global(CurrentCanvas) configure -cursor] 4]
		if { "$cursor" == "" || "$cursor" == "crosshair" } {
			repositionWindow $X $Y
			set possibles [$Global(CurrentCanvas) find enclosed \
				[expr $x - $Global(GravityVal)] \
				[expr $y - $Global(GravityVal)] \
				[expr $x + $Global(GravityVal)] \
				[expr $y + $Global(GravityVal)]]
			set hs [$Global(CurrentCanvas) find withtag handles]
			set tiend ""
			foreach possible $possibles {
				if {"$tiend" != ""} {
					break
				}
				foreach h $hs {
					if {$possible == $h} {
						set tiend $h
						break
					}
				}
			} 
			set ho [handleOrigin [lindex \
				[$Global(CurrentCanvas) itemcget $tiend -tags] end]]
			if { $Global(Gravity) && "$ho" != "" && !$Global(AnchorChosen)} {
				$Global(CurrentCanvas) move Imp_Selected \
					[expr $x - [lindex $ho 0]] \
					[expr $y - [lindex $ho 1]]
				set Global(TMoveX) \
					[expr $Global(TMoveX) + ($x - [lindex $ho 0])]
				set Global(TMoveY) \
					[expr $Global(TMoveY) + ($y - [lindex $ho 1])]
				set Global(AnchorChosen) 1
			} else {
				$Global(CurrentCanvas) move Imp_Selected \
					[expr $x - $Global(LastX)] \
					[expr $y - $Global(LastY)]
				set Global(TMoveX) \
					[expr $Global(TMoveX) + ($x - $Global(LastX))]
				set Global(TMoveY) \
					[expr $Global(TMoveY) + ($y - $Global(LastY))]
				set Global(AnchorChosen) 1
			}
			set Global(LastX) $x
			set Global(LastY) $y
		}
	}
}
proc rotateSelected {} {
	global Global Group

	. configure -cursor watch
	update
	set items [$Global(CurrentCanvas) find withtag Imp_Selected]
	foreach item $items {
		set gsave ""
 		if {[info exists Group($Global(CurrentCanvas),$item)]} {
			set gsave $Group($Global(CurrentCanvas),$item)
			unset Group($Global(CurrentCanvas),$item)
		}
		set coords [$Global(CurrentCanvas) coords $item]
		set tags [$Global(CurrentCanvas) gettags $item]
		set props [getProperties $Global(CurrentCanvas) $item none 0]
		set type [$Global(CurrentCanvas) type $item]
		$Global(CurrentCanvas) delete $item
		set i [eval $Global(CurrentCanvas) create $type \
			[eval RotateF $Global(LastAngle) $Global(LastX) $Global(LastY) \
							"$coords"] \
					$props]
		if {$gsave != ""} {
			set Group($Global(CurrentCanvas),$i) "$gsave"
		}
	}
	update idletasks
	. configure -cursor ""
	update idletasks
}

proc pasteCutCopy { x y pastetype cuttype doselect} {
	global Global Group

	. configure -cursor watch
	update idletasks
	set pastebuf $Global($cuttype)
	if {"$pastebuf" != ""} {
		switch "$pastetype" {
			relative {
				append pastebuf "
					\$Global(CurrentCanvas) move Imp_Buffer $x $y;
				"
			}
			absolute {
				append pastebuf "
					originObject Imp_Buffer;
					\$Global(CurrentCanvas) move Imp_Buffer $x $y;
				"
			}
		}
		append pastebuf "
			set itemList \[\$Global(CurrentCanvas) find withtag Imp_Buffer\];
			\$Global(CurrentCanvas) dtag Imp_Buffer;
			deselectAll;"

		if {$doselect} {
			append pastebuf "
				foreach item \$itemList {
					set tags \[\$Global(CurrentCanvas) gettags \$item\]
					selectItem \$item \"\$tags\" Add
				}
				createHandles
			"
		}
		after idle $pastebuf
	}
	update idletasks
	. configure -cursor ""
	update idletasks
}

proc OpasteCutCopy { x y cuttype lve mx my } {
	global Global Group

	. configure -cursor watch
	update idletasks
	deselectAll
	if {"$Global($cuttype)" != ""} {
		if { $lve } {
			append Global($cuttype) "
				set itemList \[\$Global(CurrentCanvas) find withtag cutImp_selected\]
				foreach item \$itemList {
					set tags \[\$Global(CurrentCanvas) gettags \$item\]
					selectItem \$item \"\$tags\" Add
				}
				moveObject cutImp_selected $mx $my
				\$Global(CurrentCanvas) dtag cutImp_selected
				createHandles
			"
			after idle $Global($cuttype)
		} else {
			append Global($cuttype) "
				moveObject cutImp_selected $mx $my
				\$Global(CurrentCanvas) dtag cutImp_selected
			"
			after idle $Global($cuttype)
		}
	}
	set Global($cuttype) ""
	if {"$cuttype" == "Cut"} {
		disablePaste
	}
	update idletasks
	. configure -cursor ""
	update idletasks
}

proc clearAll { args } {
	global Global


	if { "$args" != "" } {
		set action_status [eval $args]
	} else {
		set action_status ""
	}
	if {$Global(Plugin)} {
		. configure -cursor watch
		for {set page 1} {[winfo exists .can.c$page]} {incr page} {
			destroy .can.c$page
			catch {unset Global(.can.c${page}_ViewScale)}
		}
		set Global(CurrentPageId) 1
		newCanvas .can c$Global(CurrentPageId)
		. configure -cursor ""
	} elseif {"$action_status" != "" || ! [tk_dialog .clearAll "New?" \
		"Selecting New will erase everything?" "" "0" "Yes" "No"] } {
		. configure -cursor watch
		for {set page 1} {[winfo exists .can.c$page]} {incr page} {
			destroy .can.c$page
			catch {unset Global(.can.c${page}_ViewScale)}
		}
		set Global(CurrentPageId) 1
		newCanvas .can c$Global(CurrentPageId)
		. configure -cursor ""
	}
}

proc doExit { args } {
	global Global


	if { "$args" != "" } {
		set action_status [eval $args]
	} else {
		set action_status ""
	}
	if {"$action_status" != "" || ! [tk_dialog .exit "Exit?" \
		"Exit without saving?" "" "0" "Yes" "No"] } {
		exit
	}
}

proc saveAll {} {
	global Global Group

	append nativeOut {#!/bin/sh
# restart trick }
	append nativeOut "\\"
	append nativeOut {
exec wish "$0" "$@"
if {![info exists Global(CurrentCanvas)]} {
	proc nextPage {} {
		global Global

		set Global(CurrentPageId) [expr $Global(CurrentPageId) + 1]
		if {![winfo exists .can.c$Global(CurrentPageId)]} {
			if {$Global(Circulate)} {
				set Global(CurrentPageId) 1 
			} else {
				set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
			}
		}
		newCanvas .can c$Global(CurrentPageId)
		update idletasks
	}

	proc prevPage {} {
		global Global
	
		if {$Global(CurrentPageId) > 1} {
			set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
			newCanvas .can c$Global(CurrentPageId)
			update idletasks
		}
	}
	proc newCanvas { cf name } {
		global Global

		if {[winfo exists $Global(CurrentCanvas)]} {
			pack forget $Global(CurrentCanvas)
		}
		set Global(CurrentCanvas) $cf.$name
		if {[winfo exists $Global(CurrentCanvas)]} {
			pack $Global(CurrentCanvas) -in $cf.top -side left -fill both \
				-expand true
			update idletasks
			if {$Global(Fit)} {
				scaleObject all "" \
				[winfo width $Global(CurrentCanvas)] \
				[winfo height $Global(CurrentCanvas)]
			}
		} else {
			if {!$Global(Plugin)} {
    			wm maxsize . [winfo pixels . $Global(PageWidth)] \
					[winfo pixels . $Global(PageHeight)]
			}
    		canvas $Global(CurrentCanvas) -bg white \
				-scrollregion "0i 0i $Global(PageWidth) $Global(PageHeight)" \
				-xscrollcommand "$cf.scrollx set" \
				-yscrollcommand "$cf.scrolly set"
			bind $Global(CurrentCanvas) <2> {%W scan mark %x %y}
			bind $Global(CurrentCanvas) <B2-Motion> {%W scan dragto %x %y}
			bind . <Key-Next> {nextPage}
			bind . <Key-Prior> {prevPage}
			pack $Global(CurrentCanvas) -in $cf.top -side left -fill both \
				-expand true
		}
	}

	set Global(Circulate) 0
	set Global(Fit) 0
	set Global(PointsInch) [winfo fpixels . 1i]
	if {[info exists embed_args]} {
		set Global(Plugin) 1
	} else {
		set Global(Plugin) 0
	}
    frame .can
    frame .can.top
    frame .can.bottom
	frame .can.buttons
	button .can.origin -text Origin -command \
		{originObject $Global(CurrentCanvas) all}
	checkbutton .can.fit -text Fit -variable Global(Fit)
	checkbutton .can.circ -text Circulate -variable Global(Circulate)
	button .can.next -text Next -command {nextPage}
	button .can.prev -text Prev -command {prevPage}
	button .can.dismiss -text Dismiss -command "exit"
    scrollbar .can.scrolly -bd 2 -width 15 \
		-command {$Global(CurrentCanvas) yview}
    scrollbar .can.scrollx -orient h -bd 2 -width 15 \
		-command {$Global(CurrentCanvas) xview}
    frame .can.corner -height 15 -width 15 -bd 2
	if {!$Global(Plugin)} {
    	wm maxsize . [winfo pixels . 8.5i] [winfo pixels . 11i]
	}
    pack .can.scrolly -in .can.top -anchor se -side right -fill y
    pack .can.scrollx -in .can.bottom -anchor se -side left -expand true -fill x
    pack .can.corner -in .can.bottom -anchor ne -in .can.bottom \
		-side right -fill both
	pack .can.prev .can.next .can.origin .can.fit .can.circ -side left \
		-in .can.buttons
    pack .can.top -side top -in .can -expand true -fill both
    pack .can.bottom -side top -in .can -anchor sw -fill x
    pack .can.buttons -side top -in .can -anchor sw -fill x
    pack .can -fill both -expand true
	proc scaleObject {name ratio width height} {
		global Global

		set c $Global(CurrentCanvas)
		set bb [$c bbox $name]
		if {"$bb" == ""} {
			return
		}
		set x [lindex $bb 2]
		set y [lindex $bb 3]
		if {$ratio != ""} {
			set scale $ratio
		} else {
			if {$x > $y} {
				set scale [expr ( $width + 0.0 ) / $x]
			} else {
				set scale [expr ( $height + 0.0 ) / $y]
			}
		}
		$c scale $name 0 0 $scale $scale

		foreach i [$c find withtag all] {
			set type [$c type $i]
			if {"$type" != "text"} {
				continue
			}
			if {1} {
				set fn [$c itemcget $i -font]
				regexp \
				{([-][^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-)([^-]*)(-.*)}\
					$fn dummy d1 size d2;
				if {"$dummy" != ""} {
					set nsize [expr round($size * $scale)]
					if {$nsize < 20} {
						set nsize 20
					}
					$c itemconfigure $i \
						-font ${d1}${nsize}${d2}
					set fnn [$c itemcget $i -font]
					regexp \
					{([-][^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-)([^-]*)(-.*)}\
					$fnn dummy d1 nsize d2;
					if { ($scale < 1 && $nsize < $size ) || \
				 		($scale > 1 && $nsize > $size) } {
						$c itemconfigure $i \
							-width [expr [$c itemcget $i \
								-width] * $scale]
					} else {
						$c itemconfigure $i \
							-font $fn
					}
				}
			} else {
				$c itemconfigure $i \
					-width [expr [$c itemcget $i -width] \
						* $scale]
			}
		}
	}
	proc originObject { c name } {
		set bb [$c bbox $name]
		set x [lindex $bb 0]
		set y [lindex $bb 1]
		if {$x > 0} {
			set nx -$x
		} else {
			set nx [expr abs($x)]
		}
		if {$y > 0} {
			set ny -$y
		} else {
			set ny [expr abs($y)]
		}
		$c move $name $nx $ny
	}
}
	if {[info exists Global(EmbedPage)]} {
		if {!$Global(EmbedPage)} {
			set Global(CurrentPageId) 0
			set Global(CurrentCanvas) ""
		} elseif {[info exists Global(CurrentPageId)]} {
			set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
		}
	} else {
		set Global(CurrentPageId) 0
		set Global(CurrentCanvas) ""
	}
	set Global(LoadPageId) [expr $Global(CurrentPageId) + 1]
}
	append nativeOut "    set Global(DocPointsInch) $Global(PointsInch)
    set Global(SlideBG) $Global(SlideBG)
	set Global(Circulate) $Global(Circulate)
	set Global(SlideScale) $Global(SlideScale)
	"
	if {[info procs newCanvasBegin] == "newCanvasBegin"} {
		append nativeOut "    proc newCanvasBegin {} {"
		append nativeOut "[info body newCanvasBegin]
		}
	"
	} 
 
	for {set page 1} {[winfo exists .can.c$page]} {incr page} {
		set Global(CurrentCanvas) .can.c$page
		# Compute the "undo" scale to turn the saved page into scale 1.0
		if {[info exists Global($Global(CurrentCanvas)_ViewScale)]} {
			set newscale \
				[expr 1.0 / $Global($Global(CurrentCanvas)_ViewScale)]
		} else {
			set newscale 1
		}

		# Clear selections, prepare for writing objects
		deselectAll
		. configure -cursor watch
		update idletasks	
		$Global(CurrentCanvas) delete selectorbox

		# Get all of the canvas items into a list
		set itemList [$Global(CurrentCanvas) find withtag all]

		# Output page properties, create new canvas page, execute
		# any prepatory newCanvasBegin commands.
		append nativeOut \
			"
			set Global(CurrentPageId) \[expr \$Global(CurrentPageId) + 1\]
			set Global(PageHeight) $Global($Global(CurrentCanvas)_Height)
			set Global(PageWidth) $Global($Global(CurrentCanvas)_Width)
			set Global(Landscape) $Global($Global(CurrentCanvas)_Landscape)
			newCanvas .can c\$Global(CurrentPageId)
			if {\[info procs newCanvasBegin\] == {newCanvasBegin}} {
				newCanvasBegin
			} 
			"
		if {$itemList != ""} {
			# Go through each item....attempt to preserve groups.
			foreach item $itemList {
				set gsave ""
 				if {[info exists Group($Global(CurrentCanvas),$item)]} {
					set gsave $Group($Global(CurrentCanvas),$item)
				}
				set props [getProperties $Global(CurrentCanvas) $item "" 0]
				set coords [$Global(CurrentCanvas) coords $item]
				set type [$Global(CurrentCanvas) type $item]
				if {"$type" == "window"} {
					continue
				}
				if {"$gsave" != ""} {
					append nativeOut \
					"set i \[\$Global(CurrentCanvas) create $type [regsub -all \
				{([^ ][^ ]* [^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)} $coords {\1 \\
} stuff; set stuff] $props\]\n"
					append nativeOut \
						"set Group(\$Global(CurrentCanvas),\$i) {$gsave}\n"
				} else {
					append nativeOut \
					"\$Global(CurrentCanvas) create $type [regsub -all \
				{([^ ][^ ]* [^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)} $coords {\1 \\
} stuff; set stuff] $props\n"
				}
			}

			# Scale it based on differences in DPI between saving device
			# and reading device.  Adjust also for ViewScale in which
			# it was saved.
			append nativeOut "scaleObject all \
				\[expr \$Global(PointsInch)/\$Global(DocPointsInch) * \
				$newscale\] {} {}"
		}
	}
	append nativeOut {
		set Global(CurrentPageId) $Global(LoadPageId)
		newCanvas .can c$Global(CurrentPageId)
	}
	update idletasks	
	. configure -cursor ""
	update idletasks	
	set Global(CurrentCanvas) .can.c$Global(CurrentPageId)
	return $nativeOut
}
proc cutCopySelected { cuttype tagname dogroups } {
	global Global Group

	set Global($cuttype) ""
	. configure -cursor watch
	update idletasks	
	$Global(CurrentCanvas) delete selectorbox
	set itemList [$Global(CurrentCanvas) find withtag $tagname]
	if {$itemList != ""} {
		set bb [$Global(CurrentCanvas) bbox $tagname]
		foreach item $itemList {
			set gsave ""
 			if {$dogroups && [info exists Group($Global(CurrentCanvas),$item)]} {
				foreach g $Group($Global(CurrentCanvas),$item) {
					if {![info exists CopyGroup($g)]} {
						set GroupNo [clock clicks]
						set CopyGroup($g) "Group${GroupNo}"
					}
					lappend gsave $CopyGroup($g)
				}
			}
			set props [getProperties $Global(CurrentCanvas) $item Esc $dogroups]
			set coords [$Global(CurrentCanvas) coords $item]
			set type [$Global(CurrentCanvas) type $item]
			if {"$type" == "window"} {
				continue
			}
			append Global($cuttype) "
			set i \[eval \$Global(CurrentCanvas) create $type $coords $props\];
			\$Global(CurrentCanvas) addtag Imp_Buffer withtag \$i;"
			if { $gsave != "" } {
				append Global($cuttype) "
					set Group(\$Global(CurrentCanvas),\$i) {$gsave};"
				foreach g $gsave {
					append Global($cuttype) "
						\$Global(CurrentCanvas) addtag $g withtag \$i;"
				}
			}
			if {"$cuttype" == "Cut"} {
				$Global(CurrentCanvas) delete $item
			}
		}
		if {"$cuttype" == "Cut"} {
			enablePaste
		}
	}
	update idletasks	
	. configure -cursor ""
	update idletasks	
}
proc OcutCopySelected { cuttype tagname preserve } {
	global Global Group

	set Global($cuttype) ""
	. configure -cursor watch
	update idletasks	
	$Global(CurrentCanvas) delete selectorbox
	set itemList [$Global(CurrentCanvas) find withtag $tagname]
	if {$itemList != ""} {
		set bb [$Global(CurrentCanvas) bbox $tagname]
		set x [lindex $bb 0]
		set y [lindex $bb 1]
		if {!$preserve} {
			if {$x > 0} {
				set nx -$x
			} else {
				set nx [expr abs($x)]
			}
			if {$y > 0} {
				set ny -$y
			} else {
				set ny [expr abs($y)]
			}
		}
		deselectAll
		foreach item $itemList {
			set gsave ""
 			if {[info exists Group($Global(CurrentCanvas),$item)]} {
				set gsave $Group($Global(CurrentCanvas),$item)
			}
			$Global(CurrentCanvas) addtag cutImp_selected withtag $item
			set props [getProperties $Global(CurrentCanvas) $item Esc 0]
			set coords [$Global(CurrentCanvas) coords $item]
			set type [$Global(CurrentCanvas) type $item]
			if {"$type" == "window"} {
				continue
			}
			if {$preserve} {
				append Global($cuttype) \
				"set i \[eval \$Global(CurrentCanvas) create $type $coords $props\];"
			} else {
				append Global($cuttype) \
				"set i \[eval \$Global(CurrentCanvas) create $type \[trans \$x \$y \"[trans $nx $ny $coords]\"\] $props\];"
				if {"$gsave" != ""} {
					append Global($cuttype) \
						"set Group(\$Global(CurrentCanvas),\$i) {$gsave};"
					unset Group($Global(CurrentCanvas),$item)
				}
			}
			if {"$cuttype" == "Cut"} {
				$Global(CurrentCanvas) delete $item
			}
			$Global(CurrentCanvas) dtag cutImp_selected
		}
		if {"$cuttype" == "Cut"} {
			enablePaste
		}
	}
	update idletasks	
	. configure -cursor ""
	update idletasks	
}

proc duplicateSelected {} {
	global Group Global GroupNo

	. configure -cursor watch
	update idletasks
	cutCopySelected Copy Imp_Selected 1
	deselectAll
	update idletasks
	pasteCutCopy 20 20 relative Copy 1
	update idletasks
	. configure -cursor ""
	update idletasks
}

proc OduplicateSelected {} {
	global Group Global GroupNo

	set GroupNo [clock clicks]
	$Global(CurrentCanvas) configure -cursor watch
	update idletasks	
	$Global(CurrentCanvas) delete selectorbox
	set itemList [$Global(CurrentCanvas) find withtag Imp_Selected]
	if {$itemList != ""} {
		if {$Global(Duplicate) != $itemList} {
			set Global(DuplicateX) 20
			set Global(DuplicateY) 20
		}
		deselectAll
		foreach item $itemList {
			set gsave ""
 			if {[info exists Group($Global(CurrentCanvas),$item)]} {
				set gsave $Group($Global(CurrentCanvas),$item)
			}
			set props [getProperties $Global(CurrentCanvas) $item none 1]
			set coords [$Global(CurrentCanvas) coords $item]
			set type [$Global(CurrentCanvas) type $item]
			set i [eval $Global(CurrentCanvas) create $type \
				[trans $Global(DuplicateX) $Global(DuplicateY) $coords] \
				$props]
			$Global(CurrentCanvas) addtag duplicate withtag $i
			if {$gsave != ""} {
				$Global(CurrentCanvas) dtag $i ${gsave}
				$Global(CurrentCanvas) addtag "${gsave}${GroupNo}" withtag $i
				set Group($Global(CurrentCanvas),$i) "${gsave}${GroupNo}"
			}
		}
		incr Global(DuplicateX) 20
		incr Global(DuplicateY) 20
		set itemList [$Global(CurrentCanvas) find withtag duplicate]
		foreach item $itemList {
			set tags [$Global(CurrentCanvas) gettags $item]
			selectItem $item $tags Add
			$Global(CurrentCanvas) dtag duplicate
		}
	}
	update idletasks
	$Global(CurrentCanvas) configure -cursor ""
	update idletasks
}

proc updateDemoLine { args } {
	global Global

	if {"$args" == "spline" } {
		if {$Global(Smooth)} {
			set Global(Smooth) 0
			set Global(Spline) 0
			set Global(Message) "Change to Smooth Lines"
		} else {
			set Global(Smooth) $Global(Spline)
			if {$Global(Spline)} {
				set Global(Message) "Change to Straight Lines"
			}
		}
	}
	.widthc itemconfigure line \
		-fill "$Global(Outline)" -stipple "$Global(Stipple)" \
		-arrow "$Global(Arrow)" \
		-arrowshape "$Global(ArrowP) $Global(ArrowD) $Global(ArrowW)" \
		-joinstyle "$Global(JoinStyle)" \
		-width "$Global(Width)" -smooth "$Global(Smooth)"
}

proc colorRequestor {name colorslot redlist greenlist bluelist replace} {
	global Global rede grne blue redv grnv bluv

	set w ${name}
	set Global($name) $replace
	if {! $Global(Plugin) } {
		eval toplevel $w $Global(PrivateCmap)
#		wm transient $w .
		wm protocol $w WM_DELETE_WINDOW {set dummy 1}
	} else {
		frame $w -borderwidth 0
	}
	set redv "0000"
	set grnv "0000"
	set bluv "0000"

	frame $w.left -borderwidth 0 -highlightthickness 0
	frame $w.right -borderwidth 0 -highlightthickness 0
	frame $w.color -relief sunken -bd 2 -highlightthickness 0
	frame $w.colortop -borderwidth 0 -highlightthickness 0
	frame $w.colorbottom -borderwidth 0 -highlightthickness 0

	set rede [createEntry $w red "hex" 4 -width 5 -textvariable redv]
	set reds [createScale $w reds -to 65535 -length 2i -orient h \
		-showvalue false]
	set redcs [createComboScale $w redcs Red $reds $rede]
	pack $redcs -in $w.left -side top -fill x -expand true

	set grne [createEntry $w grn "hex" 4 -width 5 -textvariable grnv]
	set grns [createScale $w grns -to 65535 -length 2i -orient h \
		-showvalue false]
	set grncs [createComboScale $w grncs Green $grns $grne]
	pack $grncs -in $w.left -side top -fill x -expand true

	set blue [createEntry $w blu "hex" 4 -width 5 -textvariable bluv]
	set blus [createScale $w blus -to 65535 -length 2i -orient h \
		-showvalue false]
	set blucs [createComboScale $w blucs Blue $blus $blue]
	pack $blucs -in $w.left -side top -fill x -expand true

	set cancel [createButton $w cancel "" -text "Cancel"]
	set ok [createButton $w ok 1 -text "Ok"]
	$ok configure -command "set Global(NewColor) \[setColor {}\]
		destroy .cr
		if {\$Global(NewColor) != \"\"} {
			set Global($colorslot) \$Global(NewColor)
			set Global(\$Global(colortype)) \$Global(NewColor)
			$Global(F_$Global(colortype)).f_\$Global(colortype) \
				configure -bg \$Global(NewColor)
		}
		colorPaletteReq .colorpalette {$redlist} \
			{$greenlist} {$bluelist} $replace
	"
	$cancel configure -command "set Global(NewColor) \"\"
		destroy $w
		colorPaletteReq .colorpalette {$redlist} \
			{$greenlist} {$bluelist} $replace
	"
	bind $w <Control-Key-Escape> "set Global(NewColor) \"\"
		destroy $w
		colorPaletteReq .colorpalette {$redlist} \
			{$greenlist} {$bluelist} $replace
	"

	frame $w.colorc -height 2i -width 2i -highlightthickness 0
	raise $w.color
	raise $w.colorc
	pack $w.colorc -in $w.color -fill both -expand true
	pack $w.color -in $w.right -padx 2m -pady 2m -fill both -expand true
	pack $w.left $w.right -side left -in $w.colortop -fill both -expand true
	pack $cancel $ok -side left -expand true -in $w.colorbottom \
		-padx 2m -pady 2m
	pack $w.colortop -side top -in $w -fill both -expand true
	pack $w.colorbottom -side bottom -in $w

	proc setColor {v} "
		global rede grne blue
		
		if { \"\$v\" != \"\" } {
			set color \$v
			scan \"\$v\" \{#%4x%4x%4x\} redv grnv bluv
			set_red \$redv
			set_grn \$grnv
			set_blu \$bluv
		} else {
			set color \"#\[\$rede get\]\[\$grne get\]\[\$blue get\]\"
		}
		$w.colorc configure -bg \$color
		return \$color
	"

	proc set_red { val } "
		[info body set_red]
		$reds set \$val
		setColor {}
	"
	bind $rede <Key-Return> "+setColor {}"

	proc set_grn { val } "
		[info body set_grn]
		$grns set \$val
		setColor {}
	"
	bind $blue <Key-Return> "+setColor {}"

	proc set_blu { val } "
		[info body set_blu]
		$blus set \$val
		setColor {}
	"
	bind $blue <Key-Return> "+setColor {}"

	setColor [$colorslot cget -bg]

	if { $Global(Plugin) } {
		pack $w -in $replace -fill both -expand true
	}
}


proc clearRadioVariable {var} {
	global Global

	if {[info exists Global($var)] && [winfo exists $Global($var)]} {
		set bd [$Global($var) cget -bd]
		$Global($var) configure -relief $Global(ButtonRelief)
		eval $Global($var) move all -$bd -$bd
	}
	set $var ""
}

proc setRadioButton { var value } {
	global Global

	if {[info exists Global(W_${value})]} {
		set bd [$Global(W_${value}) cget -bd]
		clearRadioVariable $var
		$Global(W_${value}) configure -relief sunken
		$Global(W_${value}) move all $bd $bd
		set Global($var) $Global(W_${value})
	}
	set $var "$value"
}

proc createNormalButton {name width height cmds value args} {
	global Global

	eval canvas $name -width $width -height $height \
		-relief $Global(ButtonRelief) $args

	set saveit $Global(CurrentCanvas)
	set Global(CurrentCanvas) $name
	eval $cmds
	originObject all
	scaleObject all "" [winfo fpixels $name $width] \
		[winfo fpixels $name $height]
	set Global(CurrentCanvas) $saveit
	bind $name <Button-1> "
		if {\[%W find withtag disabled\] == \"\"} {
			set bd \[%W cget -bd\]
			%W configure -relief sunken
			%W move all \$bd \$bd
			update idletasks
		}
	"
	bind $name <ButtonRelease-1> "
		if {\[%W find withtag disabled\] == \"\"} {
			set bd \[%W cget -bd\]
			popupCanvasSet $value
			%W move all -\$bd -\$bd
			%W configure -relief $Global(ButtonRelief)
		}
	"
	bind $name <Enter> "
		if {\[%W find withtag disabled\] == \"\"} {
			%W configure -bg $Global(ActiveBackground)
			if {[info exists Global(Msg_$value)]} {
				set Global(Message) \$Global(Msg_$value)
			} else {
				set Global(Message) $value
			}
		}
	"
	bind $name <Leave> {
		if {[%W find withtag disabled] == ""} {
			%W configure -bg $Global(Background)
			set Global(Message) $Global(Cursor)
		}
	}

	return $name  
}
proc createRadioButton {name width height cmds var value args} {
	global Global

	eval canvas $name -width $width -height $height \
		-relief $Global(ButtonRelief) $args

	set saveit $Global(CurrentCanvas)
	set Global(CurrentCanvas) $name
	eval $cmds
	originObject all
	scaleObject all "" [winfo fpixels $name $width] \
		[winfo fpixels $name $height]
	set Global(CurrentCanvas) $saveit
	bind $name <Button-1> "
		if {\[%W find withtag disabled\] == \"\"} {
			setRadioButton $var $value
			if {\"$var\" == \"Global(Cursor)\"} {
				popupCanvasSet $value
			}
		}
	"
	bind $name <Enter> "
		if {\[%W find withtag disabled\] == \"\"} {
			%W configure -bg $Global(ActiveBackground)
			if {[info exists Global(Msg_$value)]} {
				set Global(Message) \$Global(Msg_$value)
			} else {
				set Global(Message) $value
			}
		}
	"
	bind $name <Leave> {
		if {[%W find withtag disabled] == ""} {
			%W configure -bg $Global(Background)
			set Global(Message) $Global(Cursor)
		}
	}

	return $name  
}

proc buttonReq { name var replace } {
	global Global

	if {$Global(ButtonOrient) == "left"} {
		set suborient top
	} else {
		set suborient left
	}
	set w ${name}
	if {[winfo exists $w]} {
		if {!$Global(Plugin)} {
			wm deiconify $w
			raise $w
			return
		}
		return
	}
	set Global($name) $replace

	if { !$Global(Plugin) } {
		eval toplevel $w
		wm protocol $w WM_DELETE_WINDOW "wm withdraw $w"
	} else {
		frame $w -borderwidth 0
	}
	
	frame $w.f
	set bframes "$w.f1 $w.f2 $w.f3 $w.f4 $w.f5 $w.f6 $w.f7 $w.f8 $w.f9"

	set i 0
	set bframe ""
	foreach buttontype $var {

		if {![expr $i % $Global(ButtonCount)]} {
			if {$bframe != ""} {
				pack $bframe -in $w.f -side $suborient
			}
			set bframe [lindex $bframes [expr $i / $Global(ButtonCount)]]
			frame $bframe
		}
		incr i
		set type [lindex $buttontype 0]
		set buttonName [lindex $buttontype 1]
		set buttonCanv [lindex $buttontype 2]
		switch "$type" {
			RadioButton {
				createRadioButton $w.b_${buttonName} \
					$Global(ButtonSize) $Global(ButtonSize) \
					"$buttonCanv" Global(Cursor) \
					$buttonName -bd 1 -highlightthickness 0
			}
			Button {
				createNormalButton $w.b_${buttonName} \
					$Global(ButtonSize) $Global(ButtonSize) \
					"$buttonCanv" \
					$buttonName -bd 1 -highlightthickness 0
			}
			JoinButton { 
				createRadioButton $w.b_${buttonName} \
					$Global(ButtonSize) $Global(ButtonSize) \
					"$buttonCanv" Global(JoinStyle) \
					$buttonName -bd 1 -highlightthickness 0
			}
			ArrowButton {
				createRadioButton $w.b_${buttonName} \
					$Global(ButtonSize) $Global(ButtonSize) \
					"$buttonCanv" Global(Arrow) \
					$buttonName -bd 1 -highlightthickness 0
			}
		}
		switch "$buttonName" {
			Paste {
				disablePaste
			}
			Rulers {
				bind $w.b_Rulers <Double-Button-1> {
					%W addtag disabled withtag all
                	$Global(CurrentCanvas) delete $Global(RulerX)
                	$Global(CurrentCanvas) delete $Global(RulerY)
        		}     
				bind $w.b_Rulers <ButtonRelease-1> {+
					%W dtag disabled
				}
			}
			first {
				bind $w.b_first <Double-Button-1> {
					arrowRaise .arrow
				}
			}
			last {
				bind $w.b_last <Double-Button-1> {
					arrowRaise .arrow
				}
			}
			both {
				bind $w.b_both <Double-Button-1> {
					arrowRaise .arrow
				}
			}
		}
		set Global(W_${buttonName}) $w.b_${buttonName}
		pack $w.b_${buttonName} -in $bframe -side $Global(ButtonOrient)
	}
	pack $bframe -in $w.f -side left
	pack $w.f -in $w
	if { $Global(Plugin) } {
		pack $w -in $replace -fill both -expand true
		update idletasks
	}
}

proc colorPaletteReq { name redlist greenlist bluelist replace } {
	global Global

	# Setup
	set w ${name}
	if {[winfo exists $w]} {
		if {$Global(Plugin)} {
			destroy $w
		} else {
			wm deiconify $w
			raise $w
			return
		}
	}
	set Global($name) $replace
	if { !$Global(Plugin) } {
		eval toplevel $w $Global(PrivateCmap)
		wm protocol $w WM_DELETE_WINDOW "wm withdraw $w"
	} else {
		frame $w -borderwidth 0
	}
  
	frame $w.f

	foreach red $redlist {
		frame $w.f.rcol_${red}
		foreach green $greenlist {
			frame $w.f.grow_${red}${green}
			foreach blue $bluelist {
				if { [info exists Global($w.f.c${red}${green}${blue})] } {
					frame $w.f.c${red}${green}${blue} \
						-relief raised -height 2m -width 2m \
						-highlightthickness 0 \
						-bd 1 -bg $Global($w.f.c${red}${green}${blue})
				} else {
					frame $w.f.c${red}${green}${blue} \
						-relief raised -height 2m -width 2m \
						-highlightthickness 0 \
						-bd 1 -bg "#${red}${green}${blue}"
				}
				pack $w.f.c${red}${green}${blue} -side left \
					-in $w.f.grow_${red}${green} -fill both -expand true
				bind $w.f.c${red}${green}${blue} <1> {
					%W configure -relief sunken
				}
				bind $w.f.c${red}${green}${blue} <Double-Button-1> "
					set Global(NewColor) {None}
					colorRequestor .cr %W {$redlist} {$greenlist} {$bluelist} \
						$replace
					destroy $w 
				"
				bind $w.f.c${red}${green}${blue} <ButtonRelease-1> {
					%W configure -relief raised
					set Global($Global(colortype)) [%W cget -bg]
					$Global(F_$Global(colortype)).f_$Global(colortype) configure \
						-bg $Global($Global(colortype))
				}
			}
			pack $w.f.grow_${red}${green} -side top \
				-in $w.f.rcol_${red} -fill both -expand true
		}
		pack $w.f.rcol_${red} -side left -in $w.f -fill both \
			-expand true
	}
	if {!$Global(Plugin)} {
		bind $w <Configure> "
			set g \[wm geometry $w\]
			scan \"\$g\" {%%dx%%d%%d%%d} Global(ColorWidth) Global(ColorHeight)\
				Global(ColorPosX) Global(ColorPosY)
		"
	}
	frame $w.f.c_none -width 4m -relief raised -bd 1 \
		-highlightthickness 0
	pack $w.f.c_none -in $w.f -side left -fill y   
	bind $w.f.c_none <1> {
		%W configure -relief sunken
	}
	bind $w.f.c_none <ButtonRelease-1> {
		%W configure -relief raised
		set Global($Global(colortype)) ""
		$Global(F_$Global(colortype)).f_$Global(colortype) configure \
			-bg [lindex [$Global(F_$Global(colortype)).f_$Global(colortype) configure -bg] 3]
	}
	bind $w.f <Enter> {
		set Global(MessageSave) $Global(Message)
		set Global(Message) "$Global(colortype) Color"
	}
	bind $w.f <Leave> {
		set Global(Message) $Global(MessageSave)
	}
  

	pack $w.f -in $w -expand true -fill both

	# Return
	if { $Global(Plugin) } {
		pack $w -in $replace -fill both -expand true
		update idletasks
	} else {
		if {[info exists Global(ColorPosX)]} {
			wm geometry $w \
$Global(ColorWidth)x$Global(ColorHeight)+$Global(ColorPosX)+$Global(ColorPosY)
		} else {
			wm geometry $w $Global(ColorWidth)x$Global(ColorHeight)
		}
	}
}

proc cacheSlides {} {
	global Global

	set canvasSave $Global(CurrentPageId)
	for {set page 1} {[winfo exists .can.c$page]} {incr page} {
		set Global(CurrentPageId) $page
		newSlide
	}
	set Global(CurrentPageId) $canvasSave
	newSlide
}

proc newSlide {} {
	global Global

	if {![winfo exists .slide]} {
		. configure -cursor watch
		update idletasks
#		set Global(CanvasSave) $Global(CurrentPageId)
		toplevel .slide -height $Global(ScreenH) -width $Global(ScreenW) \
			-bg $Global(SlideBG) -borderwidth 0 -relief flat \
			-highlightthickness 0
		wm withdraw .slide
		wm overrideredirect .slide true
		bind .slide <Double-Button-3> {
			destroy .slide
			set Global(CurrentCanvas) .can.c$Global(CanvasSave)
			set Global(CurrentPageId) $Global(CanvasSave)
			newCanvas .can c$Global(CurrentPageId)
			update idletasks
		}
		bind .slide <Control-Button-1> {
			destroy .slide
			set Global(CurrentCanvas) .can.c$Global(CanvasSave)
			set Global(CurrentPageId) $Global(CanvasSave)
			newCanvas .can c$Global(CurrentPageId)
			update idletasks
		}
		bind .slide <Key-Escape> {
			destroy .slide
			set Global(CurrentCanvas) .can.c$Global(CanvasSave)
			set Global(CurrentPageId) $Global(CanvasSave)
			newCanvas .can c$Global(CurrentPageId)
			update idletasks
		}
		bind .slide <Button-1> {
			set Global(CurrentCanvas) .can.c$Global(CanvasSave)
			set Global(CurrentPageId) [expr $Global(CurrentPageId) + 1]
			if {! [winfo exists .can.c$Global(CurrentPageId)]} {
				if {$Global(Circulate)} {
					set Global(CurrentPageId) 1
				} else {
					set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
					break
				}
			}
			newSlide
			wm deiconify .slide
			raise .slide
			raise .slide.c$Global(CurrentPageId)
			focus .slide
		}
		bind .slide <Key-Next> {
			set Global(CurrentCanvas) .can.c$Global(CanvasSave)
			set Global(CurrentPageId) [expr $Global(CurrentPageId) + 1]
			if {! [winfo exists .can.c$Global(CurrentPageId)]} {
				if {$Global(Circulate)} {
					set Global(CurrentPageId) 1
				} else {
					set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
					break
				}
			}
			newSlide
			wm deiconify .slide
			raise .slide
			raise .slide.c$Global(CurrentPageId)
			focus .slide
		}
		bind .slide <Button-3> {
			set Global(CurrentCanvas) .can.c$Global(CanvasSave)
			set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
			if {[winfo exists .can.c$Global(CurrentPageId)]} {
				newSlide
				wm deiconify .slide
				raise .slide
				raise .slide.c$Global(CurrentPageId)
				focus .slide
			} else {
				set Global(CurrentPageId) [expr $Global(CurrentPageId) + 1]
			}
		}
		bind .slide <Key-Prior> {
			set Global(CurrentCanvas) .can.c$Global(CanvasSave)
			set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
			if {[winfo exists .can.c$Global(CurrentPageId)]} {
				newSlide
				wm deiconify .slide
				raise .slide
				raise .slide.c$Global(CurrentPageId)
				focus .slide
			} else {
				set Global(CurrentPageId) [expr $Global(CurrentPageId) + 1]
			}
		}
	} else {
		.slide configure -cursor watch
		update idletasks
	}
	if {![winfo exists .slide.c$Global(CurrentPageId)]} {
		canvas .slide.c$Global(CurrentPageId) -bg $Global(SlideBG) \
			-height $Global(ScreenH) \
			-width $Global(ScreenW) -highlightthickness 0 -bd 0
		set Global(CurrentCanvas) .can.c$Global(CurrentPageId)
		cutCopySelected Copy all 0
		set Global(CurrentCanvas) .slide.c$Global(CurrentPageId)
		pasteCutCopy 0 0 normal Copy 0
		pack forget [pack slaves .slide]
		pack .slide.c$Global(CurrentPageId) -in .slide \
			-expand true -fill both
		if {$Global(SlideScale)} {
			scaleObject all "" $Global(ScreenW) $Global(ScreenH)
		} else {
			set scalex [expr ($Global(ScreenW) + 0.0) / \
				[winfo fpixels $Global(CurrentCanvas) $Global(PageWidth)]]
			set scaley [expr ($Global(ScreenH) + 0.0) / \
				[winfo fpixels $Global(CurrentCanvas) $Global(PageHeight)]]
			if {$scalex > $scaley} {
				set scale $scaley
			} else {
				set scale $scalex
			}
			scaleObject all $scale $Global(ScreenW) $Global(ScreenH)
		}
	
		scaleObject Imp_Background variable $Global(ScreenW)+3 \
			$Global(ScreenH)+3
		.slide configure -cursor ""
		. configure -cursor ""
	set Global(CurrentCanvas) .slide.c$Global(CurrentPageId)
	if {[info exists Global(anim_$Global(CurrentPageId))]} {
		eval eval \$Global(anim_$Global(CurrentPageId))
	}
		update idletasks
	} else {
		pack forget [pack slaves .slide]
		.slide.c$Global(CurrentPageId) configure -bg $Global(SlideBG)
		pack .slide.c$Global(CurrentPageId) -in .slide \
			-expand true -fill both
	set Global(CurrentCanvas) .slide.c$Global(CurrentPageId)
	if {[info exists Global(anim_$Global(CurrentPageId))]} {
		eval eval \$Global(anim_$Global(CurrentPageId))
	}
		update idletasks
		.slide configure -cursor ""
		. configure -cursor ""
		update idletasks
		wm deiconify .slide
		raise .slide
		raise .slide.c$Global(CurrentPageId)
		focus .slide
	}
}

proc newCanvas { cf name } {
	global Global

	if {[winfo exists $Global(CurrentCanvas)]} {
		pack forget $Global(CurrentCanvas)
	}
	set Global(CurrentCanvas) "$cf.$name"
	if {![winfo exists $Global(CurrentCanvas)]} {
		canvas $Global(CurrentCanvas) -scrollregion \
			"0i 0i $Global(PageWidth) $Global(PageHeight)" \
			-width $Global(PageVisX) -height $Global(PageVisY) \
			-bg $Global(SlideBG) -xscrollcommand "$cf.scrollx set" \
			-yscrollcommand "$cf.scrolly set" -bd 0
		canvas $Global(CurrentCanvas).rulerx \
			-width $Global(PageWidth) -height .25i \
			-relief raised -bd 1 -highlightthickness 0
		canvas $Global(CurrentCanvas).rulery \
			-width .25i -height $Global(PageHeight) \
			-relief raised -bd 1 -highlightthickness 0
		doRuler $Global(CurrentCanvas).rulerx $Global(PageWidth) .25i 0 0 1 h \
			{.0625 .125 .25 .5} ""
		doRuler $Global(CurrentCanvas).rulery $Global(PageHeight) .25i 0 0 1 v \
			{.0625 .125 .25 .5} ""
		set Global(RulerX) [$Global(CurrentCanvas) create window 0i .25i \
			-anchor sw -window $Global(CurrentCanvas).rulerx -tags rulerx]
		set Global(RulerY) [$Global(CurrentCanvas) create window 0i 0i \
			-anchor nw -window $Global(CurrentCanvas).rulery -tags rulery]
		$Global(CurrentCanvas) delete $Global(RulerX)
		$Global(CurrentCanvas) delete $Global(RulerY)

	bind $Global(CurrentCanvas).rulery <1> {
		set pc [winfo parent %W]
		set rylastx [$pc canvasx %X]
		set rylasty [$pc canvasy %Y]
	}
	bind $Global(CurrentCanvas).rulerx <1> {
		set pc [winfo parent %W]
		set rxlastx [$pc canvasx %X]
		set rxlasty [$pc canvasy %Y]
	}
	bind $Global(CurrentCanvas).rulerx <Motion> {
		if {$Global(Grid)} {
			set x [%W canvasx %x $Global(GridX)]
		} else {
			set x [%W canvasx %x 1]
		}
		set Global(Xpos) \
			"[format {%%3.3f} [expr $x / $Global(CoordFactorX)]]$Global(UnitX)"
		$Global(CurrentCanvas).rulerx coords h \
			$x [$Global(CurrentCanvas) cget -height] $x 0 
	}
	bind $Global(CurrentCanvas).rulery <Motion> {
		if {$Global(Grid)} {
			set y [%W canvasy %y $Global(GridY)]
		} else {
			set y [%W canvasy %y 1]
		}
		set Global(Ypos) \
			"[format {%%3.3f} [expr $y / $Global(CoordFactorY)]]$Global(UnitY)"
		$Global(CurrentCanvas).rulery coords v \
			0 $y [$Global(CurrentCanvas) cget -width] $y 
	}
	bind $Global(CurrentCanvas).rulery <B1-Motion> {
		set pc [winfo parent %W]
		set x [$pc canvasx %X]
		$pc move rulery [expr $x - $rylastx] 0
		set rylastx $x
	}
	bind $Global(CurrentCanvas).rulerx <B1-Motion> {
		set pc [winfo parent %W]
		set y [$pc canvasy %Y]
		$pc move rulerx 0 [expr $y - $rxlasty]
		set rxlasty $y
	}

	bind $Global(CurrentCanvas) <Key-Next> {
		nextPage
	}
	bind $Global(CurrentCanvas) <Key-Prior> {
		prevPage
	}

	bind $Global(CurrentCanvas) <Control-Key-v> {
		pasteCutCopy $Global(LastX) $Global(LastY) absolute Cut 1
	}

	bind $Global(CurrentCanvas) <Key-Delete> {
		set Global(Message) Cut
		cutCopySelected Cut Imp_Selected 1
		setCursor Select
		set Global(Message) Select
		enableSelectionButtons
	}

	bind $Global(CurrentCanvas) <Control-Key-u> {
		popUndo
	}

	if {!$Global(Plugin)} {
		bind $Global(CurrentCanvas) <Alt-Key-s> {
			set Global(CanvasSave) $Global(CurrentPageId)
			if {$Global(CacheSlides)} {
				cacheSlides
			} else {
				newSlide
				newSlide
			}
		}
	}

	bind $Global(CurrentCanvas) <ButtonRelease-1> {
		set boxselector [%W coords selector]
		set Global(AnchorChosen) 0
		set Global(undo) {}
		if {"$boxselector" != ""} {
			switch $Global(Cursor) {
				Select {
					%W delete selector
					selectBoundedItems $boxselector Add
					createHandles
				}
				Oval {
					%W delete selector
					set i [createOval $boxselector]
					$Global(CurrentCanvas) addtag [genTag] withtag $i
					set Global(undo) \
						"$Global(CurrentCanvas) delete T-$Global(TagId)"
					if {$Global(MenuSelect)} {
						setCursor Select
						set Global(Message) Select
						enableSelectionButtons
						set Global(MenuSelect) 0
					}
				}
				Rounded_Rectangle {
					%W delete selector
					set i [createRRectangle $boxselector 1]
					$Global(CurrentCanvas) addtag [genTag] withtag $i
					set Global(undo) \
						"$Global(CurrentCanvas) delete T-$Global(TagId)"
					if {$Global(MenuSelect)} {
						setCursor Select
						set Global(Message) Select
						enableSelectionButtons
						set Global(MenuSelect) 0
					}
				}
				Rectangle {
					%W delete selector
					set i [createRRectangle $boxselector 0]
					$Global(CurrentCanvas) addtag [genTag] withtag $i
					set Global(undo) \
						"$Global(CurrentCanvas) delete T-$Global(TagId)"
					if {$Global(MenuSelect)} {
						setCursor Select
						set Global(Message) Select
						enableSelectionButtons
						set Global(MenuSelect) 0
					}
				}
				Text {
					%W delete selector
					set i [createText $boxselector]
					$Global(CurrentCanvas) addtag [genTag] withtag $i
					set Global(undo) \
						"$Global(CurrentCanvas) delete T-$Global(TagId)"
					if {$Global(MenuSelect)} {
						setCursor Select
						set Global(Message) Select
						enableSelectionButtons
						set Global(MenuSelect) 0
					}
				}
				Rotate {
					%W delete selector
					$Global(CurrentCanvas) addtag [genTag] withtag Imp_selected
					set Global(undo) "$Global(CurrentCanvas) addtag \
						Imp_Selected withtag T-$Global(TagId); \
						set Global(LastAngle) [expr 0 - $Global(LastAngle)]; \
						set Global(LastX) $Global(LastX); \
						set Global(LastY) $Global(LastY); \
						rotateSelected; \
						$Global(CurrentCanvas) dtag Imp_Selected; \
						$Global(CurrentCanvas) dtag T-$Global(TagId)"
					rotateSelected
					%W raise selectorbox
					set Global(Sub-Cursor) ""
				}
			}
		} else {
			switch $Global(Cursor) {
				Scale {
					$Global(CurrentCanvas) addtag [genTag] withtag Imp_selected
					set Global(undo) "$Global(CurrentCanvas) scale \
						T-$Global(TagId) $Global(originx) \
						$Global(originy) $Global(TScaleX) \
						$Global(TScaleY); \
						$Global(CurrentCanvas) dtag T-$Global(TagId)"
					setCursor Select
					set Global(Message) Select
					enableSelectionButtons
					%W configure -cursor ""
				}
				Draw {
					%W delete Global(curline)
					if {[llength $Global(curline)] > 3} {
					set i [eval %W create line $Global(curline) \
						-fill \"$Global(Outline)\" \
						-stipple \"$Global(Stipple)\" \
						-width \"$Global(Width)\" \
						-smooth \"$Global(Smooth)\" \
						-arrow \"$Global(Arrow)\" \
						-arrowshape \"$Global(ArrowP) $Global(ArrowD) $Global(ArrowW)\" \
						-joinstyle \"$Global(JoinStyle)\" ]
					$Global(CurrentCanvas) addtag [genTag] withtag $i
					set Global(undo) \
						"$Global(CurrentCanvas) delete T-$Global(TagId)"
					if {$Global(MenuSelect)} {
						setCursor Select
						set Global(Message) Select
						enableSelectionButtons
						set Global(MenuSelect) 0
					}
					}
				}
				Select {
					if {[$Global(CurrentCanvas) find withtag current] != "" \
						&& [expr $Global(TMoveX) + $Global(TMoveY)]} {
						$Global(CurrentCanvas) addtag [genTag] withtag \
							Imp_selected
						set Global(undo) \
							"$Global(CurrentCanvas) move T-$Global(TagId) \
							[expr -($Global(TMoveX))] \
							[expr -($Global(TMoveY))]; \
							$Global(CurrentCanvas) dtag T-$Global(TagId)"
					}
				}
			}
		}
		if {$Global(undo) != ""} {
			pushUndo "$Global(undo)$Global(FontUndo)"
		}
	}

	bind $Global(CurrentCanvas) <Button-3> {
		set Global(undo) {}
		switch $Global(Cursor) {
			Polygon -
			Line { 
				switch "$Global(Sub-Cursor)" {
					Line-Active {
						set Global(Sub-Cursor) ""
						%W delete Global(curline)
						%W delete selector
						set i [createLine $Global(curline)]
						$Global(CurrentCanvas) addtag [genTag] withtag $i
						set Global(undo) \
							"$Global(CurrentCanvas) delete T-$Global(TagId)"
						if {$Global(MenuSelect)} {
							setCursor Select
							set Global(Message) Select
							enableSelectionButtons
							set Global(MenuSelect) 0
						}
					}
					Polygon-Active {
						set Global(Sub-Cursor) ""
						%W delete Global(curline)
						%W delete selector
						set i [createPolygon $Global(curline)]
						if {$Global(MenuSelect)} {
							setCursor Select
							set Global(Message) Select
							enableSelectionButtons
							set Global(MenuSelect) 0
						}
					}
				}
			}
		}
		if {$Global(undo) != ""} {
			pushUndo "$Global(undo)"
		}
	}

	bind $Global(CurrentCanvas) <Control-Button-1> {
		focus %W
		markSpot %x %y
		switch $Global(Cursor) {
			Select {
				set item [findItemUnderCursor]
				set tags [%W gettags $item]
				. configure -cursor watch
				update idletasks
				selectItem $item $tags Add
				createHandles
				update idletasks
				. configure -cursor ""
				update idletasks
			}
		}
		break
	}

	bind $Global(CurrentCanvas) <Double-Button-1> {
		focus %W
		markSpot %x %y
		switch $Global(Cursor) {
			Select {
				set items [%W find withtag Imp_selected]
				if {"$items" != ""} {
					propRaise .prop $items
				}
			}
		}
	}

	bind $Global(CurrentCanvas) <Key-Return> {
		focus %W
		markSpot %x %y
		switch $Global(Cursor) {
			Select {
				set item [findItemUnderCursor]
				set tags [%W gettags $item]
				. configure -cursor watch
				update idletasks
				selectItem $item $tags New
				createHandles
				update idletasks
				. configure -cursor ""
				update idletasks
			}
			Draw {
				set Global(curline) ""
				lappend Global(curline) [eval expr int($Global(LastX))] \
					[eval expr int($Global(LastY))]
			}
			Line {
				switch $Global(Sub-Cursor) {
					Line-Active {
						lappend Global(curline) $Global(LastX) \
							$Global(LastY)
						set l [llength $Global(curline)]
						if {$l > 2} {
							eval %W create line \
								[lrange $Global(curline) \
								[eval expr $l - 4] end] \
								-tags Global(curline)
						}
					}
					default {
						set Global(curline) ""
						lappend Global(curline) \
							[eval expr int($Global(LastX))] \
							[eval expr int($Global(LastY))]
						set Global(Sub-Cursor) Line-Active
					}
				}
			}
			Oval {
			}
			Rectangle {
			}
			Rounded_Rectangle {
			}
			Text {
			}
			Polygon {
				switch $Global(Sub-Cursor) {
					Polygon-Active {
						lappend Global(curline) \
							[eval expr int($Global(LastX))] \
							[eval expr int($Global(LastY))]
						set l [llength $Global(curline)]
						if {$l > 2} {
							eval %W create line \
								[lrange $Global(curline) \
								[eval expr $l - 4] end] \
								-tags Global(curline)
						}
					}
					default {
						set Global(curline) ""
						lappend Global(curline) \
							[eval expr int($Global(LastX))] \
							[eval expr int($Global(LastY))]
						set Global(Sub-Cursor) Polygon-Active
					}
				}
			}
			Rotate {
				set Global(Sub-Cursor) Rotate-Active
			}
			Paste {
				%W configure -cursor watch
				pasteCutCopy $Global(LastX) $Global(LastY) absolute Cut 1
				update idletasks
				createHandles
				cutCopySelected Copy Imp_Selected 1
				set Global(Cut) $Global(Copy)
				%W configure -cursor ""
			}
		}
	}

	bind $Global(CurrentCanvas) <Button-1> {
		focus %W
		markSpot %x %y
		switch $Global(Cursor) {
			Select {
				set item [findItemUnderCursor]
				set tags [%W gettags $item]
				. configure -cursor watch
				update idletasks
				selectItem $item $tags New
				createHandles
				update idletasks
				. configure -cursor ""
				update idletasks
			}
			Draw {
				set Global(curline) ""
				lappend Global(curline) [eval expr int($Global(LastX))] \
					[eval expr int($Global(LastY))]
			}
			Line {
				switch $Global(Sub-Cursor) {
					Line-Active {
						lappend Global(curline) $Global(LastX) \
							$Global(LastY)
						set l [llength $Global(curline)]
						if {$l > 2} {
							eval %W create line \
								[lrange $Global(curline) \
								[eval expr $l - 4] end] \
								-tags Global(curline)
						}
					}
					default {
						set Global(curline) ""
						lappend Global(curline) \
							[eval expr int($Global(LastX))] \
							[eval expr int($Global(LastY))]
						set Global(Sub-Cursor) Line-Active
					}
				}
			}
			Oval {
			}
			Rectangle {
			}
			Rounded_Rectangle {
			}
			Text {
			}
			Polygon {
				switch $Global(Sub-Cursor) {
					Polygon-Active {
						lappend Global(curline) \
							[eval expr int($Global(LastX))] \
							[eval expr int($Global(LastY))]
						set l [llength $Global(curline)]
						if {$l > 2} {
							eval %W create line \
								[lrange $Global(curline) \
								[eval expr $l - 4] end] \
								-tags Global(curline)
						}
					}
					default {
						set Global(curline) ""
						lappend Global(curline) \
							[eval expr int($Global(LastX))] \
							[eval expr int($Global(LastY))]
						set Global(Sub-Cursor) Polygon-Active
					}
				}
			}
			Rotate {
				set Global(Sub-Cursor) Rotate-Active
			}
			Paste {
				%W configure -cursor watch
				pasteCutCopy $Global(LastX) $Global(LastY) absolute Cut 1
				update idletasks
				createHandles
				cutCopySelected Copy Imp_Selected 1
				set Global(Cut) $Global(Copy)
				%W configure -cursor ""
			}
		}
	}

	bind $Global(CurrentCanvas) <Motion> {
		raise %W
		focus %W
		if {$Global(Grid)} {
			set x [%W canvasx %x $Global(GridX)]
		} else {
			set x [%W canvasx %x 1]
		}
		if {$Global(Grid)} {
			set y [%W canvasy %y $Global(GridY)]
		} else {
			set y [%W canvasy %y 1]
		}
		set Global(Xpos) \
			"[format {%%3.3f} [expr $x / $Global(CoordFactorX)]]$Global(UnitX)"
		set Global(Ypos) \
			"[format {%%3.3f} [expr $y / $Global(CoordFactorY)]]$Global(UnitY)"
		$Global(CurrentCanvas).rulerx coords h \
			$x [$Global(CurrentCanvas) cget -height] $x 0
		$Global(CurrentCanvas).rulery coords v \
			0 $y [$Global(CurrentCanvas) cget -width] $y

		switch $Global(Cursor) {
			Polygon -
			Line {
				switch $Global(Sub-Cursor) {
					Polygon-Active -
					Line-Active {
						%W delete selector
						%W create line $Global(LastX) $Global(LastY) $x $y \
							-tags selector
					}
				}
			}
		}
	}

	bind $Global(CurrentCanvas) <Control-B1-Motion> {
		raise %W
		focus %W
		if {$Global(Grid)} {
			set x [%W canvasx %x $Global(GridX)]
		} else {
			set x [%W canvasx %x 1]
		}
		if {$Global(Grid)} {
			set y [%W canvasy %y $Global(GridY)]
		} else {
			set y [%W canvasy %y 1]
		}
		set Global(Xpos) \
			"[format {%%3.3f} [expr $x / $Global(CoordFactorX)]]$Global(UnitX)"
		set Global(Ypos) \
			"[format {%%3.3f} [expr $y / $Global(CoordFactorY)]]$Global(UnitY)"
		$Global(CurrentCanvas).rulerx coords h \
			$x [$Global(CurrentCanvas) cget -height] $x 0 
		$Global(CurrentCanvas).rulery coords v \
			0 $y [$Global(CurrentCanvas) cget -width] $y 

		switch $Global(Cursor) {
			Scale {
				set cursor [lindex [%W configure -cursor] 4]
				scaleSelected $cursor $x $y %X %Y
			}
			Select {
				dragBoxOrMove $item $tags $x $y %X %Y
			}
		}
	}
	bind $Global(CurrentCanvas) <B1-Motion> {
		focus %W
		if {$Global(Grid)} {
			set x [%W canvasx %x $Global(GridX)]
		} else {
			set x [%W canvasx %x 1]
		}
		if {$Global(Grid)} {
			set y [%W canvasy %y $Global(GridY)]
		} else {
			set y [%W canvasy %y 1]
		}
		set Global(Xpos) \
			"[format {%%3.3f} [expr $x / $Global(CoordFactorX)]]$Global(UnitX)"
		set Global(Ypos) \
			"[format {%%3.3f} [expr $y / $Global(CoordFactorY)]]$Global(UnitY)"
		$Global(CurrentCanvas).rulerx coords h \
			$x [$Global(CurrentCanvas) cget -height] $x 0 
		$Global(CurrentCanvas).rulery coords v \
			0 $y [$Global(CurrentCanvas) cget -width] $y 

		switch $Global(Cursor) {
			Scale {
				set cursor [lindex [%W configure -cursor] 4]
				scaleSelected $cursor $x $y %X %Y
			}
			Select {
				dragBoxOrMove $item $tags $x $y %X %Y
			}
			Draw {
				%W create line $Global(LastX) $Global(LastY) $x $y \
					-tags Global(curline)
				repositionWindow %X %Y
				lappend Global(curline) $x $y
				set Global(LastX) $x
				set Global(LastY) $y
			}
			Oval {
				%W delete selector
				%W create oval $Global(LastX) $Global(LastY) $x $y \
					-tags selector
				repositionWindow %X %Y
			}
			Rounded_Rectangle {
				%W delete selector
				%W create rectangle $Global(LastX) $Global(LastY) $x $y \
					-tags selector
				repositionWindow %X %Y
			}
			Rectangle {
				%W delete selector
				%W create rectangle $Global(LastX) $Global(LastY) $x $y \
					-tags selector
				repositionWindow %X %Y
			}
			Text {
				%W delete selector
				%W create rectangle $Global(LastX) $Global(LastY) $x $y \
					-tags selector
				repositionWindow %X %Y
			}
			Rotate -
			Polygon -
			Line {
				switch $Global(Sub-Cursor) {
					Polygon-Active -
					Line-Active {
						%W delete selector
						%W create line $Global(LastX) $Global(LastY) $x $y \
							-tags selector
						repositionWindow %X %Y
					}
					Rotate-Active {
						%W delete selector
						%W create line $Global(LastX) $Global(LastY) $x $y \
							-arrow last -tags selector
						set xnorm [eval expr $x - $Global(LastX)]
						set ynorm [eval expr $y - $Global(LastY)]
						set rho [eval expr sqrt(pow(($x - $Global(LastX)),2) +\
							 pow(($y - $Global(LastY)),2))]
						if {$rho != 0} {
							set angle [eval expr asin($ynorm/$rho)]
							set degrees [eval expr \
								$angle*180.0/3.14159265358979323846]
							if {$xnorm >= 0} {
								if {$ynorm >= 0} {
									set degrees [eval expr abs($degrees)]
								} else {
									set degrees \
										[eval expr 360.0 - abs($degrees)]
								}
							} else {
								if {$ynorm >= 0} {
									set degrees \
										[eval expr 180.0 - abs($degrees)]
								} else {
									set degrees \
										[eval expr 180.0 + abs($degrees)]
								}
							}
							%W create arc [eval expr $Global(LastX) - 20] \
								[eval expr $Global(LastY) - 20] \
								[eval expr $Global(LastX) + 20] \
								[eval expr $Global(LastY) + 20] \
								-start 0 -extent [eval expr 0 - $degrees] \
								-stipple gray50 -outline black -fill white \
								-tags selector
							set coords [%W coords selectorbox]
							%W delete selectorbox
							eval %W create polygon \
								[eval RotateF [eval expr $degrees - \
								$Global(LastAngle)] \
								$Global(LastX) $Global(LastY) $coords] \
								-tags selectorbox \
								-stipple gray25 -outline \"\" -fill black
							set Global(LastAngle) $degrees
							set Global(Message) $degrees
						}
					}
				}
			}
		}
	}
	} else {
		$Global(CurrentCanvas) configure -bg $Global(SlideBG)
	}
	pack $Global(CurrentCanvas) -in $cf.top -side left -expand true \
		-fill both
	changePageProp

	return $Global(CurrentCanvas)
}

proc nextPage {} {
	global Global

	set Global(CurrentPageId) [expr $Global(CurrentPageId) + 1]
	newCanvas .can c$Global(CurrentPageId)
	update idletasks
}

proc prevPage {} {
	global Global

	if {$Global(CurrentPageId) > 1} {
		set Global(CurrentPageId) [expr $Global(CurrentPageId) - 1]
		newCanvas .can c$Global(CurrentPageId)
		update idletasks
	}
}

proc createCanvasF { name } {
	global Global

	frame $name -bd 2 -relief raised
	regexp {.(.*)} "$name" match tname
	frame $name.top -bd 0 -highlightthickness 0
	frame $name.bottom -bd 0 -highlightthickness 0
	frame $name.corner -height 20 -width 20 -bd 2
	scrollbar $name.scrolly -bd 2 -width 15 \
		-command {eval $Global(CurrentCanvas) yview} 
	scrollbar $name.scrollx -bd 2 -width 15 -orient horiz \
		-command {eval $Global(CurrentCanvas) xview}
	frame .right
	if {$Global(Plugin)} {
		frame .radios -relief raised -bd 2
	}
	frame .colors -relief raised -bd 2
	frame .colorsp
	frame .colorssel
	frame .colorseltop
	frame .colorselbottom
	frame .f_Fill -width 20 -height 20 -bd 1 -relief sunken
	frame .f_Outline -bg black -width 20 -height 20 -bd 1 -relief sunken
	scale .lw -from 1.0 -to 100.0 -bd 1 -orient h \
		-showvalue false -variable Global(Width)
	bind .lw <Enter> {
		set Global(MessageSave) $Global(Message)
		set Global(Message) "Line Width"
	}
	bind .lw <Leave> {
		set Global(Message) $Global(MessageSave)
	}
	label .llw -width 3 -textvariable Global(Width)
	newCanvas .can c$Global(CurrentPageId)
	button .nextpage -text "Next" -pady 1 -command "nextPage"
	button .prevpage -text "Prev" -pady 1 -command "prevPage"
	radiobutton .s_Color -value Fill -text "Fill" \
		-variable Global(colortype) \
		-anchor sw -indicatoron false -selectcolor ""
	radiobutton .s_Outline -value Outline -text "Outline" \
		-variable Global(colortype) \
		-anchor sw -indicatoron false -selectcolor ""
	if {!$Global(Plugin)} {
		bind .s_Color <Double-Button-1> {
			colorPaletteReq .colorpalette \
				{0000 3300 6600 9900 CC00 FF00} \
				{0000 3300 6600 9900 CC00 FF00} \
				{0000 3300 6600 9900 CC00 FF00} \
				.colorsp
		}
		bind .s_Outline <Double-Button-1> {
			colorPaletteReq .colorpalette \
				{0000 3300 6600 9900 CC00 FF00} \
				{0000 3300 6600 9900 CC00 FF00} \
				{0000 3300 6600 9900 CC00 FF00} \
				.colorsp
		}
	}
	label .xpos -textvariable Global(Xpos) -height 1 -width 10
	label .ypos -textvariable Global(Ypos) -height 1 -width 10
	createEntry "" msg "float" 10 -textvariable Global(Message) -relief flat \
		-state disabled
#	entry .msg -state disabled -relief flat \
#		-textvariable Global(Message) -width 20
	pack .f_Fill .s_Color -side left -in .colorseltop
	pack .f_Outline .s_Outline -side left -in .colorselbottom
	pack .colorseltop .colorselbottom -side left -anchor sw -in .colorssel \
		-fill x
	pack .colorssel -in .colors -side left
	pack .xpos .ypos -in .colors -side left
	pack .msg_e -in .colors -side right -fill x -expand true
	colorPaletteReq .colorpalette \
				{0000 3300 6600 9900 CC00 FF00} \
				{0000 3300 6600 9900 CC00 FF00} \
				{0000 3300 6600 9900 CC00 FF00} \
		.colorsp
	if {!$Global(Plugin)} {
		wm withdraw .colorpalette
	}

	frame .radiosr
	frame .rotatef
	entry .rrotatee -width 6 -textvariable Global(LastAngle) -relief flat
	label .copyright -text "ImPress 1.0, Copyright  1996-1999 Christopher Jay Cox, All Rights Reserved." -relief raised

	buttonReq .buttons $Global(Buttons) .radiosr
	frame .width -relief raised -bd 1
	canvas .widthc -relief flat -height 8m -width 2.25i
	.widthc create text 2 2 -anchor nw -text "Line Width"
	.widthc create line 1i .14i 1.5i .14i 1.5i .21i 2i .21i \
			-tags line \
			-fill "$Global(Outline)" -stipple "$Global(Stipple)" \
			-arrow "$Global(Arrow)" -joinstyle "$Global(JoinStyle)" \
			-arrowshape "$Global(ArrowP) $Global(ArrowD) $Global(ArrowW)" \
			-width "$Global(Width)"
		
	frame .space -width .25i
	frame .space2 -width .25i

	frame .textframe -bd 1 -relief raised
	frame .textmid
	text .text -exportselection true -width 20 -height 10 -wrap word \
		-yscrollcommand ".tscrolly set"
	scrollbar .tscrolly -bd 2 -width 15 -command ".text yview" 
	button .tclose -text "Close" -padx 2m -pady 2m \
		-command "pack forget .textframe;pack $name -fill both -expand true"
	button .tcopy -text "Copy" -padx 2m -pady 2m \
		-command ".text tag add sel 1.0 end"
	pack .text -in .textmid -side left -anchor sw -fill both -expand true
	pack .tscrolly -in .textmid -side right -fill y -anchor se
	pack .textmid -in .textframe -side top -anchor sw -fill both -expand true
	pack .tcopy .tclose -padx 1m -pady 1m -in .textframe -side left

	pack $name.scrolly -in $name.top -anchor se -side right -fill y
	pack .nextpage .prevpage -anchor sw -side left -in $name.bottom
	pack $name.scrollx -anchor se -in $name.bottom -side left -expand true \
		-fill x 
	pack $name.corner -anchor ne -in $name.bottom -side right
	pack .copyright -anchor sw -fill x
	pack .lw .llw -in .colors -side left
	pack .colors -fill x -in $name -side top
	pack $name.top -side top -in $name -expand true -fill both
	pack $name.bottom -anchor sw -in $name -side top -fill x

	if {$Global(Plugin)} {
		pack .radiosr -side left -in .radios -anchor sw 
		pack .colorsp -side left -in .radios -anchor sw -fill both -expand true
		pack .radios -anchor sw -fill x
	}

	pack $name -expand true -fill both 
	changePageProp
	focus $Global(CurrentCanvas)

	return $name.c
}


proc doProperties { c item } {
	set type [$c type $item]
	switch "$type" {
		line {
		}
	}
}
proc getProperties { c item type nogroups} {
	if { "$item" != "" } {
		set gprops ""
		foreach prop [$c itemconfigure $item] {
			set gpropname [lindex $prop 0]
			set gpropval [lindex $prop 4]
			if {$nogroups && $gpropname == "-tags"} {
				set ntags ""
				foreach tag $gpropval {
					if {![string match "Group*" $tag]} {
						lappend ntags $tag
					}
				}
				set gpropval $ntags
			}
			if {"$type" == "Esc"} {
				lappend gprops $gpropname "{$gpropval}"
			} else {
				lappend gprops $gpropname $gpropval
			}
		}
		return $gprops
	}
}
proc getGroupItems { items } {
	global Group Global

	set l ""
	foreach item $items {
		if {[info exists Group($Global(CurrentCanvas),$item)]} {
			set l [concat $l [$Global(CurrentCanvas) find withtag \
				[lindex $Group($Global(CurrentCanvas),$item) 0]]]
		}
	}
	return [lsort -integer [concat $items $l]]
}

proc createOval {bb} {
	global Global

	set r1 [expr ([lindex $bb 2] - [lindex $bb 0])/2.0]
	set r2 [expr ([lindex $bb 3] - [lindex $bb 1])/2.0]
	set xc [expr [lindex $bb 0] + $r1]
	set yc [expr [lindex $bb 1] + $r2]

	for {set r 0} {$r < 360} {incr r 10} {
		set sr [expr sin($r*3.14159265358979323846/180.0)]
		set cr [expr cos($r*3.14159265358979323846/180.0)]
		lappend shape [expr $xc + $r1 * $cr] [expr $yc + $r2 * $sr]
	}
	set i [eval $Global(CurrentCanvas) create polygon $shape \
		-tags oval -smooth 1 -fill \"$Global(Fill)\" \
		-outline \"$Global(Outline)\" -stipple \"$Global(Stipple)\" \
		-width \"$Global(Width)\"]
	return $i
}

proc createEditText {c textitem} {
	if {"$textitem" != ""} {
	}
}
proc createText {boxselector} {
	global Global

	textRaise .textIn
	set x [lindex $boxselector 0]
	set y [lindex $boxselector 3]
	set Global(TextWidth) [expr [lindex $boxselector 2] - $x]
	if {$Global(Outline) == ""} {
		set fill ""
	} else {
		set fill "-fill {$Global(Outline)}"
	}
	set Global(Text) [eval \$Global(CurrentCanvas) create text $x $y \
		-anchor sw -justify left \
		-font \"\$Global(Font)\" \
		$fill \
		-stipple \"\$Global(Stipple)\" -width \"\$Global(TextWidth)\" \
		-text \" \" -tags Imp_Text]
}
proc createRRectangle {boxselector smooth} {
	global Global
	set bb [bboxToCorners $boxselector]
	set xpix [winfo pixels . .25i]
	set ypix $xpix

	set x1 [lindex $bb 0]
	set y1 [lindex $bb 1]
	set x2 [lindex $bb 2]
	set y2 [lindex $bb 3]
	set x3 [lindex $bb 4]
	set y3 [lindex $bb 5]
	set x4 [lindex $bb 6]
	set y4 [lindex $bb 7]
	if {[expr $x2 - $x1] < [expr 2 * $xpix]} {
		set xpix [expr ($x2 - $x1) * .4]
	}
	if {[expr $y3 - $y1] < [expr 2 * $ypix]} {
		set ypix [expr ($y3 - $y1) * .4]
	} 
	if {$xpix > $ypix} {
		set xpix $ypix
	} else {
		set ypix $xpix
	}
	lappend nb $x1 $y1 [expr $x1 + $xpix] $y1 [expr $x1 + $xpix] $y1 \
		[expr $x2 - $xpix] $y2 [expr $x2 - $xpix] $y2 $x2 $y2 \
		$x2 [expr $y2 + $ypix] $x2 [expr $y2 + $ypix] \
		$x3 [expr $y3 - $ypix] $x3 [expr $y3 - $ypix] \
		$x3 $y3 [expr $x3 - $xpix] $y3 [expr $x3 - $xpix] $y3 \
		[expr $x4 + $xpix] $y4 [expr $x4 + $xpix] $y4 $x4 $y4 \
		$x4 [expr $y4 - $ypix] $x4 [expr $y4 - $ypix] \
		$x1 [expr $y1 + $ypix] $x1 [expr $y1 + $ypix]
	eval $Global(CurrentCanvas) create polygon $nb \
		-smooth $smooth -fill \"$Global(Fill)\" -outline \"$Global(Outline)\" \
		-stipple \"$Global(Stipple)\" -width \"$Global(Width)\"
}
proc createRectangle {boxselector} {
	global Global
	eval $Global(CurrentCanvas) create polygon [bboxToCorners $boxselector] \
		-fill \"$Global(Fill)\" -outline \"$Global(Outline)\" \
		-stipple \"$Global(Stipple)\" -width \"$Global(Width)\"
}
proc createLine {coords} {
	global Global
	if {[llength $coords] > 2} {
		set i [eval $Global(CurrentCanvas) create line $coords \
			-fill \"$Global(Outline)\" -stipple \"$Global(Stipple)\" \
			-arrow \"$Global(Arrow)\" -joinstyle \"$Global(JoinStyle)\" \
			-arrowshape \"$Global(ArrowP) $Global(ArrowD) $Global(ArrowW)\" \
			-width \"$Global(Width)\" -smooth \"$Global(Smooth)\"] 
		$Global(CurrentCanvas) addtag [genTag] withtag $i
		set Global(undo) \
			"$Global(CurrentCanvas) delete T-$Global(TagId)"
		return $i
	}
}
proc createSelection {} {
	global Global(selectnum)

	#
	# Select if something tagged within box.
	#
	$Global(CurrentCanvas) dtag disabled Imp_selected
	$Global(CurrentCanvas) dtag disabled Imp_selected${Global(selectnum)}

	for {set i 0} {1} {incr i} {
		set bb [$Global(CurrentCanvas) bbox Imp_selected${i}]
		if {"$bb" == ""} {
			break
		}
		eval $Global(CurrentCanvas) create polygon \
			[bboxToCorners "[$Global(CurrentCanvas) bbox Imp_selected${i}]"] \
			-tags {"selectorbox"} \
			-stipple gray25 -outline {""} -fill black
	}
}
proc createPolygon {coords} {
	global Global

	if {[llength $coords] > 5} {
		set i [eval $Global(CurrentCanvas) create polygon $coords \
			-fill \"$Global(Fill)\" -outline \"$Global(Outline)\" \
			-stipple \"$Global(Stipple)\" \
			-smooth \"$Global(Smooth)\" \
			-width \"$Global(Width)\"]
		$Global(CurrentCanvas) addtag [genTag] withtag $i
		set Global(undo) \
			"$Global(CurrentCanvas) delete T-$Global(TagId)"
		return $i
	}
}
proc createdBoundedSelection {boxselector} {
	global Global(selectnum)

	$Global(CurrentCanvas) configure -cursor watch
	update idletasks	
	#
	# If a boxselector is present, find everything it encompasses.
	#
	set bb [$Global(CurrentCanvas) bbox $boxselector]
	$Global(CurrentCanvas) delete selector
	set itemList [eval $Global(CurrentCanvas) find enclosed $bb]
	$Global(CurrentCanvas) dtag selector

	set itemList [getGroupItems $itemList]
	foreach item $itemList {
		$Global(CurrentCanvas) addtag Imp_selected withtag $item
		$Global(CurrentCanvas) addtag Imp_selected${Global(selectnum)} withtag $item
	}
	createSelection
	incr Global(selectnum)
	update idletasks
	. configure -cursor ""
	update idletasks
}
proc readFile {c name} {
	global Global

	set f [open $name r]
	gets $f line
	gets $f line
	gets $f line
	gets $f line
	set art [read $f]
	eval $art
}

proc getScale {name width height} {
	global Global

	set bb [eval $Global(CurrentCanvas) bbox $name]
	set x [expr [lindex $bb 2] - [lindex $bb 0]]
	set y [expr [lindex $bb 3] - [lindex $bb 1]]
	if {$x > $y} {
		set scale [expr $width / $x]
	} else {
		set scale [expr $height / $y]
	}
	return $scale
}
proc scaleObject {name ratio width height} {
	global Global

	set bb [eval $Global(CurrentCanvas) bbox $name]
	if {"$bb" != ""} {
		set x [lindex $bb 2]
		set y [lindex $bb 3]
		if {$ratio == "variable"} {
			set scalex [expr ($width + 0.0) / $x]
			set scaley [expr ($height + 0.0) / $y]
			if {$scalex > $scaley} {
				set scale $scaley
			} else {
				set scale $scalex
			}
		} elseif {$ratio != ""} {
			set scalex $ratio
			set scaley $ratio
			set scale $ratio
		} else {
			set scalex [expr ($width + 0.0) / $x]
			set scaley [expr ($height + 0.0) / $y]
			if {$scalex > $scaley} {
				set scalex $scaley
				set scale $scaley
			} else {
				set scaley $scalex
				set scale $scalex
			}
		}
		$Global(CurrentCanvas) scale $name 0 0 $scalex $scaley
		foreach i [$Global(CurrentCanvas) find withtag all] {
			set type [$Global(CurrentCanvas) type $i]
			if {"$type" != "text"} {
				continue
			}
			if {$Global(FontScale)} {
				set fn [$Global(CurrentCanvas) itemcget $i -font]
				regexp \
				{([-][^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-)([^-]*)(-.*)}\
					$fn dummy d1 size d2;
				if {"$dummy" != ""} {
					set nsize [expr round($size * $scale)]
					if {$nsize < 20} {
						set nsize 20
					}
					$Global(CurrentCanvas) itemconfigure $i \
						-font ${d1}${nsize}${d2}
					set fnn [$Global(CurrentCanvas) itemcget $i -font]
					regexp \
						{([-][^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-[^-]*-)([^-]*)(-.*)}\
						$fnn dummy d1 nsize d2;
					if { ($scale < 1 && $nsize < $size ) || \
						 ($scale > 1 && $nsize > $size) } {
						$Global(CurrentCanvas) itemconfigure $i \
							-width [expr [$Global(CurrentCanvas) itemcget $i \
							-width] * $scale]
					} else {
						$Global(CurrentCanvas) itemconfigure $i \
							-font $fn
					}
				}
			} else {
				$Global(CurrentCanvas) itemconfigure $i \
					-width [expr [$Global(CurrentCanvas) itemcget $i -width] \
						* $scale]
			}
		}
	}
}

proc getOrigin { name } {
	global Global

	set bb [eval $Global(CurrentCanvas) bbox $name]
	set x [lindex $bb 0]
	set y [lindex $bb 1]
	if {$x > 0} {
		set nx -$x
	} else {
		set nx [expr abs($x)]
	}
	if {$y > 0} {
		set ny -$y
	} else {
		set ny [expr abs($y)]
	}
	return "$nx $ny"
}

proc moveObject { name x y } {
	global Global

	$Global(CurrentCanvas) move $name $x $y
}

proc flip { name type } {
	global Global

	set bb [$Global(CurrentCanvas) bbox $name]
	if {"$bb" != ""} {
		set Global(undo) ""
		. configure -cursor watch
		update idletasks
		$Global(CurrentCanvas) delete handles
		if {"$type" == "v"} {
			set d [expr ([lindex $bb 2] - [lindex $bb 0])/2.0 + [lindex $bb 0]]
			$Global(CurrentCanvas) addtag [genTag] withtag $name
			set Global(undo) "flip T-$Global(TagId) v;
				$Global(CurrentCanvas) dtag T-$Global(TagId);"
		} else {
			set d [expr ([lindex $bb 3] - [lindex $bb 1])/2.0 + [lindex $bb 1]]
			$Global(CurrentCanvas) addtag [genTag] withtag $name
			set Global(undo) "flip T-$Global(TagId) h;
				$Global(CurrentCanvas) dtag T-$Global(TagId);"
		}
		set items [$Global(CurrentCanvas) find withtag $name]
		foreach item $items {
			set coords [$Global(CurrentCanvas) coords $item]
			if {"$type" == "v"} {
				set i 1
			} else {
				set i 0
			}
			set newcoords ""
			foreach coord $coords {
				if {$i} {
					lappend newcoords [expr $coord - (2.0 * ($coord - $d))]
					set i 0
				} else {
					lappend newcoords $coord
					set i 1
				}
			}
			eval $Global(CurrentCanvas) coords $item $newcoords
		}
		createHandles
		update idletasks
		. configure -cursor ""
		update idletasks
	}
}

proc originObject { name } {
	global Global

	set bb [$Global(CurrentCanvas) bbox $name]
	set x [lindex $bb 0]
	set y [lindex $bb 1]
	if {$x > 0} {
		set nx -$x
	} else {
		set nx [expr abs($x)]
	}
	if {$y > 0} {
		set ny -$y
	} else {
		set ny [expr abs($y)]
	}
	$Global(CurrentCanvas) move $name $nx $ny
}

set list {
menu Menu {} {}
{
	{
		file File {-underline 0} {}
		{
			{
				new New {-underline 0} { clearAll saveAsFile 0}
			}
			{
				open Open... {-underline 0} {openFile source Tk}
			}
			{
				saveas "Save As..." {-underline 5} {saveAsFile 1}
			}
			{
				print Print... {-underline 0} {printRaise .print}
			}
			{
				slide "Slide Properties..." {-underline 0} {slideRaise .slideP}
			}
			{
				pageprop "Page Properties..." {-underline 2} {set pageWidth \$Global(PageWidth);set pageHeight \$Global(PageHeight);pagePropRaise .pageProp}
			}
			{
				sep1 {} {} {}
			}
			{
				exit Exit {-underline 1} {doExit saveAsFile 0}
			}
		}
	}
	{
		insert Insert {-underline 0} {}
		{
			{
				oval Oval {-underline 0} {set Global(MenuSelect) 1;popupCanvasSet Oval}
			}
			{
				rect Rectangle {-underline 0} {set Global(MenuSelect) 1;popupCanvasSet Rectangle}
			}
			{
				line Line {-underline 0} {set Global(MenuSelect) 1;popupCanvasSet Line}
			}
			{
				poly Polygon {-underline 0} {set Global(MenuSelect) 1;popupCanvasSet Polygon}
			}
			{
				draw Draw {-underline 0} {set Global(MenuSelect) 1;popupCanvasSet Draw}
			}
			{
				text Text {-underline 0} {set Global(MenuSelect) 1;popupCanvasSet Text}
			}
		}
	}
	{
		edit Edit {-underline 0} {}
		{
			{
				selectall {Select All} {-underline 7} {selectAll}
			}
			{
				select Select {-underline 0} {popupCanvasSet Select}
			}
			{
				group Group {-underline 0} {popupCanvasSet Group}
			}
			{
				ungroup Ungroup {-underline 0} {popupCanvasSet UnGroup}
			}
			{
				duplicate Duplicate {-underline 0} \
					{popupCanvasSet Duplicate}
			}
			{
				fliph {Flip Horiz.} {-underline 5} {popupCanvasSet Flip_Horiz}
			}
			{
				flipv {Flip Vert.} {-underline 5} {popupCanvasSet Flip_Vert}
			}
			{
				raise Raise {-underline 0} {popupCanvasSet Raise}
			}
			{
				lower Lower {-underline 0} {popupCanvasSet Lower}
			}
			{
				cut Cut {-underline 0} {popupCanvasSet Cut}
			}
			{
				paste Paste {-underline 0} {popupCanvasSet Paste}
			}
		}
	}
	{
		layout Layout {-underline 0} {}
		{
			{
				grid Grid {-underline 0} {set GridX \$Global(GridX);set GridY \$Global(GridY);gridRaise .grid}
			}
			{
				headfoot Header/Footer {-underline 0} {}
			}
			{
				annotate Annotations {-underline 0} {}
			}
		}
	}
	{
		preferences Preferences {-underline 0} {} 
		{
			{
				buttons ToolBar {-underline 0}
				{buttonReq .buttons \$Global(Buttons) .radiosr}
			}
		}
	}
}
}
proc changePageProp {} {
	global Global

	set unit ""

	. configure -cursor watch
	update idletasks
	regexp {(.*)(.)$} "$Global(PageWidth)" match lenW Global(UnitX)
	regexp {(.*)(.)$} "$Global(PageHeight)" match lenH Global(UnitY)
	set lenW [expr $lenW * $Global(ViewScale)]
	set lenH [expr $lenH * $Global(ViewScale)]

	if { "$Global(UnitX)" == "" } {
		set Global(CoordFactorX) 1
	} else {
		set Global(CoordFactorX) [winfo fpixels . 1$Global(UnitX)]
	}
	if { "$Global(UnitY)" == "" } {
		set Global(CoordFactorY) 1
	} else {
		set Global(CoordFactorY) [winfo fpixels . 1$Global(UnitY)]
	}

	update idletasks
	if {!$Global(Plugin)} {
		set w [winfo width .]
		set h [winfo height .]
		set wp [winfo pixels . ${lenW}$Global(UnitX)]
		set hp [winfo pixels . ${lenH}$Global(UnitY)]
		set junkw [expr $w - [winfo width $Global(CurrentCanvas)]]
		set junkh [expr $h - [winfo height $Global(CurrentCanvas)]]
		set nw [expr $wp + $junkw]
		set nh [expr $hp + $junkh]
		wm maxsize .  $nw $nh
		if {$nw < $w || $nh < $h} {
			wm geometry . ${nw}x${nh}
		}
	}
	$Global(CurrentCanvas) configure \
		-scrollregion "0i 0i ${lenW}$Global(UnitX) ${lenH}$Global(UnitY)"

	$Global(CurrentCanvas).rulerx configure \
	 	-width ${lenW}$Global(UnitX)
	doRuler $Global(CurrentCanvas).rulerx $Global(PageWidth) .25i 0 0 1 h \
		"" ""
	$Global(CurrentCanvas).rulery configure \
	 	-height ${lenH}$Global(UnitY)
	doRuler $Global(CurrentCanvas).rulery $Global(PageHeight) .25i 0 0 1 v \
		"" ""

	if {[info exists Global($Global(CurrentCanvas)_ViewScale)]} {
		set newscale [expr $Global(ViewScale)/$Global($Global(CurrentCanvas)_ViewScale)]
	} else {
		set newscale $Global(ViewScale)
	}

	if {$newscale != 1.0} {
		scaleObject all $newscale 0 0
	}
	set Global($Global(CurrentCanvas)_Width) $Global(PageWidth)
	set Global($Global(CurrentCanvas)_Height) $Global(PageHeight)
	set Global($Global(CurrentCanvas)_Landscape) $Global(Landscape)
	set Global($Global(CurrentCanvas)_ViewScale) $Global(ViewScale)
	. configure -cursor ""
	update idletasks
}

set Global(CurrentCanvas) ""
if { ! $Global(Plugin) } {
	getPalette
	set menuparms [createMenu "" menu $list]
	eval tk_menuBar $menuparms
}
set c [createCanvasF ".can"]
setCursor Select

if { [lindex $argv 0] != "" } {
	openfile source [lindex $argv 0]
}

Added Demo/Applets/impress_complete.tar.gz.

cannot compute difference between binary files

Added Demo/Applets/index.html.





































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<BODY BGCOLOR=cyan>

Following are some simple Tcl applets:
<UL>
<LI><A href=tetris.html>Tetris - a game</A>
<LI><A href=backgammon.html>Backgammon - a game</A>
<LI><A href=bertspel.html>Bertspel - a game</A>
<LI><A href=bike.html>Bicycle gear cacluator</A>
<LI><A href=maplot.html>Map Plotter</A>
<LI><A href=picpuzzle.html>Picture puzzle - a game</A>
<LI><A href=qdbtclet.html>Database query tool demo</A>
</UL>

<H2>Impress</H2>

<A href=newimpress.html>Impress</A> is a design layout tool.  It is
an example of a more sophisticated Tcl application.

Added Demo/Applets/maplot.html.

























>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
<html>
<head>
<title>Sun position tclet v. 1.0</title>
</head>
<body>
Try me!
<p>
<embed src=maplot.tcl width=500 height=400>
</body>
</html>

]

Added Demo/Applets/maplot.tcl.































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
# tclet for drawing sun position on map
# (c) Matti Koskinen 1997
#
#
global mapd
# map data, adopted from gnuplot
set mapd "-140.37:60.25\
-132.08:57.20\
-131.46:55.98\
-133.84:57.12\
-136.01:59.12\
-137.12:58.28\
-139.98:59.73\
-146.54:60.36\
-149.90:59.50\
-149.18:60.81\
-153.53:59.32\
-156.52:57.11\
-162.34:55.06\
-157.85:58.12\
-162.06:58.36\
-164.58:60.06\
-165.29:62.57\
-161.12:64.49\
-168.23:65.49\
-162.99:65.97\
-161.56:66.55\
-166.64:68.25\
-159.53:70.38\
-154.37:70.96\
-148.09:70.26\
-142.49:69.83\
-141.21:69.56\
*\
-152.62:58.41\
-152.60:58.40\
*\
-153.30:57.80\
-152.40:57.48\
-153.32:57.79\
*\
-166.96:53.96\
-167.01:53.95\
*\
-168.36:53.50\
-168.19:53.36\
*\
-170.73:52.68\
-170.60:52.55\
*\
-174.47:51.94\
-174.47:51.92\
*\
-176.58:51.71\
-176.64:51.73\
*\
-177.55:51.76\
-177.41:51.63\
*\
-178.27:51.75\
-178.30:51.65\
*\
177.35:51.80\
177.33:51.76\
*\
172.44:53.00\
172.55:53.03\
*\
-141.21:60.16\
-133.38:58.93\
-130.88:54.83\
-128.86:53.90\
-126.58:52.12\
-127.08:50.80\
-124.42:49.66\
-122.56:48.91\
*\
-92.32:48.24\
-88.13:48.92\
-83.11:46.27\
-81.66:44.76\
-82.09:42.29\
-77.10:44.00\
-69.95:46.92\
-65.92:45.32\
-66.37:44.25\
-61.22:45.43\
-64.94:47.34\
-64.12:48.52\
-70.68:47.02\
-67.24:49.33\
-59.82:50.48\
-56.14:52.46\
-59.07:53.58\
-58.26:54.21\
-60.69:55.33\
-61.97:57.41\
-64.35:59.49\
-67.29:58.15\
-69.89:59.91\
-71.31:61.45\
-78.22:61.97\
-77.28:59.53\
-77.09:55.88\
-79.06:51.68\
-82.23:52.70\
-86.75:55.72\
-92.17:56.86\
-95.61:58.82\
-92.66:62.02\
-90.65:63.24\
-95.96:64.12\
-89.88:63.98\
-89.30:65.22\
-86.86:66.12\
-84.54:66.88\
-82.30:67.76\
-83.10:69.68\
-86.05:67.98\
-88.18:68.20\
-91.00:68.82\
-91.72:69.69\
-93.15:71.09\
-96.58:71.05\
-93.35:69.52\
-94.23:68.25\
-95.96:66.73\
-98.83:68.27\
-102.45:67.69\
-108.34:68.43\
-105.83:68.05\
-108.15:66.60\
-111.15:67.63\
-114.10:68.23\
-120.92:69.44\
-124.32:69.26\
-128.76:70.50\
-131.86:69.19\
-131.15:69.79\
-135.81:69.13\
-140.19:69.37\
-141.20:69.58\
*\
-123.40:48.33\
-128.00:50.84\
-123.50:48.34\
*\
-132.49:52.88\
-132.44:52.91\
*\
-132.64:53.02\
-131.97:53.71\
-132.63:53.02\
*\
-55.36:51.56\
-54.66:49.52\
-53.65:47.48\
-52.98:46.31\
-56.12:46.84\
-58.47:47.57\
-57.61:50.38\
-55.39:51.53\
*\
-61.37:49.01\
-61.80:49.29\
-61.38:49.03\
*\
-63.01:46.71\
-64.42:46.61\
-63.04:46.68\
*\
-60.14:46.48\
-60.14:46.50\
*\
-122.44:48.92\
-124.42:47.18\
-124.52:42.48\
-123.09:38.45\
-121.73:36.62\
-117.60:33.34\
-117.28:32.64\
*\
-97.62:25.82\
-95.62:28.84\
-90.77:29.03\
-87.33:30.22\
-82.69:28.15\
-80.16:26.66\
-80.74:32.31\
-76.89:35.43\
-76.47:38.21\
-75.66:37.67\
-71.31:41.76\
-69.44:44.17\
-67.69:47.03\
-73.18:45.14\
-79.26:43.28\
-82.84:42.59\
-83.49:45.32\
-86.36:43.65\
-87.75:43.42\
-86.01:45.96\
-87.00:46.59\
-91.39:46.79\
-90.05:47.96\
*\
-71.97:41.11\
-71.97:41.15\
*\
-80.79:27.03\
-81.01:26.99\
*\
-113.01:42.09\
-113.10:42.01\
*\
-155.74:20.02\
-155.73:19.98\
*\
-156.51:20.78\
-156.51:20.78\
*\
-157.12:21.21\
-157.08:20.95\
*\
-157.87:21.42\
-157.89:21.45\
*\
-159.53:22.07\
-159.56:22.09\
*\
-117.44:66.46\
-119.59:65.24\
-123.95:65.03\
-123.69:66.44\
-119.21:66.22\
-117.44:66.44\
*\
-120.71:64.03\
-114.91:62.30\
-109.07:62.72\
-112.62:61.19\
-118.68:61.19\
-117.01:61.17\
-115.97:62.56\
-119.46:64.00\
-120.59:63.94\
*\
-112.31:58.46\
-108.90:59.44\
-104.14:58.90\
-102.56:56.72\
-101.82:58.73\
-104.65:58.91\
-111.00:58.51\
-112.35:58.62\
*\
-98.74:50.09\
-99.75:52.24\
-99.62:51.47\
-98.82:50.39\
*\
-97.02:50.21\
-97.50:54.02\
-98.69:52.93\
-97.19:51.09\
-96.98:50.20\
*\
-95.34:49.04\
-92.32:50.34\
-94.14:49.47\
-95.36:48.82\
*\
-80.39:56.16\
-79.22:55.94\
-80.34:56.08\
*\
-103.56:58.60\
-103.60:58.58\
*\
-101.82:58.03\
-102.33:58.10\
-101.77:58.06\
*\
-101.88:55.79\
-97.92:57.15\
-101.22:55.85\
-101.88:55.74\
*\
-117.29:32.48\
-114.75:27.80\
-112.53:24.80\
-110.55:24.07\
-114.23:29.59\
-112.58:29.99\
-109.57:25.94\
-105.61:21.94\
-102.09:17.87\
-95.75:15.94\
-92.21:14.97\
*\
-88.45:17.42\
-87.01:21.33\
-91.65:18.72\
-96.96:20.37\
-97.65:25.67\
*\
-92.22:14.71\
-86.74:12.06\
-83.03:8.65\
-79.93:8.74\
-77.17:7.94\
-81.99:8.97\
-83.92:12.70\
-86.33:15.80\
-88.40:15.92\
*\
-77.61:6.80\
-78.70:0.97\
-80.75:-4.47\
-76.19:-14.57\
-70.44:-18.75\
-70.68:-26.15\
-71.44:-32.03\
-73.38:-37.27\
-73.06:-42.11\
-73.17:-46.09\
-73.52:-48.05\
-73.67:-51.56\
-71.06:-53.88\
-69.14:-50.77\
-67.51:-46.59\
-63.49:-42.80\
-62.14:-40.16\
-57.12:-36.71\
-53.17:-34.15\
-51.26:-32.02\
-48.16:-25.48\
-40.73:-22.32\
-38.88:-15.24\
-34.60:-7.81\
-41.95:-3.42\
-48.02:-1.84\
-48.44:-1.57\
-50.81:0.00\
-54.47:5.39\
-60.59:8.32\
-64.19:9.88\
-70.78:10.64\
-70.97:11.89\
-76.26:8.76\
-77.61:6.80\
*\
-69.14:-52.79\
-66.16:-55.08\
-70.01:-54.88\
-70.55:-53.85\
-69.31:-52.81\
*\
-59.29:-51.58\