LCL: added StoredWidth property to grid column; dispose FWidth if negative width is set. Issue #28959

git-svn-id: trunk@50262 -
This commit is contained in:
ondrej 2015-11-09 09:57:13 +00:00
parent 99dee96a0a
commit fa277e1eb3

View File

@ -499,6 +499,7 @@ type
function GetMinSize: Integer; function GetMinSize: Integer;
function GetSizePriority: Integer; function GetSizePriority: Integer;
function GetReadOnly: Boolean; function GetReadOnly: Boolean;
function GetStoredWidth: Integer;
function GetVisible: Boolean; function GetVisible: Boolean;
function GetWidth: Integer; function GetWidth: Integer;
function IsAlignmentStored: boolean; function IsAlignmentStored: boolean;
@ -558,6 +559,7 @@ type
procedure FillDefaultFont; procedure FillDefaultFont;
function IsDefault: boolean; virtual; function IsDefault: boolean; virtual;
property Grid: TCustomGrid read GetGrid; property Grid: TCustomGrid read GetGrid;
property StoredWidth: Integer read GetStoredWidth;
property WidthChanged: boolean read FWidthChanged; property WidthChanged: boolean read FWidthChanged;
published published
@ -11381,6 +11383,14 @@ begin
result := FReadOnly^; result := FReadOnly^;
end; end;
function TGridColumn.GetStoredWidth: Integer;
begin
if FWidth=nil then
result := -1
else
result := FWidth^;
end;
function TGridColumn.GetValueChecked: string; function TGridColumn.GetValueChecked: string;
begin begin
if FValueChecked = nil then if FValueChecked = nil then
@ -11634,13 +11644,22 @@ procedure TGridColumn.SetWidth(const AValue: Integer);
begin begin
if (AValue=0) and not Visible then if (AValue=0) and not Visible then
exit; exit;
if FWidth = nil then begin if AValue>0 then begin
if AValue=GetDefaultWidth then if FWidth = nil then begin
if AValue=GetDefaultWidth then
exit;
New(FWidth)
end else if FWidth^ = AVAlue then
exit; exit;
New(FWidth) FWidth^ := AValue;
end else if FWidth^ = AVAlue then end else begin
exit; // negative value is handed over - dispose FWidth to use DefaultWidth
FWidth^ := AValue; if FWidth <> nil then begin
Dispose(FWidth);
FWidth := nil;
end else
exit;
end;
FWidthChanged:=true; FWidthChanged:=true;
ColumnChanged; ColumnChanged;
end; end;