mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 20:59:08 +02:00
carbon: added support fot ExtTextOut( .. Dx) parameter
git-svn-id: trunk@19975 -
This commit is contained in:
parent
a457bd46cd
commit
414194be74
@ -840,7 +840,7 @@ end;
|
|||||||
Rect - Optional clipping and/or opaquing rectangle (TODO)
|
Rect - Optional clipping and/or opaquing rectangle (TODO)
|
||||||
Str - Character string to be drawn
|
Str - Character string to be drawn
|
||||||
Count - Number of characters in string
|
Count - Number of characters in string
|
||||||
Dx - Pointer to array of intercharacter spacing values (IGNORED)
|
Dx - Pointer to array of intercharacter spacing values
|
||||||
Returns: If the string was drawn
|
Returns: If the string was drawn
|
||||||
|
|
||||||
Draws a character string by using the currently selected font
|
Draws a character string by using the currently selected font
|
||||||
@ -854,7 +854,7 @@ begin
|
|||||||
Result := False;
|
Result := False;
|
||||||
//DebugLn('TCarbonDeviceContext.ExtTextOut ' + DbgS(X) + ', ' + DbgS(Y) + ' R: ' + DbgS(Rect^) +
|
//DebugLn('TCarbonDeviceContext.ExtTextOut ' + DbgS(X) + ', ' + DbgS(Y) + ' R: ' + DbgS(Rect^) +
|
||||||
// ' S: ' + Str + ' C: ' + DbgS(Count));
|
// ' S: ' + Str + ' C: ' + DbgS(Count));
|
||||||
|
|
||||||
if Rect <> nil then
|
if Rect <> nil then
|
||||||
begin
|
begin
|
||||||
// fill background
|
// fill background
|
||||||
@ -887,7 +887,7 @@ begin
|
|||||||
TextBrush.Apply(Self, False); // do not use ROP2
|
TextBrush.Apply(Self, False); // do not use ROP2
|
||||||
|
|
||||||
// finally draw the text
|
// finally draw the text
|
||||||
if not TextLayout.Draw(X, Y) then Exit;
|
if not TextLayout.Draw(X, Y, DX) then Exit;
|
||||||
Result := True;
|
Result := True;
|
||||||
finally
|
finally
|
||||||
EndTextRender(TextLayout);
|
EndTextRender(TextLayout);
|
||||||
|
@ -89,7 +89,7 @@ type
|
|||||||
FLineRotation: Fixed;
|
FLineRotation: Fixed;
|
||||||
public
|
public
|
||||||
procedure Apply(ADC: TCarbonContext); virtual; abstract;
|
procedure Apply(ADC: TCarbonContext); virtual; abstract;
|
||||||
function Draw(X, Y: Integer): Boolean; virtual; abstract;
|
function Draw(X, Y: Integer; DX: PInteger): Boolean; virtual; abstract;
|
||||||
procedure Release; virtual;
|
procedure Release; virtual;
|
||||||
|
|
||||||
function GetHeight: Integer;
|
function GetHeight: Integer;
|
||||||
@ -110,10 +110,13 @@ type
|
|||||||
FWidget: HIViewRef;
|
FWidget: HIViewRef;
|
||||||
FTextBuffer: WideString;
|
FTextBuffer: WideString;
|
||||||
FDC: TCarbonContext;
|
FDC: TCarbonContext;
|
||||||
|
FDX: Integer;
|
||||||
|
protected
|
||||||
|
procedure DoJustify(iLineRef: ATSULineRef; var Handled: Boolean);
|
||||||
public
|
public
|
||||||
constructor Create(const Text: String; Font: TCarbonFont; TextFractional: Boolean);
|
constructor Create(const Text: String; Font: TCarbonFont; TextFractional: Boolean);
|
||||||
procedure Apply(ADC: TCarbonContext); override;
|
procedure Apply(ADC: TCarbonContext); override;
|
||||||
function Draw(X, Y: Integer): Boolean; override;
|
function Draw(X, Y: Integer; DX: PInteger): Boolean; override;
|
||||||
procedure Release; override;
|
procedure Release; override;
|
||||||
|
|
||||||
property Layout: ATSUTextLayout read FLayout;
|
property Layout: ATSUTextLayout read FLayout;
|
||||||
@ -129,7 +132,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(const Text: String; Font: TCarbonFont);
|
constructor Create(const Text: String; Font: TCarbonFont);
|
||||||
procedure Apply(ADC: TCarbonContext); override;
|
procedure Apply(ADC: TCarbonContext); override;
|
||||||
function Draw(X, Y: Integer): Boolean; override;
|
function Draw(X, Y: Integer; DX: PInteger): Boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonFont }
|
{ TCarbonFont }
|
||||||
@ -803,7 +806,6 @@ begin
|
|||||||
-Y, X + RoundFixed(FTextAfter), -Y - RoundFixed(FAscent + FDescent));
|
-Y, X + RoundFixed(FTextAfter), -Y - RoundFixed(FAscent + FDescent));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCarbonTextLayoutBuffer }
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCarbonTextLayoutBuffer.Create
|
Method: TCarbonTextLayoutBuffer.Create
|
||||||
@ -907,10 +909,54 @@ begin
|
|||||||
Self, 'Apply', SGetUnjustifiedBounds) then Exit;
|
Self, 'Apply', SGetUnjustifiedBounds) then Exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonTextLayoutBuffer.Draw(X, Y: Integer): Boolean;
|
|
||||||
|
function ATSUCallback(iCurrentOperation: ATSULayoutOperationSelector; iLineRef: ATSULineRef; iRefCon: UInt32; iOperationCallbackParameterPtr: UnivPtr;
|
||||||
|
var oCallbackStatus: ATSULayoutOperationCallbackStatus ): OSStatus; {$ifdef DARWIN}mwpascal;{$endif}
|
||||||
|
var
|
||||||
|
Buffer : TCarbonTextLayoutBuffer;
|
||||||
|
Handled : Boolean;
|
||||||
|
begin
|
||||||
|
Buffer := TCarbonTextLayoutBuffer(iRefCon);
|
||||||
|
if not Assigned(Buffer) then
|
||||||
|
Result := noErr
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Handled := false;
|
||||||
|
case iCurrentOperation of
|
||||||
|
kATSULayoutOperationJustification:
|
||||||
|
Buffer.DoJustify(iLineRef, Handled);
|
||||||
|
end;
|
||||||
|
Result := noErr;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCarbonTextLayoutBuffer.DoJustify(iLineRef: ATSULineRef; var Handled: Boolean);
|
||||||
|
type
|
||||||
|
TFixedArray = array [Word] of Fixed;
|
||||||
|
PFixedArray = ^TFixedArray;
|
||||||
|
var
|
||||||
|
Deltas : PFixedArray;
|
||||||
|
Count : ItemCount;
|
||||||
|
i : Integer;
|
||||||
|
begin
|
||||||
|
ATSUDirectGetLayoutDataArrayPtrFromLineRef (iLineRef,
|
||||||
|
kATSUDirectDataAdvanceDeltaFixedArray, true, @Deltas, Count);
|
||||||
|
if Assigned(Deltas) and (Count > 0) then
|
||||||
|
begin
|
||||||
|
for i := 1 to Count - 1 do
|
||||||
|
Deltas^[i] := Long2Fix(FDX);
|
||||||
|
Handled := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCarbonTextLayoutBuffer.Draw(X, Y: Integer; Dx: PInteger): Boolean;
|
||||||
var
|
var
|
||||||
MX, MY: ATSUTextMeasurement;
|
MX, MY: ATSUTextMeasurement;
|
||||||
A: Single;
|
A: Single;
|
||||||
|
theTag : ATSUAttributeTag;
|
||||||
|
theSize : ByteCount;
|
||||||
|
theValue : ATSUAttributeValuePtr;
|
||||||
|
OverSpec : ATSULayoutOperationOverrideSpecifier;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
@ -926,9 +972,24 @@ begin
|
|||||||
MY := 0;
|
MY := 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if Assigned(Dx) then begin
|
||||||
|
FDX := Dx^;
|
||||||
|
OverSpec.operationSelector := kATSULayoutOperationJustification;
|
||||||
|
OverSpec.overrideUPP := NewATSUDirectLayoutOperationOverrideUPP(@ATSUCallback);
|
||||||
|
theTag := kATSULayoutOperationOverrideTag;
|
||||||
|
theSize := sizeof (ATSULayoutOperationOverrideSpecifier);
|
||||||
|
theValue := @OverSpec;
|
||||||
|
end;
|
||||||
|
|
||||||
if OSError(ATSUDrawText(FLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
if OSError(ATSUDrawText(FLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
||||||
X shl 16 - FTextBefore + MX, -(Y shl 16) - FAscent + MY),
|
X shl 16 - FTextBefore + MX, -(Y shl 16) - FAscent + MY),
|
||||||
Self, 'Draw', 'ATSUDrawText') then Exit;
|
Self, 'Draw', 'ATSUDrawText') then Exit;
|
||||||
|
|
||||||
|
if Assigned(Dx) then begin
|
||||||
|
DisposeATSUDirectLayoutOperationOverrideUPP(OverSpec.overrideUPP);
|
||||||
|
OverSpec.overrideUPP := nil;
|
||||||
|
ATSUSetLayoutControls (FLayout, 1, @theTag, @theSize, @theValue);
|
||||||
|
end;
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
@ -991,7 +1052,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCarbonTextLayoutArray.Draw(X, Y: Integer): Boolean;
|
function TCarbonTextLayoutArray.Draw(X, Y: Integer; Dx: PInteger): Boolean;
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
begin
|
||||||
@ -999,8 +1060,9 @@ begin
|
|||||||
|
|
||||||
for I := 1 to Length(FText) do
|
for I := 1 to Length(FText) do
|
||||||
begin
|
begin
|
||||||
Result := FFont.FCachedLayouts[Ord(FText[I])].Draw(X, Y);
|
Result := FFont.FCachedLayouts[Ord(FText[I])].Draw(X, Y, nil);
|
||||||
Inc(X, FFont.FCachedLayouts[Ord(FText[I])].GetWidth);
|
if Assigned(dx) then Inc(X, Dx^)
|
||||||
|
else Inc(X, FFont.FCachedLayouts[Ord(FText[I])].GetWidth);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
|
Loading…
Reference in New Issue
Block a user