Recent

Author Topic: Difference between Linux and Windows canvas resp. GradientFill?  (Read 1200 times)

Fish

  • New Member
  • *
  • Posts: 14
Hi,

I wrote my own procedure to add, among other things, a gradient to whatever components which very simplified looks like this:

Code: Pascal  [Select][+][-]
  1. procedure PaintGradient(ACanvas: TCanvas);
  2. begin
  3.   ACanvas.GradientFill(Rect(0, 0, ACanvas.Width, ACanvas.Height), clRed, clBlue, gdVertical);
  4. end;


This works under Linux without any problems. Under Windows it doesn't.
So I made some tests with TPanels and their onPaint events. Under Linux it makes no difference wether you pass Rect(0, 0, Panel.Width, Panel.Height) or  Rect(0, 0, Panel.Canvas.Width, Panel.Canvas.Height) to GradientFill, whereas under Windows only the first version is working correctly. If you increase the height of the panels, you can see that there definitely is a gradient, but it seems to run over the size of the form (?).
Since there is no Canvas.Parent I'm running into problems here. Any ideas how this can be solved?

Screenshots and test-project attached.
Thanks Chris

Fish

  • New Member
  • *
  • Posts: 14
Re: Difference between Linux and Windows canvas resp. GradientFill?
« Reply #1 on: May 21, 2020, 05:09:38 pm »
No one? No idea? No hint? No comment?

I worked around the problem by passing height and width as arguments, which is working as expected.
But it still would be interesting whether this different behavior is intended or a bug.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Difference between Linux and Windows canvas resp. GradientFill?
« Reply #2 on: May 21, 2020, 05:51:17 pm »
Hi!

Don't rely on the dimensions of the canvas.
It is known to be buggy in Windows.
Pass the width and the height as parameter to your function.
Take the width and height from the component and not
from the component.canvas.

Winni

Fish

  • New Member
  • *
  • Posts: 14
Re: Difference between Linux and Windows canvas resp. GradientFill?
« Reply #3 on: May 23, 2020, 09:13:56 am »
Quote
It is known to be buggy in Windows.
Ok, thank you for this information.

 

TinyPortal © 2005-2018