From 89190707c1a329f16ebdbdd840f34b983aaaeaef Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 6 Nov 2015 18:35:28 +0000 Subject: [PATCH] LCL: exploded some With-blocks for fpc 3.1.1 git-svn-id: trunk@50237 - --- lcl/calendar.pp | 3 +- lcl/dbgrids.pas | 8 ++-- lcl/editbtn.pas | 3 +- lcl/extdlgs.pas | 3 +- lcl/graphmath.pp | 6 +-- lcl/industrialbase.pp | 3 +- lcl/lazcanvas.pas | 85 ++++++++++++++++++---------------------- lcl/postscriptcanvas.pas | 21 ++++------ lcl/printers.pas | 40 ++++++++++--------- 9 files changed, 75 insertions(+), 97 deletions(-) diff --git a/lcl/calendar.pp b/lcl/calendar.pp index 169acf2019..40d3cc8aaf 100644 --- a/lcl/calendar.pp +++ b/lcl/calendar.pp @@ -159,8 +159,7 @@ constructor TCustomCalendar.Create(AOwner: TComponent); begin inherited Create(AOwner); fCompStyle := csCalendar; - with GetControlClassDefaultSize do - SetInitialBounds(0, 0, CX, CY); + SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY); FDisplaySettings := DefaultDisplaySettings; ControlStyle:=ControlStyle-[csTripleClicks,csQuadClicks,csAcceptsControls,csCaptureMouse]; DateTime := Now; diff --git a/lcl/dbgrids.pas b/lcl/dbgrids.pas index d7ed91eeda..e633571903 100644 --- a/lcl/dbgrids.pas +++ b/lcl/dbgrids.pas @@ -1674,9 +1674,7 @@ begin {$ifdef dbgDBGrid} DebugLn('%s.IsEOF', [ClassName]); {$endif} - with FDatalink do - result := - Active and DataSet.EOF; + Result := FDatalink.Active and FDatalink.DataSet.EOF; end; function TCustomDBGrid.ValidDataSet: boolean; @@ -1684,13 +1682,13 @@ begin {$ifdef dbgDBGrid} DebugLn('%s.ValidDataSet', [ClassName]); {$endif} - result := FDatalink.Active And (FDatalink.DataSet<>nil) + Result := FDatalink.Active And (FDatalink.DataSet<>nil) end; function TCustomDBGrid.InsertCancelable: boolean; begin with FDatalink.DataSet do - Result := (State=dsInsert) and not (Modified or FDataLink.FModified); + Result := (State=dsInsert) and not (Modified or FDataLink.FModified); end; procedure TCustomDBGrid.StartUpdating; diff --git a/lcl/editbtn.pas b/lcl/editbtn.pas index 77d0bd0046..406d485baf 100644 --- a/lcl/editbtn.pas +++ b/lcl/editbtn.pas @@ -1944,8 +1944,7 @@ begin TabStop := True; FocusOnButtonClick := False; - with GetControlClassDefaultSize do - SetInitialBounds(0, 0, CX, CY); + SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY); with FButton do begin diff --git a/lcl/extdlgs.pas b/lcl/extdlgs.pas index bb0b9d4482..46fa03d2f0 100644 --- a/lcl/extdlgs.pas +++ b/lcl/extdlgs.pas @@ -266,8 +266,7 @@ constructor TPreviewFileControl.Create(TheOwner: TComponent); begin inherited Create(TheOwner); FCompStyle:=csPreviewFileControl; - with GetControlClassDefaultSize do - SetInitialBounds(0, 0, CX, CY); + SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY); end; { TPreviewFileDialog } diff --git a/lcl/graphmath.pp b/lcl/graphmath.pp index 36c656f3b5..07a1c13c3f 100644 --- a/lcl/graphmath.pp +++ b/lcl/graphmath.pp @@ -268,10 +268,8 @@ end; Operator := (Value : TFloatPoint) : TPoint; begin - With Result do begin - X := Trunc(SimpleRoundTo(Value.X, 0)); - Y := Trunc(SimpleRoundTo(Value.Y, 0)); - end; + Result.X := Trunc(SimpleRoundTo(Value.X, 0)); + Result.Y := Trunc(SimpleRoundTo(Value.Y, 0)); end; Operator := (Value : TPoint) : TFloatPoint; diff --git a/lcl/industrialbase.pp b/lcl/industrialbase.pp index 4cce713e6a..18aff5ee1f 100644 --- a/lcl/industrialbase.pp +++ b/lcl/industrialbase.pp @@ -30,8 +30,7 @@ constructor TIndustrialBase.Create(aOwner: TComponent); begin inherited Create(aOwner); FAntiAliasingMode := amDontCare; - with GetControlClassDefaultSize do - SetInitialBounds(0, 0, cx, cy); + SetInitialBounds(0, 0, GetControlClassDefaultSize.cx, GetControlClassDefaultSize.cy); ControlStyle := ControlStyle - [csSetCaption]; end; diff --git a/lcl/lazcanvas.pas b/lcl/lazcanvas.pas index 4ad5d0c1bf..2f15bb6c60 100644 --- a/lcl/lazcanvas.pas +++ b/lcl/lazcanvas.pas @@ -261,30 +261,24 @@ begin b.bottom := b.bottom-1; if pen.style = psSolid then for r := 1 to pen.width do - begin - with b do - begin - CheckLine (left,top,left,bottom); - CheckLine (left,bottom,right,bottom); - CheckLine (right,bottom,right,top); - CheckLine (right,top,left,top); - end; - DecRect (b); - end - else if pen.style <> psClear then begin + CheckLine (b.left,b.top,b.left,b.bottom); + CheckLine (b.left,b.bottom,b.right,b.bottom); + CheckLine (b.right,b.bottom,b.right,b.top); + CheckLine (b.right,b.top,b.left,b.top); + DecRect (b); + end + else if pen.style <> psClear then + begin if pen.style = psPattern then pattern := Pen.pattern else pattern := PenPatterns[pen.style]; - with b do - begin - CheckPLine (left,top,left,bottom); - CheckPLine (left,bottom,right,bottom); - CheckPLine (right,bottom,right,top); - CheckPLine (right,top,left,top); - end; - end; + CheckPLine (b.left,b.top,b.left,b.bottom); + CheckPLine (b.left,b.bottom,b.right,b.bottom); + CheckPLine (b.right,b.bottom,b.right,b.top); + CheckPLine (b.right,b.top,b.left,b.top); + end; end; procedure TLazCanvas.DoRectangleFill(const Bounds: TRect); @@ -303,35 +297,32 @@ begin Exit; end; -// if clipping then -// CheckRectClipping (ClipRect, B); - with b do - case Brush.style of - bsSolid : FillRectangleColor (self, left,top, right,bottom); - bsPattern : FillRectanglePattern (self, left,top, right,bottom, brush.pattern); - bsImage : - if assigned (brush.image) then - if RelativeBrushImage then - FillRectangleImageRel (self, left,top, right,bottom, brush.image) - else - FillRectangleImage (self, left,top, right,bottom, brush.image) + case Brush.style of + bsSolid : FillRectangleColor (self, b.left,b.top, b.right,b.bottom); + bsPattern : FillRectanglePattern (self, b.left,b.top, b.right,b.bottom, brush.pattern); + bsImage : + if assigned (brush.image) then + if RelativeBrushImage then + FillRectangleImageRel (self, b.left,b.top, b.right,b.bottom, brush.image) else - raise PixelCanvasException.Create (sErrNoImage); - bsBDiagonal : FillRectangleHashDiagonal (self, b, HashWidth); - bsFDiagonal : FillRectangleHashBackDiagonal (self, b, HashWidth); - bsCross : - begin - FillRectangleHashHorizontal (self, b, HashWidth); - FillRectangleHashVertical (self, b, HashWidth); - end; - bsDiagCross : - begin - FillRectangleHashDiagonal (self, b, HashWidth); - FillRectangleHashBackDiagonal (self, b, HashWidth); - end; - bsHorizontal : FillRectangleHashHorizontal (self, b, HashWidth); - bsVertical : FillRectangleHashVertical (self, b, HashWidth); - end; + FillRectangleImage (self, b.left,b.top, b.right,b.bottom, brush.image) + else + raise PixelCanvasException.Create (sErrNoImage); + bsBDiagonal : FillRectangleHashDiagonal (self, b, HashWidth); + bsFDiagonal : FillRectangleHashBackDiagonal (self, b, HashWidth); + bsCross : + begin + FillRectangleHashHorizontal (self, b, HashWidth); + FillRectangleHashVertical (self, b, HashWidth); + end; + bsDiagCross : + begin + FillRectangleHashDiagonal (self, b, HashWidth); + FillRectangleHashBackDiagonal (self, b, HashWidth); + end; + bsHorizontal : FillRectangleHashHorizontal (self, b, HashWidth); + bsVertical : FillRectangleHashVertical (self, b, HashWidth); + end; end; // unimplemented in FPC diff --git a/lcl/postscriptcanvas.pas b/lcl/postscriptcanvas.pas index 0b689464f9..6df90d1a90 100644 --- a/lcl/postscriptcanvas.pas +++ b/lcl/postscriptcanvas.pas @@ -1113,8 +1113,7 @@ begin Self.WriteComment('Pushing and Setting current clip rect'); Self.Write('clipsave'); B := TxRectToBounds(FLazClipRect); - with B do - Self.Write(Format('%f %f %f %f rectclip',[fx, fy, fwidth, fheight],FFs)); + Write(Format('%f %f %f %f rectclip',[B.fx, B.fy, B.fwidth, B.fheight],FFs)); Include(FStatus, pcsClipSaved); end; @@ -1820,18 +1819,12 @@ begin ellipsePath:='matrix currentmatrix %f %f translate %f %f scale 0 0 1 %d %d arc setmatrix'; PixelsToPoints(RX,RY,r.fx,r.fy); - {choice between newpath and moveto beginning of arc - go with newpath for precision, does this violate any assumptions in code??? - write(format('%d %d moveto',[x1+rx, y1]),Lst # this also works} - with r do - begin - WriteB('newpath'); - WriteB(Format(ellipsePath,[pp1.fx+fx,pp1.fy-fy,fx,fy,90,180],FFs)); - WriteB(Format(ellipsePath,[pp1.fx+fx,pp2.fy+fy,fx,fy,180,270],FFs)); - WriteB(Format(ellipsePath,[pp2.fx-fx,pp2.fy+fy,fx,fy,270,360],FFs)); - WriteB(Format(ellipsePath,[pp2.fx-fx,pp1.fy-fy,fx,fy,0,90],FFs)); - WriteB('closepath'); - end; + WriteB('newpath'); + WriteB(Format(ellipsePath,[pp1.fx+r.fx,pp1.fy-r.fy,r.fx,r.fy,90,180],FFs)); + WriteB(Format(ellipsePath,[pp1.fx+r.fx,pp2.fy+r.fy,r.fx,r.fy,180,270],FFs)); + WriteB(Format(ellipsePath,[pp2.fx-r.fx,pp2.fy+r.fy,r.fx,r.fy,270,360],FFs)); + WriteB(Format(ellipsePath,[pp2.fx-r.fx,pp1.fy-r.fy,r.fx,r.fy,0,90],FFs)); + WriteB('closepath'); SetBrushFillPattern(True,True); diff --git a/lcl/printers.pas b/lcl/printers.pas index 4cc96bba6b..3f9cb42695 100644 --- a/lcl/printers.pas +++ b/lcl/printers.pas @@ -1011,28 +1011,28 @@ end; function TPaperSize.GetDefaultPaperRect(const AName: string; var APaperRect:TPaperRect): Integer; +var + PR: TPaperRect; begin Result := IndexOfDefaultPaper(AName); if Result>=0 then - with FInternalPapers[Result].PaperRect do begin - if FOwnedPrinter.Orientation in [poPortrait, poReversePortrait] then - begin - APaperRect.PhysicalRect := PhysicalRect; - APaperRect.WorkRect := WorkRect; - end else - begin - APaperRect.PhysicalRect.Left := 0; - APaperRect.PhysicalRect.Top := 0; - APaperRect.PhysicalRect.Right := PhysicalRect.Bottom; - APaperRect.Physicalrect.Bottom := PhysicalRect.Right; + PR:=FInternalPapers[Result].PaperRect; + if FOwnedPrinter.Orientation in [poPortrait, poReversePortrait] then + begin + APaperRect.PhysicalRect := PR.PhysicalRect; + APaperRect.WorkRect := PR.WorkRect; + end else + begin + APaperRect.PhysicalRect.Left := 0; + APaperRect.PhysicalRect.Top := 0; + APaperRect.PhysicalRect.Right := PR.PhysicalRect.Bottom; + APaperRect.Physicalrect.Bottom := PR.PhysicalRect.Right; - APaperRect.WorkRect.Left := WorkRect.Top; - APaperRect.WorkRect.Top := PhysicalRect.Right-WorkRect.Right; - APaperRect.WorkRect.Right := WorkRect.Bottom; - APaperRect.WorkRect.Bottom := PhysicalRect.Right-Workrect.Left; - end; + APaperRect.WorkRect.Left := PR.WorkRect.Top; + APaperRect.WorkRect.Top := PR.PhysicalRect.Right-PR.WorkRect.Right; + APaperRect.WorkRect.Right := PR.WorkRect.Bottom; + APaperRect.WorkRect.Bottom := PR.PhysicalRect.Right-PR.Workrect.Left; end; - end; function TPaperSize.GetPhysPaperHeight: Integer; @@ -1335,11 +1335,13 @@ begin end; function TPrinterCanvas.GetRightMargin: Integer; +var + PR: TPaperRect; begin if (fRightMargin=0) and (fPrinter<>nil) then begin - with fPrinter.Papersize.PaperRect do - Result := PhysicalRect.Right-WorkRect.Right; + PR:=fPrinter.Papersize.PaperRect; + Result := PR.PhysicalRect.Right-PR.WorkRect.Right; end else Result := fRightMargin; end;