Difference between revisions of "Cocoa Internals"
Sekelsenmat (talk | contribs) |
Sekelsenmat (talk | contribs) |
||
Line 1: | Line 1: | ||
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. | 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. | ||
+ | |||
+ | {{Other Interfaces}} | ||
=LCL specific ObjC classes= | =LCL specific ObjC classes= |
Revision as of 15:56, 12 November 2015
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.
Other Interfaces
- Lazarus known issues (things that will never be fixed) - A list of interface compatibility issues
- Win32/64 Interface - The Windows API (formerly Win32 API) interface for Windows 95/98/Me/2000/XP/Vista/10, but not CE
- Windows CE Interface - For Pocket PC and Smartphones
- Carbon Interface - The Carbon 32 bit interface for macOS (deprecated; removed from macOS 10.15)
- Cocoa Interface - The Cocoa 64 bit interface for macOS
- Qt Interface - The Qt4 interface for Unixes, macOS, Windows, and Linux-based PDAs
- Qt5 Interface - The Qt5 interface for Unixes, macOS, Windows, and Linux-based PDAs
- GTK1 Interface - The gtk1 interface for Unixes, macOS (X11), Windows
- GTK2 Interface - The gtk2 interface for Unixes, macOS (X11), Windows
- GTK3 Interface - The gtk3 interface for Unixes, macOS (X11), Windows
- fpGUI Interface - Based on the fpGUI library, which is a cross-platform toolkit completely written in Object Pascal
- Custom Drawn Interface - A cross-platform LCL backend written completely in Object Pascal inside Lazarus. The Lazarus interface to Android.
Platform specific Tips
- Android Programming - For Android smartphones and tablets
- iPhone/iPod development - About using Objective Pascal to develop iOS applications
- FreeBSD Programming Tips - FreeBSD programming tips
- Linux Programming Tips - How to execute particular programming tasks in Linux
- macOS Programming Tips - Lazarus tips, useful tools, Unix commands, and more...
- WinCE Programming Tips - Using the telephone API, sending SMSes, and more...
- Windows Programming Tips - Desktop Windows programming tips
Interface Development Articles
- Carbon interface internals - If you want to help improving the Carbon interface
- Windows CE Development Notes - For Pocket PC and Smartphones
- Adding a new interface - How to add a new widget set interface
- LCL Defines - Choosing the right options to recompile LCL
- LCL Internals - Some info about the inner workings of the LCL
- Cocoa Internals - Some info about the inner workings of the Cocoa widgetset
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)
LCL Control | Cocoa class | Notes |
---|---|---|
TMemo | NSTextView inside a NSScrollView | - |
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.
- 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;
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
Example of NSCell usage is CocoaStatusBar drawing
Fonts
NSFont class provides a number of class methods to get proper system font without selecting the font by name. The same of getting system-native font size.