Difference between revisions of "Carbon interface internals/de"

From Lazarus wiki
Jump to navigationJump to search
m
m (Deleted page categories already in template; rationalised macOS naming)
 
(39 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{Carbon interface internals}}
 
{{Carbon interface internals}}
  
Diese Seite bietet einen Überblick über die LCL Carbon Schnittstelle für Mac OS X und soll neuen Entwicklern helfen.
+
== 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/de|Carbon Interface]].
 
Für die Installation und Erzeugung einer ersten Carbon Anwendung lesen sie zunächst [[Carbon Interface/de|Carbon Interface]].
 +
 +
==Andere Schnittstellen==
 +
*[[Lazarus known issues (things that will never be fixed)]] - Eine Liste mit Kompatibilitätsproblemen der Schnittstellen
 +
*[[Win32/64 Interface]] - Die winapi Schnittstelle für Windows 95/98/Me/2K/XP/Vista, aber nicht CE
 +
*[[GTK2 Interface]] - Die gtk2 Schnittstelle für Unixes, macOS, Windows
 +
*[[Carbon Interface]] - Die Carbon Schnittstelle für macOS
 +
*[[Qt Interface]] - Die Qt 4 Schnittstelle für Unixes, macOS und linux-basierte PDAs
 +
*[[Windows CE Interface]] - Für Pocket PC und Smartphones
 +
*[[fpGUI Interface]] - Ein Widgetset komplett in Object Pascal geschrieben
 +
===Artikel über die Entwicklung von Schnittstellen===
 +
*[[Carbon interface internals]] - Wenn du helfen willst, die Carbon Schnittstelle zu verbessern
 +
*[[Windows CE Development Notes]] - Für Pocket PC und Smartphones
 +
*[[Adding a new interface]] - Wie man eine neue Widgetset-Schnittstelle entwickelt
  
 
== Dokumentation über Carbon ==
 
== Dokumentation über Carbon ==
  
[http://www.mactech.com/macintosh-c/downloads.html Carbon Buch zum Download]
+
* [http://developer.apple.com/documentation/Carbon Apple Carbon docs]
 +
 
 +
* [http://search.lists.apple.com Apple Mailing List search]
  
[http://www.carbondev.com/site/ Carbon Dev]
+
* [http://www.mactech.com/macintosh-c/downloads.html Carbon Buch zum Download]
  
[http://developer.apple.com/documentation/Carbon Apple Carbon docs]
+
* [http://www.carbondev.com/site/ Carbon Dev]
  
[http://www.oreilly.com/catalog/learncarbon "Learning Carbon" sample book chapter]
+
* [http://www.oreilly.com/catalog/learncarbon "Learning Carbon" sample book chapter]
  
Free Pascal's Carbon API unit is FPCMacOSAll.pas in /usr/local/share/fpcsrc/packages/extra/univint.
+
Die Carbon API unit von FreePascal ist FPCMacOSAll.pas in /usr/local/share/fpcsrc/packages/extra/univint.
  
 
== Carbon Schnittstelle Entwicklungs-Grundlagen ==
 
== Carbon Schnittstelle Entwicklungs-Grundlagen ==
  
* Die Mac OS X Zielversion ist 10.4
+
* Die macOS Zielversion ist 10.4
 
* Vermeiden sie die Verwendung von veralteten oder ausgemusterten APIs und Funktionen (z.B. QuickDraw vs. ''Quartz 2D'')
 
* Vermeiden sie die Verwendung von veralteten oder ausgemusterten APIs und Funktionen (z.B. QuickDraw vs. ''Quartz 2D'')
 
* Verwenden sie den Objektansatz
 
* Verwenden sie den Objektansatz
 
* Prüfen sie die Ergebnisse von Carbon Aufrufen mit der OSError Funktion
 
* Prüfen sie die Ergebnisse von Carbon Aufrufen mit der OSError Funktion
* Assume UTF-8 encoded strings between LCL and Carbon widgetset (für zukünftige Lazarus Unicode Unterstützung)
+
* erwenden Sie UTF-8 kodierte Zeichenketten zwischen LCL und dem Carbon widgetset (für zukünftige Lazarus Unicode Unterstützung)
  
 
== Was funktioniert bereits ? ==
 
== Was funktioniert bereits ? ==
  
 +
* Features - siehe [[Roadmap#Status_of_features_on_each_widgetset]]
 
* Formulare und Bedienelemente - siehe [[Roadmap#Widgetset_dependent_components|Roadmap Widgetset dependent components]]
 
* Formulare und Bedienelemente - siehe [[Roadmap#Widgetset_dependent_components|Roadmap Widgetset dependent components]]
 
* Erstellen von TOpenGLControl mit AGL Kontext (siehe components/opengl/)
 
* Erstellen von TOpenGLControl mit AGL Kontext (siehe components/opengl/)
 
* Maus Ereignisse
 
* Maus Ereignisse
* Tastatur Ereignisse (VK_ mapping für fremde Tastaturen muß noch getestet werden)
+
* Tastatur Ereignisse (VK_ mapping für fremde Tastaturen muss noch getestet werden)
  
 
[[Image:Carbon interface show case.png|640px|Working components in the Carbon interface]]
 
[[Image:Carbon interface show case.png|640px|Working components in the Carbon interface]]
  
== Was muß als nächstes getan werden ? ==
+
== Was muss als nächstes getan werden ? ==
  
{|BORDER="1" CELLSPACING="0"
+
Siehe [http://www.freepascal.org/mantis/view_all_set.php?type=3&source_query_id=1017 Bug Tracker Carbon open issues]
!STYLE="background:#99D2FD;"|Item
 
!STYLE="background:#99D2FD;"|Anmerkung
 
!STYLE="background:#99D2FD;"|Abhängigkeiten
 
!STYLE="background:#99D2FD;"|Verantwortlich
 
|----
 
|Mouse Capture releasing|| || ||
 
|----
 
|GDI objects||Delete only unselected objects|| ||
 
|----
 
|TListBox + TCheckListBox||CreateListBoxControl does not function in compositing mode! We must create our own Carbon list box control.|| ||
 
|----
 
|TBitBtn default glyphs|| ||CreatePixmapIndirect||
 
|----
 
|TBrush Patterns||CGPatternCreate|| ||
 
|----
 
|ScreenDC||CGDisplayCapture, CGDisplayGetDrawingContext - CGDisplayCapture locks screen!||TCarbonScreenContext||
 
|----
 
|StretchMaskBlt||Implement: ROP, stretch mode||||
 
|----
 
|TCalendar||no counterpart|| ||
 
|----
 
|TFontDialog||FPShowHideFontPanel|| ||
 
|----
 
|TListView||CreateDataBrowserControl|| ||
 
|----
 
|TSpeedButton|| ||DrawFrameControl||[[User:Tombo|Tombo]]
 
|----
 
|TScrollBox, TCustomControl with scrollbars, TScrollingWinControl||HIScrollViewCreate|| || [[User:Tombo|Tombo]]
 
|----
 
|TClipboard||PasteboardCreate|| ||
 
|}
 
  
== Bugs ==
+
== Carbon IDE Bugs ==
  
 
{|BORDER="1" CELLSPACING="0"
 
{|BORDER="1" CELLSPACING="0"
Line 77: Line 64:
 
!STYLE="background:#FF9999;"|Verantwortlich
 
!STYLE="background:#FF9999;"|Verantwortlich
 
|----
 
|----
|TCustomEdit.CharCase||Is ignored when typing text|| ||
+
|'...' buttons in dialogs||Now they are too large I think|| ||
 +
|----
 +
|OK/Cancel||Many dialogs have non-Mac check-X glyphs|| ||  
 
|----
 
|----
|TMemo.WordWrap||persistent bug, when word wrap is disabled the memo doesn't scroll to caret|| ||
+
||Menu bar||Too wide for 1024x768 display resolution|| ||
 
|----
 
|----
|TMaskEdit||Every typed char is doubled|| ||
+
||Lazarus menu||Help About and app prefs (Environment options) should be accessible here|| ||
 +
|----
 +
||Menus||Many missing or non-standard menu shortcuts:<BR>
 +
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!
 +
|| ||
 
|}
 
|}
 +
 +
Siehe [http://www.freepascal.org/mantis/view_all_set.php?type=3&source_query_id=1018 Bug Tracker Carbon IDE open issues]
 +
 +
== Implementation Details ==
 +
 +
=== Keyboard ===
 +
* Apple Command key is mapped to ssCtrl per [http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html Apple Guidelines]
 +
* Apple Control key is mapped to ssMeta
 +
* Apple Option key is mapped to its inscription, i.e. ssAlt
 +
* Virtual key codes mapping is not reliable (depends on keyboard language layout!)
 +
 +
=== Application ===
 +
 +
* Title: You cannot change it at runtime. You have to set it in Application Bundle.
 +
* OnDropFiles event is fired when file is dropped on application dock icon or opened via Finder if is associated. You have to enable this event in Application Bundle.
 +
 +
=== 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:
 +
* CarbonWidgetSet.SetTextFractional(Canvas, False); // from CarbonInt unit
 +
* TCarbonCustomControl(CustomControl.Handle).TextFractional := False; // from CarbonPrivate unit
 +
* TCarbonDeviceContext(Canvas.Handle)..TextFractional := False; // from CarbonCanvas unit
 +
 +
=== 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 ==
 
== Kompatibilitätsprobleme ==
  
=== Tastatur ===
+
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 ===
 +
 
 +
* Icon wird nicht unterstützt
 +
* ShowInTaskbar wird nicht unterstützt
 +
 
 +
=== 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 ===
 +
 
 +
* OnDropDown is called when set focus
 +
* OnCloseUp is called when released focus
 +
* DroppedDown does not show drop down list when style is csDropDownList
 +
* DropDownCount wird nicht unterstützt
 +
* Style: csSimple, csOwnerDrawFixed und csOwnerDrawVariable werden nicht unterstützt
 +
 
 +
=== TPanel.Bevelxxx: bvLowered und bvSpace werden nicht unterstützt ===
  
* Apple Command key is mapped to ssCtrl due to [http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html Apple Guidelines]
+
=== TBitBtn.Spacing is not supported ===
* 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)
 
  
=== Drawing on canvas outside OnPaint event ===
+
=== TTrackBar ===
  
* paints into QuickDraw window port, maybe QDBeginCGContext, QDEndCGContext would help
+
* LineSize wird nicht unterstützt
 +
* ScalePos wird nicht unterstützt
 +
* TickMarks werden nicht unterstützt
  
''Note that Quickdraw is deprecated as of Mac OS X 10.5, so in the long term this needs another solution''.
+
=== TProgressBar ===
  
=== TControl.Color ===
+
* BarShowText wird nicht unterstützt
 +
* Smooth wird nicht unterstützt
 +
* Step wird nicht unterstützt
  
* der Hintergrund von Carbon Bedienelementen ist transparent
+
=== TColorDialog.Title is not supported ===
  
 
== Wie man ein neues Bedienelement hinzufügt ==
 
== Wie man ein neues Bedienelement hinzufügt ==
Line 121: Line 189:
 
   end;
 
   end;
  
Jede WS Klasse, die tatsächlich etwas implementiert, muß registriert werden. Schauen sie den initialization Abschnitt am Ende der carbonwsXXX.pp Unit an:
+
Jede WS Klasse, die tatsächlich etwas implementiert, muss registriert werden. Schauen sie sich den initialization Abschnitt am Ende der carbonwsXXX.pp Unit an:
 
   RegisterWSComponent(TCustomButton, TCarbonWSButton);
 
   RegisterWSComponent(TCustomButton, TCarbonWSButton);
  
TCarbonWSButton setzt CreateHandle außer Kraft, 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.
+
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.

Latest revision as of 22:41, 17 December 2019

Deutsch (de) English (en)

macOSlogo.png

Dieser Artikel behandelt ausschließlich macOS.

Siehe auch: Multiplatform Programming Guide/de

Apple iOS new.svg

Dieser Artikel behandelt ausschließlich iOS.

Siehe auch: Multiplatform Programming Guide/de


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

  • Die macOS Zielversion ist 10.4
  • Vermeiden sie die Verwendung von veralteten oder ausgemusterten APIs und Funktionen (z.B. QuickDraw vs. Quartz 2D)
  • Verwenden sie den Objektansatz
  • Prüfen sie die Ergebnisse von Carbon Aufrufen mit der OSError Funktion
  • erwenden Sie UTF-8 kodierte Zeichenketten zwischen LCL und dem Carbon widgetset (für zukünftige Lazarus Unicode Unterstützung)

Was funktioniert bereits ?

Working components in the Carbon interface

Was muss als nächstes getan werden ?

Siehe Bug Tracker Carbon open issues

Carbon IDE Bugs

Item Anmerkung Abhängigkeiten Verantwortlich
'...' buttons in dialogs Now they are too large I think
OK/Cancel Many dialogs have non-Mac check-X glyphs
Menu bar Too wide for 1024x768 display resolution
Lazarus menu Help About and app prefs (Environment options) should be accessible here
Menus Many missing or non-standard menu shortcuts:

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

Siehe Bug Tracker Carbon IDE open issues

Implementation Details

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 is not reliable (depends on keyboard language layout!)

Application

  • Title: You cannot change it at runtime. You have to set it in Application Bundle.
  • OnDropFiles event is fired when file is dropped on application dock icon or opened via Finder if is associated. You have to enable this event in Application Bundle.

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:

  • CarbonWidgetSet.SetTextFractional(Canvas, False); // from CarbonInt unit
  • TCarbonCustomControl(CustomControl.Handle).TextFractional := False; // from CarbonPrivate unit
  • TCarbonDeviceContext(Canvas.Handle)..TextFractional := False; // from CarbonCanvas unit

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

  • Icon wird nicht unterstützt
  • ShowInTaskbar wird nicht unterstützt

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

  • OnDropDown is called when set focus
  • OnCloseUp is called when released focus
  • DroppedDown does not show drop down list when style is csDropDownList
  • DropDownCount wird nicht unterstützt
  • Style: csSimple, csOwnerDrawFixed und csOwnerDrawVariable werden nicht unterstützt

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

TBitBtn.Spacing is not supported

TTrackBar

  • LineSize wird nicht unterstützt
  • ScalePos wird nicht unterstützt
  • TickMarks werden nicht unterstützt

TProgressBar

  • BarShowText wird nicht unterstützt
  • Smooth wird nicht unterstützt
  • Step wird nicht unterstützt

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:

 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:

 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.