1{%MainUnit ../comctrls.pp}
2
3{ $Id$
4
5 *****************************************************************************
6  This file is part of the Lazarus Component Library (LCL)
7
8  See the file COPYING.modifiedLGPL.txt, included in this distribution,
9  for details about the license.
10 *****************************************************************************
11}
12
13{------------------------------------------------------------------------------}
14{   TListColumns                                                               }
15{------------------------------------------------------------------------------}
16function TListColumns.Add: TListColumn;
17begin
18  Result := TListColumn(inherited Add);
19  if (Owner<>nil)
20  and ([csDesigning,csLoading,csReading]*Owner.ComponentState=[csDesigning])
21  then
22    OwnerFormDesignerModified(Owner);
23end;
24
25procedure TListColumns.Assign(Source: TPersistent);
26var
27  I: Integer;
28  NewColumn: TListColumn;
29begin
30  if (Source=nil) or (Source=Self) then exit;
31  BeginUpdate;
32  //inherited Assign(Source);
33
34  If Source is TCollection then begin
35    Clear;
36    // workaround for compiler bug: Add.Assign calls 2 times Add
37    For I:=0 To TCollection(Source).Count-1 do begin
38      NewColumn:=Add;
39      NewColumn.Assign(TCollection(Source).Items[I]);
40    end;
41  end
42  else
43    Inherited Assign(Source);
44
45  EndUpdate;
46  if (Owner<>nil)
47  and ([csDesigning,csLoading,csReading]*Owner.ComponentState=[csDesigning])
48  then
49    OwnerFormDesignerModified(Owner);
50end;
51
52constructor TListColumns.Create(AOwner: TCustomListView);
53begin
54  FOwner := AOwner;
55  inherited Create(TListColumn);
56end;
57
58destructor TListColumns.Destroy;
59begin
60  BeginUpdate;
61  inherited Destroy;
62  EndUpdate;
63end;
64
65procedure TListColumns.DoFinalizeWnd;
66var
67  I: Integer;
68begin
69  for I := 0 to Count-1 do
70    Items[I].GetWidth; // store real width from WS into FWidth
71end;
72
73procedure TListColumns.Update(Item: TCollectionItem);
74begin
75  if (Item = nil) and FNeedsUpdate then
76    Item := FItemNeedsUpdate;
77  inherited Update(Item);
78end;
79
80function TListColumns.GetItem(const AIndex: Integer): TListColumn;
81begin
82  Result := TListColumn(inherited GetItem(AIndex));
83end;
84
85procedure TListColumns.WSCreateColumns;
86var
87  n: Integer;
88begin
89  // remove columns at first if exists to prevent doubling them
90  for n := Count - 1 downto 0 do
91    GetItem(n).WSDestroyColumn;
92
93  for n := 0 to Count - 1 do
94    GetItem(n).WSCreateColumn;
95end;
96
97procedure TListColumns.SetItem(const AIndex: Integer; const AValue: TListColumn);
98begin
99  inherited SetItem(AIndex, AValue);
100end;
101
102function TListColumns.GetOwner: TPersistent;
103begin
104  Result := FOwner;
105end;
106
107// included by comctrls.pp
108
109