[lazarus] Widget vs. Platform Independence

Shane Miller SMiller1 at stvgb.org
Thu Sep 30 14:00:36 EDT 1999


But why not have the call back function simply call  TControl(self).wndproc or something like that.

For example, once the callback gtkshowCB(widget ... ; Data ...;) is called the code would be....
var
msg : TMessage
begin
TControl(data).wndProc(msg);

end;

Now, the problem I see is that if we have a component that isn't declared from TControl, but we can get around that by checking what type the DATA is.  

Shane


>>> "Michael A. Hess" <mhess at miraclec.com> 09/30/99 11:39AM >>>
Samuel Liddicott wrote:
>  
> Michael I am saying we should take the GTK callback handlers we now
> have (you wrote them?) and have THEM call .wndproc instead of
> .dispatch.

The problem is, what wndproc does it call? Which control or component is
it suppose to call? That is what dispatch does. It is a lower level RTL
feature of all classes (objects). The dispatch routine is what routes
the call to the correct control (object). In other words if you had a
form with 3 buttons on it and a button click message was returned by a
GTK button widget, which LCL button does it report to? The message from
GTK doesn't know. All it contains is the Self pointer established when
the LCL class was created. The only way it can send the message to the
correct LCL control is to call dispatch which can determine from the
table that FPC creates which LCL object should be called with the
message.

That is why I asked whether you want to use a global wndproc or one for
every object. A global could be done. One for every object can't easily
be done. The only way it could be done would be to attach the GTK call
backs directly to the LCL object when it was created. Then the messages
from that widget would be returned to the LCL object and that object
only. The problem with this is that means we need to link GTK directly
to the LCL which then blows away the ability to use WIN32 which is what
you are after in the first place. The GTK callback routine must be a
CDECL procedure that is NOT part of a class. It can not be a method of a
pascal class.

What you would have to do is create a message for the LCL controls (I
guess the base class) that is the wndproc method. then you would have to
have all messages (signals) that come in from GTK be sent to the
Dispatch which would call the wndproc for the correct object. Then this
wndproc method would have to have a large case statement to deal with
every kind of message that needs to be dealt with.

Does that get you where you want to go? 

-- 
==== Programming my first best destiny! ====

Michael A. Hess      Miracle Concepts, Inc.
mhess at miraclec.com   http://www.miraclec.com 

_________________________________________________________________
     To unsubscribe: mail lazarus-request at miraclec.com with
                "unsubscribe" as the Subject
    archives at http://www.miraclec.com/list_archives/lazarus






More information about the Lazarus mailing list