Carbon interface internals/de
│ Deutsch (de) │ English (en) │
Dieser Artikel behandelt ausschließlich macOS.
Siehe auch: Multiplatform Programming Guide/de
Dieser Artikel behandelt ausschließlich iOS.
Siehe auch: Multiplatform Programming Guide/de
Diese Seite bietet einen Überblick über die LCL Carbon Schnittstelle für Mac OS X und soll neuen Entwicklern helfen.
Für die Installation und Erzeugung einer ersten Carbon Anwendung lesen sie zunächst Carbon Interface.
Dokumentation über Carbon
Die Carbon API unit von FreePascal ist FPCMacOSAll.pas in /usr/local/share/fpcsrc/packages/extra/univint.
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
Carbon Schnittstelle Entwicklungs-Grundlagen
- Die Mac OS X 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 ?
- Features - siehe Roadmap#Status_of_features_on_each_widgetset
- Formulare und Bedienelemente - siehe Roadmap Widgetset dependent components
- Erstellen von TOpenGLControl mit AGL Kontext (siehe components/opengl/)
- Maus Ereignisse
- Tastatur Ereignisse (VK_ mapping für fremde Tastaturen muss noch getestet werden)
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 |
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 Mac OS X 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
Command line parameters
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 is not supported
TForm
- Icon is not supported
- ShowInTaskbar is not supported
TEdit.PasswordChar different then default is not supported
TMemo.WordWrap when is disabled, does not allow to scroll text horizontally
TListBox.Columns is not supported
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 is not supported
- Style: csSimple, csOwnerDrawFixed and csOwnerDrawVariable are not supported
TPanel.Bevelxxx: bvLowered and bvSpace are not supported
TBitBtn.Spacing is not supported
TTrackBar
- LineSize is not supported
- ScalePos is not supported
- TickMarks are not supported
TProgressBar
- BarShowText is not supported
- Smooth is not supported
- Step is not supported
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.