Recent

Author Topic: [Solved] Problem drawing on Canvas  (Read 1474 times)

apeoperaio

  • Full Member
  • ***
  • Posts: 158
[Solved] Problem drawing on Canvas
« 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

« Last Edit: July 17, 2018, 02:36:46 pm by apeoperaio »

Fritzew

  • Newbie
  • Posts: 2
Re: Problem drawing on Canvas
« Reply #1 on: July 16, 2018, 06:54:22 pm »
You should use Client with and Height

Thaddy

  • Hero Member
  • *****
  • Posts: 9187
Re: Problem drawing on Canvas
« Reply #2 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.
also related to equus asinus.

apeoperaio

  • Full Member
  • ***
  • Posts: 158
Re: Problem drawing on Canvas
« Reply #3 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.

apeoperaio

  • Full Member
  • ***
  • Posts: 158
Re: [Solved] Problem drawing on Canvas
« Reply #4 on: July 17, 2018, 02:37:19 pm »
Tested using cocoa in lazarus trunk and it works as expected.