Sign in Join
Wiki copytemporary

Carbon interface internals/de: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Carbon interface internals/de

OldNewLine
1+## Einleitung
2+
3+Diese Seite bietet einen Überblick über die LCL Carbon Schnittstelle für macOS und soll neuen Entwicklern helfen.
4+
5+Für die Installation und Erzeugung einer ersten Carbon Anwendung lesen sie zunächst [[Carbon Interface/de|Carbon Interface]].
6+
7+## Andere Schnittstellen
8+
9+- [[Lazarus known issues (things that will never be fixed)]] - Eine Liste mit Kompatibilitätsproblemen der Schnittstellen
10+- [[Win32/64 Interface]] - Die winapi Schnittstelle für Windows 95/98/Me/2K/XP/Vista, aber nicht CE
11+- [[GTK2 Interface]] - Die gtk2 Schnittstelle für Unixes, macOS, Windows
12+- [[Carbon Interface]] - Die Carbon Schnittstelle für macOS
13+- [[Qt Interface]] - Die Qt 4 Schnittstelle für Unixes, macOS und linux-basierte PDAs
14+- [[Windows CE Interface]] - Für Pocket PC und Smartphones
15+- [[fpGUI Interface]] - Ein Widgetset komplett in Object Pascal geschrieben
16+
17+### Artikel über die Entwicklung von Schnittstellen
18+
19+- [[Carbon interface internals]] - Wenn du helfen willst, die Carbon Schnittstelle zu verbessern
20+- [[Windows CE Development Notes]] - Für Pocket PC und Smartphones
21+- [[Adding a new interface]] - Wie man eine neue Widgetset-Schnittstelle entwickelt
22+
23+## Dokumentation über Carbon
24+
25+- [Apple Carbon docs](http://developer.apple.com/documentation/Carbon)
26+
27+- [Apple Mailing List search](http://search.lists.apple.com)
28+
29+- [Carbon Buch zum Download](http://www.mactech.com/macintosh-c/downloads.html)
30+
31+- [Carbon Dev](http://www.carbondev.com/site/)
32+
33+- ["Learning Carbon" sample book chapter](http://www.oreilly.com/catalog/learncarbon)
34+
35+Die Carbon API unit von FreePascal ist FPCMacOSAll.pas in /usr/local/share/fpcsrc/packages/extra/univint.
36+
37+## Carbon Schnittstelle Entwicklungs-Grundlagen
38+
39+- Die macOS Zielversion ist 10.4
40+- Vermeiden sie die Verwendung von veralteten oder ausgemusterten APIs und Funktionen (z.B. QuickDraw vs. *Quartz 2D*)
41+- Verwenden sie den Objektansatz
42+- Prüfen sie die Ergebnisse von Carbon Aufrufen mit der OSError Funktion
43+- erwenden Sie UTF-8 kodierte Zeichenketten zwischen LCL und dem Carbon widgetset (für zukünftige Lazarus Unicode Unterstützung)
44+
45+## Was funktioniert bereits ?
46+
47+- Features - siehe [[Roadmap|Roadmap#Status_of_features_on_each_widgetset]]
48+- Formulare und Bedienelemente - siehe [[Roadmap|Roadmap Widgetset dependent components]]
49+- Erstellen von TOpenGLControl mit AGL Kontext (siehe components/opengl/)
50+- Maus Ereignisse
51+- Tastatur Ereignisse (VK_ mapping für fremde Tastaturen muss noch getestet werden)
52+
53+<figure>
54+<img src="Carbon_interface_show_case.png" title="Working components in the Carbon interface" width="640" />
55+<figcaption>Working components in the Carbon interface</figcaption>
56+</figure>
57+
58+## Was muss als nächstes getan werden ?
59+
60+Siehe [Bug Tracker Carbon open issues](http://www.freepascal.org/mantis/view_all_set.php?type=3&source_query_id=1017)
61+
62+## Carbon IDE Bugs
63+
64+<table>
65+<thead>
66+<tr>
67+<th data-STYLE="background:#FF9999;">Item</th>
68+<th data-STYLE="background:#FF9999;">Anmerkung</th>
69+<th data-STYLE="background:#FF9999;">Abhängigkeiten</th>
70+<th data-STYLE="background:#FF9999;">Verantwortlich</th>
71+</tr>
72+</thead>
73+<tbody>
74+<tr>
75+<td>'...' buttons in dialogs</td>
76+<td>Now they are too large I think</td>
77+<td></td>
78+<td></td>
79+</tr>
80+<tr>
81+<td>OK/Cancel</td>
82+<td>Many dialogs have non-Mac check-X glyphs</td>
83+<td></td>
84+<td></td>
85+</tr>
86+<tr>
87+<td>|Menu bar</td>
88+<td>Too wide for 1024x768 display resolution</td>
89+<td></td>
90+<td></td>
91+</tr>
92+<tr>
93+<td>|Lazarus menu</td>
94+<td>Help About and app prefs (Environment options) should be accessible here</td>
95+<td></td>
96+<td></td>
97+</tr>
98+<tr>
99+<td>|Menus</td>
100+<td>Many missing or non-standard menu shortcuts:<br />
101+File New should be Cmd+N<br />
102+File Save As should be Shift+Cmd+S<br />
103+File Quit should be Cmd+Q<br />
104+Search Find should be Cmd+F<br />
105+Search Find Next should be Cmd+G<br />
106+Search Find Previous should be Shift+Cmd+G<br />
107+(Goto line and Procedure List need to be reassigned)<br />
108+Option+Cmd+F does not bring up Search Results<br />
109+F11 behaves weird!</td>
110+<td>|</td>
111+<td></td>
112+</tr>
113+</tbody>
114+</table>
115+
116+Siehe [Bug Tracker Carbon IDE open issues](http://www.freepascal.org/mantis/view_all_set.php?type=3&source_query_id=1018)
117+
118+## Implementation Details
119+
120+### Keyboard
121+
122+- Apple Command key is mapped to ssCtrl per [Apple Guidelines](http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/index.html)
123+- Apple Control key is mapped to ssMeta
124+- Apple Option key is mapped to its inscription, i.e. ssAlt
125+- Virtual key codes mapping is not reliable (depends on keyboard language layout!)
126+
127+### Application
128+
129+- Title: You cannot change it at runtime. You have to set it in Application Bundle.
130+- 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.
131+
132+### Drawing and measuring text precisely in parts
133+
134+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:
135+
136+- CarbonWidgetSet.SetTextFractional(Canvas, False); // from CarbonInt unit
137+- TCarbonCustomControl(CustomControl.Handle).TextFractional := False; // from CarbonPrivate unit
138+- TCarbonDeviceContext(Canvas.Handle)..TextFractional := False; // from CarbonCanvas unit
139+
140+### Screenshot taking
141+
142+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.
143+
144+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.
145+
146+## Kompatibilitätsprobleme
147+
148+These are things that will probably never be solved.
149+
150+### Mouse.CursorPos changing does not generate mouse (move) events
151+
152+### Release mouse capture is not supported
153+
154+### Kommandozeilenparameter
155+
156+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.
157+
158+### Shortcuts indication is not supported
159+
160+### Drawing on Canvas outside OnPaint event is not supported
161+
162+### Drawing on screen device context is not supported
163+
164+### TCustomControl.Color of clBtnFace makes its background transparent
165+
166+### TWinControl.Font fsStrikeOut wird nicht unterstützt
167+
168+### TForm
169+
170+- Icon wird nicht unterstützt
171+- ShowInTaskbar wird nicht unterstützt
172+
173+### TEdit.PasswordChar different then default is not supported
174+
175+### TMemo.WordWrap when is disabled, does not allow to scroll text horizontally
176+
177+### TListBox.Columns wird nicht unterstützt
178+
179+### TComboBox
180+
181+- OnDropDown is called when set focus
182+- OnCloseUp is called when released focus
183+- DroppedDown does not show drop down list when style is csDropDownList
184+- DropDownCount wird nicht unterstützt
185+- Style: csSimple, csOwnerDrawFixed und csOwnerDrawVariable werden nicht unterstützt
186+
187+### TPanel.Bevelxxx: bvLowered und bvSpace werden nicht unterstützt
188+
189+### TBitBtn.Spacing is not supported
190+
191+### TTrackBar
192+
193+- LineSize wird nicht unterstützt
194+- ScalePos wird nicht unterstützt
195+- TickMarks werden nicht unterstützt
196+
197+### TProgressBar
198+
199+- BarShowText wird nicht unterstützt
200+- Smooth wird nicht unterstützt
201+- Step wird nicht unterstützt
202+
203+### TColorDialog.Title is not supported
204+
205+## Wie man ein neues Bedienelement hinzufügt
206+
207+Zum Beispiel TButton.
208+
209+TButton wird definiert in lcl/buttons.pp. Dies ist der plattformunabhängige Teil der LCL, welcher vom normalen LCL Programmierer benutzt wird.
210+
211+Seine widgetset Klasse befindet sich in lcl/widgetset/wsbuttons.pp. Dies ist die plattformabhängige Basis für alle widgetsets (carbon, gtk, win32, ...).
212+
213+Seine Carbon Schnittstellenklasse ist in lcl/interfaces/carbon/carbonwsbuttons.pp:
214+
215+` TCarbonWSButton = class(TWSButton)`\
216+` private`\
217+` protected`\
218+` public`\
219+`   class function  CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;`\
220+` end;`
221+
222+Jede WS Klasse, die tatsächlich etwas implementiert, muss registriert werden. Schauen sie sich den initialization Abschnitt am Ende der carbonwsXXX.pp Unit an:
223+
224+` RegisterWSComponent(TCustomButton, TCarbonWSButton);`
225+
226+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.
227+
228+---
229+*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