From: <ob...@us...> - 2006-06-08 09:56:54
|
Revision: 10664 Author: obones Date: 2006-06-08 02:56:49 -0700 (Thu, 08 Jun 2006) ViewCVS: http://svn.sourceforge.net/jvcl/?rev=10664&view=rev Log Message: ----------- Mantis 3300: Add does not trigger an AV anymore. Modified Paths: -------------- trunk/jvcl/run/JvCustomItemViewer.pas Modified: trunk/jvcl/run/JvCustomItemViewer.pas =================================================================== --- trunk/jvcl/run/JvCustomItemViewer.pas 2006-06-08 09:35:28 UTC (rev 10663) +++ trunk/jvcl/run/JvCustomItemViewer.pas 2006-06-08 09:56:49 UTC (rev 10664) @@ -38,6 +38,7 @@ {$IFDEF UNITVERSIONING} JclUnitVersioning, {$ENDIF UNITVERSIONING} + Contnrs, Windows, Messages, Classes, Graphics, Controls, Forms, StdCtrls, ComCtrls, ExtCtrls, JvConsts, // for clSkyBlue @@ -167,6 +168,15 @@ property Data: Pointer read FData write SetData; end; + TJvViewerItemList = class(TObjectList) + private + function GetItem(Index: Integer): TJvViewerItem; + procedure SetItem(Index: Integer; const Value: TJvViewerItem); + published + public + property Items[Index: Integer]: TJvViewerItem read GetItem write SetItem; default; + end; + TJvViewerItemClass = class of TJvViewerItem; // TODO @@ -187,7 +197,7 @@ TJvCustomItemViewer = class(TJvExScrollingWinControl) private FCanvas: TCanvas; - FItems: TList; + FItems: TJvViewerItemList; FOptions: TJvCustomItemViewerOptions; FTopLeft: TPoint; FItemSize: TSize; @@ -799,7 +809,7 @@ inherited Create(AOwner); ParentColor := False; ControlStyle := [csCaptureMouse, csDisplayDragImage, csClickEvents, csOpaque, csDoubleClicks]; - FItems := TList.Create; + FItems := TJvViewerItemList.Create; FOptions := GetOptionsClass.Create(Self); FCanvas := TControlCanvas.Create; TControlCanvas(FCanvas).Control := Self; @@ -830,7 +840,7 @@ function TJvCustomItemViewer.Add(AItem: TJvViewerItem): Integer; begin - Insert(FItems.Count + 1, AItem); + Insert(FItems.Count, AItem); Result := FItems.Count - 1; end; @@ -889,14 +899,10 @@ end; procedure TJvCustomItemViewer.Clear; -var - I: Integer; begin BeginUpdate; try - for I := 0 to FItems.Count - 1 do - TObject(FItems[I]).Free; - FItems.Count := 0; + FItems.Clear; finally EndUpdate; end; @@ -1983,6 +1989,18 @@ DragCursor := crArrow; end; +{ TJvViewerItemList } + +function TJvViewerItemList.GetItem(Index: Integer): TJvViewerItem; +begin + Result := inherited Items[Index] as TJvViewerItem; +end; + +procedure TJvViewerItemList.SetItem(Index: Integer; const Value: TJvViewerItem); +begin + inherited Items[Index] := Value; +end; + initialization {$IFDEF UNITVERSIONING} RegisterUnitVersion(HInstance, UnitVersioning); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |