Difference between revisions of "Cocoa Internals"

From Lazarus wiki
Jump to navigationJump to search
Line 9: Line 9:
 
** TCustomWSForm it is content NSView.
 
** TCustomWSForm it is content NSView.
 
** Any control that has scroll bars (i.e. TCustomWSList) the it its the embedding NSScrollView (TCocoaScrollView)
 
** Any control that has scroll bars (i.e. TCustomWSList) the it its the embedding NSScrollView (TCocoaScrollView)
 +
=Code Style=
 +
 +
* '''Operators'''  Keep the operator separated by spaces between operands
 +
  A := B;
 +
  A := B * C;
 +
* '''Blocks''' The main rule is to make 2 character spacing from the code block start. Begin / Else should start on a new line.
 +
 +
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;
 +
 +
* '''Standard Function Name''' please keep naming in ProperCase. Reserved words should be lower case. Name of (global/local) variables and fields should match declaration. (local variables should start with lower case)
 +
 +
  if not Assigned(A) then
 +
  begin
 +
    Result := nil;
 +
  end;
 +
 
[[Category:Mac OS]]
 
[[Category:Mac OS]]
 
[[Category:Mac OS X]]
 
[[Category:Mac OS X]]
 
[[Category:Widgetsets]]
 
[[Category:Widgetsets]]

Revision as of 21:42, 15 December 2013

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

  • Window handle (HWND) is always NSView.
    • TCustomWSForm it is content NSView.
    • Any control that has scroll bars (i.e. TCustomWSList) the it its the embedding NSScrollView (TCocoaScrollView)

Code Style

  • Operators Keep the operator separated by spaces between operands
 A := B; 
 A := B * C;
  • Blocks The main rule is to make 2 character spacing from the code block start. Begin / Else should start on a new line.
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;
  • Standard Function Name please keep naming in ProperCase. Reserved words should be lower case. Name of (global/local) variables and fields should match declaration. (local variables should start with lower case)
 if not Assigned(A) then
 begin
   Result := nil;
 end;