diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/fpgfx.pas | 117 | ||||
-rw-r--r-- | src/corelib/gdi/gfx_gdi.pas | 49 | ||||
-rw-r--r-- | src/corelib/gfxbase.pas | 74 | ||||
-rw-r--r-- | src/corelib/x11/gfx_x11.pas | 48 |
4 files changed, 178 insertions, 110 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas index a9dddf07..c98dc8ae 100644 --- a/src/corelib/fpgfx.pas +++ b/src/corelib/fpgfx.pas @@ -136,8 +136,11 @@ type constructor Create(awin: TfpgWindow); reintroduce; destructor Destroy; override; procedure DrawButtonFace(x, y, w, h: TfpgCoord; AFlags: TFButtonFlags); + procedure DrawButtonFace(r: TfpgRect; AFlags: TFButtonFlags); procedure DrawControlFrame(x, y, w, h: TfpgCoord); + procedure DrawControlFrame(r: TfpgRect); procedure DrawDirectionArrow(x, y, w, h: TfpgCoord; direction: integer); + procedure DrawDirectionArrow(r: TfpgRect; direction: integer); end; @@ -153,10 +156,10 @@ type MenuDisabledFont: TfpgFont; public constructor Create; virtual; - procedure DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: integer; AFlags: TFButtonFlags); virtual; - procedure DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: integer); virtual; - procedure DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: integer; direction: integer); virtual; - procedure DrawString(ACanvas: TfpgCanvas; x, y: integer; AText: string; AEnabled: boolean = True); virtual; + procedure DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TFButtonFlags); virtual; + procedure DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); virtual; + procedure DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; direction: integer); virtual; + procedure DrawString(ACanvas: TfpgCanvas; x, y: TfpgCoord; AText: string; AEnabled: boolean = True); virtual; end; @@ -264,11 +267,15 @@ function fpgClosestTimer(ctime: TDateTime; amaxtime: integer): integer; // Rectangle routines function InflateRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean; +function InflateRect(var Rect: TfpgRect; dx: Integer; dy: Integer): Boolean; function OffsetRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean; +function OffsetRect(var Rect: TfpgRect; dx: Integer; dy: Integer): Boolean; function CenterPoint(const Rect: TRect): TPoint; +function fpgRect(ALeft, ATop, AWidth, AHeight: integer): TfpgRect; // Debug rountines procedure PrintRect(var Rect: TRect); +procedure PrintRect(var Rect: TfpgRect); implementation @@ -367,6 +374,20 @@ begin Result := False; end; +function InflateRect(var Rect: TfpgRect; dx: Integer; dy: Integer): Boolean; +begin + if Assigned(@Rect) then + begin + dec(Rect.Left, dx); + dec(Rect.Top, dy); + inc(Rect.Width, 2*dx); + inc(Rect.Height, 2*dy); + Result := True; + end + else + Result := False; +end; + function OffsetRect(var Rect: TRect; dx: Integer; dy: Integer): Boolean; begin if Assigned(@Rect) then @@ -384,6 +405,21 @@ begin OffsetRect := False; end; +function OffsetRect(var Rect: TfpgRect; dx: Integer; dy: Integer): Boolean; +begin + if Assigned(@Rect) then + begin + with Rect do + begin + inc(Left, dx); + inc(Top, dy); + end; + OffsetRect := True; + end + else + OffsetRect := False; +end; + function CenterPoint(const Rect: TRect): TPoint; begin with Rect do @@ -393,9 +429,21 @@ begin end; end; +function fpgRect(ALeft, ATop, AWidth, AHeight: integer): TfpgRect; +begin + Result.SetRect(ALeft, ATop, AWidth, AHeight); +end; + procedure PrintRect(var Rect: TRect); begin - writeln('Rect x1=', Rect.Left, ' y1=', Rect.Top, ' x2=', Rect.Right, ' y2=', Rect.Bottom); + writeln('Rect left=', Rect.Left, ' top=', Rect.Top, ' right=', Rect.Right, + ' bottom=', Rect.Bottom); +end; + +procedure PrintRect(var Rect: TfpgRect); +begin + writeln('Rect left=', Rect.Left, ' top=', Rect.Top, ' right=', Rect.Right, + ' bottom=', Rect.Bottom, ' width=', Rect.Width, ' height=', Rect.Height); end; { TfpgTimer } @@ -716,16 +764,32 @@ begin fpgStyle.DrawButtonFace(self, x, y, w, h, AFlags); end; +procedure TfpgCanvas.DrawButtonFace(r: TfpgRect; AFlags: TFButtonFlags); +begin + DrawButtonFace(r.Left, r.Top, r.Width, r.Height, AFlags); +end; + procedure TfpgCanvas.DrawControlFrame(x, y, w, h: TfpgCoord); begin fpgStyle.DrawControlFrame(self, x, y, w, h); end; +procedure TfpgCanvas.DrawControlFrame(r: TfpgRect); +begin + PrintRect(r); + DrawControlFrame(r.Left, r.Top, r.Width, r.Height); +end; + procedure TfpgCanvas.DrawDirectionArrow(x, y, w, h: TfpgCoord; direction: integer); begin fpgStyle.DrawDirectionArrow(self, x, y, w, h, direction); end; +procedure TfpgCanvas.DrawDirectionArrow(r: TfpgRect; direction: integer); +begin + DrawDirectionArrow(r.Left, r.Top, r.Width, r.Height, direction); +end; + { TfpgWindow } constructor TfpgWindow.Create(AOwner: TComponent); @@ -824,19 +888,19 @@ begin MenuDisabledFont := fpgGetFont(fpgGetNamedFontDesc('MenuDisabled')); end; -procedure TfpgStyle.DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: integer; AFlags: TFButtonFlags); +procedure TfpgStyle.DrawButtonFace(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; AFlags: TFButtonFlags); var - r: TRect; + r: TfpgRect; begin + r.SetRect(x, y, w, h); if btnIsDefault in AFlags then begin - r := Rect(x, y, x+w+1, y+h+1); ACanvas.SetColor(clBlack); ACanvas.SetLineStyle(1, lsSolid); ACanvas.DrawRectangle(r); InflateRect(r, -1, -1); Exclude(AFlags, btnIsDefault); - fpgStyle.DrawButtonFace(ACanvas, r.Left, r.Top, r.Right-r.Left-1, r.Bottom-r.Top-1, AFlags); + fpgStyle.DrawButtonFace(ACanvas, r.Left, r.Top, r.Width, r.Height, AFlags); Exit; //==> end; @@ -854,8 +918,8 @@ begin end else ACanvas.SetColor(clHilite1); - ACanvas.DrawLine(x, y+h-1, x, y); // left - ACanvas.DrawLine(x, y, x+w, y); // top + ACanvas.DrawLine(r.Left, r.Bottom, r.Left, r.Top); // left + ACanvas.DrawLine(r.Left, r.Top, r.Right, r.Top); // top // Left and Top (inner) //if btnIsPressed in AFlags then @@ -875,8 +939,8 @@ begin end else ACanvas.SetColor(clShadow2); - ACanvas.DrawLine(x+w, y, x+w, y+h); // right - ACanvas.DrawLine(x+w, y+h, x-1, y+h); // bottom + ACanvas.DrawLine(r.Right, r.Top, r.Right, r.Bottom); // right + ACanvas.DrawLine(r.Right, r.Bottom, r.Left-1, r.Bottom); // bottom // Right and Bottom (inner) if btnIsPressed in AFlags then @@ -888,30 +952,33 @@ begin end else ACanvas.SetColor(clShadow1); - ACanvas.DrawLine(x+w-1, y+1, x+w-1, y+h-1); // right - ACanvas.DrawLine(x+w-1, y+h-1, x, y+h-1); // bottom + ACanvas.DrawLine(r.Right-1, r.Top+1, r.Right-1, r.Bottom-1); // right + ACanvas.DrawLine(r.Right-1, r.Bottom-1, r.Left, r.Bottom-1); // bottom end; -procedure TfpgStyle.DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: integer); +procedure TfpgStyle.DrawControlFrame(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord); +var + r: TfpgRect; begin + r.SetRect(x, y, w, h); ACanvas.SetColor(clShadow1); - ACanvas.DrawLine(x, y+h, x, y); // left (outer) - ACanvas.DrawLine(x, y, x+w, y); // top (outer) + ACanvas.DrawLine(r.Left, r.Bottom, r.Left, r.Top); // left (outer) + ACanvas.DrawLine(r.Left, r.Top, r.Right, r.Top); // top (outer) ACanvas.SetColor(clHilite2); - ACanvas.DrawLine(x+w, y, x+w, y+h); // right (outer) - ACanvas.DrawLine(x+w, y+h, x, y+h); // bottom (outer) + ACanvas.DrawLine(r.Right, r.Top, r.Right, r.Bottom); // right (outer) + ACanvas.DrawLine(r.Right, r.Bottom, r.Left, r.Bottom); // bottom (outer) ACanvas.SetColor(clShadow2); - ACanvas.DrawLine(x+1, y+h-1, x+1, y+1); // left (inner) - ACanvas.DrawLine(x+1, y+1, x+w-1, y+1); // top (inner) + ACanvas.DrawLine(r.Left+1, r.Bottom-1, r.Left+1, r.Top+1); // left (inner) + ACanvas.DrawLine(r.Left+1, r.Top+1, r.Right-1, r.Top+1); // top (inner) ACanvas.SetColor(clHilite1); - ACanvas.DrawLine(x+w-1, y+1, x+w-1, y+h-1); // right (inner) - ACanvas.DrawLine(x+w-1, y+h-1, x+1, y+h-1); // bottom (inner) + ACanvas.DrawLine(r.Right-1, r.Top+1, r.Right-1, r.Bottom-1); // right (inner) + ACanvas.DrawLine(r.Right-1, r.Bottom-1, r.Left+1, r.Bottom-1); // bottom (inner) end; -procedure TfpgStyle.DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: integer; direction: integer); +procedure TfpgStyle.DrawDirectionArrow(ACanvas: TfpgCanvas; x, y, w, h: TfpgCoord; direction: integer); var peekx: integer; peeky: integer; diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index d0fc1e95..ca1d97b0 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -78,7 +78,7 @@ type FWinGC: TfpgGContext; FBackgroundColor: TfpgColor; FCurFontRes: TfpgFontResourceImpl; - FClipRect: TRect; + FClipRect: TfpgRect; FClipRectSet: Boolean; FWindowsColor: longword; FBrush: HBRUSH; @@ -90,17 +90,17 @@ type procedure DoSetTextColor(cl: TfpgColor); override; procedure DoSetColor(cl: TfpgColor); override; procedure DoSetLineStyle(awidth: integer; astyle: TfpgLineStyle); override; - procedure DoGetWinRect(out r: TRect); override; - procedure DoFillRectangle(x, y, w, h: integer); override; + procedure DoGetWinRect(out r: TfpgRect); override; + procedure DoFillRectangle(x, y, w, h: TfpgCoord); override; procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); override; procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); override; - procedure DoDrawRectangle(x, y, w, h: integer); override; - procedure DoDrawLine(x1, y1, x2, y2: integer); override; + procedure DoDrawRectangle(x, y, w, h: TfpgCoord); override; + procedure DoDrawLine(x1, y1, x2, y2: TfpgCoord); override; procedure DoDrawImagePart(x, y: TfpgCoord; img: TfpgImageBase; xi, yi, w, h: integer); override; procedure DoDrawString(x, y: TfpgCoord; const txt: string); override; - procedure DoSetClipRect(const ARect: TRect); override; - function DoGetClipRect: TRect; override; - procedure DoAddClipRect(const ARect: TRect); override; + procedure DoSetClipRect(const ARect: TfpgRect); override; + function DoGetClipRect: TfpgRect; override; + procedure DoAddClipRect(const ARect: TfpgRect); override; procedure DoClearClipRect; override; procedure DoBeginDraw(awin: TfpgWindowBase; buffered: boolean); override; procedure DoPutBufferToScreen(x, y, w, h: TfpgCoord); override; @@ -1209,7 +1209,7 @@ begin BitBlt(FWinGC, x, y, w, h, Fgc, x, y, SRCCOPY); end; -procedure TfpgCanvasImpl.DoAddClipRect(const ARect: TRect); +procedure TfpgCanvasImpl.DoAddClipRect(const ARect: TfpgRect); var rg: HRGN; begin @@ -1227,21 +1227,21 @@ begin FClipRectSet := False; end; -procedure TfpgCanvasImpl.DoDrawLine(x1, y1, x2, y2: integer); +procedure TfpgCanvasImpl.DoDrawLine(x1, y1, x2, y2: TfpgCoord); begin Windows.MoveToEx(Fgc, x1, y1, nil); Windows.LineTo(Fgc, x2, y2); end; -procedure TfpgCanvasImpl.DoDrawRectangle(x, y, w, h: integer); +procedure TfpgCanvasImpl.DoDrawRectangle(x, y, w, h: TfpgCoord); var - r: TRect; + r: TfpgRect; begin if (w = 1) and (h = 1) then SetPixel(x, y, FColor) else begin - r := Rect(x, y, x+w-1, y+h-1); + r.SetRect(x, y, w, h); DoDrawLine(r.Left, r.Top, r.Right, r.Top); DoDrawLine(r.Right, r.Top, r.Right, r.Bottom); DoDrawLine(r.Right, r.Bottom, r.Left, r.Bottom); @@ -1264,11 +1264,13 @@ begin {$endif} end; -procedure TfpgCanvasImpl.DoFillRectangle(x, y, w, h: integer); +procedure TfpgCanvasImpl.DoFillRectangle(x, y, w, h: TfpgCoord); var + fr: TfpgRect; r: TRect; begin - r := Rect(x, y, x+w, y+h); + fr.SetRect(x, y, w, h); + r := Rect(fr.Left, fr.Top, fr.Right, fr.Bottom); Windows.FillRect(Fgc, r, FBrush); end; @@ -1285,23 +1287,28 @@ begin Windows.Polygon(Fgc, pts, 3); end; -function TfpgCanvasImpl.DoGetClipRect: TRect; +function TfpgCanvasImpl.DoGetClipRect: TfpgRect; begin Result := FClipRect; end; -procedure TfpgCanvasImpl.DoGetWinRect(out r: TRect); +procedure TfpgCanvasImpl.DoGetWinRect(out r: TfpgRect); +var + lr: TRect; begin - GetClientRect(FDrawWindow.FWinHandle, r); + GetClientRect(FDrawWindow.FWinHandle, lr); + r.Left := lr.Left; + r.Top := lr.Top; + r.Right := lr.Right; + r.Bottom := lr.Bottom; end; -procedure TfpgCanvasImpl.DoSetClipRect(const ARect: TRect); +procedure TfpgCanvasImpl.DoSetClipRect(const ARect: TfpgRect); begin FClipRectSet := True; FClipRect := ARect; DeleteObject(FClipRegion); - // This is a bit of a hack!!! Double check this again and compare output to X11. - FClipRegion := CreateRectRgn(ARect.Left, ARect.Top, ARect.Right+1, ARect.Bottom+1); + FClipRegion := CreateRectRgn(ARect.Left, ARect.Top, ARect.Width, ARect.Height); SelectClipRgn(Fgc, FClipRegion); end; diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index b3f4d672..e4174ef5 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -235,17 +235,17 @@ type procedure DoSetTextColor(cl: TfpgColor); virtual; abstract; procedure DoSetColor(cl: TfpgColor); virtual; abstract; procedure DoSetLineStyle(awidth: integer; astyle: TfpgLineStyle); virtual; abstract; - procedure DoGetWinRect(out r: TRect); virtual; abstract; - procedure DoFillRectangle(x, y, w, h: integer); virtual; abstract; + procedure DoGetWinRect(out r: TfpgRect); virtual; abstract; + procedure DoFillRectangle(x, y, w, h: TfpgCoord); virtual; abstract; procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); virtual; abstract; procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); virtual; abstract; - procedure DoDrawRectangle(x, y, w, h: integer); virtual; abstract; - procedure DoDrawLine(x1, y1, x2, y2: integer); virtual; abstract; + procedure DoDrawRectangle(x, y, w, h: TfpgCoord); virtual; abstract; + procedure DoDrawLine(x1, y1, x2, y2: TfpgCoord); virtual; abstract; procedure DoDrawImagePart(x, y: TfpgCoord; img: TfpgImageBase; xi, yi, w, h: integer); virtual; abstract; procedure DoDrawString(x, y: TfpgCoord; const txt: string); virtual; abstract; - procedure DoSetClipRect(const ARect: TRect); virtual; abstract; - function DoGetClipRect: TRect; virtual; abstract; - procedure DoAddClipRect(const ARect: TRect); virtual; abstract; + procedure DoSetClipRect(const ARect: TfpgRect); virtual; abstract; + function DoGetClipRect: TfpgRect; virtual; abstract; + procedure DoAddClipRect(const ARect: TfpgRect); virtual; abstract; procedure DoClearClipRect; virtual; abstract; procedure DoBeginDraw(awin: TfpgWindowBase; buffered: boolean); virtual; abstract; procedure DoPutBufferToScreen(x, y, w, h: TfpgCoord); virtual; abstract; @@ -257,8 +257,8 @@ type public constructor Create; virtual; destructor Destroy; override; - procedure DrawRectangle(x, y, w, h: integer); overload; - procedure DrawRectangle(r: TRect); overload; + procedure DrawRectangle(x, y, w, h: TfpgCoord); overload; + procedure DrawRectangle(r: TfpgRect); overload; procedure DrawLine(x1, y1, x2, y2: TfpgCoord); procedure DrawImage(x, y: TfpgCoord; img: TfpgImageBase); procedure DrawImagePart(x, y: TfpgCoord; img: TfpgImageBase; xi, yi, w, h: integer); @@ -266,19 +266,19 @@ type procedure StretchDraw (x, y, w, h: TfpgCoord; ASource: TfpgImageBase); procedure CopyRect(x, y: TfpgCoord; ACanvas: TfpgCanvasBase; var SourceRect: TRect); procedure DrawString(x, y: TfpgCoord; const txt: string); - procedure FillRectangle(x, y, w, h: integer); overload; - procedure FillRectangle(r: TRect); overload; + procedure FillRectangle(x, y, w, h: TfpgCoord); overload; + procedure FillRectangle(r: TfpgRect); overload; procedure FillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); procedure FillArc(x, y, w, h: TfpgCoord; a1, a2: double); - procedure GradientFill(ARect: TRect; AStart, AStop: TfpgColor; ADirection: TGradientDirection); + procedure GradientFill(ARect: TfpgRect; AStart, AStop: TfpgColor; ADirection: TGradientDirection); procedure XORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); overload; procedure XORFillRectangle(col: TfpgColor; r: TfpgRect); overload; - procedure SetClipRect(const ARect: TRect); - function GetClipRect: TRect; - procedure AddClipRect(const ARect: TRect); + procedure SetClipRect(const ARect: TfpgRect); + function GetClipRect: TfpgRect; + procedure AddClipRect(const ARect: TfpgRect); procedure ClearClipRect; procedure Clear(AColor: TfpgColor); - procedure GetWinRect(out r: TRect); + procedure GetWinRect(out r: TfpgRect); procedure SetColor(AColor: TfpgColor); procedure SetTextColor(AColor: TfpgColor); procedure SetLineStyle(AWidth: integer; AStyle: TfpgLineStyle); @@ -380,7 +380,6 @@ function fpgGetAlpha(const AColor: TfpgColor): word; { Points } function PtInRect(const ARect: TfpgRect; const APoint: TPoint): Boolean; procedure SortRect(var ARect: TRect); -procedure SortRect(var left, top, right, bottom: integer); implementation @@ -584,12 +583,6 @@ begin (APoint.y < ARect.Bottom); end; -procedure SortRect(var ARect: TRect); -begin - with ARect do - SortRect(left, top, right, bottom); -end; - procedure SortRect(var left, top, right, bottom: integer); var r: integer; @@ -608,6 +601,13 @@ begin end; end; +procedure SortRect(var ARect: TRect); +begin + with ARect do + SortRect(left, top, right, bottom); +end; + + { TfpgRect } procedure TfpgRect.SetRect(aleft, atop, awidth, aheight: TfpgCoord); @@ -730,15 +730,14 @@ begin inherited Destroy; end; -procedure TfpgCanvasBase.DrawRectangle(x, y, w, h: integer); +procedure TfpgCanvasBase.DrawRectangle(x, y, w, h: TfpgCoord); begin DoDrawRectangle(x, y, w, h); end; -procedure TfpgCanvasBase.DrawRectangle(r: TRect); +procedure TfpgCanvasBase.DrawRectangle(r: TfpgRect); begin - SortRect(r); - DoDrawRectangle(r.Left, r.Top, r.Right-r.Left, r.Bottom-r.Top); + DoDrawRectangle(r.Left, r.Top, r.Width, r.Height); end; procedure TfpgCanvasBase.DrawLine(x1, y1, x2, y2: TfpgCoord); @@ -823,15 +822,14 @@ begin end; end; -procedure TfpgCanvasBase.FillRectangle(x, y, w, h: integer); +procedure TfpgCanvasBase.FillRectangle(x, y, w, h: TfpgCoord); begin DoFillRectangle(x, y, w, h); end; -procedure TfpgCanvasBase.FillRectangle(r: TRect); +procedure TfpgCanvasBase.FillRectangle(r: TfpgRect); begin - SortRect(r); - DoFillRectangle(r.Left, r.Top, r.Right-r.Left, r.Bottom-r.Top); + DoFillRectangle(r.Left, r.Top, r.Width, r.Height); end; procedure TfpgCanvasBase.FillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); @@ -844,7 +842,7 @@ begin DoFillArc(x, y, w, h, a1, a2); end; -procedure TfpgCanvasBase.GradientFill(ARect: TRect; AStart, AStop: TfpgColor; +procedure TfpgCanvasBase.GradientFill(ARect: TfpgRect; AStart, AStop: TfpgColor; ADirection: TGradientDirection); var RGBStart: TRGBTriple; @@ -892,17 +890,17 @@ begin DoXORFillRectangle(col, r.Left, r.Top, r.Width, r.Height); end; -procedure TfpgCanvasBase.SetClipRect(const ARect: TRect); +procedure TfpgCanvasBase.SetClipRect(const ARect: TfpgRect); begin DoSetClipRect(ARect); end; -function TfpgCanvasBase.GetClipRect: TRect; +function TfpgCanvasBase.GetClipRect: TfpgRect; begin Result := DoGetClipRect; end; -procedure TfpgCanvasBase.AddClipRect(const ARect: TRect); +procedure TfpgCanvasBase.AddClipRect(const ARect: TfpgRect); begin DoAddClipRect(ARect); end; @@ -915,16 +913,16 @@ end; procedure TfpgCanvasBase.Clear(AColor: TfpgColor); var lCol: TfpgColor; - lWinRect: TRect; + lWinRect: TfpgRect; begin lCol := FColor; DoSetColor(AColor); DoGetWinRect(lWinRect); - DoFillRectangle(0, 0, lWinRect.Right, lWinRect.Bottom); + DoFillRectangle(0, 0, lWinRect.Width, lWinRect.Height); DoSetColor(lCol); end; -procedure TfpgCanvasBase.GetWinRect(out r: TRect); +procedure TfpgCanvasBase.GetWinRect(out r: TfpgRect); begin DoGetWinRect(r); end; diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index f41ce904..85d580cc 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -88,7 +88,7 @@ type FDrawHandle: TXID; Fgc: TfpgGContext; FCurFontRes: TfpgFontResourceImpl; - FClipRect: TRect; + FClipRect: TfpgRect; FClipRectSet: boolean; FXftDraw: PXftDraw; FXftDrawBuffer: PXftDraw; @@ -99,17 +99,17 @@ type procedure DoSetTextColor(cl: TfpgColor); override; procedure DoSetColor(cl: TfpgColor); override; procedure DoSetLineStyle(awidth: integer; astyle: TfpgLineStyle); override; - procedure DoGetWinRect(out r: TRect); override; - procedure DoFillRectangle(x, y, w, h: integer); override; + procedure DoGetWinRect(out r: TfpgRect); override; + procedure DoFillRectangle(x, y, w, h: TfpgCoord); override; procedure DoXORFillRectangle(col: TfpgColor; x, y, w, h: TfpgCoord); override; procedure DoFillTriangle(x1, y1, x2, y2, x3, y3: TfpgCoord); override; - procedure DoDrawRectangle(x, y, w, h: integer); override; - procedure DoDrawLine(x1, y1, x2, y2: integer); override; + procedure DoDrawRectangle(x, y, w, h: TfpgCoord); override; + procedure DoDrawLine(x1, y1, x2, y2: TfpgCoord); override; procedure DoDrawImagePart(x, y: TfpgCoord; img: TfpgImageBase; xi, yi, w, h: integer); override; procedure DoDrawString(x, y: TfpgCoord; const txt: string); override; - procedure DoSetClipRect(const ARect: TRect); override; - function DoGetClipRect: TRect; override; - procedure DoAddClipRect(const ARect: TRect); override; + procedure DoSetClipRect(const ARect: TfpgRect); override; + function DoGetClipRect: TfpgRect; override; + procedure DoAddClipRect(const ARect: TfpgRect); override; procedure DoClearClipRect; override; procedure DoBeginDraw(awin: TfpgWindowBase; buffered: boolean); override; procedure DoPutBufferToScreen(x, y, w, h: TfpgCoord); override; @@ -1418,25 +1418,21 @@ begin y + FCurFontRes.GetAscent, PChar(txt), Length(txt)); end; -procedure TfpgCanvasImpl.DoGetWinRect(out r: TRect); +procedure TfpgCanvasImpl.DoGetWinRect(out r: TfpgRect); var rw: TfpgWinHandle; x: integer; y: integer; bw: longword; d: longword; - w: Cardinal; - h: Cardinal; begin - XGetGeometry(xapplication.display, FDrawWindow.FWinHandle, @rw, @x, @y, - @w, @h, @bw, @d); r.Left := 0; r.Top := 0; - r.Right := w; - r.Bottom := h; + XGetGeometry(xapplication.display, FDrawWindow.FWinHandle, @rw, @x, @y, + @(r.width), @(r.height), @bw, @d); end; -procedure TfpgCanvasImpl.DoFillRectangle(x, y, w, h: integer); +procedure TfpgCanvasImpl.DoFillRectangle(x, y, w, h: TfpgCoord); begin XFillRectangle(xapplication.display, FDrawHandle, Fgc, x, y, w, h); end; @@ -1464,28 +1460,28 @@ begin XFillPolygon(xapplication.display, FDrawHandle, Fgc, @pts, 3, 0, 0); end; -procedure TfpgCanvasImpl.DoDrawRectangle(x, y, w, h: integer); +procedure TfpgCanvasImpl.DoDrawRectangle(x, y, w, h: TfpgCoord); begin // writeln(Format('DoDrawRectangle x=%d y=%d w=%d h=%d', [x, y, w, h])); // Same behavior as Windows. See documentation for reason. XDrawRectangle(xapplication.display, FDrawHandle, Fgc, x, y, w-1, h-1); end; -procedure TfpgCanvasImpl.DoDrawLine(x1, y1, x2, y2: integer); +procedure TfpgCanvasImpl.DoDrawLine(x1, y1, x2, y2: TfpgCoord); begin // Same behavior as Windows. See documentation for reason. XDrawLine(xapplication.display, FDrawHandle, Fgc, x1, y1, x2, y2); end; -procedure TfpgCanvasImpl.DoSetClipRect(const ARect: TRect); +procedure TfpgCanvasImpl.DoSetClipRect(const ARect: TfpgRect); var r: TXRectangle; rg: TRegion; begin r.x := ARect.Left; r.y := ARect.Top; - r.Width := ARect.Right - ARect.Left + 1; - r.Height := ARect.Bottom - ARect.Top + 1; + r.Width := ARect.Width; + r.Height := ARect.Height; rg := XCreateRegion; @@ -1498,20 +1494,20 @@ begin XDestroyRegion(rg); end; -function TfpgCanvasImpl.DoGetClipRect: TRect; +function TfpgCanvasImpl.DoGetClipRect: TfpgRect; begin Result := FClipRect; end; -procedure TfpgCanvasImpl.DoAddClipRect(const ARect: TRect); +procedure TfpgCanvasImpl.DoAddClipRect(const ARect: TfpgRect); var r: TXRectangle; rg: TRegion; begin r.x := ARect.Left; r.y := ARect.Top; - r.Width := ARect.Right - ARect.Left + 1; - r.Height := ARect.Bottom - ARect.Top + 1; + r.Width := ARect.Width; + r.Height := ARect.Height; rg := XCreateRegion; XUnionRectWithRegion(@r, rg, rg); @@ -1527,7 +1523,7 @@ end; procedure TfpgCanvasImpl.DoClearClipRect; var - r: TRect; + r: TfpgRect; begin DoGetWinRect(r); DoSetClipRect(r); |