Carbon interface internals

This is an old revision of Carbon interface internals, edited by Sekelsenmat at . The current revision is 16937.

/* Compatibility issues */

This article applies to macOS only.

See also: Multiplatform Programming Guide

This article applies to iOS only.

See also: Multiplatform Programming Guide

Introduction

This page gives an overview of the LCL Carbon interface for Mac OS X and will help new developers.

For installation and creating a first Carbon application refer to Carbon Interface.

Other Interfaces

Platform specific Tips

Interface Development Articles

Documentation about Carbon

Carbon interface development basics

What is already working ?

Working components in the Carbon interface

What needs to be done next?

See Bug Tracker Carbon open issues

Carbon IDE Bugs

Item Note Dependencies Responsible
'...' buttons in dialogs Now they are too large I think
OK/Cancel Many dialogs have non-Mac check-X glyphs
Menu bar Too wide for 1024x768 display resolution
Lazarus menu Help About and app prefs (Environment options) should be accessible here
Menus Many missing or non-standard menu shortcuts: File New should be Cmd+N File Save As should be Shift+Cmd+S File Quit should be Cmd+Q Search Find should be Cmd+F Search Find Next should be Cmd+G Search Find Previous should be Shift+Cmd+G (Goto line and Procedure List need to be reassigned) Option+Cmd+F does not bring up Search Results F11 behaves weird!

See Bug Tracker Carbon IDE open issues

Implementation Details

Keyboard

Application

Drawing and measuring text precisely in parts

If you want to draw (via TextOut, TextRect) or measure (via TextWidth, TextHeight) text divided into various parts and rely it will be displayed same each time not depending on its division, you have to disable some default typographic features (like kerning, fractional positioning, ...) of Canvas. You can choose one of the following:

Compatibility issues

These are things that will probably never be solved.

Mouse.CursorPos changing does not generate mouse (move) events

Release mouse capture is not supported

Command line parameters

Because Carbon applications are executed via Application Bundle, command line parameters are not passed. You have to use OnDropFiles event to detect openning associated files.

Shortcuts indication is not supported

Drawing on Canvas outside OnPaint event is not supported

Drawing on screen device context is not supported

TCustomControl.Color of clBtnFace makes its background transparent

TWinControl.Font fsStrikeOut is not supported

TForm

TEdit.PasswordChar different then default is not supported

TMemo.WordWrap when is disabled, does not allow to scroll text horizontally

TListBox.Columns is not supported

TComboBox

TPanel.Bevelxxx: bvLowered and bvSpace are not supported

TBitBtn.Spacing is not supported

TTrackBar

TProgressBar

TColorDialog.Title is not supported

How to add a new control

For example TButton.

TButton is defined in lcl/buttons.pp. This is the platform independent part of the LCL, which is used by the normal LCL programmer.

Its widgetset class is in lcl/widgetset/wsbuttons.pp. This is the platform independent base for all widgetsets (carbon, gtk, win32, ...).

Its Carbon interface class is in lcl/interfaces/carbon/carbonwsbuttons.pp:

 TCarbonWSButton = class(TWSButton)
 private
 protected
 public
   class function  CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
 end;

Every WS class that actually implements something must be registered. See the initialization section at the end of the carbonwsXXX.pp unit:

 RegisterWSComponent(TCustomButton, TCarbonWSButton);

TCarbonWSButton overrides CreateHandle to create a Carbon button helper class called TCarbonButton in carbonprivate.pp, which really creates the button control in the Carbon and installs event handlers.