[REBOL] Re: [REBOL]Panel Problems - make a copy of box/edge
From: arolls::bigpond::net::au at: 27-Jun-2001 17:49
The boxes use an embedded object 'edge.
This is shared by all the boxes.
To see it:
probe get-style 'box
You will need to make a copy of the edge
object and set it into your own style of
box.
Let's see source at bottom:
> Can anyone replicate or explain this problem with panels? And
> then suggest a
> work-around?
>
> On my machine (PC / Win 98; View 1.2) the change to one box
> alters ALL boxes
> in BOTH Panels. I get the same problem when changing text
> effects, and other
> features, when using subpanels.
>
> Thanks,
> Colin.
>
> mainlayout: layout [across
> My-panel: box 400x600 green ;field for subpanels
> return
> Button "Display panel 1" [
> My-panel/pane: panel1
> Show My-Panel
> ]
> Button "Display Panel 2" [
> My-panel/pane: panel2
> Show My-Panel
> ]
> Button "Modify&Display panel2"
> [MyBox/edge/size: 3x3
> MyBox/edge/color: 255.255.255
> My-panel/pane: panel2
> Show My-Panel
> ]
> ] ;layout
>
> Panel1: layout [info "Panel1"
> box red box white box blue
> ]
>
> panel2: layout [info "panel2"
> mybox: box silver box gray box maroon]
>
> unview/all
> view mainlayout
> halt
rebol [
Title: ""
File: %stylize-box-edge.r
Date: 27-Jun-2001
Version: 1.0.0
Needs: [view]
Author: "Anton Rolls"
Language: 'English
Purpose: {
Demonstrate how to make a new style of box
with a different embedded edge object,
so that changes to the edge of a box
don't affect the edges of all boxes.
}
ToDo: {
-
}
History: [
1.0.0 [27-Jun-2001 {First version} "Anton"]
]
Notes: {
probe get-style 'box
}
]
my-style: stylize [
my-box: box with [ ; you could just box: box with [...]
; modify the box's init function
append init [
edge: make edge [ ; make a copy of the box/edge
color: black ; make it black too
]
]
]
]
view center-face layout [
styles my-style
; using default box
; - both change as a result of changing first box's edge
b: box "b: box" blue [
b/edge/size: 4x4 ; large
b/edge/color: red
show [b b2 b3 b4] ; show all boxes
]
b2: box "b2: box" blue / 2 [
b/edge/size: 1x1 ; small
b/edge/color: red
show [b b2 b3 b4] ; show all boxes
]
; now using my-box, a style based on box
; - only third box changes as a result of
;changing third box's edge
b3: my-box "b3: my-box" green / 2 [
b3/edge/size: 4x4 ; large
show [b b2 b3 b4] ; show all boxes
]
b4: my-box "b4: my-box" green / 3 [
b3/edge/size: 1x1 ; small
show [b b2 b3 b4] ; show all boxes
]
]