[REBOL] Re: Rebol Virtual Office project ...
From: etienne:alaurent:free at: 17-Aug-2001 12:05
Hi, Allen,
Le ven, 17 aoû 2001, vous avez écrit :
>Very cool!
Thank you
> I take it this is the enhanced version of what you showed me a while back
>;-)
That's true.
>So you managed to fix that problem you had with my dropdown style? (I
>guess you had to recode it from scratch, which would have been the best
>solution, I'd like to see the fix for that.)
In fact, all your advices where good. The dropdown code was enhanced (a lttle
if I can remember), and I mixed the calendar and dropdown styles to make a
calendar dropdown style.
dropdown style :
----------------------------------
dropdown: text
black white 100 edge [color: 110.120.130 size: 2x2 effect: 'ibevel] effect [grid 1200x4
230.230.230]
font [shadow: none]
middle
with [
list-lay: none
show-arrow?: true
rows: 4
size: 100x24
line-list: action: none
list-data: copy []
dd-feel: make face/feel [
over: redraw: detect: none
engage: func [face action event][
switch action [
time [if not face/state [face/blinker: not face/blinker]]
down [face/state: on]
alt-down [face/state: on]
up [if face/state [face/show-dropdown] face/state: off]
alt-up [if face/state [do-face-alt face none] face/state: off]
over [face/state: on]
away [face/state: off]
]
show face
]
]
arrow-button: does [
layout [
origin 0x0 arrow down [self/show-dropdown]
edge [color: 110.120.130 size: 2x2 effect: 'ibevel] 128.128.128 14x20 ar-but ;img-bleu1
; image in the arrow-button
]
]
show-dropdown: func [/local tl picked][
if not list-lay [
list-lay: layout [
;styles skin-ui
origin 0x0 at 0x0
tl: text-list data self/list-data to-pair reduce [size/x rows * 15 + 4] effect [grid
1200x4 230.230.230]
self/font/color self/color bold
[ self/data: self/text: value show list-lay
wait 0:0:0.03 ; long enough to see selection
hide-popup show self
]
do [if picked: find self/list-data self/text [append clear tl/picked first picked]]
]
list-lay/offset: to-pair reduce [self/offset/x self/offset/y + self/size/y]
]
show-popup/window/away list-lay self/parent-face
do-events list-lay
do-face self self/data
]
reset: does [list-lay: none]
resize: does [
reset ; so list-pane will redraw at correct size
{Reset if a change has been made to the data}
size/x: max 32 size/x
size/y: max 24 size/y
either show-arrow? [
pane: arrow-button
pane/offset: 0x0 pane/offset/x: self/size/x - arrow-button/size/x - 4
arrow-button/size/y: self/size/y
][pane: none]
show self
]
pane: none
words: [data [new/list-data: second args next args]
rows [new/rows: second args next args]]
init: append copy init [
arrow-button: arrow-button
resize
self/feel: self/dd-feel
]
]
----------------------------------
calendar dropdown style :
Be careful : in the show-caldropdown func, layout is referring to "styles
skins". Skins must contain the calendar widget as you defined it
----------------------------------
caldropdown: text
black white 100 edge [color: 110.120.130 size: 2x2 effect: 'ibevel] effect [grid 1200x4
230.230.230]
font [shadow: none]
middle
with [
cal-lay: none
show-arrow?: true
size: 100x24
line-list: action: none
dd-feel: make face/feel [
over: redraw: detect: none
engage: func [face action event][
switch action [
time [if not face/state [face/blinker: not face/blinker]]
down [face/state: on]
alt-down [face/state: on]
up [if face/state [face/show-caldropdown] face/state: off]
alt-up [if face/state [do-face-alt face none] face/state: off]
over [face/state: on]
away [face/state: off]
]
show face
]
]
arrow-button: does [
layout [
origin 0x0 arrow down [self/show-caldropdown]
edge [color: 110.120.130 size: 2x2 effect: 'ibevel] 128.128.128 14x20 ar-but ;img-bleu1
; image in the arrow-button
]
]
show-caldropdown: func [/local c][
cal-lay: layout [
styles skins
origin 0x0 at 0x0
c: calendar with [show-navbar?: true] [
either c/effect? c/date 'oval [
c/remove-effect c/date 'oval
][
c/add-effect c/date 'oval
]
self/data: self/text: c/date show cal-lay
wait 0:0:0.03
hide-popup show self
]
]
cal-lay/offset: to-pair reduce [self/offset/x self/offset/y + self/size/y]
show-popup/window/away cal-lay self/parent-face/parent-face/parent-face
do-events cal-lay
do-face self self/data
]
reset: does [cal-lay: none]
resize: does [
reset ; so list-pane will redraw at correct size
{Reset if a change has been made to the data}
size/x: max 32 size/x
size/y: max 24 size/y
either show-arrow? [
pane: arrow-button
pane/offset: 0x0 pane/offset/x: self/size/x - arrow-button/size/x - 4
arrow-button/size/y: self/size/y
][pane: none]
show self
]
pane: none
init: append copy init [
arrow-button: arrow-button
resize
self/feel: self/dd-feel
]
]
----------------------------------
Cheers,
---
Etienne