Difference between revisions of "Custom Drawn Interface"
Sekelsenmat (talk | contribs) |
Sekelsenmat (talk | contribs) |
||
Line 80: | Line 80: | ||
==Conditional defines accepted by LCL-CustomDrawn== | ==Conditional defines accepted by LCL-CustomDrawn== | ||
+ | |||
+ | Here are defines which affect the functionality offered by this interface: | ||
+ | |||
+ | *CD_UseNativeText - Activates using native text instead of PasFreeType. This define will be automatically set if convenient for a particular backend | ||
+ | |||
+ | And here debug information defines: | ||
*VerboseCDPaintProfiler - Adds profiling information to indicate how fast the paint event is processed | *VerboseCDPaintProfiler - Adds profiling information to indicate how fast the paint event is processed |
Revision as of 17:59, 13 December 2011
Other Interfaces
- Lazarus known issues (things that will never be fixed) - A list of interface compatibility issues
- Win32/64 Interface - The Windows API (formerly Win32 API) interface for Windows 95/98/Me/2000/XP/Vista/10, but not CE
- Windows CE Interface - For Pocket PC and Smartphones
- Carbon Interface - The Carbon 32 bit interface for macOS (deprecated; removed from macOS 10.15)
- Cocoa Interface - The Cocoa 64 bit interface for macOS
- Qt Interface - The Qt4 interface for Unixes, macOS, Windows, and Linux-based PDAs
- Qt5 Interface - The Qt5 interface for Unixes, macOS, Windows, and Linux-based PDAs
- GTK1 Interface - The gtk1 interface for Unixes, macOS (X11), Windows
- GTK2 Interface - The gtk2 interface for Unixes, macOS (X11), Windows
- GTK3 Interface - The gtk3 interface for Unixes, macOS (X11), Windows
- fpGUI Interface - Based on the fpGUI library, which is a cross-platform toolkit completely written in Object Pascal
- Custom Drawn Interface - A cross-platform LCL backend written completely in Object Pascal inside Lazarus. The Lazarus interface to Android.
Platform specific Tips
- Android Programming - For Android smartphones and tablets
- iPhone/iPod development - About using Objective Pascal to develop iOS applications
- FreeBSD Programming Tips - FreeBSD programming tips
- Linux Programming Tips - How to execute particular programming tasks in Linux
- macOS Programming Tips - Lazarus tips, useful tools, Unix commands, and more...
- WinCE Programming Tips - Using the telephone API, sending SMSes, and more...
- Windows Programming Tips - Desktop Windows programming tips
Interface Development Articles
- Carbon interface internals - If you want to help improving the Carbon interface
- Windows CE Development Notes - For Pocket PC and Smartphones
- Adding a new interface - How to add a new widget set interface
- LCL Defines - Choosing the right options to recompile LCL
- LCL Internals - Some info about the inner workings of the LCL
- Cocoa Internals - Some info about the inner workings of the Cocoa widgetset
Introduction
LCL-CustomDrawn-Android has the following features:
- Backends for X11, Android and Windows and a partially working one for Cocoa, more can be added in the future
- Painting is done completely inside Lazarus without any interference from the native libraries except for text drawing. This assures a complete perfection of the executed drawings in all platforms and a uniform level of supported features
- Only 1 native window is utilized for each form, in the Android backend at the moment this is 1 native window for the entire application
- Utilizes the Lazarus Custom Drawn Controls for implementing the LCL standard controls
- Utilizes as it's painting engine the lcl parts: TLazIntfImage, TRawImage, lazcanvas and lazregions
FAQ
Comparison of LCL-CustomDrawn and LCL-fpGUI
Item | LCL-fpGUI | LCL-CustomDrawn |
---|---|---|
Native handles | fpGUI uses 1 native window for each control | LCL-CustomDrawn uses 1 native window for each form in X11, Cocoa and Windows and 1 native surface for all forms in Android |
Canvas implementation | fpGUI uses native Canvas routines from the platform | LCL-CustomDrawn uses only native text metrics/rendering and everything else from canvas drawing is implemented by TRawImage+TLazIntfImage+TLazCanvas. But even a non-native text rendering might be implemented via freetype or pasfreetype if the platform has no native text rendering. |
Supported platforms | Windows, Windows CE and Linux (via X11) | Windows, Cocoa (Mac OS X), X11 (Linux) and Android |
Level of indirection | fpGUI acts as an intermediary between the LCL and the platform | There are no intermediaries, the LCL talks directly to each platform |
Adaptation for platforms without native sub-windows | fpGUI would need extensive changes to work in platforms which do not have native sub-controls, for example Android, linux framebuffer, OpenGL | LCL-CustomDrawn is designed from the start to work on very limited platforms, for example the Linux Framebuffer, an Android SurfaceView or OpenGL |
LCL Adaptation | fpGUI is a separate unrelated framework. It's controls and Canvas APIs do not necessary match what is required by the LCL | LCL-CustomDrawn is designed to perfectly implement all features from the LCL and perfectly paint it's Canvas drawing routines like LCL-Win32, LCL-Gtk2 and LCL-Qt do |
How to port the LCL to a new platform using this widgetset? | First you need to port fpGUI and then verify if LCL-fpgui keeps working | You can port LCL-CustomDrawn directly to new platforms by implementing a new backend which contains support for form, application and and other parts |
More comments on why developing LCL-CustomDrawn instead of LCL-fpGUI: Just to start with, it is the correct architecture. There is no need for an intermediary API which complicates the architecture and makes debugging and porting harder. We can do everything directly without it and greatly simplify our code. Also, by eating our own dog food we ensure that our platform is more strongly tested and has a higher quality. Each feature in LCL-CustomDrawn is implemented using other more basic features. For example TButton, TPageControl and all other visual controls are implemented with TCanvas, so it guarantees that our Canvas drawing is in excellent shape. Drawing in LCL-CustomDrawn is executed via LCL classes: TRawImage, TLazIntfImage and TLazCanvas. If there is an intermediary API then porting the LCL means first porting the intermediary API and debugging it and then debug the combined package. LCL porters should not need to learn unrelated frameworks to port the LCL.
On top of that, LCL-CustomDrawn is designed from the start to be portable to even the most spartan and problematic of platforms. It requires from the platform only a raster surface in any pixel format and also input events. From that onwards we can implement everything else non-natively. There are non-native implementations of Forms, WinControls, standard controls, TCanvas drawing, dialogs and even text can be provided if necessary. Each backend can select its mix of non-native / native elements, although they should never attempt to implement TWinControl natively. fpGUI on the other hand would need a large rewrite to be able to support this level of portability.
The LCL-CustomDrawn Backends
LCL-CustomDrawn needs backends to implement the most basic parts of the widgetset. Each backend should implement the following minimal parts:
- TWidgetSet.Run, ProcessMessages, etc
- TForm
- TWinControl with all events
- TTrayIcon
LCL-CustomDrawn-Android
This backend is working. See this page Custom Drawn Interface/Android
And also Android Programming
LCL-CustomDrawn-X11
This backend is working. See Custom Drawn Interface/X11
LCL-CustomDrawn-Cocoa
This backend is working.
LCL-CustomDrawn-Windows
This backend is working.
LCL-CustomDrawn-iPhone
This is planned, but not yet started.
Canvas
TCanvas will be fully non-native in this widgetset and based on LazCanvas. All drawings to visual controls and on the OnPaint event of controls of the form are naturally double-buffered because the entire drawing of the form is first performed on an off-screen buffer and then copied in 1 operation to the form native canvas. In reality there is only 1 TLazCanvas for the entire form, but sub-controls will think they are on a separate canvas because the property BaseWindowOrg sets an internal start position of the canvas and also because all drawings will be clipped to reflect the size and shape of the sub-control.
Font rendering
This area is still not decided, it might be made selectable to use either the native text renderer of the platform or PasFreeType.
Windowed visual controls
All Windowed visual controls (TButton, TPageControl, etc) will be based in the Lazarus Custom Drawn Controls
Conditional defines accepted by LCL-CustomDrawn
Here are defines which affect the functionality offered by this interface:
- CD_UseNativeText - Activates using native text instead of PasFreeType. This define will be automatically set if convenient for a particular backend
And here debug information defines:
- VerboseCDPaintProfiler - Adds profiling information to indicate how fast the paint event is processed
- VerboseCDWinAPI - Extended verbose information for LCLIntf calls, except those which are covered by one of these defines instead:
- VerboseCDText - Verbose info for text winapi calls
- VerboseCDDrawing - Verbose info for Canvas and drawing operations
- VerboseCDBitmap - Verbose info for Bitmap and rawimage creation and handling
- VerboseCDForms - Extended verbose information for TWSCustomForm methods and about the non-native form from customdrawnproc (when utilized)
- VerboseCDEvents - Extended verbose information for native events (for example mouse click, key input, etc). This excludes the paint event
- VerboseCDPaintEvent - Debug info for the paint event
- VerboseCDApplication - Verbose info for App routines from the Widgetset object
- VerboseCDMessages - Verbose info for messages from the operating system (Paint, keyboard, mouse)