[Lazarus] (how) is it possible to add a new "Widget Type" to Lazarus, using a Lazarus packet ?

Michael Schnell mschnell at lumino.de
Tue Mar 30 11:14:30 CEST 2010


In fact I found that it's very easy to create and debug your own Widget
Type. You just create a unit called "interface" and add it to the project.

I suppose adding the directory to the path would suffice. (So, using a
Lazarus Package, the "application generator" defined by same can be
configured to offer an Application Type using a new Widget Type, even if
same can't be selected in the "Project Options" yet.)

Doing this, I succeeded in enhancing the "NoGUI" Widget Type to be
slightly less dummy than it was. Now I can create a (simple !!! but
working) normal (GTK2) Application and afterwards set the Widget Type to
NoGUI in the "Project Options" (or add the new units (including
"Interface") to the Project (or Path) ), and I can compile and run the
project without changing the source code.

(The original NoGUI Widget Type allowed to compile the project but when
running it, it crashed within "Application.CreateForm, as the TForm this
Widget Type creates, does not get a handle.)

Of course the new Widget type does nothing useful yet, other than create
an invisible dummy form, but in "Application.CreateForm", it calls the
form's "OnCreate" and "OnActivate" events before it stops in
"Application.Run".

What I did, is just define the Classes TNOGUIWSCustomForm,
TNoGUIPrivateScrollingWinControl, and TNoGUIWSScrollingWinControl and
have them registered when the Widget Type is registered with the
application. (The current NoGUI application was a nice template for
that, enhancements made according to the GTK2 Widget Type code.) The
only code that is performed in the new classes is create a handle <> 0
so that the "Forms" unit thinks the Widget for the appropriate TForm
decedent is successfully created.

-Michael.

P.S.: What is the current version of the NoGUI Widget Type actually used
for ? I supposed it can be used together with FPGUI, but this in fact is
another predefined Widget Type.... ?

Thanks, -Michael




More information about the Lazarus mailing list