[VID][layout] Changing origin and space
[1/4] from: atruter::labyrinth::net::au at: 20-Mar-2004 21:48
My crude attempts to set a "global" origin and space in VID resulted in
the following code:
code: second first next find third system/words [layout:]
change find code 8x8 20x20 ; space
change first find/only code [20x20][100x100] ; origin
but there must be a more elegant solution than this!?
Which got me to thinking about how I typically use layout:
view/new/options/title center-face layout [...] compose [parent
(main-out)] title
and the fact that, for me at least, most of the complexity in these mezz
functions ('view 'center-face 'layout) is not needed. I checked the VID
source to see which layout refinements are used and only came up with
three hits:
PANEL -> layout/parent/size/styles
LIST -> layout/parent/origin/styles
TEXT-LIST -> layout/size
which lets me write a stream-lined version of layout, but leads to the
question of how do I replace 'layout in the 'system/view/VID context with
my version? I've started extending the approach adopted above (for 'origin
/ 'space) but like before wonder if there is an easier way. Comments?
Regards,
Ashley
[2/4] from: brett:codeconscious at: 20-Mar-2004 23:16
> which lets me write a stream-lined version of layout, but leads to the
> question of how do I replace 'layout in the 'system/view/VID context with
> my version? I've started extending the approach adopted above (for 'origin
> / 'space) but like before wonder if there is an easier way. Comments?
An answer to the context problem might be:
my-layout: load mold :layout ; Without bindings
set 'layout do bind my-layout in system/view/vid 'self
Regards,
Brett.
[3/4] from: atruter:labyrinth:au at: 20-Mar-2004 23:51
> An answer to the context problem might be:
No might about it, that hit the nail right on the head. Thanks!
Regards,
Ashley
[4/4] from: atruter:labyrinth:au at: 22-Mar-2004 12:41
A simple function to set some of those "hard-coded" layout values.
<code>
set-layout: function [
"Changes layout settings."
/origin margin [pair!] "default is 20x20"
/space size [pair!] "default is 8x8"
/way dir [pair!] "'below (0x1, the default) or 'across (1x0)"
/tabs stop [pair!] "default is 100x100"
][
blk
][
blk: second first next find third system/words [layout:]
if any [
20 <> index? find blk [origin:]
26 <> index? find blk [space:]
28 <> index? find blk [way:]
33 <> index? find blk [tabs:]
][to-error "layout version not supported"]
if all [origin pair? blk/25/1][change blk/25 margin]
if all [space pair? blk/27][poke blk 27 size]
if all [way pair? blk/29 find [0x1 1x0] dir][poke blk 29 dir]
if all [tabs pair? blk/34][poke blk 34 stop]
return
]
</code>
Regards,
Ashley