mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-05 00:37:11 +01:00
Implements column autosizing for TListView in Carbon
git-svn-id: trunk@27827 -
This commit is contained in:
parent
30b65050e7
commit
1323d7f8d1
@ -78,7 +78,7 @@ type
|
||||
procedure SetMinWidth(AMinWidth: Integer);
|
||||
procedure SetMaxWidth(AMaxWidth: Integer);
|
||||
procedure SetVisible(AVisible: Boolean);
|
||||
procedure SetWidth(AWidth: Integer);
|
||||
procedure SetWidth(AWidth: Integer; AAutoSize: Boolean);
|
||||
property TextWithIcon: Boolean read fTextWithIcon write fTextWithIcon;
|
||||
end;
|
||||
|
||||
@ -581,9 +581,22 @@ begin
|
||||
else Remove;
|
||||
end;
|
||||
|
||||
procedure TCarbonListColumn.SetWidth(AWidth: Integer);
|
||||
procedure TCarbonListColumn.SetWidth(AWidth: Integer; AAutoSize: Boolean);
|
||||
var
|
||||
lBmp: TBitmap;
|
||||
begin
|
||||
FWidth := AWidth;
|
||||
// Implements Column Autosizing
|
||||
if AAutoSize then
|
||||
begin
|
||||
lBmp := TBitmap.Create;
|
||||
// The standard Mac listview font is quite bigger then the standard TCanvas font
|
||||
// plus, we also need an extra spacing
|
||||
FWidth := lBmp.Canvas.TextWidth(FListColumn.Caption) * 2;
|
||||
lBmp.Free;
|
||||
end
|
||||
else
|
||||
FWidth := AWidth;
|
||||
|
||||
if FVisible then SetHeaderWidth(FWidth);
|
||||
end;
|
||||
|
||||
|
||||
@ -356,7 +356,7 @@ begin
|
||||
if not CheckHandle(ALV, Self, 'ColumnSetWidth') then Exit;
|
||||
|
||||
Column := TCarbonListView(ALV.Handle).GetColumn(AIndex);
|
||||
if Column <> nil then Column.SetWidth(AWidth); // Avoids crash
|
||||
if Column <> nil then Column.SetWidth(AWidth, AColumn.AutoSize); // Avoids crash
|
||||
end;
|
||||
|
||||
class procedure TCarbonWSCustomListView.ColumnSetVisible(const ALV: TCustomListView;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user