gtk, qt: don't draw a rectangle if Width or Height = 0 (bug #0010980)

git-svn-id: trunk@18864 -
This commit is contained in:
paul 2009-03-02 03:19:19 +00:00
parent 084ca7e3cd
commit 980be4b83e
4 changed files with 29 additions and 20 deletions

View File

@ -7493,6 +7493,7 @@ begin
if not IsValidDC(DC) then Exit(False);
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}

View File

@ -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;

View File

@ -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;

View File

@ -1654,17 +1654,23 @@ end;
procedure CalculateLeftTopWidthHeight(X1, Y1, X2, Y2: integer;
var Left, Top, Width, Height: integer);
begin
if X1<=X2 then begin
if X1 <= X2 then
begin
Left := X1;
Width := X2 - X1;
end else begin
end
else
begin
Left := X2;
Width := X1 - X2;
end;
if Y1<=Y2 then begin
if Y1 <= Y2 then
begin
Top := Y1;
Height := Y2 - Y1;
end else begin
end
else
begin
Top := Y2;
Height := Y1 - Y2;
end;