Ignore:
Timestamp:
Mar 12, 2011, 6:53:25 PM (13 years ago)
Author:
george
Message:
  • Added: Generic Bitmap class.
  • Modified: Swaped X, Y parameters in ItemsXY property of generic TMatrix.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Generic/GenericMatrix.inc

    r175 r196  
    1919    FItems: array of array of TGMatrixItem;
    2020    FCount: TGMatrixIndex;
    21     function GetXY(Y: TGMatrixIndexY; X: TGMatrixIndexX): TGMatrixItem;
    22     function Get(Index: TGMatrixIndex): TGMatrixItem;
     21    function GetItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY): TGMatrixItem;
     22    function GetItem(Index: TGMatrixIndex): TGMatrixItem;
    2323    function GetCapacity: TGMatrixIndex;
    2424    function GetLast: TGMatrixItem;
     
    2727    procedure SetLast(AValue: TGMatrixItem);
    2828    procedure SetFirst(AValue: TGMatrixItem);
    29     procedure PutXY(Y: TGMatrixIndexY; X: TGMatrixIndexX; const AValue: TGMatrixItem); virtual;
    30     procedure Put(Index: TGMatrixIndex; const AValue: TGMatrixItem); virtual;
     29    procedure PutItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY; const AValue: TGMatrixItem); virtual;
     30    procedure PutItem(Index: TGMatrixIndex; const AValue: TGMatrixItem); virtual;
    3131    procedure SetCount(const AValue: TGMatrixIndex);
    3232  public
     
    4545    procedure Exchange(Index1, Index2: TGMatrixIndex);
    4646    property First: TGMatrixItem read GetFirst write SetFirst;
     47    procedure FillAll(Value: TGMatrixItem);
    4748    procedure Fill(Start, Count: TGMatrixIndex; Value: TGMatrixItem);
    4849    function Implode(RowSeparator, ColSeparator: string; Converter: TGMatrixToStringConverter): string;
     
    6566    property Count: TGMatrixIndex read FCount write SetCount;
    6667    property Capacity: TGMatrixIndex read GetCapacity write SetCapacity;
    67     property ItemsXY[Y: TGMatrixIndexY; X: TGMatrixIndexX]: TGMatrixItem read GetXY write PutXY; default;
    68     property Items[Index: TGMatrixIndex]: TGMatrixItem read Get write Put;
     68    property ItemsXY[X: TGMatrixIndexX; Y: TGMatrixIndexY]: TGMatrixItem
     69      read GetItemXY write PutItemXY; default;
     70    property Items[Index: TGMatrixIndex]: TGMatrixItem
     71      read GetItem write PutItem;
    6972    property Last: TGMatrixItem read GetLast write SetLast;
    7073  end;
     
    97100    X := 0;
    98101    while X < Source.Count.X do begin
    99       ItemsXY[Index.Y + Y, Index.X + X] := Source.ItemsXY[Y, X];
     102      ItemsXY[Index.X + X, Index.Y + Y] := Source.ItemsXY[X, Y];
    100103      X := X + 1;
    101104    end;
     
    113116    X := 0;
    114117    while X < Source.Count.X do begin
    115       ItemsXY[Index.Y + Y, Index.X + X] := Proc(ItemsXY[Index.Y + Y, Index.X + X], Source.ItemsXY[Y, X]);
     118      ItemsXY[Index.X + X, Index.Y + Y] := Proc(ItemsXY[Index.X + X, Index.Y + Y], Source.ItemsXY[X, Y]);
    116119      X := X + 1;
    117120    end;
     
    149152end;
    150153
    151 function TGMatrix.GetXY(Y: TGMatrixIndexY; X: TGMatrixIndexX): TGMatrixItem;
     154function TGMatrix.GetItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY): TGMatrixItem;
    152155begin
    153156  if (X < 0) or (X >= Count.X) or
     
    157160end;
    158161
    159 function TGMatrix.Get(Index: TGMatrixIndex): TGMatrixItem;
     162function TGMatrix.GetItem(Index: TGMatrixIndex): TGMatrixItem;
    160163begin
    161164  if (Index.X < 0) or (Index.X >= Count.X) or
     
    165168end;
    166169
    167 procedure TGMatrix.PutXY(Y: TGMatrixIndexY; X: TGMatrixIndexX; const AValue: TGMatrixItem);
     170procedure TGMatrix.PutItemXY(X: TGMatrixIndexX; Y: TGMatrixIndexY; const AValue: TGMatrixItem);
    168171begin
    169172  if (X < 0) or (X >= Count.X) or
     
    173176end;
    174177
    175 procedure TGMatrix.Put(Index: TGMatrixIndex; const AValue: TGMatrixItem);
     178procedure TGMatrix.PutItem(Index: TGMatrixIndex; const AValue: TGMatrixItem);
    176179begin
    177180  if (Index.X < 0) or (Index.X >= Count.X) or
     
    510513    X := 0;
    511514    while X < Count.X do begin
    512       Result := Result + Converter(ItemsXY[Y, X]);
     515      Result := Result + Converter(ItemsXY[X, Y]);
    513516      if X < (Count.X - 1) then
    514517        Result := Result + ColSeparator;
     
    589592    X := Start.X;
    590593    while X < Count.X do begin
    591       ItemsXY[Y, X] := Value;
     594      ItemsXY[X, Y] := Value;
    592595      X := X + 1;
    593596    end;
    594597    Y := Y + 1;
    595598  end;
     599end;
     600
     601procedure TGMatrix.FillAll(Value: TGMatrixItem);
     602begin
     603  Fill(CreateIndex(0, 0), CreateIndex(Count.X - 1, Count.Y - 1), Value);
    596604end;
    597605
Note: See TracChangeset for help on using the changeset viewer.