LCL Defines

From Free Pascal wiki
Jump to: navigation, search

English (en) français (fr)

This page documents the defines that can be utilized to recompile the different widgetsets of LCL. It isn´t a compreensive list, but may become one as more defines are added.

Other Interfaces

Platform specific Tips

Interfaces Development Articles

Why use defines?

Defines allow to add non-standard functionality to LCL, test experimental features or to add debug output that helps testing the widgetsets.

Recompiling LCL with a define

To recompile LCL with a special define go to the Lazarus menu Tools -> "Configure Build Lazarus"

There add -d<DEFINE_NAME> on the Options box.

So if you wish to add the PassWin32MessagesToLCL define, you will add -dPassWin32MessagesToLCL to this box.

General LCL defines

  • DEBUG_SHELLCTRLS - Turns on the use of writelns to output debug information for the shellctrls unit.

Win32 defines

  • DisableWindowsUnicodeSupport - Turns off Unicode support on Windows. The win32 interface gives string in ansi encoding to the LCL (instead of UTF8).

WinCE defines

  • VerboseWinCE - Turns on the use of writelns to output debug information. Useful in desktop windows to trace bugs which are reproducible in the desktop too.

Gtk defines

DebugLCLComponents

This activates saving information on every creation or destruction of LCL components, device contexts, gdi objects (pen, brush, font, ...) and main widgets. It will spot mem leaks and double frees with stacktraces.

TraceGDICalls

This activates saving information on every creation or destruction of gdi objects (pen, brush, font, ...). It will spot mem leaks and double frees with stacktraces.

GTK2_USE_OLD_CAPTURE

As of lazarus 0.9.29 r27638 we use new way of capturing (TGtk2WidgetSet.SetCapture). Old way can be reached with this define. It's used only for debugging purposes (eg. diff in capturing before old & new code) if some bug is filled against gtk2 capturing.

USE_GTK_MAIN_OLD_ITERATION

As of lazarus 0.9.29 r27896 we use g_main_context* instead of g_main* which is deprecated from gtk2-2.2. This define fixes sending/receiving messages via PostMessage() from other threads than main.Also, we hook g_main_context's poll function to make g_main_context_wakeup accurate.From glib2 >= 2.24 g_main_context_wakeup is enough, but for smaller versions we need to check if new message arrived (from another thread), and interrupt main_context_iteration. For those who want to use deprecated gtk_main_* there's USE_GTK_MAIN_OLD_ITERATION.


GTK2OLDENUMFONTFAMILIES

As of lazarus 0.9.31 r35400 TGtk2WidgetSet.EnumFontFamiliesEx() does not use raw X11 fonts naming, but pango via fontconfig. Old fashioned font names can be used with this define.


GTK2USEDUMMYNOTEBOOKPAGE

As of lazarus 1.1 svn revision 39882 dummy notebook page isn't used anymore for gtk2 notebook. If some old gtk2 version needs it just use this define and pls. report issue about gtk2 version and needed dummy notebook page.

Qt defines

You can use the following defines while building LCL to configure your Qt Interface:

  • USE_QT_4_3 - The default Qt version utilized by the interface is 4.2 or superior. By setting this define you allow the interface to use 4.3+ features, like MDI Forms. - Made default and removed as of 0.9.25
  • VerboseQt - Writes extensive debug information about the creation and deletion of Qt objects and LCL Objects to the StdOut.
  • VerboseQtWinAPI - Writes extensive debug information about the Qt implementation of the functions on the LCLIntf unit to StdOut.
  • VerboseQtEvents - Writes extensive debug information about qt events passed via event filter to the StdOut.If defined VerboseQt then this define isn't needed.
  • QT_HIDDEN_BUTTON_WORKAROUND - This activates a work around for a LCL miss-behavior which makes it create a hidden button to overcome some Gtk problem. This should be removed after LCL is fixed. Link for the bug: http://www.freepascal.org/mantis/view.php?id=9152
  • QT_LAZARUS_IDE_WORKAROUND - Activates workaround for invisible mainmenu inside lazarus ide, also moving offsets of TGraphicControl descendants , because geometry of form doesn't take TMainMenu height and TToolbar height into account. This should be removed, as soon as we fix offsets, and accounting of TMainMenu & TToolBar height.
  • VerboseQtWinAPI_MISSING_IMPLEMENTATION - Writes extensive debug information about the MISSING Qt implementation of the functions on the LCLIntf unit to StdOut.
  • VerboseQtWinAPI_DEBUG_CLIPBOARD - Writes extensive debug information about LCL clipboard operations.
  • QT_NO_MENU_EFFECTS - Turns off menu effects, fading and animating, which sometimes produces problems (eg. stays visible even they are closed). It is also possible that this is an Qt bug, but have to check it first.
  • USE_QT_44 - The default Qt version utilized by the interface is 4.3 or superior. By setting this define you allow the interface to use qt 4.4 features like better QPrinter,QPainter support etc.Also, if you use this define, you must download qt bindings for 4.4 (1.66 or superior). as of lazarus svn r 21913 qt-4.5.X is default (no more USE_QT_XX defines).
  • USE_QT_45 - The default Qt version utilized by the interface is 4.3 or superior. By setting this define you allow the interface to use qt 4.5 features like better QPrinter,QPainter support etc.Also, if you use this define, you must download qt bindings for 4.5 (1.69 or superior). as of lazarus svn r 21913 qt-4.5.X is default (no more USE_QT_XX defines).
  • QTOPIA - Build for qtopia/embedded Qt Interface. See also Supported Platforms of FreePascal Qt4 binding.Do not use QTOPIA define (comment it) if you build qt application for eg. Nokia N9 phone (arm) - it's pure X11 app, so QTOPIA must be off.
  • QT_NATIVE_DIALOGS - Build with native dialogs (TOpenDialog, TSaveDialog ...). In that case there's no eg. OnFilterChanged() events since qt uses static functions for native dialogs.
  • QTDIALOGS_USES_QT_LOOP - As of lazarus svn r23536 qtlcl uses LCL loop for QDialog and QFileDialog classes (TQtDialog, TQtMessageBox, TQtFileDialog).If you want to use "old" (original qt way) then you can use this define, and QDialogs should run in it's own loop managed by qt.This define doesn't do anything in case we use QT_NATIVE_DIALOGS (for TQtFileDialog only).
  • QTSizeFix - fixes resizing overhead by reducing InvalidateClientRectCache() calls to minimum.Now only TQtPage calls it from resize event. Works ok with -dOldAutoSize and especially with new autosize algorithms.Will be set as default soon (and removed define). as of lazarus svn revision 25065 this is default behaviour, define removed.
  • QT_ENABLE_LCL_PAINT_TABS - as of r25354 used to allow LCL to paint over tabwidget tabs. PaintEvent from tab provides rect in tab coordinates.
  • QT_DRAWTEXT_MAP_TO_CLIPRECT - there's an issue (fixed already) [1] about TCanvas.TextRect() with qtlcl.If you enable QT_DRAWTEXT_MAP_TO_CLIPRECT then qt will paint your text with respect to DT_WORDBREAK (testpaintrect_2.png), otherwise it works like other widgetsets (testpaintrect_1.png).
  • VerboseQtCustomControlResizeDeadlock - Writes debug information about intercepted deadlocks inside TQtCustomControl when resized.
  • DebugQtGDIObjects - writes debug info about TQtGdiObjects class (checks validity of HGDIObj in IsValidGDIObject())
  • QTSCROLLABLEFORMS - Central widgets of forms are QAbstractScrollArea class, this is enabled by default except if QTCOCOA define is enabled.If you want less cpu/memory intrusive TCustomForms then uncomment this define.In that case we use QWidget as central widget of TCustomForm, but in that case there's no scrollbars in TCustomForm (eg. TCustomForm.AutoScroll means nothing, same applies to TCustomForm.Vertical & Horizontal scrollbars.
  • QTCOCOA - Automatically enabled if we are on DARWIN and CPU=64bit.If this define is enabled QTSCROLLABLEFORMS is disabled.When QTSCROLLABLEFORMS is enabled with QTCOCOA there are various crashes which aren't fixed yet.

Carbon defines

List of Carbon defines used to show debug info when tracing:

  • DebugEventLoop
  • VerboseObject - Carbon interface application
  • VerboseTimer
  • VerboseWinAPI
  • VerboseLCLIntf
  • VerboseMouse
  • VerboseCursor
  • VerboseKeyboard
  • VerbosePaint
  • VerboseCanvas
  • VerboseMenu
  • VerboseScroll
  • VerboseWidget - TCarbonWidget class
  • VerboseAppEvent - Carbon application event handlers
  • VerboseControlEvent - Carbon control event handlers
  • VerboseWindowEvent - Carbon window event handlers
  • VerboseCommonEvent - Carbon common event handlers
  • VerboseWSClass - TCarbonWS classes
  • VerboseCarbonTrayIcon - TCarbonWSTrayIcon verbose mode

Other defines:

  • CarbonUseCocoa - Activates using Cocoa controls. Removed in Lazarus 0.9.29
  • CarbonDontUseCocoa - Deactivates using Cocoa controls. Added in Lazarus 0.9.29
  • CarbonUsePrivateAPIs - Activates using _NSGetCarbonMenu in TTrayIcon. Not very useful at the moment.