[REBOL] Re: Modal progress dialog
From: adl:absentis at: 14-Apr-2006 16:52
On Fri, Apr 14, 2006 at 12:39:59PM +0200, Gabriele Santilli wrote:
> You can use SHOW-POPUP directly.
> Basically you don't want the WAIT (DO-EVENTS is WAIT []) in the
> last line.
That more or less solves the main problem, thanks, I just have a
couple of details to clean up, here is some example code;
REBOL []
inform-and-process: func [
dlg [object!]
fun [function!] "Function to be run, passed the progress dialog wrapper"
/offset where [pair!] "Offset of panel"
/title ttl [string!] "Dialog window title"
][
dlg/lay/text: copy any [ttl "Dialog"]
dlg/lay/offset: either offset [where] [system/view/screen-face/size - dlg/lay/size /
2]
dlg/lay/feel: system/view/window-feel
dlg/show
fun dlg
dlg/hide
]
my-progress-dialog: make object! [
progress-bar: none
lay: layout [
txt "Process in process, please wait"
progress-bar: progress 200 black red]
set-progress: func ["This doesn't appear to work" val][
progress-bar/data: val
show progress-bar]
show: does [show-popup lay]
hide: does [hide-popup]
]
my-func: func [dlg][
wait 1
for x 1 100 1 [
dlg/progress-bar/data: (x / 100)
show dlg/progress-bar
;dlg/set-progress (x / 100)
wait 0.05
]
]
inform-and-process my-progress-dialog :my-func
You'll see that I prefer to wrap the layout in an object to keep
everything nicely wrapped. It does require that I agree a protocol
with myself but I'll manage. What I do wonder though is why the
commented out line in my-func does not update the progress bar in the
way that the two preceding lines do? Secondly, how would I set up an
event handler to make the dialog un-closeable?
cheers
Andrew