[lazarus] Progress

Shane Miller smiller at lakefield.net
Tue Aug 31 22:46:31 EDT 1999


-----Original Message-----
From: Michael A. Hess <mhess at miraclec.com>
To: lazarus at miraclec.com <lazarus at miraclec.com>
Date: Tuesday, August 31, 1999 5:06 PM
Subject: Re: [lazarus] Progress


>Marc Weustink wrote:
>>
>> Why not ?
>
>For the reason I explained right after.
>
>> >The reason is due to the fact that ALL and I mean ALL of the
>> >generation of the Button, how it looks, how it is drawn, how it
>> >reacts to events is found in and controled by the GTK library.
>>
>> OK, but if you found a way to pass drawing to the canvas of the
>> LCL-button to the widget-librar, then I cant see why it's wrong to
>> inherit a LCL button and add your own stuff.\
>
>Because you can't. All of the events that are generated by a component
>are done IN the GTK library. The LCL does not generate any events for
>any components, EVER. It only receives events that are passed to it from
>the GTK lib that were generated by the GTK widget that was made by the
>GTK library. The LCL is acting as a wrapper around the GTK library
>widgets and the wrapper is being made to look like the same kind of
>classes found in Delphi. However the LCL doesn't have any control over
>the widgets themselves. They are made by the GTK lib. You can not
>override the drawing of a GTK widget from within the LCL. That is part
>of the C code within the GTK library.


Actually, you can create new "events" for the components simply by using the
DISPATCH method.  For example, in my code I may need to detect a "move mouse
right" event and a "move mouse left" event.  So in my code I create a const

LM_MOVEMOUSERIGHT = NUMBER;
LM_MOVEMOUSELEFT = NUMBER +1;

then in the mouse move event (that gtk sends) I track and detect if it is
moving right or left.
If moving_right then
    Dispatch(LM_MOVEMOUSERIGHT)
else
   Dispatch(LM_MOVEMOUSELEFT);

in the component, obvoiusly I will have a
Procedure MoveRight(var msg); message LM_MOVEMOUSELEFT;
etc.
In that procedure I do a
If Assigned(SomeProcedure) then
  Someprocedure(sender);

So, to the user of that component it appears to have a movemouseleft and
movemouseright event.
This will not be easy for very complicated events, but that's how it's done.
Think about it, if you create a component that extends itself off of TBUTTON
and want to add events that aren't handled by default, you have to do a
dispatch or call a procedure manually.


------------------------------------------------------------
Shane Miller

Home page : http://www.lakefield.net/~smiller

Auto-IP Publisher : http://www.lakefield.net/~smiller/autoip

Advanced Clipboard : http://www.lakefield.net/~smiller/advclipboard

Lazarus : http://www.miraclec.com/lazarus
----------------------------------------------------------







More information about the Lazarus mailing list