<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.33 i586) [Netscape]">
</HEAD>
<BODY>
<CENTER>
<H1>
<B>STklos version 4.0</B></H1></CENTER>
<H3>
What is STklos</H3>
STklos is an extension of STk which provides à la CLOS objets to
STk. This implementation is based on the
<BR>implementation of version 1.3 of the Tiny CLOS package defined
by Gregor Kickzales (available by ftp at <A HREF="ftp://parcftp.xerox.com/pub/mop/">parcftp.xerox.com:/pub/mop/*</A>).
<H3>
Compiling STklos</H3>
STklos is compiled during the interpreter construction. You don't have
to do something in this directory.
<H3>
Simple Test of STklos</H3>
STklos needs some files to run properly. Until you have installed it in
its definitive place, you have to:
<OL>
<LI>
set your default directory to STklos</LI>
<LI>
use the the shell script ../Src/test-stk to run the interpreter</LI>
</OL>
So, you just have to type
<UL><TT>$ cd STklos; ../Src/test-stk</TT></UL>
To test, that everything is OK, you can try:
<UL><TT>(let ()</TT>
<BR><TT> (define-class A () ((a :initform 10) b))</TT>
<BR><TT> (define inst (make A))</TT>
<BR><TT> (slot-set! inst 'b 20)</TT>
<BR><TT> (+ (slot-ref inst 'a) (slot-ref inst 'b)))</TT></UL>
which should yield 30 if everything is correct.
<H3>
Using STklos with the Tk toolkit</H3>
A set of classes have been defined to use Tk with object flavor. All the
Tk widgets have been wrapped in STklos. classes.The following example
creates a three buttons panel (button 1 & 2 being on top of button
3).
<UL><TT>(require "Tk-classes")</TT>
<BR><TT>(define f (make <Frame>))</TT>
<BR><TT>(define b1 (make <Button> :text "Button 1" :parent f))</TT>
<BR><TT>(define b2 (make <Button> :text "Button 2" :parent f))</TT>
<BR><TT>(define b3 (make <Button> :text "Button 3"))</TT>
<BR><TT>(pack b1 b2 :side "left")</TT>
<BR><TT>(pack f b3 :fill "both" :expand #t)</TT></UL>
Note usage of Scheme names in the two preceding pack calls instead of dotted
Tcl/Tk names.
<P>Tk options can be seen as slot in the STklos world. So getting the font
of button 3 can be done with
<UL><TT>(font b3)</TT></UL>
and changing its value can be done with
<UL> (<TT>set! (font b3) '(Courier))</TT></UL>
and associating a callback to button 1 can be done with the following expression
<UL><TT>(set! (command b1) (lambda ()</TT>
<BR><TT>
(format #t "You have typed on \"Button1\"\n"))</TT></UL>
The desribe function permits to see all the slots value of a given object.
For instance,
<UL><TT>(describe b2)</TT></UL>
would give something like:
<UL><TT>#[<button> 401bfdbc] is an instance of class <button></TT>
<BR><TT>Slots are:</TT>
<BR><TT> id = #[Tk-command .v184.v214]</TT>
<BR><TT> eid = #[Tk-command .v184.v214]</TT>
<BR><TT> parent = #[<frame> 401b5304]</TT>
<BR><TT> bitmap = ""</TT>
<BR><TT> width = 0</TT>
<BR><TT> height = 0</TT>
<BR><TT> anchor = "center"</TT>
<BR><TT> font = "-Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-*"</TT>
<BR><TT> foreground = "Black"</TT>
<BR><TT> image = ""</TT>
<BR><TT> justify = "center"</TT>
<BR><TT> pad-x = 9</TT>
<BR><TT> pad-y = 3</TT>
<BR><TT> text = "Button 2"</TT>
<BR><TT> text-variable = ""</TT>
<BR><TT> underline = -1</TT>
<BR><TT> wrap-length = 0</TT>
<BR><TT> background = "#d9d9d9"</TT>
<BR><TT> border-width = 2</TT>
<BR><TT> cursor = ""</TT>
<BR><TT> highlight-background = "#d9d9d9"</TT>
<BR><TT> highlight-color = "Black"</TT>
<BR><TT> highlight-thickness = 0</TT>
<BR><TT> relief = "raised"</TT>
<BR><TT> take-focus = ""</TT>
<BR><TT> active-background = "#ececec"</TT>
<BR><TT> active-foreground = "Black"</TT>
<BR><TT> command = ""</TT>
<BR><TT> disabled-foreground = "#a3a3a3"</TT>
<BR><TT> state = "normal"</TT></UL>
Destruction of a button can be obtained with the destroy-widget generic
function as in
<UL>(<TT>destroy b2)</TT></UL>
<H3>
Examples</H3>
Some examples (too few) are available in the Examples directory. What those
examples do is not interesting <I>per se </I>but rather how they are written.
<BR><B>Note</B>:There are not enough examples. Send me programs if you
have interestingpieces of code to make this directory growing.Thanks
<BR>
<P>Have fun.
<BR>
</BODY>
</HTML>