Carbon interface internals/fr

From Lazarus-ccr

Jump to: navigation, search

Deutsch (de) English (en) Français (fr)

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.

Contents

[edit] Documentation about Carbon

Apple Carbon docs

Carbon Book for download

Carbon Dev

"Learning Carbon" sample book chapter

Free Pascal's Carbon API unit is FPCMacOSAll.pas in /usr/local/share/fpcsrc/packages/extra/univint.

[edit] Carbon interface development basics

  • Target Mac OS X version is 10.4
  • Avoid using obsolete or deprecated APIs and functions (e. g. QuickDraw vs. Quartz 2D)
  • Use object approach
  • Check Carbon calls result with OSError function
  • Assume UTF-8 encoded strings between LCL and Carbon widgetset (for future Lazarus Unicode support)

[edit] What is already working ?

Working components in the Carbon interface

[edit] What needs to be done next?

Item Note Dependencies Responsible
Mouse Capture releasing
TBrush PatternsCGPatternCreate
ScreenDCCGDisplayCapture, CGDisplayGetDrawingContext - CGDisplayCapture locks screen!TCarbonScreenContext
StretchMaskBltImplement: ROP, stretch mode
TCalendarno counterpart
TFontDialogFPShowHideFontPanel
TListViewCreateDataBrowserControl
TScrollBox, TCustomControl with scrollbars, TScrollingWinControlHIScrollViewCreate Tombo
TClipboardPasteboardCreate

[edit] Bugs

Item Note Dependencies Responsible
TCustomControl - keyboard focus
TCustomEdit.CharCaseIs ignored when typing text
TMemo.WordWrappersistent bug, when word wrap is disabled the memo doesn't scroll to caret
TMaskEditEvery typed char is doubled

[edit] Compatibility issues

[edit] Keyboard

  • Apple Command key is mapped to ssCtrl per Apple Guidelines
  • Apple control key is mapped to ssMeta
  • Apple option key is mapped to its inscription, i.e. ssAlt
  • Virtual key codes mapping (depends on keyboard language layout!)
  • Shortcuts indication (ampersand)

[edit] Drawing on canvas outside OnPaint event

  • paints into QuickDraw window port, maybe QDBeginCGContext, QDEndCGContext would help

Note that Quickdraw is deprecated as of Mac OS X 10.5, so in the long term this needs another solution.

[edit] TControl.Color

  • background of Carbon controls is transparent

[edit] 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.