From 3596975672d5dbb568b4838d654071e65b9e4802 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Tue, 21 Oct 2008 18:56:38 +0000 Subject: [PATCH] Only draw the focused grid cell using highlight fg/bg colors if multiple rows are selected. --- source/childwin.dfm | 6 ++---- source/childwin.pas | 33 +++++++++------------------------ 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/source/childwin.dfm b/source/childwin.dfm index 8c6bd5c0..467e977d 100644 --- a/source/childwin.dfm +++ b/source/childwin.dfm @@ -957,7 +957,7 @@ object MDIChild: TMDIChild TabOrder = 2 TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoTristateTracking, toAutoDeleteMovedNodes, toDisableAutoscrollOnFocus, toDisableAutoscrollOnEdit] TreeOptions.MiscOptions = [toAcceptOLEDrop, toEditable, toFullRepaintOnResize, toGridExtensions, toInitOnSave, toToggleOnDblClick, toWheelPanning] - TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toShowHorzGridLines, toShowVertGridLines, toThemeAware, toUseBlendedImages] + TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toShowHorzGridLines, toShowVertGridLines, toThemeAware, toUseBlendedImages, toAlwaysHideSelection] TreeOptions.SelectionOptions = [toExtendedFocus, toMultiSelect, toRightClickSelect] WantTabs = True OnAfterCellPaint = DataGridAfterCellPaint @@ -968,7 +968,6 @@ object MDIChild: TMDIChild OnEditCancelled = DataGridEditCancelled OnEdited = DataGridEdited OnEditing = DataGridEditing - OnFocusChanged = GridFocusChanged OnFocusChanging = DataGridFocusChanging OnGetText = GridGetText OnPaintText = GridPaintText @@ -1154,11 +1153,10 @@ object MDIChild: TMDIChild TabOrder = 2 TreeOptions.AutoOptions = [toAutoDropExpand, toAutoScrollOnExpand, toAutoTristateTracking, toAutoDeleteMovedNodes, toDisableAutoscrollOnFocus, toDisableAutoscrollOnEdit] TreeOptions.MiscOptions = [toAcceptOLEDrop, toEditable, toFullRepaintOnResize, toGridExtensions, toInitOnSave, toToggleOnDblClick, toWheelPanning] - TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toShowHorzGridLines, toShowVertGridLines, toThemeAware, toUseBlendedImages] + TreeOptions.PaintOptions = [toShowButtons, toShowDropmark, toShowHorzGridLines, toShowVertGridLines, toThemeAware, toUseBlendedImages, toAlwaysHideSelection] TreeOptions.SelectionOptions = [toExtendedFocus, toMultiSelect, toRightClickSelect] WantTabs = True OnBeforeCellPaint = GridBeforeCellPaint - OnFocusChanged = GridFocusChanged OnFocusChanging = QueryGridFocusChanging OnGetText = GridGetText OnPaintText = GridPaintText diff --git a/source/childwin.pas b/source/childwin.pas index 3b610d02..04e0ddb8 100644 --- a/source/childwin.pas +++ b/source/childwin.pas @@ -451,8 +451,6 @@ type procedure QueryGridFocusChanging(Sender: TBaseVirtualTree; OldNode, NewNode: PVirtualNode; OldColumn, NewColumn: TColumnIndex; var Allowed: Boolean); - procedure GridFocusChanged(Sender: TBaseVirtualTree; Node: PVirtualNode; - Column: TColumnIndex); procedure pnlQueryHelpersCanResize(Sender: TObject; var NewWidth, NewHeight: Integer; var Resize: Boolean); procedure pnlQueryMemoCanResize(Sender: TObject; var NewWidth, @@ -5672,16 +5670,14 @@ begin if r.Columns[Column].IsPriPart then TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold]; - // Do not apply any color on a selected, highlighted node to keep readability - if (vsSelected in Node.States) and ( - (Column = Sender.FocusedColumn) or (toFullRowSelect in TVirtualStringTree(Sender).TreeOptions.SelectionOptions) - ) then - Exit; - // NULL value isNull := r.Rows[Node.Index].Cells[Column].IsNull; + + // Do not apply any color on a selected, highlighted cell to keep readability + if (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then + cl := clHighlightText // Numeric field - if r.Columns[Column].isInt or r.Columns[Column].isFloat then + else if r.Columns[Column].isInt or r.Columns[Column].isFloat then if isNull then cl := prefNullColorNumeric else cl := prefFieldColorNumeric // Date field else if r.Columns[Column].isDate then @@ -5856,20 +5852,6 @@ begin end; -procedure TMDIChild.GridFocusChanged(Sender: TBaseVirtualTree; - Node: PVirtualNode; Column: TColumnIndex); -var - g: TVirtualStringTree; -begin - // Switch to full row selecting if > 1 node is selected - g := (Sender as TVirtualStringTree); - if g.SelectedCount <= 1 then - g.TreeOptions.SelectionOptions := g.TreeOptions.SelectionOptions - [toFullRowSelect] - else - g.TreeOptions.SelectionOptions := g.TreeOptions.SelectionOptions + [toFullRowSelect]; -end; - - {** DataGrid: invoke update or insert routine } @@ -6444,7 +6426,10 @@ begin if prefEnableNullBG and gr.Rows[Node.Index].Cells[Column].IsNull then begin TargetCanvas.Brush.Color := prefNullBG; TargetCanvas.FillRect(CellRect); - end else if (vsSelected in Node.States) and (Column <> Sender.FocusedColumn) then begin + end else if (Node = Sender.FocusedNode) and (Column = Sender.FocusedColumn) then begin + TargetCanvas.Brush.Color := clHighlight; + TargetCanvas.FillRect(CellRect); + end else if vsSelected in Node.States then begin TargetCanvas.Brush.Color := clInfoBk; TargetCanvas.FillRect(CellRect); end;