ICustomBasicList Base Interface 

www.madshi.net

The interface "ICustomBasicList" is the base interface for all those lists whose items are IBasic objects. That are the very most of all list interfaces you'll find in the mad* packages. For a full list of the properties and methods look at the ICustomBasicList Reference.

type ICustomBasicList = interface (IList) ['{EE6D35A0-5F85-11D3-A52D-00005A180D69}'];

The following property gives you read access to all the items that our list object currently contains:

property ICustomBasicList.Items [index: integer] : IBasic;

Some parts of the sorting functionality were already introduced with the properties IList.SortDown and IList.SortInfo. Here is the 3rd missing member, namely "SortProc", which wants to have a function that you have to define yourself. This "TCompareBasic" function gets 2 items and must return which one should be placed before or after the other one. Additionally you can use the methods "GetSortParams" or "SetSortParams" to access all 3 sort properties at the same time.

type TCompareBasic = function (const list: IList; const item1, item2: IBasic; info: integer) : integer;

property ICustomBasicList.SortProc : TCompareBasic;

function ICustomBasicList.GetSortParams (var func: TCompareBasic;
                                         var down: boolean;
                                         var info: integer       ) : boolean;
function ICustomBasicList.SetSortParams (    func: TCompareBasic;
                                             down: boolean = true;
                                             info: integer = 0   ) : boolean;

You can register an event handler which then gets called whenever an item changes or gets deleted or whenever a new item is added. The event handler can either be a procedure or a method.

type
  TIListChangeEvent   = procedure (const list: ICustomBasicList; const item: IBasic;
                                   beforeChange: boolean;
                                   changeType: TChangeType; oldIndex, index: integer);
  TIListChangeEventOO = procedure (const list: ICustomBasicList; const item: IBasic;
                                   beforeChange: boolean;
                                   changeType: TChangeType; oldIndex, index: integer) of object;

procedure ICustomBasicList.  RegisterChangeEvent (changeEvent: TIListChangeEvent  ); overload;
procedure ICustomBasicList.  RegisterChangeEvent (changeEvent: TIListChangeEventOO); overload;
function  ICustomBasicList.UnregisterChangeEvent (changeEvent: TIListChangeEvent  ) : boolean; overload;
function  ICustomBasicList.UnregisterChangeEvent (changeEvent: TIListChangeEventOO) : boolean; overload;