This issue was also bugging me, together with the one where the column header text was splling over into other columns if the header was centred or right aligned. Here are some code suggestions that:
- draws a sort arrow everytime, so that if there is not enough space to display both header text and sort arrow, the header text is truncated, and the sort arrow is drawn on the far right
- addresses the text spilling issue
Note that it does not address the case where a glyph is displayed in the column header (I haven't had the need to use that yet). All changes in the TStyleDisplay.DrawHeaderContent method, enclosed in // mod blocks:
CODE
procedure TStyleDisplay.DrawHeaderContent(Column: TNxCustomColumn; R: TRect);
var
...
// start mod
TextRectRight: Integer;
// end mod
begin
with Canvas, Column.Header do
begin
// start mod
TextRectRight := R.Right;
// end mod
...
if not(Glyph.Empty or (DisplayMode = dmTextOnly)) then { show glyph }
begin
...
end else
begin
case Alignment of
taLeftJustify:
begin
TextPos.X := R.Left + spHeaderMargin;
// start mod
if Column.Sorted then
begin
Dec(TextRectRight, siSortArrowWidth + spArrowDistance + spHeaderMargin);
if (TextRectRight - TextPos.X) < CaptionWidth then
begin
TextRectRight := R.Right - siSortArrowWidth - spHeaderMargin;
end;
if TextRectRight < (TextPos.X) then
TextRectRight := TextPos.X;
end;
// end mod
end;
taRightJustify:
begin
// start mod
TextPos.X := R.Left + spHeaderMargin;
if CaptionWidth < (Column.Width - spHeaderMargin) then
TextPos.X := R.Right - CaptionWidth;
if Column.Sorted then
begin
Dec(TextPos.X, (siSortArrowWidth + spArrowDistance + spHeaderMargin));
if TextPos.X < (R.Left + spHeaderMargin) then
begin
TextPos.X := R.Left + spHeaderMargin;
Dec(TextRectRight, siSortArrowWidth + spHeaderMargin);
end;
end;
// end mod
end;
taCenter:
begin
TextPos.X := R.Left + (R.Right - R.Left) div 2 - CaptionWidth div 2;
// start mod
if TextPos.X < (R.Left + spHeaderMargin) then
TextPos.X := R.Left + spHeaderMargin;
if Column.Sorted then
begin
if (TextPos.X + CaptionWidth + siSortArrowWidth + spHeaderMargin) > R.Right then
begin
TextRectRight := R.Right - siSortArrowWidth - spHeaderMargin;
end;
end;
// end mod
end;
end;
end;
if DisplayMode <> dmImageOnly then { show text }
begin
// start mod
CaptionRect := Rect(TextPos.X, R.Top, TextRectRight, R.Bottom);
// end mod
...
if Column.Sorted then
begin
...
// start mod
if (ArrowPos.X + siSortArrowWidth) > R.Right then
begin
if (R.Right - siSortArrowWidth - spHeaderMargin) > TextPos.X then
ArrowPos.X := R.Right - siSortArrowWidth - spHeaderMargin;
end;
// end mod
...
end;