Adding a new interface: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Adding a new interface
| Old | New | Line | |
|---|---|---|---|
| 1 | + | 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. | |
| 2 | + | ||
| 3 | + | ## Steps | |
| 4 | + | ||
| 5 | + | As example we write the steps for adding a new interface for the *pogo* widget set. | |
| 6 | + | ||
| 7 | + | ### Register the new widgetset in the IDE | |
| 8 | + | ||
| 9 | + | In the file lcl/interfacebase.pp add *lppogo* to TLCLPlatform add 'pogo' to LCLPlatformDirNames. Add 'pogo' to ide/lazconf.pp (LCLPlatformDisplayNames). | |
| 10 | + | ||
| 11 | + | 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. | |
| 12 | + | ||
| 13 | + | ### Create a directory for the interface | |
| 14 | + | ||
| 15 | + | Create a subdirectory pogo in lazarus\lcl\interface. | |
| 16 | + | ||
| 17 | + | 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]]: | |
| 18 | + | ||
| 19 | + | For *nix: | |
| 20 | + | ||
| 21 | + | ` cd lazarus/lcl/interfaces/pogo`\ | |
| 22 | + | ` export FPCDIR=/home/username/fpc_sources_trunk/`\ | |
| 23 | + | ` fpcmake -Tall`\ | |
| 24 | + | ` export FPCDIR=` | |
| 25 | + | ||
| 26 | + | For windows: | |
| 27 | + | ||
| 28 | + | ` cd lazarus\lcl\interfaces\pogo`\ | |
| 29 | + | ` set FPCDIR=lazarus\fpc\source`\ | |
| 30 | + | ` lazarus\fpc\2.3.1\bin\i386-win32\fpcmake -Tall`\ | |
| 31 | + | ` set FPCDIR=` | |
| 32 | + | ||
| 33 | + | 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. | |
| 34 | + | ||
| 35 | + | Then copy the interfaces.pp from one of the other widgetsets and adapt it. For example rename the widgetset class to TPogoWidgetSet. | |
| 36 | + | ||
| 37 | + | 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. | |
| 38 | + | ||
| 39 | + | ### Update Makefiles | |
| 40 | + | ||
| 41 | + | Edit lazarus\lcl\interfaces\Makefile.fpc and append *pogo* to the Target directories | |
| 42 | + | ||
| 43 | + | [target] | |
| 44 | + | dirs=gtk gtk2 win32 wince qt carbon fpgui pogo | |
| 45 | + | ||
| 46 | + | Generate the Makefile in lazarus\lcl\interfaces using [[Fpcmake]]. | |
| 47 | + | ||
| 48 | + | ### Add widgetset directory to update_allunits | |
| 49 | + | ||
| 50 | + | 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 | |
| 51 | + | ||
| 52 | + | ` instantfpc ./update_allunits.lpr` | |
| 53 | + | ||
| 54 | + | Or you could run | |
| 55 | + | ||
| 56 | + | ` lazbuild ./update_allunits.lpr`\ | |
| 57 | + | ` ./update_all_units` | |
| 58 | + | ||
| 59 | + | You can now compile your new widgetset in the IDE, by setting the widgetset in the 'Configure build lazarus' dialog. | |
| 60 | + | ||
| 61 | + | ### Compiler options / search paths | |
| 62 | + | ||
| 63 | + | 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 LCL.lpk. Otherwise: ask Mattias via mail. | |
| 64 | + | ||
| 65 | + | --- | |
| 66 | + | *From the Free Pascal wiki, page "Adding a new interface", as it stood on 2021-02-21 after a change by Mattias2, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 67 | + | Category: LCL | |
| 68 | + | Category: Widgetsets |
