From 675ad0221508dfb3b2ee9ede28386c256e8f00b3 Mon Sep 17 00:00:00 2001 From: Bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sat, 15 Oct 2022 16:10:24 +0200 Subject: [PATCH] Grids: implement option to set ParentColor and ParentFont of the internal cell editor. --- lcl/grids.pas | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lcl/grids.pas b/lcl/grids.pas index cefa14b61f..bab4d587b9 100644 --- a/lcl/grids.pas +++ b/lcl/grids.pas @@ -120,8 +120,10 @@ type TGridOptions = set of TGridOption; TGridOption2 = ( - goScrollToLastCol, // Allow scrolling to last column (so that last column can be LeftCol) - goScrollToLastRow // Allow scrolling to last row (so that last row can be TopRow) + goScrollToLastCol, // Allow scrolling to last column (so that last column can be LeftCol) + goScrollToLastRow, // Allow scrolling to last row (so that last row can be TopRow) + goEditorParentColor, // Set editor's ParentColor to True + goEditorParentFont // Set editor's ParentFont to True ); TGridOptions2 = set of TGridOption2; @@ -1981,6 +1983,9 @@ uses {$WARN IMPLICIT_STRING_CAST_LOSS OFF} {$ENDIF} +type + TWinControlAccess = Class(TWinControl); //used in TCustomGrid.DoEditorShow + const MULTISEL_MODIFIER = {$IFDEF Darwin}ssMeta{$ELSE}ssCtrl{$ENDIF}; @@ -7383,6 +7388,7 @@ begin Editor.Visible:=False; {$ifdef dbgGrid}DebugLnExit('grid.DoEditorHide [',Editor.ClassName,'] END');{$endif} end; + procedure TCustomGrid.DoEditorShow; var ParentChanged: Boolean; @@ -7409,6 +7415,14 @@ begin else FStringEditor.Alignment:=taLeftJustify; end; + TWinControlAccess(FEditor).ParentColor := (goEditorParentColor in Options2); + TWinControlAccess(FEditor).ParentFont := (goEditorParentFont in Options2); + if (FEditor is TCompositeCellEditor) then + begin + TWinControlAccess(TCompositeCellEditor(FEditor).ActiveControl).ParentColor := (goEditorParentColor in Options2); + TWinControlAccess(TCompositeCellEditor(FEditor).ActiveControl).ParentFont := (goEditorParentFont in Options2); + end; + Editor.Visible:=True; if Focused and Editor.CanFocus then Editor.SetFocus;