[REBOL] Re: Dynamically adding boxes to layout
From: carl:cybercraft at: 19-Dec-2001 9:23
On 19-Dec-01, Robert M. Muench wrote:
> Hi, I have to followig problem: I'm doing some calculation that
> results in some object positions. Now I want to draw boxes with
> these calculcated positions. The number of boxes is not known until
> run-time.
> It's easy to do it statically:
> view layout [
> box 25x25
> box 10x10
> ]
> Ok, but how do I add further boxes at run-time? Robert
Depending on what you're after, using View's Draw dialect may be the
way to go...
view layout [
b: box black 400x200 effect [draw[]]
button "Add Box" [
append b/effect/draw reduce [
'pen random 255.255.255
'fill-pen random 255.255.255
'box random 399x199 random 399x199
]
show b
]
]
Each click of the button there adds a box and its color definitions to
b's 'draw block, and with it being a block, you can add and remove
its contents at will, not to mention adding lines, circles, polygons,
text and images too.
--
Carl Read