[REBOL] Re: Iterated check box anomaly (resend) - now, the ROTARY!
From: anton:lexicon at: 6-May-2002 23:13
I am still trying to figure it out myself, but just quickly,
this might do enough what you want:
rebol [
Title: "Iterated Rotarys"
File: %iterated-rotarys.r
Date: 6-May-2002
Version: 1.0.0
Needs: [view]
Author: "Anton Rolls"
Language: 'English
Purpose: {Make rotarys in a VID list work}
Usage: {}
ToDo: {
- iterated rotary doesn't react quite the same as a single rotary:
- single rotary shows next value while mouse button down
- can't go backwards with alt-down (right mouse button)
- depends on face/state
}
History: [
1.0.0 [6-May-2002 {First version inspired by a post by Geza Lakner
MD [[geza67--freestart--hu]]
entitled "[REBOL] Re: Iterated check box anomaly (resend) - now, the
ROTARY!" on 6/5/2002} "Anton"]
]
Notes: {
adds a new facet word: 'my-count to the rotary
I am theorizing that to make all faces iterateable,
we could add a new facet, eg. 'save-data, which is an object!
with the facets that need to be stored (eg. data, text etc.)
The list should get/set this object in the supply code.
This get/set code will always be the same, making it trivial
to implement iterated faces on any style.
We would need to modify all the styles so that the appropriate
data is stored in save-data.
}
]
rows: 5 ; number of rows in list
rot-texts: ["first" "second" "third" "fourth"]
rot-data: copy []
rot-states: copy []
repeat n rows [
append/only rot-data rot-texts
append rot-states false
]
?? rot-data
view center-face layout [
list 500x150 [
across
cnt: info "1"
answer: rotary 240 with [my-count: none][
print [newline 'action face/my-count face/data]
; change the displayed value
face/data: either tail? next face/data [
head face/data
][
next face/data
]
; store face/data in rot-data
poke rot-data face/my-count face/data
?? rot-data
; store face/state in rot-states
;poke rot-states face/my-count face/state
;face/state: pick rot-states face/my-count
;?? rot-states
show face
] data rot-texts ; initial data goes into face/texts and face/data
] supply [
if count > rows [face/show?: false exit]
face/show?: true
if face/style = 'rotary [
face/my-count: count
]
switch index [
1 [
; info
face/text: form count
]
2 [
; rotary
;face/state: pick rot-states face/my-count
;poke rot-states face/my-count face/state
;?? rot-states
face/data: pick rot-data face/my-count
face/text: first face/data
;face/texts: rot-texts
]
]
]
]
Anton.