[REBOL] Re: /view custom styles
From: dockimbel:free at: 24-Aug-2001 12:05
Hi Max !
Maxim Olivier-Adlhoch wrote:
> I have peeled doc kimbel's win95 skin code and still have not figured
> out how it "hooks" upon view layout, so that it may parse arguments and
> have its own setup dialect?
To answer your question, you can find a patched 'layout function within the
/skin directory. It adds to the standard 'layout function, support for a
new facet called 'init-last, which is called after all the faces are builded.
(I needed this to get the final size of the root face and some other "effects")
In your example, you have to first load my %layout.r script in order to use 'init-last.
The standard 'layout function doesn't know about it and would just ignore it.
VID provides a standard way to "hook": the 'init facet. Just give it a block of code
it will be executed during the layout building. 'init have to be a block, not a function.
About the setup dialect, i use the standard 'action facet. When VID encounters a block,
it stores it in the current face's 'action facet for execution. But sometimes, the purpose
'action is changed and the block is parsed for a sub-dialect instead of been executed
(see 'panel source for example, >> probe get-style 'panel). I use the same trick and
with menu dialect rules. All this is done within 'init-last, but could be done in 'init
'init is the standard way.
PS: Here is a modified source :
title: "vid test"
skin: stylize [
menu: label 100x100 "menu container"
pane: make block! 1
switch-off-all: func [/local item][
foreach item pane [item/state: off]
init-last: function [root][item li][ ; load %skin/layout.r first !
print "FUCK" ; to use 'init-last
print "Oh my god!" ; init have to be a block !
probe second :action ; now you can parse it.
sub-popup: make object! 
builder: make object! 
view layout [
menu [ "hey"]
button "quit" [quit]