ColorPalette: Fix 1-pixel error when drawing the selection rect.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4292 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2015-08-24 22:34:36 +00:00
parent 365546a580
commit 68424fab94

View File

@@ -126,8 +126,8 @@ type
procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual; procedure DoColorPick(AColor: TColor; AShift: TShiftState); virtual;
procedure DoDeleteColor(AIndex: Integer); virtual; procedure DoDeleteColor(AIndex: Integer); virtual;
procedure DoSelectColor(AColor: TColor); virtual; procedure DoSelectColor(AColor: TColor); virtual;
function GetCellHeight: Integer; function GetCellHeight: Integer; inline;
function GetCellWidth: Integer; function GetCellWidth: Integer; inline;
function GetColorIndex(X,Y: Integer): Integer; function GetColorIndex(X,Y: Integer): Integer;
function GetHintText(AIndex: Integer): String; virtual; function GetHintText(AIndex: Integer): String; virtual;
function IsCorrectShift(Shift: TShiftState): Boolean; function IsCorrectShift(Shift: TShiftState): Boolean;
@@ -254,6 +254,7 @@ begin
FColors := TStringList.Create; FColors := TStringList.Create;
FButtonBorderColor := clBlack; FButtonBorderColor := clBlack;
FButtonDistance := 0; FButtonDistance := 0;
FMargin := 1;
FButtonHeight := 12; FButtonHeight := 12;
FButtonWidth := 12; FButtonWidth := 12;
FPrevMouseIndex := -1; FPrevMouseIndex := -1;
@@ -706,8 +707,6 @@ var
Rsel: TRect; Rsel: TRect;
xmax: Integer; xmax: Integer;
begin begin
Canvas.Pen.Endcap := pecSquare;
// Paint background color // Paint background color
if Color <> clNone then begin if Color <> clNone then begin
Canvas.Brush.Color := Color; Canvas.Brush.Color := Color;
@@ -715,6 +714,8 @@ begin
Canvas.FillRect(0, 0, Width, Height); Canvas.FillRect(0, 0, Width, Height);
end; end;
Canvas.Pen.Endcap := pecFlat;
// Paint color boxes // Paint color boxes
X := FMargin; X := FMargin;
Y := FMargin; Y := FMargin;
@@ -789,7 +790,7 @@ begin
FButtonDistance := AValue; FButtonDistance := AValue;
if FButtonDistance = 0 then if FButtonDistance = 0 then
FMargin := 1 else FMargin := 1 else
FMargin := FButtonDistance div 2; FMargin := FButtonDistance div 2 + FButtonDistance mod 2;
UpdateSize; UpdateSize;
Invalidate; Invalidate;
end; end;
@@ -1284,8 +1285,8 @@ procedure TCustomColorPalette.UpdateSize;
var var
d, dx, dy: Integer; d, dx, dy: Integer;
begin begin
if (FCols = 0) or (FColors.Count = 0) then FRows := 0 if (FCols = 0) or (FColors.Count = 0) then
else FRows := 0 else
FRows := Ceil(FColors.Count / FCols); FRows := Ceil(FColors.Count / FCols);
dx := GetCellWidth; dx := GetCellWidth;
@@ -1295,7 +1296,7 @@ begin
begin begin
dec(dx); dec(dx);
dec(dy); dec(dy);
d := -1; d := -1; // Correct for button frame line width
end; end;
SetBounds(Left, Top, FCols * dx - d + 2*FMargin, FRows * dy - d + 2*FMargin); SetBounds(Left, Top, FCols * dx - d + 2*FMargin, FRows * dy - d + 2*FMargin);
end; end;