[REBOL] Re: Dynamic resizing question
From: carl::cybercraft::co::nz at: 4-Feb-2006 10:54
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 [
foreach pane lo/pane [
if none? pane/user-data [
pane/user-data: reduce [
'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 [
lo/size: lo/user-data/size * scale
test-lo: layout [
button "Button 1"
button "Button 2"
button "Wide Button" 210
area wrap 100x100 "The rain in Spain falls mainly on the plain."
text-list 100x100 "A" "B" "C" "D" "E" "F"
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]