summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/fpgfx.pas26
-rw-r--r--src/corelib/gdi/gfx_gdi.pas35
-rw-r--r--src/corelib/gfxbase.pas2
3 files changed, 49 insertions, 14 deletions
diff --git a/src/corelib/fpgfx.pas b/src/corelib/fpgfx.pas
index 58759d1e..2e737fff 100644
--- a/src/corelib/fpgfx.pas
+++ b/src/corelib/fpgfx.pas
@@ -141,6 +141,7 @@ type
procedure DrawControlFrame(r: TfpgRect);
procedure DrawDirectionArrow(x, y, w, h: TfpgCoord; direction: integer);
procedure DrawDirectionArrow(r: TfpgRect; direction: integer);
+ procedure DrawFocusRect(r: TfpgRect);
end;
@@ -160,6 +161,7 @@ type
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;
+ procedure DrawFocusRect(ACanvas: TfpgCanvas; r: TfpgRect); virtual;
end;
@@ -789,6 +791,11 @@ begin
DrawDirectionArrow(r.Left, r.Top, r.Width, r.Height, direction);
end;
+procedure TfpgCanvas.DrawFocusRect(r: TfpgRect);
+begin
+ fpgStyle.DrawFocusRect(self, r);
+end;
+
{ TfpgWindow }
constructor TfpgWindow.Create(AOwner: TComponent);
@@ -1034,6 +1041,25 @@ begin
ACanvas.DrawString(x, y, AText);
end;
+procedure TfpgStyle.DrawFocusRect(ACanvas: TfpgCanvas; r: TfpgRect);
+var
+ oldColor: TfpgColor;
+ oldLineWidth: integer;
+ oldLineStyle: TfpgLineStyle;
+begin
+ oldColor := ACanvas.Color;
+ oldLineWidth := ACanvas.LineWidth;
+ oldLineStyle := ACanvas.LineStyle;
+
+ ACanvas.SetColor(clText1);
+ ACanvas.SetLineStyle(1, lsDot);
+ ACanvas.DrawRectangle(r);
+
+ // restore previous settings
+ ACanvas.SetColor(oldColor);
+ ACanvas.SetLineStyle(oldLineWidth, oldLineStyle);
+end;
+
{ TfpgCaret }
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas
index de097c02..ee92b156 100644
--- a/src/corelib/gdi/gfx_gdi.pas
+++ b/src/corelib/gdi/gfx_gdi.pas
@@ -1077,7 +1077,7 @@ begin
mcCross: hc := wapplication.hcr_crosshair;
mcHourGlass: hc := wapplication.hcr_wait;
else
- hc := hcr_default;
+ hc := wapplication.hcr_default;
end;
SetCursor(hc);
@@ -1153,10 +1153,13 @@ begin
if buffered then
begin
- if (FastDoubleBuffer = False) or (FBufferBitmap = 0) or (FBufWidth <> w) or (FBufHeight <> h) then begin
+ DoGetWinRect(ARect);
+ if (FastDoubleBuffer = False) or (FBufferBitmap = 0)
+ or (FBufWidth <> ARect.Width) or (FBufHeight <> ARect.Height) then
+ begin
TryFreeBackBuffer;
- DoGetWinRect(ARect);
- FBufferBitmap := Windows.CreateCompatibleBitmap(FWinGC, (ARect.Right-ARect.Left+1), (ARect.Bottom-ARect.Top+1));
+// DoGetWinRect(ARect);
+ FBufferBitmap := Windows.CreateCompatibleBitmap(FWinGC, ARect.Width, ARect.Height);
FBufgc := CreateCompatibleDC(FWinGC);
Fgc := FBufgc;
end;
@@ -1247,7 +1250,7 @@ procedure TfpgCanvasImpl.DoAddClipRect(const ARect: TfpgRect);
var
rg: HRGN;
begin
- rg := CreateRectRgn(ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
+ rg := CreateRectRgn(ARect.Left, ARect.Top, ARect.Left+ARect.Width, ARect.Top+ARect.Height);
FClipRect := ARect;
FClipRectSet := True;
CombineRgn(FClipRegion, rg, FClipRegion, RGN_AND);
@@ -1270,19 +1273,23 @@ end;
procedure TfpgCanvasImpl.DoDrawRectangle(x, y, w, h: TfpgCoord);
var
wr: Windows.TRect;
+ r: TfpgRect;
begin
- wr.Left := x;
- wr.Top := y;
- wr.Right := x + w;
- wr.Bottom := y + h;
if FLineStyle = lsSolid then
+ begin
+ wr.Left := x;
+ wr.Top := y;
+ wr.Right := x + w;
+ wr.Bottom := y + h;
Windows.FrameRect(Fgc, wr, FBrush) // this handles 1x1 rectangles
+ end
else
begin
- DoDrawLine(wr.Left, wr.Top, wr.Right, wr.Top);
- DoDrawLine(wr.Right, wr.Top, wr.Right, wr.Bottom);
- DoDrawLine(wr.Right, wr.Bottom, wr.Left, wr.Bottom);
- DoDrawLine(wr.Left, wr.Bottom, wr.Left, wr.Top);
+ 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);
+ DoDrawLine(r.Left, r.Bottom, r.Left, r.Top);
end;
end;
@@ -1400,9 +1407,9 @@ PS_INSIDEFRAME. }
end;
end;
+ Windows.DeleteObject(FPen);
lPen := CreatePen(FintLineStyle, lw, FWindowsColor);
Windows.SelectObject(Fgc, lPen);
- Windows.DeleteObject(FPen);
FPen := lPen;
end;
diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas
index 8ab864c7..4a43fb49 100644
--- a/src/corelib/gfxbase.pas
+++ b/src/corelib/gfxbase.pas
@@ -297,6 +297,8 @@ type
property Pixels[X, Y: integer]: TfpgColor read GetPixel write SetPixel;
property InterpolationFilter: TfpgCustomInterpolation read FInterpolation write SetInterpolation;
property FastDoubleBuffer: Boolean read FFastDoubleBuffer write FFastDoubleBuffer;
+ property LineStyle: TfpgLineStyle read FLineStyle;
+ property LineWidth: integer read FLineWidth;
end;