From caf2f2c9a38328ca554c14c210ea8a092152e89b Mon Sep 17 00:00:00 2001 From: graemeg Date: Fri, 28 Sep 2007 15:02:26 +0000 Subject: * Added a new unit for tiOPF support. I've ported the ListView composite mediator, but it still needs some testing. * Added a Clear method for the Listview Items and Columns. --- src/gui/gui_listview.pas | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/gui_listview.pas b/src/gui/gui_listview.pas index 88c6a57e..52a0946d 100644 --- a/src/gui/gui_listview.pas +++ b/src/gui/gui_listview.pas @@ -30,14 +30,13 @@ uses gui_scrollbar; type - TfpgListView = class; - TfpgLVItem = class; - TfpgLVColumns = class; - TfpgLVColumn = class; + TfpgListView = class; + TfpgLVItem = class; + TfpgLVColumns = class; + TfpgLVColumn = class; TfpgLVColumnClickEvent = procedure(Listview: TfpgListView; Column: TfpgLVColumn; Button: Integer) of object; - { TfpgLVColumn } TfpgLVColumn = class(TComponent) private @@ -77,7 +76,6 @@ type property Resizable: Boolean read FResizable write SetResizable; end; - { TfpgLVColumns } TfpgLVColumns = class(TPersistent) private @@ -89,11 +87,13 @@ type constructor Create(AListView: TfpgListView); destructor Destroy; override; function Add(AColumn: TfpgLVColumn): Integer; + procedure Clear; procedure Delete(AIndex: Integer); procedure Insert(AColumn: TfpgLVColumn; AIndex: Integer); function Count: Integer; property Column[AIndex: Integer]: TfpgLVColumn read GetColumn write SetColumn; end; + TfpgLVItemState = set of (lisFocused, lisSelected, lisHotTrack); @@ -114,7 +114,6 @@ type procedure ItemsUpdated; end; - { TfpgLVItems } TfpgLVItems = class(TObject) private @@ -134,24 +133,23 @@ type procedure DoAdd(AItem: TfpgLVItem); procedure DoDelete(AItem: TfpgLVItem); procedure DoEndUpdate; - - protected public constructor Create(AViewer: IfpgLVItemViewer); destructor Destroy; override; function Add(AItem: TfpgLVItem): Integer; function Count: Integer; + procedure Clear; procedure Delete(AIndex: Integer); function IndexOf(AItem: TfpgLVItem): Integer; procedure InsertItem(AItem: TfpgLVItem; AIndex: Integer); procedure BeginUpdate; procedure EndUpdate; - property Capacity: Integer read GetCapacity write SetCapacity; property Columns: TfpgLVColumns read FColumns; property Item[AIndex: Integer]: TfpgLVItem read GetItem write SetItem; end; + TfpgLVItem = class(TObject) private FCaption: String; @@ -171,8 +169,6 @@ type property Selected[ListView: TfpgListView]: Boolean read GetSelected write SetSelected; end; - - { TfpgListView } TfpgListView = class(TfpgWidget, IfpgLVItemViewer) private @@ -208,7 +204,7 @@ type procedure ItemAdded(AIndex: Integer); procedure ItemChanged(AIndex: Integer); procedure ItemsUpdated; - + // function GetClientRect: TfpgRect; function GetVisibleColumnsWidth: Integer; function GetItemAreaHeight: Integer; @@ -405,6 +401,15 @@ begin Result := FItems.Count; end; +procedure TfpgLVItems.Clear; +var + i: integer; +begin + for i := FItems.Count-1 downto 0 do + Delete(i); + FItems.Clear; +end; + procedure TfpgLVItems.Delete(AIndex: Integer); begin DoDelete(GetItem(AIndex)); @@ -1619,6 +1624,15 @@ begin Insert(AColumn, Count); end; +procedure TfpgLVColumns.Clear; +var + i: integer; +begin + for i := FColumns.Count-1 downto 0 do + Delete(i); + FColumns.Clear; +end; + procedure TfpgLVColumns.Delete(AIndex: Integer); begin FColumns.Delete(AIndex); -- cgit v1.2.3-70-g09d2