LCL, Grids: fix focus rect painting issue #31268

git-svn-id: trunk@54000 -
This commit is contained in:
jesus 2017-01-25 14:57:04 +00:00
parent 56a4609632
commit 90a4a40c23

View File

@ -1807,7 +1807,7 @@ type
property OnValidateEntry; property OnValidateEntry;
end; end;
procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor); procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor; DrawBits:Byte=BF_RECT);
function GetWorkingCanvas(const Canvas: TCanvas): TCanvas; function GetWorkingCanvas(const Canvas: TCanvas): TCanvas;
procedure FreeWorkingCanvas(canvas: TCanvas); procedure FreeWorkingCanvas(canvas: TCanvas);
@ -1993,7 +1993,10 @@ begin
AFont.Style:= TFontStyles(cfg.GetValue(AKey + '/style/value', 0)); AFont.Style:= TFontStyles(cfg.GetValue(AKey + '/style/value', 0));
end; end;
procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor); // Draws a dotted rectangle by drawing each enabled side. By default all sides are
// enabled. The DrawBits parameter set sides to drawn, it has this layout: xxxxBRTL
procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor;
DrawBits: Byte);
procedure DrawVertLine(X1,Y1,Y2: integer); procedure DrawVertLine(X1,Y1,Y2: integer);
begin begin
if Y2<Y1 then if Y2<Y1 then
@ -2022,10 +2025,10 @@ procedure DrawRubberRect(Canvas: TCanvas; aRect: TRect; Color: TColor);
end; end;
begin begin
with aRect do begin with aRect do begin
DrawHorzLine(Left, Top, Right-1); if (DrawBits and BF_TOP = BF_TOP) then DrawHorzLine(Left, Top, Right-1);
DrawVertLine(Right-1, Top, Bottom-1); if (DrawBits and BF_RIGHT = BF_RIGHT) then DrawVertLine(Right-1, Top, Bottom-1);
DrawHorzLine(Right-1, Bottom-1, Left); if (DrawBits and BF_BOTTOM = BF_BOTTOM) then DrawHorzLine(Right-1, Bottom-1, Left);
DrawVertLine(Left, Bottom-1, Top); if (DrawBits and BF_LEFT = BF_LEFT) then DrawVertLine(Left, Bottom-1, Top);
end; end;
end; end;
@ -10068,6 +10071,7 @@ procedure TCustomDrawGrid.DrawFocusRect(aCol, aRow: Integer; ARect: TRect);
var var
OldFocusColor: TColor; OldFocusColor: TColor;
OldPenMode: TFPPenMode; OldPenMode: TFPPenMode;
DrawBits: Byte;
begin begin
// Draw focused cell if we have the focus // Draw focused cell if we have the focus
if DefaultDrawing and (Self.Focused or if DefaultDrawing and (Self.Focused or
@ -10081,7 +10085,10 @@ begin
OldPenMode:=Canvas.Pen.Mode; OldPenMode:=Canvas.Pen.Mode;
Canvas.Pen.Mode := pmXOR; Canvas.Pen.Mode := pmXOR;
end; end;
DrawRubberRect(Canvas, aRect, FFocusColor); DrawBits := BF_RECT;
if (goRowSelect in Options) and ((fTopLeft.x<>FixedCols) or (FGCache.TLColOff<>0)) then
DrawBits := DrawBits and not BF_LEFT;
DrawRubberRect(Canvas, aRect, FFocusColor, DrawBits);
if FUseXORFeatures then begin if FUseXORFeatures then begin
Canvas.Pen.Mode := OldPenMode; Canvas.Pen.Mode := OldPenMode;
Canvas.RestoreHandleState; Canvas.RestoreHandleState;