Wiki-KopieMirror

Dies ist ein Mirror des Wikis von pascal.chat. Bearbeiten, Verlauf und Anmeldung finden dort statt.

Carbon interface internals/de

Deutsch · English

Einleitung

Diese Seite bietet einen Überblick über die LCL Carbon Schnittstelle für macOS und soll neuen Entwicklern helfen.

Für die Installation und Erzeugung einer ersten Carbon Anwendung lesen sie zunächst Carbon Interface.

Andere Schnittstellen

Artikel über die Entwicklung von Schnittstellen

Dokumentation über Carbon

Die Carbon API unit von FreePascal ist FPCMacOSAll.pas in /usr/local/share/fpcsrc/packages/extra/univint.

Carbon Schnittstelle Entwicklungs-Grundlagen

Was funktioniert bereits ?

Was muss als nächstes getan werden ?

Siehe Bug Tracker Carbon open issues

Carbon IDE Bugs

<thead>

</thead> <tbody>

File New should be Cmd+N<br /> File Save As should be Shift+Cmd+S<br /> File Quit should be Cmd+Q<br /> Search Find should be Cmd+F<br /> Search Find Next should be Cmd+G<br /> Search Find Previous should be Shift+Cmd+G<br /> (Goto line and Procedure List need to be reassigned)<br /> Option+Cmd+F does not bring up Search Results<br /> F11 behaves weird!</td>

</tbody>

Siehe 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:

Screenshot taking

The only possible efficient way of taking a screenshot on macOS is using OpenGL. Apple provides a demonstration function which returns a CGImageRef with the screenshot. This function was converted to Pascal and is available on the glgrab.pas unit on the carbon interface directory. This function requires the Apple-specific parts of the Apple OpenGL headers, and those didn't exist yet in Pascal at this point, so the headers were translated and are placed on opengl.pas until they are released on a stable Free Pascal.

It isn't possible to directly access the bytes of a CGImageRef, and the Screenshot taking rountine (TWidgetset.RawImage_fromDevice) requires doing that, so the image needs to be drawn to a CGContextRef which uses a memory area allocated by us as buffer. This painting has the great advantage of converting from the internal format of the screenshot bytes to the very convenient ARGB, 32-bits depth, 8-bits per channel format that is default to LCL.

Kompatibilitätsprobleme

These are things that will probably never be solved.

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

Release mouse capture is not supported

Kommandozeilenparameter

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 wird nicht unterstützt

TForm

TEdit.PasswordChar different then default is not supported

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

TListBox.Columns wird nicht unterstützt

TComboBox

TPanel.Bevelxxx: bvLowered und bvSpace werden nicht unterstützt

TBitBtn.Spacing is not supported

TTrackBar

TProgressBar

TColorDialog.Title is not supported

Wie man ein neues Bedienelement hinzufügt

Zum Beispiel TButton.

TButton wird definiert in lcl/buttons.pp. Dies ist der plattformunabhängige Teil der LCL, welcher vom normalen LCL Programmierer benutzt wird.

Seine widgetset Klasse befindet sich in lcl/widgetset/wsbuttons.pp. Dies ist die plattformabhängige Basis für alle widgetsets (carbon, gtk, win32, ...).

Seine Carbon Schnittstellenklasse ist in lcl/interfaces/carbon/carbonwsbuttons.pp:

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

Jede WS Klasse, die tatsächlich etwas implementiert, muss registriert werden. Schauen sie sich den initialization Abschnitt am Ende der carbonwsXXX.pp Unit an:

text
 RegisterWSComponent(TCustomButton, TCarbonWSButton);

TCarbonWSButton setzt CreateHandle außer Kraft und erzeugt eine Carbon-Schaltfläche-Helfer-Klasse namens TCarbonButton in carbonprivate.pp, die die Schaltfläche in Carbon erzeugt und die Event-Handler installiert.


From the Free Pascal wiki, page "Carbon interface internals/de", as it stood on 2019-12-17 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Version 6, zuletzt geändert von WikiArchive .