Difference between revisions of "Adding a new interface"

From Free Pascal wiki
(added info for update_allunits)
Line 45: Line 45:
 
</pre>
 
</pre>
 
Generate the Makefile in lazarus\lcl\interfaces using [[Fpcmake]].
 
Generate the Makefile in lazarus\lcl\interfaces using [[Fpcmake]].
 +
 +
=== Add widgetset directory to update_allunits ===
 +
Add a line in lcl/update_allunits.lpr for the ''pogo'' widgetset. You will need to run this program as you implement the PogoWSxxxx units. I used
 +
  instantfpc ./update_allunits.lpr
 +
Or you could run
 +
  lazbuild ./update_allunits.lpr
 +
  ./update_all_units
  
 
You can now compile your new widgetset in the IDE, by setting the widgetset in the 'Configure build lazarus' dialog.
 
You can now compile your new widgetset in the IDE, by setting the widgetset in the 'Configure build lazarus' dialog.

Revision as of 00:04, 20 October 2011

This article describes the steps to add a new widgetset interface. This article is intended for developers who want to make an existing widget set available for use with the LCL. It describes the first steps to set up the directories and adapt the IDE for developing the new interface.

Other Interfaces

Platform specific Tips

Interface Development Articles

Steps

As example we write the steps for adding a new interface for the pogo widget set.

Register the new widgetset in the IDE

Add 'pogo' to ide/lazconf.pp. In the file lcl/interfacebase.pp add lppogo to TLCLPlatform add 'pogo' to LCLPlatformDirNames. In ide/compileroptions.pp add an entry to LCLWidgetLinkerAddition.

Then rebuild the IDE with the LCL and restart it. You should now see the new wigdetset in the 'Configure build lazarus' dialog. Now the codetools know about it and basic code functions will work.

Create a directory for the interface

Create a subdirectory pogo in lazarus\lcl\interface.

Then copy the Makefile.fpc from one of the existing widgetsets and adapt it. For example change the unittargetdir. Then create the Makefile with Fpcmake:

For *nix:

 cd lazarus/lcl/interfaces/pogo
 export FPCDIR=/home/username/fpc_sources_2.3/
 fpcmake -Tall
 export FPCDIR=

For windows:

 cd lazarus\lcl\interfaces\pogo
 set FPCDIR=lazarus\fpc\source
 lazarus\fpc\2.3.1\bin\i386-win32\fpcmake -Tall
 set FPCDIR=

You must use fpcmake from the latest and greatest and unstable FPC version, so that all FPC platforms are known in the Makefile. For the source it is less critical. The last line sets the variable FPCDIR to none. Otherwise other Makefiles will be auto regenerated too, which can accidently break things. So better make sure with the last line that FPCDIR is not set.

Then copy the interfaces.pp from one of the other widgetsets and adapt it. For example rename the widgetset class to TPogoWidgetSet.

Then create a first unit pogoint.pp for the new class TPogoWidgetSet. Every widgetset needs to override some abstract methods. Position the blinking cursor on class and use the refactoring tool Source Editor / Popup menu / Refactoring / Show abstract methods to automatically add the method stubs. Don't forget to use pogoint in the new interfaces.pp.

Update Makefiles

Edit lazarus\lcl\interfaces\Makefile.fpc and append pogo to the Target directories

[target]
dirs=gtk gtk2 win32 wince qt carbon fpgui pogo

Generate the Makefile in lazarus\lcl\interfaces using Fpcmake.

Add widgetset directory to update_allunits

Add a line in lcl/update_allunits.lpr for the pogo widgetset. You will need to run this program as you implement the PogoWSxxxx units. I used

 instantfpc ./update_allunits.lpr

Or you could run

 lazbuild ./update_allunits.lpr
 ./update_all_units

You can now compile your new widgetset in the IDE, by setting the widgetset in the 'Configure build lazarus' dialog.


Compiler options / search paths

If the new widgetset has subdirectories or need some extra flags, then these must be added to the Makefile (e.g. lcl/interfaces/pogo/Makefile) and to the codetools components/codetools/definetemplates.pas in method TDefinePool.CreateLazarusSrcTemplate. Search for lcl/interfaces/gtk and see there for some examples. Otherwise: ask Mattias via mail.