Hi,
I just saw a Mantis bug report come thought about a old issue and
something I was fighting with in fpGUI as well. See mantis bug report
#8342 for more details. In fpGUI I have been going back and forward
between what behavior is right and what isn't.
Should TCanvas.Rectangle(0,0,1,1) draw an 1x1 (as Windows.Rectangle
does) rectangle or a 2x2 rectangle (as Lazarus does currently)?
Here is the definition of Rectangle in TCanvas:
Procedure Rectangle(X1,Y1,X2,Y2: Integer); virtual; // already in fpcanvas
Procedure Rectangle(const ARect: TRect); // already in fpcanvas
In the end I decided to be mathematically correct in fpGUI.
TfpgCanvas.DrawRectangle(X1,Y1,X2,Y2: Integer)
which mean if I call DrawRect(0, 0, 1, 1) it will draw a rectangle
starting at (0, 0) and ending at (1, 1) which translates to a 2x2
pixel rectangle.
*IF* Rectangle was defined as Rectangle(X, Y, Width, Height), which it
isn't, confusion would be less. In this case Rectangle(0, 0, 1, 1)
would draw a rectangle 1x1 pixels big, starting at coordinate (0, 0)
and ending at (0,0).
Again, TRect is defined as Top, Left, Bottom and Right. No Width and
Height is mentioned. So Right and Bottom must be considered as
coordinates.
My take is that Windows.Rectangle is actually wrong and I don't think
Lazarus should follow that mistake! You have to distinguish between
TRect.Right and Width. What does everybody else think?
Here is Qt's take on this. http://doc.trolltech.com/4.3/qrect.html#details
And here is a link to Microsoft's take:
The canvas routines in Delphi are inspired by the winapi for device
contexts. See http://msdn2.microsoft.com/en-gb/library/ms533879.aspx
[^] for the winapi documentation. It states that "The rectangle that
is drawn excludes the bottom and right edges."
Somewhere else this is explained as nRightRect-nLeftRect should be
considered as width.
Regards,
- Graeme -
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives