mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 13:40:20 +02:00
LCL: Improve the column sort feature of TStringGrid. User defined glyphs are retained after sorting.
git-svn-id: trunk@30645 -
This commit is contained in:
parent
bf205acf8a
commit
16c323b485
@ -365,6 +365,7 @@ type
|
|||||||
FAlignment: ^TAlignment;
|
FAlignment: ^TAlignment;
|
||||||
FFont: TFont;
|
FFont: TFont;
|
||||||
FImageIndex: Integer;
|
FImageIndex: Integer;
|
||||||
|
FOldImageIndex: Integer;
|
||||||
FImageLayout: TButtonLayout;
|
FImageLayout: TButtonLayout;
|
||||||
FIsDefaultTitleFont: boolean;
|
FIsDefaultTitleFont: boolean;
|
||||||
FLayout: ^TTextLayout;
|
FLayout: ^TTextLayout;
|
||||||
@ -3253,17 +3254,23 @@ begin
|
|||||||
// Remove glyph from previous column.
|
// Remove glyph from previous column.
|
||||||
ColOfs := FSortColumn - FFixedCols;
|
ColOfs := FSortColumn - FFixedCols;
|
||||||
if (ColOfs > -1) and (ColOfs < FColumns.Count ) then
|
if (ColOfs > -1) and (ColOfs < FColumns.Count ) then
|
||||||
FColumns[ColOfs].Title.ImageIndex := -1;
|
with FColumns[ColOfs].Title do
|
||||||
|
ImageIndex := FOldImageIndex;
|
||||||
end;
|
end;
|
||||||
FSortColumn := index;
|
FSortColumn := index;
|
||||||
ColOfs := index - FFixedCols; // For accessing FColumns[].
|
// Show the sort glyph only if clicked column has a TGridColumn defined.
|
||||||
// Show the right sort glyph.
|
ColOfs := index - FFixedCols;
|
||||||
if (ColOfs > -1) and (ColOfs < FColumns.Count)
|
if (ColOfs > -1) and (ColOfs < FColumns.Count)
|
||||||
and (FAscImgInd < TitleImageList.Count)
|
and (FAscImgInd < TitleImageList.Count)
|
||||||
and (FDescImgInd < TitleImageList.Count) then
|
and (FDescImgInd < TitleImageList.Count) then
|
||||||
case FSortOrder of
|
with FColumns[ColOfs].Title do begin
|
||||||
soAscending: FColumns[ColOfs].Title.ImageIndex := FAscImgInd;
|
// Save previous ImageIndex of the clicked column.
|
||||||
soDescending: FColumns[ColOfs].Title.ImageIndex := FDescImgInd;
|
if (ImageIndex <> FAscImgInd) and (ImageIndex <> FDescImgInd) then
|
||||||
|
FOldImageIndex := ImageIndex;
|
||||||
|
case FSortOrder of // Show the right sort glyph.
|
||||||
|
soAscending: ImageIndex := FAscImgInd;
|
||||||
|
soDescending: ImageIndex := FDescImgInd;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
Sort(True, index, FFixedRows, RowCount-1);
|
Sort(True, index, FFixedRows, RowCount-1);
|
||||||
end;
|
end;
|
||||||
@ -10064,6 +10071,7 @@ begin
|
|||||||
FillTitleDefaultFont;
|
FillTitleDefaultFont;
|
||||||
FFont.OnChange := @FontChanged;
|
FFont.OnChange := @FontChanged;
|
||||||
FImageIndex := -1;
|
FImageIndex := -1;
|
||||||
|
FOldImageIndex := -1;
|
||||||
FImageLayout := blGlyphRight;
|
FImageLayout := blGlyphRight;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user