View Issue Details

IDProjectCategoryView StatusLast Update
0021758LazarusLCLpublic2012-04-18 23:51
ReporterDavid JenkinsAssigned ToPaul Ishenin 
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Product Version0.9.30.5 (SVN)Product Build 
Target VersionFixed in Version1.1 (SVN) 
Summary0021758: TListView using TlistItem descendent
DescriptionWe'd like to match the delphi functionality that allows for custom TListItem descendents to be used in TListView.

Suggested implementation patches against rev 36681 attached
TagsNo tags attached.
Fixed in Revision36812
LazTarget-
WidgetsetCarbon
Attached Files
  • comctrls.pp.patch (1,609 bytes)
    --- /Users/djenkins/laz-changes/13607/comctrls.pp	2012-04-09 12:02:05.000000000 
    +++ /Users/djenkins/laz-changes/13607/comctrls.pp.ss	2012-04-09 12:06:13.000000000 
    @@ -1013,6 +1013,8 @@
         If FCacheIndex = -1 then the cache is not valid.
       }
     
    +  TListITemClass = class of TListItem;
    +
       TListItems = class(TPersistent)
       private
         FOwner: TCustomListView;
    @@ -1020,6 +1022,7 @@
         FFlags: TListItemsFlags;
         FCacheIndex: Integer;  // Caches the last used item 
         FCacheItem: TListItem; //
    +    FListItemClass: TListItemClass;
         procedure WSCreateCacheItem;
         function WSUpdateAllowed: Boolean;
         procedure WSUpdateItem(const AIndex:Integer; const AValue: TListItem);
    @@ -1043,6 +1046,7 @@
         procedure BeginUpdate;
         procedure Clear; virtual;
         constructor Create(AOwner : TCustomListView);
    +    constructor Create(AOwner : TCustomListView; AItemClass : TListItemClass); reintroduce; overload;
         destructor Destroy; override;
         procedure Delete(const AIndex : Integer);
         procedure EndUpdate;
    @@ -1393,6 +1397,7 @@
         function CustomDrawSubItem(AItem: TListItem; ASubItem: Integer; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; virtual; //
         function IntfCustomDraw(ATarget: TCustomDrawTarget; AStage: TCustomDrawStage; AItem, ASubItem: Integer; AState: TCustomDrawState; const ARect: PRect): TCustomDrawResult;
         function GetUpdateCount: Integer;
    +    function CreateListItems: TListItems; virtual;
     
         procedure DoGetOwnerData(Item: TListItem); virtual;
         function DoOwnerDataHint(AStartIndex, AEndIndex: Integer): Boolean; virtual;
    
    comctrls.pp.patch (1,609 bytes)
  • customlistview.inc.patch (800 bytes)
    --- /Users/djenkins/laz-changes/13607/customlistview.inc	2012-04-09 11:45:46.000000000 
    +++ /Users/djenkins/laz-changes/13607/customlistview.inc.ss	2012-04-09 11:49:02.000000000 
    @@ -121,7 +121,7 @@
       FSortDirection := sdAscending;
       FIconOptions := TIconOptions.Create(Self);
       FColumns := TListColumns.Create(Self);
    -  FListItems := TListItems.Create(Self);
    +  FListItems := CreateListItems.Create(Self);
       BorderStyle := bsSingle;
       FScrollBars := ssBoth;
       FCompStyle := csListView;
    @@ -150,6 +150,12 @@
       FEditor.Visible := False;
       FEditor.Parent := Self;
     end;
    +
    +function TCustomListView.CreateListItems: TListItems;
    +begin
    +  Result := TListItems.Create(Self);
    +end;
    +
     
     {------------------------------------------------------------------------------
        TCustomListView CustomDraw
    
  • listitems.inc.patch (1,237 bytes)
    --- /Users/djenkins/laz-changes/13607/listitems.inc	2012-04-09 11:56:36.000000000 
    +++ /Users/djenkins/laz-changes/13607/listitems.inc.ss	2012-04-09 11:59:01.000000000 
    @@ -24,7 +24,19 @@
       FItems := TFPList.Create;
       FOwner := AOwner;
       FCacheIndex := -1;
    +  FListItemClass := TListItem;
     end;
    +
    +constructor TListItems.Create(AOwner : TCustomListView; AItemClass : TListItemClass);
    +begin
    +  Inherited Create;
    +  FItems := TFPList.Create;
    +  FOwner := AOwner;
    +  FCacheIndex := -1;
    +  FListItemClass := AItemClass;
    +end;
    +
    +
     
     {------------------------------------------------------------------------------}
     {   TListItems GetCount                                                        }
    @@ -97,7 +109,7 @@
     {------------------------------------------------------------------------------}
     function TListItems.Add: TListItem;
     begin
    -  Result := TListItem.Create(self);
    +  Result := FListItemClass.Create(self);
       AddItem(Result);
     end;
     
    @@ -332,7 +344,7 @@
     ------------------------------------------------------------------------------}
     function TListItems.Insert(const AIndex: Integer): TListItem;
     begin
    -  Result := TListItem.Create(self);
    +  Result := FListItemClass.Create(self);
       InsertItem(Result, AIndex);
     end;
     
    
    listitems.inc.patch (1,237 bytes)

Activities

2012-04-13 22:30

 

comctrls.pp.patch (1,609 bytes)
--- /Users/djenkins/laz-changes/13607/comctrls.pp	2012-04-09 12:02:05.000000000 
+++ /Users/djenkins/laz-changes/13607/comctrls.pp.ss	2012-04-09 12:06:13.000000000 
@@ -1013,6 +1013,8 @@
     If FCacheIndex = -1 then the cache is not valid.
   }
 
+  TListITemClass = class of TListItem;
+
   TListItems = class(TPersistent)
   private
     FOwner: TCustomListView;
@@ -1020,6 +1022,7 @@
     FFlags: TListItemsFlags;
     FCacheIndex: Integer;  // Caches the last used item 
     FCacheItem: TListItem; //
+    FListItemClass: TListItemClass;
     procedure WSCreateCacheItem;
     function WSUpdateAllowed: Boolean;
     procedure WSUpdateItem(const AIndex:Integer; const AValue: TListItem);
@@ -1043,6 +1046,7 @@
     procedure BeginUpdate;
     procedure Clear; virtual;
     constructor Create(AOwner : TCustomListView);
+    constructor Create(AOwner : TCustomListView; AItemClass : TListItemClass); reintroduce; overload;
     destructor Destroy; override;
     procedure Delete(const AIndex : Integer);
     procedure EndUpdate;
@@ -1393,6 +1397,7 @@
     function CustomDrawSubItem(AItem: TListItem; ASubItem: Integer; AState: TCustomDrawState; AStage: TCustomDrawStage): Boolean; virtual; //
     function IntfCustomDraw(ATarget: TCustomDrawTarget; AStage: TCustomDrawStage; AItem, ASubItem: Integer; AState: TCustomDrawState; const ARect: PRect): TCustomDrawResult;
     function GetUpdateCount: Integer;
+    function CreateListItems: TListItems; virtual;
 
     procedure DoGetOwnerData(Item: TListItem); virtual;
     function DoOwnerDataHint(AStartIndex, AEndIndex: Integer): Boolean; virtual;
comctrls.pp.patch (1,609 bytes)

2012-04-13 22:30

 

customlistview.inc.patch (800 bytes)
--- /Users/djenkins/laz-changes/13607/customlistview.inc	2012-04-09 11:45:46.000000000 
+++ /Users/djenkins/laz-changes/13607/customlistview.inc.ss	2012-04-09 11:49:02.000000000 
@@ -121,7 +121,7 @@
   FSortDirection := sdAscending;
   FIconOptions := TIconOptions.Create(Self);
   FColumns := TListColumns.Create(Self);
-  FListItems := TListItems.Create(Self);
+  FListItems := CreateListItems.Create(Self);
   BorderStyle := bsSingle;
   FScrollBars := ssBoth;
   FCompStyle := csListView;
@@ -150,6 +150,12 @@
   FEditor.Visible := False;
   FEditor.Parent := Self;
 end;
+
+function TCustomListView.CreateListItems: TListItems;
+begin
+  Result := TListItems.Create(Self);
+end;
+
 
 {------------------------------------------------------------------------------
    TCustomListView CustomDraw

2012-04-13 22:31

 

listitems.inc.patch (1,237 bytes)
--- /Users/djenkins/laz-changes/13607/listitems.inc	2012-04-09 11:56:36.000000000 
+++ /Users/djenkins/laz-changes/13607/listitems.inc.ss	2012-04-09 11:59:01.000000000 
@@ -24,7 +24,19 @@
   FItems := TFPList.Create;
   FOwner := AOwner;
   FCacheIndex := -1;
+  FListItemClass := TListItem;
 end;
+
+constructor TListItems.Create(AOwner : TCustomListView; AItemClass : TListItemClass);
+begin
+  Inherited Create;
+  FItems := TFPList.Create;
+  FOwner := AOwner;
+  FCacheIndex := -1;
+  FListItemClass := AItemClass;
+end;
+
+
 
 {------------------------------------------------------------------------------}
 {   TListItems GetCount                                                        }
@@ -97,7 +109,7 @@
 {------------------------------------------------------------------------------}
 function TListItems.Add: TListItem;
 begin
-  Result := TListItem.Create(self);
+  Result := FListItemClass.Create(self);
   AddItem(Result);
 end;
 
@@ -332,7 +344,7 @@
 ------------------------------------------------------------------------------}
 function TListItems.Insert(const AIndex: Integer): TListItem;
 begin
-  Result := TListItem.Create(self);
+  Result := FListItemClass.Create(self);
   InsertItem(Result, AIndex);
 end;
 
listitems.inc.patch (1,237 bytes)

Paul Ishenin

2012-04-16 09:30

manager   ~0058647

Thanks for the patch but I made it a different way.

Please test and close if ok.

Issue History

Date Modified Username Field Change
2012-04-13 22:30 David Jenkins New Issue
2012-04-13 22:30 David Jenkins File Added: comctrls.pp.patch
2012-04-13 22:30 David Jenkins Widgetset => Carbon
2012-04-13 22:30 David Jenkins File Added: customlistview.inc.patch
2012-04-13 22:31 David Jenkins File Added: listitems.inc.patch
2012-04-16 09:30 Paul Ishenin Fixed in Revision => 36812
2012-04-16 09:30 Paul Ishenin LazTarget => -
2012-04-16 09:30 Paul Ishenin Status new => resolved
2012-04-16 09:30 Paul Ishenin Fixed in Version => 1.1 (SVN)
2012-04-16 09:30 Paul Ishenin Resolution open => fixed
2012-04-16 09:30 Paul Ishenin Assigned To => Paul Ishenin
2012-04-16 09:30 Paul Ishenin Note Added: 0058647
2012-04-18 23:51 David Jenkins Status resolved => closed