mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 12:39:29 +02:00
gtk, qt: don't draw a rectangle if Width or Height = 0 (bug #0010980)
git-svn-id: trunk@18864 -
This commit is contained in:
parent
084ca7e3cd
commit
980be4b83e
@ -7492,7 +7492,8 @@ begin
|
||||
Assert(False, Format('trace:> [TGtkWidgetSet.Rectangle] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d', [DC, X1, Y1, X2, Y2]));
|
||||
if not IsValidDC(DC) then Exit(False);
|
||||
|
||||
CalculateLeftTopWidthHeight(X1,Y1,X2,Y2,Left,Top,Width,Height);
|
||||
CalculateLeftTopWidthHeight(X1, Y1, X2, Y2, Left, Top, Width, Height);
|
||||
if (Width = 0) or (Height = 0) then Exit(True);
|
||||
// X2, Y2 is not part of the rectangle
|
||||
dec(Width);
|
||||
dec(Height);
|
||||
@ -7520,8 +7521,8 @@ begin
|
||||
DevCtx.SelectPenProps;
|
||||
Result := dcfPenSelected in DevCtx.Flags;
|
||||
if Result and not DevCtx.IsNullPen
|
||||
then gdk_draw_rectangle(DevCtx.Drawable, DevCtx.GC, 0, Left+DCOrigin.X,
|
||||
Top+DCOrigin.Y, Width, Height);
|
||||
then gdk_draw_rectangle(DevCtx.Drawable, DevCtx.GC, 0,
|
||||
Left+DCOrigin.X, Top+DCOrigin.Y, Width, Height);
|
||||
|
||||
{$IFDEF DebugGDKTraps}EndGDKErrorTrap;{$ENDIF}
|
||||
|
||||
|
@ -46,7 +46,7 @@ uses
|
||||
// LCL
|
||||
InterfaceBase, LCLProc, LCLType, LMessages, LCLMessageGlue, LCLStrConsts,
|
||||
Controls, ExtCtrls, Forms,
|
||||
Dialogs, StdCtrls, Comctrls, LCLIntf, GraphType, Themes,
|
||||
Dialogs, StdCtrls, Comctrls, LCLIntf, GraphType, GraphUtil, Themes,
|
||||
Arrow, CheckLst,
|
||||
// WS
|
||||
qtproc;
|
||||
|
@ -3873,17 +3873,19 @@ end;
|
||||
the current pen and filled by using the current brush.
|
||||
------------------------------------------------------------------------------}
|
||||
function TQtWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean;
|
||||
var
|
||||
R: TRect;
|
||||
begin
|
||||
{$ifdef VerboseQtWinAPI}
|
||||
WriteLn('[WinAPI Rectangle] DC: ', dbghex(DC));
|
||||
{$endif}
|
||||
|
||||
Result := False;
|
||||
if not IsValidDC(DC) then Exit(False);
|
||||
|
||||
if not IsValidDC(DC) then Exit;
|
||||
|
||||
TQtDeviceContext(DC).drawRect(X1, Y1, X2 - X1 - 1, Y2 - Y1 - 1);
|
||||
R := NormalizeRect(Rect(X1, Y1, X2, Y2));
|
||||
if IsRectEmpty(R) then Exit(True);
|
||||
|
||||
TQtDeviceContext(DC).drawRect(R.Left, R.Top, R.Right - R.Left - 1, R.Bottom - R.Top - 1);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
|
@ -1654,19 +1654,25 @@ end;
|
||||
procedure CalculateLeftTopWidthHeight(X1, Y1, X2, Y2: integer;
|
||||
var Left, Top, Width, Height: integer);
|
||||
begin
|
||||
if X1<=X2 then begin
|
||||
Left:=X1;
|
||||
Width:=X2 - X1;
|
||||
end else begin
|
||||
Left:=X2;
|
||||
Width:=X1 - X2;
|
||||
if X1 <= X2 then
|
||||
begin
|
||||
Left := X1;
|
||||
Width := X2 - X1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Left := X2;
|
||||
Width := X1 - X2;
|
||||
end;
|
||||
if Y1<=Y2 then begin
|
||||
Top:=Y1;
|
||||
Height:=Y2 - Y1;
|
||||
end else begin
|
||||
Top:=Y2;
|
||||
Height:=Y1 - Y2;
|
||||
if Y1 <= Y2 then
|
||||
begin
|
||||
Top := Y1;
|
||||
Height := Y2 - Y1;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Top := Y2;
|
||||
Height := Y1 - Y2;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user