Cocoa Internals

This is an old revision of Cocoa Internals, edited by Skalogryz at . The current revision is 95286.

/* Code Style */

The page is about Cocoa Widgetset internal implementation. The page should be useful for Cocoa widgetset developers (maintainers and/or constributors) as well as any developers who need to use Cocoa specific API.

LCL specific ObjC classes

In order to control and handle an NSView's behavior LCL uses decedent classes from standard Cocoa controls. I.e. for NSWindow TCocoaWindow is introduced. The decedent are used for the purpose of "overriding" default class implementation, where it is needed. In some cases using delegate classes is not enough.

Handles

Code Style

The following requirement applies for Cocoa widgetset. Other widgetset my be following some other rules (historically), but in general LCL follows the same requirements.

 A := B; 
 A := B * C;
procedure B;
begin
  if A then // 2 character spacing from begin
  begin
    Start Here // 2 character spacing from begin
    Next Line
  end
  else
  begin
    Another Line
  end;
end;
 if not Assigned(A) then
 begin
   Result := nil;
 end;

Themed Drawing / Custom Controls

HITheme API is deprecated by Apple together with Carbon. It's still available in OSX, but for i386 only. Presumably will be completely removed on 64-bit only OSX.

However, some LCL controls cannot be mapped to existing Cocoa provided controls and thus might require some "custom drawing". The drawing should look system native though. In order to achieve that NSCell family could be used. NSCell allows to draw (hit-test and as well as handle user input) for OSX native elements. If Apple to change appears of controls (cells), the LCL application would "pick-up" the look automatically.

In order to be drawn NSCells requires a present of NSView, thus it's hard to use them forthe implementation of LCL TTheme APIs