LCL/grids: Show sort arrows in header of sorted grid even if the grid does not define columns (issue #33731).

git-svn-id: trunk@57960 -
This commit is contained in:
wp 2018-05-18 21:05:49 +00:00
parent c21d026d03
commit 7ea1e8cd31

View File

@ -120,7 +120,8 @@ type
TGridOption2 = ( TGridOption2 = (
goScrollToLastCol, // allow scrolling to last column (so that last column can be leftcol) 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) goScrollToLastRow, // allow scrolling to last row (so that last row can be toprow)
goShowSortArrows // show arrows in header when column is sorted
); );
TGridOptions2 = set of TGridOption2; TGridOptions2 = set of TGridOption2;
@ -4133,7 +4134,7 @@ var
Details: TThemedElementDetails; Details: TThemedElementDetails;
NativeSortGlyphs: Boolean; NativeSortGlyphs: Boolean;
begin begin
if FSortColumn = AColumnIndex then if (FSortColumn = AColumnIndex) and (goShowSortArrows in FOptions2) then
begin begin
GetSortTitleImageInfo(AColumnIndex, ImgList, ImgIndex, ImgListWidth, NativeSortGlyphs); GetSortTitleImageInfo(AColumnIndex, ImgList, ImgIndex, ImgListWidth, NativeSortGlyphs);
if NativeSortGlyphs then// draw native sort buttons if NativeSortGlyphs then// draw native sort buttons
@ -4492,6 +4493,13 @@ begin
tlBottom: Dec(ARect.Bottom, varCellPadding); tlBottom: Dec(ARect.Bottom, varCellPadding);
end; end;
if (gdFixed in aState) and (FSortColumn = aCol) and
(goShowSortArrows in FOptions2) then
begin
DrawColumnTitleImage(aRect, FSortColumn);
dec(ARect.Right, 2*varCellPadding);
end;
if ARect.Right<ARect.Left then if ARect.Right<ARect.Left then
ARect.Right:=ARect.Left; ARect.Right:=ARect.Left;
if ARect.Left>ARect.Right then if ARect.Left>ARect.Right then
@ -9258,6 +9266,7 @@ begin
Cfg.SetValue(Path+'goRowHighlight/value', goRowHighlight in Options); Cfg.SetValue(Path+'goRowHighlight/value', goRowHighlight in Options);
Cfg.SetValue(Path+'goScrollToLastCol/value', goScrollToLastCol in Options2); Cfg.SetValue(Path+'goScrollToLastCol/value', goScrollToLastCol in Options2);
Cfg.SetValue(Path+'goScrollToLastRow/value', goScrollToLastRow in Options2); Cfg.SetValue(Path+'goScrollToLastRow/value', goScrollToLastRow in Options2);
Cfg.SetValue(Path+'goShowSortArrows/value', goShowSortArrows in Options2);
end; end;
procedure TCustomGrid.LoadColumns(cfg: TXMLConfig; Version: integer); procedure TCustomGrid.LoadColumns(cfg: TXMLConfig; Version: integer);
@ -9454,6 +9463,7 @@ begin
end; end;
GetValue2('goScrollToLastRow',goScrollToLastRow); GetValue2('goScrollToLastRow',goScrollToLastRow);
GetValue2('goScrollToLastCol',goScrollToLastCol); GetValue2('goScrollToLastCol',goScrollToLastCol);
GetValue2('goShowSortArrows',goShowSortArrows);
Options:=Opt; Options:=Opt;
Options2:=Opt2; Options2:=Opt2;
@ -9496,9 +9506,8 @@ begin
FAutoEdit := True; FAutoEdit := True;
FFocusRectVisible := True; FFocusRectVisible := True;
FDefaultDrawing := True; FDefaultDrawing := True;
FOptions:= FOptions := DefaultGridOptions;
[goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, FOptions2 := DefaultGridOptions2;
goSmoothScroll ];
FScrollbars:=ssAutoBoth; FScrollbars:=ssAutoBoth;
fGridState:=gsNormal; fGridState:=gsNormal;
FDefColWidth:=-1; FDefColWidth:=-1;