Two questions, auto-scaling
Jim Hurley
jhurley at infostations.com
Mon Nov 10 16:48:01 EST 2003
What follows is a solution of desperation. I found that the best
solution for me on the stack I am currently working on was to just
let the user resize the window to fit his or her needs. It was easier
than using RR built-in geometry utilities.
This requires scaling everything (all controls) when the stack is resized.
Fields are treated differently. When the fields are scaled, the text
may not fit, so for these I scale the font size as well (unless there
is a vertical scrollbar in which case I only scale the rect).
Caution: I hesitate to offer this. Use with care. It works for me but
I have not tested it widely.
Jim
Place in the stack script:
local scaleX,scaleY
on resizeStack x,y, xold,yold
lock screen
repeat with i = 1 to the number of cards
go to card i
doResize x,y,xold,yold
end repeat
go to recent card
unlock screen
end resizeStack
on doResize x,y,xold,yold
put x/xold into scaleX
put y/yold into scaleY
doScaling
sizeFontToFit
end doResize
on doScaling
repeat with i = 1 to the number of controls
put the name of control i into tControl
put the rect of tControl into tRect
repeat with j =1 to 4
multiply item j of tRect by item oneOrTwo(j) of (scaleX,scaleY)
end repeat
set the rect of tControl to tRect
end repeat
end doScaling
function oneOrTwo k
return 2 - (k mod 2)
end oneOrTwo
on sizeFontToFit
repeat with n = 1 to the number of fields
if the vScrollbar of field n is true then next repeat
put the width of field n into tWidth
put the textFont of field n into tFont
put the fontsizes of tFont into tSizeList
repeat with i = 1 to the number of lines in tSizeList
set the textsize of field n to line i of tSizeList
if the formattedwidth of field n > tWidth then exit repeat
end repeat
set the height of field n to the formattedheight of field n
end repeat
end sizeFontToFit
More information about the use-livecode
mailing list