diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2013-07-12 11:45:55 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2013-07-12 11:58:39 +0100 |
commit | 3b9482f2e3bcb15d5faa5474665cf6d6bc1b327e (patch) | |
tree | 7be0c1e3ec671ca9c24e336e8ce474234ff7c4aa | |
parent | 7a41980dd5764124dbf1443615e67e54dfe0e4de (diff) | |
download | fpGUI-3b9482f2e3bcb15d5faa5474665cf6d6bc1b327e.tar.xz |
nicegrid: removed unnecessary fpg_types unit
* The code introduced in fpg_types.pas are now available in fpg_main -
maybe with slightly different names.
* replaced all references to fpg_types methods with new ones found in
fpg_main
-rw-r--r-- | extras/contributed/nicegrid/fpg_nicegrid.pas | 61 | ||||
-rw-r--r-- | extras/contributed/nicegrid/fpg_types.pas | 131 |
2 files changed, 30 insertions, 162 deletions
diff --git a/extras/contributed/nicegrid/fpg_nicegrid.pas b/extras/contributed/nicegrid/fpg_nicegrid.pas index 21ff81c0..2a27f771 100644 --- a/extras/contributed/nicegrid/fpg_nicegrid.pas +++ b/extras/contributed/nicegrid/fpg_nicegrid.pas @@ -4,7 +4,7 @@ unit fpg_nicegrid; interface uses - Classes, SysUtils, fpg_base, fpg_main, fpg_panel, fpg_scrollbar, fpg_types, fpg_edit; + Classes, SysUtils, fpg_base, fpg_main, fpg_panel, fpg_scrollbar, fpg_edit; type PHeaderInfo = ^THeaderInfo; @@ -987,13 +987,13 @@ var begin if (FGutterKind = gkNone) then Exit; - CopyfpgRect(GutterBox, CellBox); + CopyRect(GutterBox, CellBox); GutterBox.Left := 0; for x := 0 to FRowCount-1 do begin R := fpgRect(-1, (x * FDefRowHeight) -1, FGutterWidth, FDefRowHeight +1); - OffsetfpgRect(R, 2, -FVertOffset + FixedHeight); - if IntersectfpgRect(Dummy, R, GutterBox) then + OffsetRect(R, 2, -FVertOffset + FixedHeight); + if IntersectRect(Dummy, R, GutterBox) then begin case FGutterKind of gkBlank, gkPointer: @@ -1040,8 +1040,8 @@ begin GetColCoord(P^.Rc.Width+1) - GetColCoord(P^.Rc.Left)+1, FDefRowHeight * (P^.Rc.Height+1)+1 ); - OffsetfpgRect(R, -FHorzOffset + FixedWidth, 0); - if IntersectfpgRect(Dummy, R, fpgRect(1,1,ClientWidth,ClientHeight)) + OffsetRect(R, -FHorzOffset + FixedWidth, 0); + if IntersectRect(Dummy, R, fpgRect(1,1,ClientWidth,ClientHeight)) then DrawFixCell(R, P^.Str, FHeaderFont, FHeaderFontColor, FOnDrawHeader); end; R := fpgRect(1,1, FixedWidth, FixedHeight ); @@ -1063,9 +1063,9 @@ begin GetColCoord(x+1)-GetColCoord(x)+1, FooterBottom-FooterTop+1 ); - OffsetfpgRect(R, -FHorzOffset + FixedWidth, 0); + OffsetRect(R, -FHorzOffset + FixedWidth, 0); - if IntersectfpgRect(Dummy, R, fpgRect(1,1,ClientWidth,ClientHeight)) + if IntersectRect(Dummy, R, fpgRect(1,1,ClientWidth,ClientHeight)) then DrawFixCell(R, FColumns[x].FFooter, FFooterFont, FFooterFontColor, FOnDrawFooter); end; R := fpgRect(1, FooterTop, FixedWidth, FooterBottom-FooterTop); @@ -1084,8 +1084,8 @@ var begin Handled := False; Rc := GetCellRect(x, y); - OffsetfpgRect(Rc, -FHorzOffset + FixedWidth, -FVertOffset + FixedHeight); - if IntersectfpgRect(Dummy, Rc, CellBox) then + OffsetRect(Rc, -FHorzOffset + FixedWidth, -FVertOffset + FixedHeight); + if IntersectRect(Dummy, Rc, CellBox) then begin Column := FColumns[x]; with Canvas do @@ -1093,8 +1093,8 @@ begin Font:=fpgGetFont(Column.Font); SetTextColor(Column.FontColor); - if not FEnabled - then SetTextColor(FGridColor); + if not FEnabled then + SetTextColor(FGridColor); SetColor(GetCellColor(X, Y)); if Assigned(FOnDrawCell) @@ -1105,14 +1105,13 @@ begin FillRectangle(Rc); if FShowGrid then begin - SetColor(FGridColor); - inc(Rc.Width,1); - inc(Rc.Height,1); + SetColor(FGridColor); + inc(Rc.Width,1); + inc(Rc.Height,1); DrawRectangle(Rc); - end; - InflatefpgRect(Rc, -4, -2); - DrawStringUni(Canvas, SafeGetCell(x, y), Rc, Column.HorzAlign, - Column.VertAlign); + end; + InflateRect(Rc, -4, -2); + DrawStringUni(Canvas, SafeGetCell(x, y), Rc, Column.HorzAlign, Column.VertAlign); end; end; end; @@ -1127,8 +1126,8 @@ begin Handled := False; Result := Point(-1, -1); R := GetCellRect(x, y); - OffsetfpgRect(R, -FHorzOffset + FixedWidth, -FVertOffset + FixedHeight); - if IntersectfpgRect(Dummy, R, CellBox) then + OffsetRect(R, -FHorzOffset + FixedWidth, -FVertOffset + FixedHeight); + if IntersectRect(Dummy, R, CellBox) then begin Column := FColumns[x]; with Canvas do @@ -1165,7 +1164,7 @@ begin R1 := GetCellRect(FSelectArea.Left, FSelectArea.Top); R2 := GetCellRect(FSelectArea.Width, FSelectArea.Height); R := fpgRect(R1.Left+2, R1.Top+2, R2.Right - R1.Left, R2.Bottom - R1.Top); - OffsetfpgRect(R, HOffset, VOffset); + OffsetRect(R, HOffset, VOffset); with Canvas do begin @@ -1380,7 +1379,7 @@ end; function TfpgNiceGrid.CellRectToClient(R: TfpgRect): TfpgRect; begin Result := R; - OffsetfpgRect(Result, - FHorzOffset + FixedWidth, - FVertOffset + FixedHeight); + OffsetRect(Result, - FHorzOffset + FixedWidth, - FVertOffset + FixedHeight); end; function TfpgNiceGrid.GetCellAtPos(X, Y: Integer): TPoint; @@ -1959,7 +1958,7 @@ begin end; end; - if PtInfpgRect(SmallBox, Point(X, Y)) + if PtInRect(SmallBox, Point(X, Y)) then Result := gtSmallBox else if IsSizing then Result := gtColSizing else @@ -2534,8 +2533,8 @@ end; procedure TfpgNiceGrid.AdjustSelection(Value: TfpgRect; Force: Boolean); begin - if EqualfpgRect(FSelectArea, Value) and not Force - then Exit; //==> + if (FSelectArea = Value) and not Force then + Exit; //==> FSelectArea := Value; end; @@ -2988,7 +2987,7 @@ var begin for x := 0 to Mergeds.Count-1 do begin - CopyfpgRect(Rc, TfpgMergeCell(Mergeds[x]).Rc); + CopyRect(Rc, TfpgMergeCell(Mergeds[x]).Rc); for y := Rc.Left to Rc.Right do begin if (y >= FColumns.Count) @@ -3014,8 +3013,8 @@ begin t := FDefRowHeight * Data.Rc.Top; h := FDefRowHeight * (Data.Rc.Bottom - Data.Rc.Top + 1); Rc := fpgRect(l1-1, t-1, l2-l1, h); - OffsetfpgRect(Rc, -FHorzOffset + FixedWidth, -FVertOffset + FixedHeight); - if IntersectfpgRect(Dummy, Rc, CellBox) then + OffsetRect(Rc, -FHorzOffset + FixedWidth, -FVertOffset + FixedHeight); + if IntersectRect(Dummy, Rc, CellBox) then begin with Canvas do begin @@ -3032,7 +3031,7 @@ begin SetColor(Data.Color); FillRectangle(Rc); end; - InflatefpgRect(Rc, -4, -2); + InflateRect(Rc, -4, -2); DrawStringUni(Canvas, Data.Text, Rc, Data.HorzAlign, Data.VertAlign); end; end; @@ -3302,7 +3301,7 @@ begin Rc := FGrid.GetCellRect(X, Y); Rc := FGrid.CellRectToClient(Rc); - InflatefpgRect(Rc, -2, -2); + InflateRect(Rc, -2, -2); SetPosition(Rc.Left, Rc.Top,Rc.Width,Rc.Height); Visible:=true; SetFocus; diff --git a/extras/contributed/nicegrid/fpg_types.pas b/extras/contributed/nicegrid/fpg_types.pas deleted file mode 100644 index 96d5cbc2..00000000 --- a/extras/contributed/nicegrid/fpg_types.pas +++ /dev/null @@ -1,131 +0,0 @@ -unit fpg_types; -{$mode objfpc}{$H+} - -interface - -uses SysUtils, Classes, fpg_base; - -function EqualfpgRect(const r1,r2 : TfpgRect) : Boolean; -function PtInfpgRect(const ARect : TfpgRect; const p : TPoint) : Boolean; -function IntersectfpgRect(out ARect : TfpgRect; const R1,R2 : TfpgRect) : Boolean; -function UnionfpgRect(out ARect : TfpgRect; const R1,R2 : TfpgRect) : Boolean; -function IsfpgRectEmpty(const ARect : TfpgRect) : Boolean; -function OffsetfpgRect(var ARect : TfpgRect;DX : Integer;DY : Integer) : Boolean; -function InflatefpgRect(var ARect: TfpgRect; dx: Integer; dy: Integer): Boolean; -function CopyfpgRect(out Ds: TfpgRect;const Sc : TfpgRect): Boolean; - -implementation - - -function EqualfpgRect(const r1,r2 : TfpgRect) : Boolean; -begin - Result:= (r1.Left=r2.Left) and (r1.Right=r2.Right) and (r1.Width=r2.Width) and (r1.Height=r2.Height); -end; - -function PtInfpgRect(const ARect : TfpgRect;const p : TPoint) : Boolean; -begin - Result:=(p.y >= ARect.Top) and - (p.y <= ARect.Bottom) and - (p.x >= ARect.Left) and - (p.x <= ARect.Right); -end; - -function IsfpgRectEmpty(const ARect : TfpgRect) : Boolean; -begin - Result:=(ARect.Width <= 0) or (ARect.Height <= 0); -end; - -function IntersectfpgRect(out ARect : TfpgRect;const R1,R2 : TfpgRect) : Boolean; -begin - ARect:=R1; - with R2 do - begin - if Left > R1.Left then - ARect.Left:=Left; - if Top > R1.Top then - ARect.Top:=Top; - if Right < R1.Right then - ARect.Width:= ARect.Left + Right; - if Bottom < R1.Bottom then - ARect.Height:= ARect.Top + Bottom; - end; - if IsfpgRectEmpty(ARect) then - begin - FillChar(ARect,SizeOf(ARect),0); - Result:=false; - end - else - Result:=true; -end; - -function UnionfpgRect(out ARect : TfpgRect;const R1,R2 : TfpgRect) : Boolean; -begin - ARect:=R1; - with R2 do - begin - if Left < R1.Left then - ARect.Left:=Left; - if Top < R1.Top then - ARect.Top:=Top; - if Right > R1.Right then - ARect.Width:= ARect.Left + Right; - if Bottom>R1.Bottom then - ARect.Height:= ARect.Top + Bottom; - end; - if IsfpgRectEmpty(ARect) then - begin - FillChar(ARect,SizeOf(ARect),0); - Result:=false; - end - else - Result:=true; -end; - - - -function OffsetfpgRect(var ARect : TfpgRect;DX : Integer;DY : Integer) : Boolean; -begin - if assigned(@ARect) then - begin - with ARect do - begin - inc(Left,dx); - inc(Top,dy); - end; - Result:=true; - end - else - Result:=false; -end; - -function InflatefpgRect(var ARect: TfpgRect; dx: Integer; dy: Integer): Boolean; -begin - if Assigned(@ARect) then - begin - with ARect do - begin - dec(Left, dx); - dec(Top, dy); - inc(Width, dx*2); - inc(Height, dy*2); - end; - Result := True; - end - else - Result := False; -end; - -function CopyfpgRect(out Ds: TfpgRect;const Sc : TfpgRect): Boolean; -begin - Ds:=Sc; - if IsfpgRectEmpty(Ds) then - begin - FillChar(Ds,SizeOf(Ds),0); - Result:=false; - end - else - Result:=true; -end; - - -end. |