Hi Steven, yes it's cool ! :)
But I had a look and found that you probably do not
need to set words to your button faces at all, as
the faces are available in each button action.
So you can have the same functionality with even less
code ! :)
Have at look at this console session:
>> layout [b: button [print "hi"]]
>> print mold get in b 'action
func [face value][print "hi"]
As you can see, the action facet of the button face
is a function which takes two arguments FACE and VALUE.
When the action function is called, the View system passes the
face whose action is being done in the FACE argument.
This means the action code can refer to FACE if it wants to find
out anything about the button.
An example will make things clearer. Your code can be simplified
like this:
layout [
style button button 260x55 font-size 14
button "Add a new reservation/invoice" [
save-button %btnresadd.png to-image face
]
button "etc"
]
So you can see the reference to face removes the need for
setting a word to each button. :)
I've thrown in another optimization with the LAYOUT dialect keyword,
STYLE. It just restyles the BUTTON style with some default facet values,
which saves specifying them for every button.
(Mmm.. and you could move TO-IMAGE inside SAVE-BUTTON... but I'll leave
that to you.)
Regards,
Anton.
> The function assigned to a button can identify its own button by the =
> button's word (its name). It passes that button (converted to an image) =
> to another function that saves the button to a "png" file and ftp's the =
> graphic over to the server where I am writing the CGI program. =20
> REBOL [
> ]
>
> ;; [----------------------------------------------------------------]
> ;; [ These are the buttons for the temporary reservation program ]
> ;; [ for Park and Rec. ]
> ;; [----------------------------------------------------------------]
>
> SAVE-SITE: "ftp://user:[EMAIL PROTECTED]//x/y/z/graphics/"
>
> SAVE-BUTTON: func [
> BUTTON-FILENAME [file!]
> BUTTON-IMAGE [image!]
> /local SAVE-FTP-LOC=20
> ] [
> save/png BUTTON-FILENAME BUTTON-IMAGE
> SAVE-FTP-LOC: copy ""
> SAVE-FTP-LOC: to-url join SAVE-SITE [to-string BUTTON-FILENAME]
> write/binary SAVE-FTP-LOC read/binary BUTTON-FILENAME
> delete BUTTON-FILENAME
> ]
>
> view layout [
> B01: button 260x55=20
> "Add a new reservation/invoice"
> font [size: 14]
> [SAVE-BUTTON %btnresadd.png to-image B01]
> B02: button 260x55=20
> "Modify/print an invoice"
> font [size: 14]
> [SAVE-BUTTON %btnresmod.png to-image B02]
> B03: button 260x55=20
> "Display one day at a facility"
> font [size: 14]
> [SAVE-BUTTON %btnresprt.png to-image B03]
> B04: button 260x55=20
> "Display one month at a facility"
> font [size: 14]
> [SAVE-BUTTON %btnresmth.png to-image B04]
> ]
>
>
> Steven White
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.