1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
unit ListViewGeneric;
interface
uses
SysUtils, Classes, Controls, comCtrls, buttons, Graphics;
type
TLvGeneric=class;
TLvListColumns = class(TListColumns)
private
function GetItem(Index: Integer): TListColumn;
procedure SetItem(Index: Integer; Value: TListColumn);
public
constructor Create(AOwner: TCustomListView);
function Add: TListColumn;
function Owner: TLvGeneric;
property Items[Index: Integer]: TListColumn read GetItem write SetItem; default;
end;
TLvCustomListView = class(TCustomListView)
private
function GetListColumns: TLvListColumns;
procedure SetListColumns(const Value: TLvListColumns);
protected
property Columns: TLvListColumns read GetListColumns write SetListColumns;
public
constructor Create(AOwner: TComponent); override;
//destructor Destroy; override;
//property Column[Index: Integer]: TTntListColumn read ColumnFromIndex;
//procedure AddItem(const Item: WideString; AObject: TObject); reintroduce; virtual;
end;
TLvGeneric = class (TLvCustomListView)
private
function getListColumns: TLvListColumns;
procedure setListColumns(const Value: TLvListColumns);
protected
property Columns : TLvListColumns read getListColumns write setListColumns;
public
constructor Create(AOwner: TComponent); override;
end;
TListViewGeneric = class(TWinControl)
private
lv : TLvGeneric;
btnAdd : TBitBtn;
btnEdit : TBitBtn;
btnDelete : TBitBtn;
function getListColumns:TLvListColumns;
procedure setListColumns(arg:TLvListColumns);
function getFont:TFont;
procedure setFont(arg:TFont);
protected
{ Déclarations protégées }
public
{ Déclarations publiques }
constructor Create(AOwner: TComponent); override;
published
{ Déclarations publiées }
property Font : TFont read getFont write setFont;
property Columns : TLvListColumns read getListColumns write setListColumns;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Exemples', [TListViewGeneric]);
end;
constructor TListViewGeneric.Create(AOwner: TComponent);
begin
width := 300;
height:= 200;
inherited Create(AOwner);
lv:=TLvGeneric.Create(self);
lv.Parent:=self;
lv.ViewStyle:=vsReport;
lv.left := 0;
lv.Top := 0;
lv.Width := Width-30;
lv.Height := Height;
lv.Anchors:=[akLeft,akTop,akRight,akBottom];
btnAdd:=TBitBtn.Create(self);
btnAdd.Parent:=self;
btnAdd.width:=25;
btnAdd.height:=25;
btnAdd.top:=0;
btnAdd.left:=width-27;
btnAdd.Anchors:=[akTop,akRight];
btnEdit:=TBitBtn.Create(self);
btnEdit.Parent:=self;
btnEdit.width:=25;
btnEdit.height:=25;
btnEdit.top:=25;
btnEdit.left:=width-27;
btnEdit.Anchors:=[akTop,akRight];
btnDelete:=TBitBtn.Create(self);
btnDelete.Parent:=self;
btnDelete.width:=25;
btnDelete.height:=25;
btnDelete.top:=50;
btnDelete.left:=width-27;
btnDelete.Anchors:=[akTop,akRight];
end;
procedure TListViewGeneric.setListColumns(arg:TLvListColumns);
begin
Columns:= arg;
end;
function TListViewGeneric.getListColumns:TLvListColumns;
begin
result:=Columns;
end;
function TListViewGeneric.getFont:TFont;
begin
result:=lv.Font;
end;
procedure TListViewGeneric.setFont(arg:TFont);
begin
lv.Font:=arg;
end;
constructor TLvGeneric.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
function TLvGeneric.getListColumns: TLvListColumns;
begin
Result:= inherited Columns as TLvListColumns;
end;
procedure TLvGeneric.SetListColumns(const Value: TLvListColumns);
begin
Columns:= Value;
end;
constructor TLvListColumns.Create(AOwner: TCustomListView);
begin
inherited Create(AOwner);
end;
function TLvListColumns.Owner: TLvGeneric;
begin
Result := inherited Owner as TLvGeneric;
end;
function TLvListColumns.Add: TListColumn;
begin
Result := (inherited Add) as TListColumn;
end;
function TLvListColumns.GetItem(Index: Integer): TListColumn;
begin
Result := inherited Items[Index] as TListColumn;
end;
procedure TLvListColumns.SetItem(Index: Integer; Value: TListColumn);
begin
inherited SetItem(Index, Value);
end;
type
THackCustomListView = class(TCustomMultiSelectListControl)
protected
FListColumns: TListColumns;
end;
constructor TLvCustomListView.Create(AOwner: TComponent);
begin
inherited;
Assert(THackCustomListView(Self).FListColumns = inherited Columns, 'Internal Error in TLvCustomListView.Create().');
FreeAndNil(THackCustomListView(Self).FListColumns);
THackCustomListView(Self).FListColumns := TLvListColumns.Create(Self);
end;
function TLvCustomListView.GetListColumns: TLvListColumns;
begin
Result := inherited Columns as TLvListColumns;
end;
procedure TLvCustomListView.SetListColumns(const Value: TLvListColumns);
begin
Columns := Value;
end;
end. |
Partager