stk/STklos/%README

126 lines
3.5 KiB
Plaintext
Raw Normal View History

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