Sign in Join
Wiki copytemporary

Carbon interface internals/de: what changed

Revision 3 to 4. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Einleitung
22
33Diese Seite bietet einen Überblick über die LCL Carbon Schnittstelle für macOS und soll neuen Entwicklern helfen.
44
55Für die Installation und Erzeugung einer ersten Carbon Anwendung lesen sie zunächst [[Carbon Interface/de|Carbon Interface]].
66
77## Andere Schnittstellen
88
99- [[Lazarus known issues (things that will never be fixed)]] - Eine Liste mit Kompatibilitätsproblemen der Schnittstellen
1010- [[Win32/64 Interface]] - Die winapi Schnittstelle für Windows 95/98/Me/2K/XP/Vista, aber nicht CE
1111- [[GTK2 Interface]] - Die gtk2 Schnittstelle für Unixes, macOS, Windows
1212- [[Carbon Interface]] - Die Carbon Schnittstelle für macOS
1313- [[Qt Interface]] - Die Qt 4 Schnittstelle für Unixes, macOS und linux-basierte PDAs
1414- [[Windows CE Interface]] - Für Pocket PC und Smartphones
1515- [[fpGUI Interface]] - Ein Widgetset komplett in Object Pascal geschrieben
1616
1717### Artikel über die Entwicklung von Schnittstellen
1818
1919- [[Carbon interface internals]] - Wenn du helfen willst, die Carbon Schnittstelle zu verbessern
2020- [[Windows CE Development Notes]] - Für Pocket PC und Smartphones
2121- [[Adding a new interface]] - Wie man eine neue Widgetset-Schnittstelle entwickelt
2222
2323## Dokumentation über Carbon
2424
2525- [Apple Carbon docs](http://developer.apple.com/documentation/Carbon)
2626
2727- [Apple Mailing List search](http://search.lists.apple.com)
2828
2929- [Carbon Buch zum Download](http://www.mactech.com/macintosh-c/downloads.html)
3030
3131- [Carbon Dev](http://www.carbondev.com/site/)
3232
3333- ["Learning Carbon" sample book chapter](http://www.oreilly.com/catalog/learncarbon)
3434
3535Die Carbon API unit von FreePascal ist FPCMacOSAll.pas in /usr/local/share/fpcsrc/packages/extra/univint.
3636
3737## Carbon Schnittstelle Entwicklungs-Grundlagen
3838
3939- Die macOS Zielversion ist 10.4
4040- Vermeiden sie die Verwendung von veralteten oder ausgemusterten APIs und Funktionen (z.B. QuickDraw vs. *Quartz 2D*)
4141- Verwenden sie den Objektansatz
4242- Prüfen sie die Ergebnisse von Carbon Aufrufen mit der OSError Funktion
4343- erwenden Sie UTF-8 kodierte Zeichenketten zwischen LCL und dem Carbon widgetset (für zukünftige Lazarus Unicode Unterstützung)
4444
4545## Was funktioniert bereits ?
4646
4747- Features - siehe [[Roadmap|Roadmap#Status_of_features_on_each_widgetset]]
4848- Formulare und Bedienelemente - siehe [[Roadmap|Roadmap Widgetset dependent components]]
4949- Erstellen von TOpenGLControl mit AGL Kontext (siehe components/opengl/)
5050- Maus Ereignisse
5151- Tastatur Ereignisse (VK_ mapping für fremde Tastaturen muss noch getestet werden)
5252
53-<img src="Carbon_interface_show_case.png" title="Working components in the Carbon interface" width="640" />
53+![](/wiki-images/d/d3/Carbon_interface_show_case.png)
5454
5555## Was muss als nächstes getan werden ?
5656
5757Siehe [Bug Tracker Carbon open issues](http://www.freepascal.org/mantis/view_all_set.php?type=3&source_query_id=1017)
5858
5959## Carbon IDE Bugs
6060
6161<thead>
6262
6363</thead>
6464<tbody>
6565
6666File New should be Cmd+N<br />
6767File Save As should be Shift+Cmd+S<br />
6868File Quit should be Cmd+Q<br />
6969Search Find should be Cmd+F<br />
7070Search Find Next should be Cmd+G<br />
7171Search Find Previous should be Shift+Cmd+G<br />
7272(Goto line and Procedure List need to be reassigned)<br />
7373Option+Cmd+F does not bring up Search Results<br />
7474F11 behaves weird!</td>
7575
7676</tbody>
7777
7878Siehe [Bug Tracker Carbon IDE open issues](http://www.freepascal.org/mantis/view_all_set.php?type=3&source_query_id=1018)
7979
8080## Implementation Details
8181
8282### Keyboard
8383
8484- Apple Command key is mapped to ssCtrl per [Apple Guidelines](http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html)
8585- Apple Control key is mapped to ssMeta
8686- Apple Option key is mapped to its inscription, i.e. ssAlt
8787- Virtual key codes mapping is not reliable (depends on keyboard language layout!)
8888
8989### Application
9090
9191- Title: You cannot change it at runtime. You have to set it in Application Bundle.
9292- 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.
9393
9494### Drawing and measuring text precisely in parts
9595
9696If 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:
9797
9898- CarbonWidgetSet.SetTextFractional(Canvas, False); // from CarbonInt unit
9999- TCarbonCustomControl(CustomControl.Handle).TextFractional := False; // from CarbonPrivate unit
100100- TCarbonDeviceContext(Canvas.Handle)..TextFractional := False; // from CarbonCanvas unit
101101
102102### Screenshot taking
103103
104104The 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.
105105
106106It 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.
107107
108108## Kompatibilitätsprobleme
109109
110110These are things that will probably never be solved.
111111
112112### Mouse.CursorPos changing does not generate mouse (move) events
113113
114114### Release mouse capture is not supported
115115
116116### Kommandozeilenparameter
117117
118118Because Carbon applications are executed via Application Bundle, command line parameters are not passed. You have to use OnDropFiles event to detect openning associated files.
119119
120120### Shortcuts indication is not supported
121121
122122### Drawing on Canvas outside OnPaint event is not supported
123123
124124### Drawing on screen device context is not supported
125125
126126### TCustomControl.Color of clBtnFace makes its background transparent
127127
128128### TWinControl.Font fsStrikeOut wird nicht unterstützt
129129
130130### TForm
131131
132132- Icon wird nicht unterstützt
133133- ShowInTaskbar wird nicht unterstützt
134134
135135### TEdit.PasswordChar different then default is not supported
136136
137137### TMemo.WordWrap when is disabled, does not allow to scroll text horizontally
138138
139139### TListBox.Columns wird nicht unterstützt
140140
141141### TComboBox
142142
143143- OnDropDown is called when set focus
144144- OnCloseUp is called when released focus
145145- DroppedDown does not show drop down list when style is csDropDownList
146146- DropDownCount wird nicht unterstützt
147147- Style: csSimple, csOwnerDrawFixed und csOwnerDrawVariable werden nicht unterstützt
148148
149149### TPanel.Bevelxxx: bvLowered und bvSpace werden nicht unterstützt
150150
151151### TBitBtn.Spacing is not supported
152152
153153### TTrackBar
154154
155155- LineSize wird nicht unterstützt
156156- ScalePos wird nicht unterstützt
157157- TickMarks werden nicht unterstützt
158158
159159### TProgressBar
160160
161161- BarShowText wird nicht unterstützt
162162- Smooth wird nicht unterstützt
163163- Step wird nicht unterstützt
164164
165165### TColorDialog.Title is not supported
166166
167167## Wie man ein neues Bedienelement hinzufügt
168168
169169Zum Beispiel TButton.
170170
171171TButton wird definiert in lcl/buttons.pp. Dies ist der plattformunabhängige Teil der LCL, welcher vom normalen LCL Programmierer benutzt wird.
172172
173173Seine widgetset Klasse befindet sich in lcl/widgetset/wsbuttons.pp. Dies ist die plattformabhängige Basis für alle widgetsets (carbon, gtk, win32, ...).
174174
175175Seine Carbon Schnittstellenklasse ist in lcl/interfaces/carbon/carbonwsbuttons.pp:
176176
177177` TCarbonWSButton = class(TWSButton)`\
178178` private`\
179179` protected`\
180180` public`\
181181`   class function  CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;`\
182182` end;`
183183
184184Jede WS Klasse, die tatsächlich etwas implementiert, muss registriert werden. Schauen sie sich den initialization Abschnitt am Ende der carbonwsXXX.pp Unit an:
185185
186186` RegisterWSComponent(TCustomButton, TCarbonWSButton);`
187187
188188TCarbonWSButton 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.
189189
190190---
191191*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](/wiki-contact).*

Back to history