Difference between revisions of "Carbon interface internals"

From Free Pascal wiki
Jump to navigationJump to search
(Added list of TODOs, bugs and compatibility issues)
Line 26: Line 26:
 
== What needs to be done next? ==
 
== What needs to be done next? ==
  
*Create more controls (TComboBox, TRadioButton, TMemo, TListBox, TImage)
+
{|BORDER="1" CELLSPACING="0"
*Resize events (when form has been resized by user)
+
!STYLE="background:#99D2FD;"|Item
*InvalidateRect
+
!STYLE="background:#99D2FD;"|Note
*ShowModal (for dialogs)
+
!STYLE="background:#99D2FD;"|Dependencies
 +
!STYLE="background:#99D2FD;"|Responsible
 +
|----
 +
|TControl.Cursor||SetThemeCursor|| ||
 +
|----
 +
|TComboBox||HIComboBox(Create)|| ||
 +
|----
 +
|TListBox||CreateListBoxControl|| ||
 +
|----
 +
|TCanvas||Quartz 2D, CGContext|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TPen||Quartz 2D|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TBrush||Quartz 2D|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|SaveDC, RestoreDC||Quartz 2D, CGContextSaveGState, CGContextRestoreGState|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TBitmap.LoadFromFile||Quartz 2D, CGImage||GetDescriptionFromDevice, CreateBitmapFromRawImage, GetObject||[[User:Tombo|Tombo]]
 +
|----
 +
|TColorDialog||Color Picker Manager|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TButton.Default indication||kControlPushButtonDefaultTag|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TBitBtn||CreateBevelButtonControl|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TCustomControl|| || ||
 +
|----
 +
|TGraphicControl|| ||MoveWindowOrgEx, IntersectClipRect, SaveDC, RestoreDC||
 +
|----
 +
|ScreenDC||CGDisplayCapture, CGDisplayGetDrawingContext, CGDisplayRegisterReconfigurationCallback || ||
 +
|----
 +
|Hints||CreateNewWindow with, WindowFromPoint|| ||
 +
|}
  
== More difficult tasks ==
+
== Bugs ==
  
* TLabel is custom drawn in the LCL. That means TCanvas needs to be implemented first.
+
{|BORDER="1" CELLSPACING="0"
* TCanvas needs GetDC/ReleaseDC, fonts, brush, pen, clipping and paint messages
+
!STYLE="background:#FF9999;"|Item
* TMenu is quite different than the gtk and win32 menus.
+
!STYLE="background:#FF9999;"|Note
 +
!STYLE="background:#FF9999;"|Dependencies
 +
!STYLE="background:#FF9999;"|Responsible
 +
|----
 +
|Mouse events fired on structure part of TForm|| || ||
 +
|----
 +
|ShowWindow||Maximize <-> Restore is breaked|| ||
 +
|----
 +
|TScrollBar and TTrackBar live tracking|| || ||
 +
|----
 +
|TScrollBar arrow clicking|| || ||
 +
|----
 +
|TCustomEdit.MaxLength||The caret pos is not preserved when typed text is longer than maxlength|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TMemo.ReadOnly|| || ||
 +
|----
 +
|TMemo.WordWrap|| || ||
 +
|----
 +
|TMemo is not scrolling to caret|| || ||
 +
|----
 +
|TMemo.ScrollBars||Embed in HIScrollView -> solve event handling|| ||
 +
|----
 +
|EnumFontFamiliesEx, FindCarbonFontID||Get UTF-8 font names||UTF16ToUTF8||[[User:Tombo|Tombo]]
 +
|----
 +
|TCustomCheckBox.OnClick||Called before state is changed -> toggle manually|| ||[[User:Tombo|Tombo]]
 +
|----
 +
|TForm.ShowModal||Problem with repeated calling|| ||[[User:Tombo|Tombo]]
 +
|}
 +
 
 +
== Compatibility issues ==
 +
 
 +
=== Keyboard ===
 +
 
 +
* Apple Command key is mapped to ssCtrl due to [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
 +
* Shortcuts indication (ampersand)
 +
 
 +
=== Drawing on canvas outside OnPaint event===
 +
 
 +
* paints into QuickDraw window port, maybe QDBeginCGContext, QDEndCGContext would help
  
 
== How to add a new control ==
 
== How to add a new control ==

Revision as of 15:35, 25 February 2007

Deutsch (de) English (en)

macOSlogo.png

This article applies to macOS only.

See also: Multiplatform Programming Guide

Apple iOS new.svg

This article applies to iOS only.

See also: Multiplatform Programming Guide


This page gives an overview of the LCL carbon interface for Mac OS X and will help new developers.

For installation and creating a first carbon application read first Carbon Interface.

Documentation about Carbon

Carbon Book for download

Carbon Dev

What is already working ?

  • Creating a TForm
  • Creating and clicking on a TButton
  • Creating and editing a TEdit
  • Creating and clicking on a TGroupBox
  • Creating and clicking on a TCheckBox
  • Creating a TStaticText
  • Creating a TTimer
  • Creating TOpenGLControl with AGL context (see components/opengl/)
  • Mouse events
  • Keyboard events (VK_ mapping for foreign keyboards needs testing)

What needs to be done next?

Item Note Dependencies Responsible
TControl.Cursor SetThemeCursor
TComboBox HIComboBox(Create)
TListBox CreateListBoxControl
TCanvas Quartz 2D, CGContext Tombo
TPen Quartz 2D Tombo
TBrush Quartz 2D Tombo
SaveDC, RestoreDC Quartz 2D, CGContextSaveGState, CGContextRestoreGState Tombo
TBitmap.LoadFromFile Quartz 2D, CGImage GetDescriptionFromDevice, CreateBitmapFromRawImage, GetObject Tombo
TColorDialog Color Picker Manager Tombo
TButton.Default indication kControlPushButtonDefaultTag Tombo
TBitBtn CreateBevelButtonControl Tombo
TCustomControl
TGraphicControl MoveWindowOrgEx, IntersectClipRect, SaveDC, RestoreDC
ScreenDC CGDisplayCapture, CGDisplayGetDrawingContext, CGDisplayRegisterReconfigurationCallback
Hints CreateNewWindow with, WindowFromPoint

Bugs

Item Note Dependencies Responsible
Mouse events fired on structure part of TForm
ShowWindow Maximize <-> Restore is breaked
TScrollBar and TTrackBar live tracking
TScrollBar arrow clicking
TCustomEdit.MaxLength The caret pos is not preserved when typed text is longer than maxlength Tombo
TMemo.ReadOnly
TMemo.WordWrap
TMemo is not scrolling to caret
TMemo.ScrollBars Embed in HIScrollView -> solve event handling
EnumFontFamiliesEx, FindCarbonFontID Get UTF-8 font names UTF16ToUTF8 Tombo
TCustomCheckBox.OnClick Called before state is changed -> toggle manually Tombo
TForm.ShowModal Problem with repeated calling Tombo

Compatibility issues

Keyboard

  • Apple Command key is mapped to ssCtrl due to Apple Guidelines
  • Apple control key is mapped to ssMeta
  • Apple option key is mapped to its inscription, i.e. ssAlt
  • Shortcuts indication (ampersand)

Drawing on canvas outside OnPaint event

  • paints into QuickDraw window port, maybe QDBeginCGContext, QDEndCGContext would help

How to add a new control

For example TButton.

TButton is defined in lcl/buttons.pp. This is the platform independent part of the LCL, which is used by the normal LCL programmer.

Its widgetset class is in lcl/widgetset/wsbuttons.pp. This is the platform independent base for all widgetsets (carbon, gtk, win32, ...).

Its carbon interface class is in lcl/interfaces/carbon/carbonwsbuttons.pp:

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

Every WS class, that actually implements something must be registered. See the initialization section at the end of the carbonwsXXX.pp unit:

 RegisterWSComponent(TCustomButton, TCarbonWSButton);

TCarbonWSButton overrides CreateHandle to create a carbon button. The code is short and should be easily adaptable for other controls like TCheckBox.

Keyboard

  • Apple Command key is mapped to ssCtrl due to Apple Guidelines
  • Apple control key is mapped to ssMeta
  • Apple option key is mapped to its inscription, i.e. ssAlt