mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 15:59:13 +02:00
customdrawnws: Fixes Cocoa text crash and now we can already show 1 window =D
git-svn-id: trunk@33403 -
This commit is contained in:
parent
beeb5ecfbb
commit
61a605dfd4
@ -139,24 +139,11 @@ type
|
|||||||
property Height: Integer read FHeight;
|
property Height: Integer read FHeight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaTextLayout }
|
|
||||||
|
|
||||||
TCocoaTextLayout = class(TObject)
|
|
||||||
public
|
|
||||||
constructor Create; virtual;
|
|
||||||
procedure SetFont(AFont: TCocoaFont); virtual; abstract;
|
|
||||||
procedure SetText(UTF8Text: PChar; ByteSize: Integer); virtual; abstract;
|
|
||||||
function GetSize: TSize; virtual; abstract;
|
|
||||||
|
|
||||||
procedure Draw(cg: CGContextRef; X, Y: Integer; DX: PInteger); virtual; abstract;
|
|
||||||
end;
|
|
||||||
TCocoaTextLayoutClass = class of TCocoaTextLayout;
|
|
||||||
|
|
||||||
{ TCocoaContext }
|
{ TCocoaContext }
|
||||||
|
|
||||||
TCocoaContext = class(TObject)
|
TCocoaContext = class(TObject)
|
||||||
private
|
private
|
||||||
fText : TCocoaTextLayout;
|
//fText : TCocoaTextLayout;
|
||||||
fBrush : TCocoaBrush;
|
fBrush : TCocoaBrush;
|
||||||
fPen : TCocoaPen;
|
fPen : TCocoaPen;
|
||||||
fFont : TCocoaFont;
|
fFont : TCocoaFont;
|
||||||
@ -195,9 +182,6 @@ type
|
|||||||
property Bitmap: TCocoaBitmap read fBitmap write SetBitmap;
|
property Bitmap: TCocoaBitmap read fBitmap write SetBitmap;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
|
||||||
TextLayoutClass : TCocoaTextLayoutClass = nil;
|
|
||||||
|
|
||||||
function CheckDC(dc: HDC): TCocoaContext;
|
function CheckDC(dc: HDC): TCocoaContext;
|
||||||
function CheckDC(dc: HDC; Str: string): Boolean;
|
function CheckDC(dc: HDC; Str: string): Boolean;
|
||||||
function CheckGDIOBJ(obj: HGDIOBJ): TCocoaGDIObject;
|
function CheckGDIOBJ(obj: HGDIOBJ): TCocoaGDIObject;
|
||||||
@ -397,12 +381,10 @@ end;
|
|||||||
|
|
||||||
constructor TCocoaContext.Create;
|
constructor TCocoaContext.Create;
|
||||||
begin
|
begin
|
||||||
fText:=TextLayoutClass.Create;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCocoaContext.Destroy;
|
destructor TCocoaContext.Destroy;
|
||||||
begin
|
begin
|
||||||
fText.Free;
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -581,7 +563,7 @@ procedure TCocoaContext.TextOut(X,Y:Integer;UTF8Chars:PChar;Count:Integer;
|
|||||||
var
|
var
|
||||||
cg : CGContextRef;
|
cg : CGContextRef;
|
||||||
begin
|
begin
|
||||||
cg:=CGContext;
|
{cg:=CGContext;
|
||||||
if not Assigned(cg) then Exit;
|
if not Assigned(cg) then Exit;
|
||||||
|
|
||||||
CGContextScaleCTM(cg, 1, -1);
|
CGContextScaleCTM(cg, 1, -1);
|
||||||
@ -594,7 +576,7 @@ begin
|
|||||||
if Assigned(fBrush) then fBrush.Apply(cg);
|
if Assigned(fBrush) then fBrush.Apply(cg);
|
||||||
|
|
||||||
CGContextTranslateCTM(cg, 0, ContextSize.cy);
|
CGContextTranslateCTM(cg, 0, ContextSize.cy);
|
||||||
CGContextScaleCTM(cg, 1, -1);
|
CGContextScaleCTM(cg, 1, -1);}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -611,7 +593,7 @@ function TCocoaContext.GetTextExtentPoint(AStr: PChar; ACount: Integer;
|
|||||||
var
|
var
|
||||||
LStr: String;
|
LStr: String;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
{Result := False;
|
||||||
Size.cx := 0;
|
Size.cx := 0;
|
||||||
Size.cy := 0;
|
Size.cy := 0;
|
||||||
|
|
||||||
@ -623,7 +605,7 @@ begin
|
|||||||
fText.SetText(PChar(LStr), Length(LStr));
|
fText.SetText(PChar(LStr), Length(LStr));
|
||||||
Size := fText.getSize();
|
Size := fText.getSize();
|
||||||
|
|
||||||
Result := True;
|
Result := True;}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -1010,13 +992,6 @@ begin
|
|||||||
CGContextSetRGBFillColor(cg, R,G,B, 1);
|
CGContextSetRGBFillColor(cg, R,G,B, 1);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaTextLayout }
|
|
||||||
|
|
||||||
constructor TCocoaTextLayout.Create;
|
|
||||||
begin
|
|
||||||
inherited Create;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ TCocoaGDIObject }
|
{ TCocoaGDIObject }
|
||||||
|
|
||||||
procedure TCocoaGDIObject.AddRef;
|
procedure TCocoaGDIObject.AddRef;
|
||||||
|
Loading…
Reference in New Issue
Block a user