Recent

Author Topic: TStringGrid: published properties FocusColor and RowHighlightColor  (Read 787 times)

prof7bit

  • Full Member
  • ***
  • Posts: 161
TStringGrid: published properties FocusColor and RowHighlightColor
« on: September 11, 2021, 09:02:34 am »
There are at least two hardcoded colors in the grid components that are not published properties. One of them (FocusColor) is already public (but not published) and the other one does not yet exist.

  • FocusColor is the red color of the dotted rectangle around the selected cell
  • The proposed RowHighlightColor would be the background color of a selected row when the flag goRowHighlight is in the options set

This question here is 2-fold:

(1) Is it acceptable to add a new property RowHighlightColor?
(2) Should these two afforementioned properties be published?

The RowHighlight was hardcoded by xoring the background with $1F1F1F, I extended this functionality it as such:

Code: Diff  [Select][+][-]
  1. @@ -3881,7 +3893,10 @@ procedure TCustomGrid.PrepareCanvas(aCol, aRow: Integer; aState: TGridDrawState)
  2.        end;
  3.      end;
  4.      if (gdRowHighlight in aState) and not (gdFixed in AState) then
  5. -      Result := ColorToRGB(Result) xor $1F1F1F
  6. +      if FRowHighlightColor = clDefault then
  7. +        Result := ColorToRGB(Result) xor $1F1F1F
  8. +      else
  9. +        Result := FRowHighlightColor;
  10.    end;
  11.  var
  12.    AColor: TColor;
  13.  

The rest of the patch is property declarations and a setter.

The patch is still incomplete since it only publishes it for TStringGrid, not for the other grids.

Please tell me whether I should proceed in this direction.
« Last Edit: September 11, 2021, 09:27:46 am by prof7bit »

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: TStringGrid: published properties FocusColor and RowHighlightColor
« Reply #1 on: September 11, 2021, 10:33:22 am »
The OnPrepareCanvas event of the LCL grids gives you control over the background color. There is no need for a RowHighlightColor property.

 

TinyPortal © 2005-2018