Lazarus

Programming => Widgetset => Cocoa => Topic started by: apeoperaio on July 16, 2018, 01:09:30 pm

Title: [Solved] Problem drawing on Canvas
Post by: apeoperaio on July 16, 2018, 01:09:30 pm
I noticed a different behaviour when drawing on Canvas between Cocoa and all other widgetsets.
Carbon reacts as win32 and GTK2. Cocoa differently.
Open a new project and OnPaint do:

procedure TForm1.FormPaint(Sender: TObject);
begin
  Canvas.Line(0, 0, Width, Height);
end; 

See attached images, Cocoa does not draw the line properly.
Lazarus 1.8.4 fpc 3.0.4

Title: Re: Problem drawing on Canvas
Post by: Fritzew on July 16, 2018, 06:54:22 pm
You should use Client with and Height
Title: Re: Problem drawing on Canvas
Post by: Thaddy on July 16, 2018, 07:20:59 pm
You should use Client with and Height
Although that works indeed, it is still a bug I guess. Please report it, because the non-client area should not count to the canvas size.
Title: Re: Problem drawing on Canvas
Post by: apeoperaio on July 16, 2018, 09:08:04 pm
ClientHeight and Height are equal on Carbon while they differ on Cocoa, you can test it using Form1 OnPaint:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2. begin
  3.   Canvas.Line(0, 0, clientWidth, clientHeight);
  4.   label1.Caption:= Format('cwidth: %d, cheight: %d', [ClientWidth, ClientHeight]);
  5.   label2.Caption:= Format('width: %d, height: %d', [Width, Height]);
  6. end;
  7.  

Reported as 0033995.
Title: Re: [Solved] Problem drawing on Canvas
Post by: apeoperaio on July 17, 2018, 02:37:19 pm
Tested using cocoa in lazarus trunk and it works as expected.
TinyPortal © 2005-2018