Difference between revisions of "Adding a new interface"

From Free Pascal wiki
Jump to navigationJump to search
Line 6: Line 6:
 
=== Register the new widgetset in the IDE ===
 
=== Register the new widgetset in the IDE ===
  
Add 'pogo' to ide/lazconf.pp. And ''lppogo'' to lcl/interfacebase.pp.
+
Add 'pogo' to ide/lazconf.pp and ''lppogo'' to lcl/interfacebase.pp.
 
Then rebuild the IDE with the LCL and restart it. You should now see the new wigdetset in the 'Configure build lazarus' dialog.
 
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 now about it and basic code functions will work.
+
Now the codetools know about it and basic code functions will work.
  
 
=== Create a directory for the interface ===
 
=== Create a directory for the interface ===

Revision as of 12:27, 15 February 2008

This article describes the steps to add a new wdiget set 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.

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 and lppogo to lcl/interfacebase.pp. 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:

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

You must use the latest and greatest and unstable FPC sources, so that all FPC platforms are known in the Makefile. 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.

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.