[REBOL] Re: Dynamic resizing question
From: carl::cybercraft::co::nz at: 4-Feb-2006 10:54
Hi Steven,
I think you can't alter the TABS value because it's not stored in the layout object,
unlike SIZE. It's just used for the placement of faces when the layout is first created.
(That's off the top of my head, so it's just possible I'm wrong about this.)
The position of each face is stored in the OFFSET pair of each face, so that's what you'd
have to change to move the buttons.
Anyway, this got me thinking, and I came up with a function for re-sizing a layout.
It needs work though, as more complex styles (such as TEXT-LIST) would need to be gone
deeper into to re-size all of the faces within them. However, I think you'd have to
do the same with your approach too, so it's just a general problem with some styles.
So, for what it's worth, here's the function I came up with. (Sorry it's not commented.
Do ask if there's anything you don't understand.) ...
REBOL [ ]
scale-lo: func [
lo [object!]
scale [number!]
][
foreach pane lo/pane [
if none? pane/user-data [
pane/user-data: reduce [
'size pane/size
'offset pane/offset
'font make pane/font []
]
]
pane/size: pane/user-data/size * scale
pane/offset: pane/user-data/offset * scale
pane/font: make pane/user-data/font [
size: to-integer pane/user-data/font/size * scale
]
]
if none? lo/user-data [
lo/user-data: reduce [
'size lo/size
]
]
lo/size: lo/user-data/size * scale
show lo
]
test-lo: layout [
across
button "Button 1"
button "Button 2"
return
button "Wide Button" 210
return
area wrap 100x100 "The rain in Spain falls mainly on the plain."
text-list 100x100 "A" "B" "C" "D" "E" "F"
return
button "Normal" [scale-lo test-lo 1]
button "Times 1.5" [scale-lo test-lo 1.5]
button "Times 2" [scale-lo test-lo 2]
button "Times 3" [scale-lo test-lo 3]
]
view test-lo