1. Re: VCL
Daniel Berstein wrote:
>About this future ECM, Euphoria Component Model, (ECL would be the
>"standard" components deployed with Euphoria):
>
>A interface API should be developed to command the component
>appearence/functionality. The component should be built providing a defined
>interface. Interfaces may be:
> ECM_Create() -- Creates an instance of the component
> ECM_Destroy() -- Destroys an instance of the component
> ECM_Command() -- Send a component specific command (like WinAPI's
>SendMessage)
> ECM_GetProperty() -- Retrives a component property (data
member)
> etc...
Thanks for the links.
You could fold all those seperate calls into a generic sendMessage command,
much like Win32 does it. You've still encapsulated the functionality, but
implementing the interface to the actual class becomes trivial - just build
a index of routine id's:
-- create a button
MY_BUTTON = sendMessage( CREATE, PressButton, 0, 0 )
-- check if it's pressed
MY_PROPERTY = sendMessage( GET_PROPERTY, MY_BUTTON, PRESSED, 0 )
-- send a button press request
result = sendMessage( SET_PROPERTY, MY_BUTTON, PRESSED, TRUE )
-- destroy the button
result = sendMessage( DESTROY, MY_BUTTON, 0, 0 )
A lot of the Win32Lib calls could be converted to a COM-style calling
structure. For example:
setPosition( myWin, x, y )
could just as easily have an interface of:
ECM_SetProperty( myWin, X, x )
ECM_SetProperty( myWin, Y, y )
or:
sendMessage( myWin, SetProperty, X, x )
sendMessage( myWin, SetProperty, Y, y )
or even just:
sendMessage( myWin, SetProperty, Position, {x,y} )
If Win32Lib was based on a true OO model (like WinMan was), then the COM
approach would make sense. But for the most part, it's driven by the Win32
API. By not trying to bury the Win32 interface, it's possible for someone to
hack into the code and call Win32 directly - as many have chosen to do.
Hiding it all behind a COM-style interface makes it portable, but prevents
that kind of hacking.
I've also noticed that a number of UI implementations have taken a slightly
different spin on the component model. Both Java Swing and the Zinc API have
two seperate components to their UI - the control (a data field), and the
data object represented by the control (a date value).
-- David Cuny