You've already forked lazarus-ccr
spktoolbar: Google-translate the Polish comments of the original author in spkt_types to English. Some reformatting.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4096 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -28,11 +28,15 @@ type TSpkCollection = class(TPersistent)
|
|||||||
FRootComponent : TComponent;
|
FRootComponent : TComponent;
|
||||||
|
|
||||||
// *** Metody reakcji na zmiany w liœcie ***
|
// *** Metody reakcji na zmiany w liœcie ***
|
||||||
|
// *** Methods responding to changes in list ***
|
||||||
procedure Notify(Item : TComponent; Operation : TOperation); virtual;
|
procedure Notify(Item : TComponent; Operation : TOperation); virtual;
|
||||||
procedure Update; virtual;
|
procedure Update; virtual;
|
||||||
|
|
||||||
// *** Wewnêtrzne metody dodawania i wstawiania elementów ***
|
// *** Wewnêtrzne metody dodawania i wstawiania elementów ***
|
||||||
// *** Gettery i settery ***
|
// *** Gettery i settery ***
|
||||||
|
|
||||||
|
// *** Internal methods for adding and inserting elements ***
|
||||||
|
// *** Getters and setters ***
|
||||||
function GetItems(index: integer): TComponent; virtual;
|
function GetItems(index: integer): TComponent; virtual;
|
||||||
public
|
public
|
||||||
// *** Konstruktor, destruktor ***
|
// *** Konstruktor, destruktor ***
|
||||||
@ -40,21 +44,23 @@ type TSpkCollection = class(TPersistent)
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
// *** Obs³uga listy ***
|
// *** Obs³uga listy ***
|
||||||
procedure AddItem(AItem : TComponent);
|
// *** List operations ***
|
||||||
procedure InsertItem(index : integer; AItem : TComponent);
|
procedure AddItem(AItem: TComponent);
|
||||||
|
procedure InsertItem(index: integer; AItem: TComponent);
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
function Count : integer;
|
function Count: integer;
|
||||||
procedure Delete(index : integer); virtual;
|
procedure Delete(index: integer); virtual;
|
||||||
function IndexOf(Item : TComponent) : integer;
|
function IndexOf(Item: TComponent) : integer;
|
||||||
procedure Remove(Item : TComponent); virtual;
|
procedure Remove(Item: TComponent); virtual;
|
||||||
procedure RemoveReference(Item : TComponent);
|
procedure RemoveReference(Item: TComponent);
|
||||||
procedure Exchange(item1, item2 : integer);
|
procedure Exchange(item1, item2: integer);
|
||||||
procedure Move(IndexFrom, IndexTo : integer);
|
procedure Move(IndexFrom, IndexTo: integer);
|
||||||
|
|
||||||
// *** Reader, writer i obs³uga designtime i DFM ***
|
// *** Reader, writer i obs³uga designtime i DFM ***
|
||||||
procedure WriteNames(Writer : TWriter); virtual;
|
// *** Reader, writer and operation designtime and DFM
|
||||||
procedure ReadNames(Reader : TReader); virtual;
|
procedure WriteNames(Writer: TWriter); virtual;
|
||||||
procedure ProcessNames(Owner : TComponent); virtual;
|
procedure ReadNames(Reader: TReader); virtual;
|
||||||
|
procedure ProcessNames(Owner: TComponent); virtual;
|
||||||
|
|
||||||
property ListState : TSpkListState read FListState;
|
property ListState : TSpkListState read FListState;
|
||||||
property Items[index : integer] : TComponent read GetItems; default;
|
property Items[index : integer] : TComponent read GetItems; default;
|
||||||
@ -68,6 +74,7 @@ type TSpkComponent = class(TComponent)
|
|||||||
FCollection: TSpkCollection;
|
FCollection: TSpkCollection;
|
||||||
public
|
public
|
||||||
// *** Obs³uga parenta ***
|
// *** Obs³uga parenta ***
|
||||||
|
// *** Parent operations ***
|
||||||
function HasParent : boolean; override;
|
function HasParent : boolean; override;
|
||||||
function GetParentComponent : TComponent; override;
|
function GetParentComponent : TComponent; override;
|
||||||
procedure SetParentComponent(Value : TComponent); override;
|
procedure SetParentComponent(Value : TComponent); override;
|
||||||
@ -85,49 +92,47 @@ begin
|
|||||||
// Ta metoda mo¿e byæ wywo³ywana bez przetworzenia nazw (w szczególnoœci, metoda
|
// Ta metoda mo¿e byæ wywo³ywana bez przetworzenia nazw (w szczególnoœci, metoda
|
||||||
// przetwarzaj¹ca nazwy korzysta z AddItem)
|
// przetwarzaj¹ca nazwy korzysta z AddItem)
|
||||||
|
|
||||||
Notify(AItem, opInsert);
|
// This method can be recalling untreated names (in particular, the method
|
||||||
FList.Add(AItem);
|
// uses the name przetwarzaj¹ca AddItem) --- ???
|
||||||
|
|
||||||
if AItem is TSpkComponent then
|
Notify(AItem, opInsert);
|
||||||
TSpkComponent(AItem).FCollection := self;
|
FList.Add(AItem);
|
||||||
|
|
||||||
Update;
|
if AItem is TSpkComponent then
|
||||||
|
TSpkComponent(AItem).FCollection := self;
|
||||||
|
|
||||||
|
Update;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.Clear;
|
procedure TSpkCollection.Clear;
|
||||||
begin
|
begin
|
||||||
FList.Clear;
|
FList.Clear;
|
||||||
|
Update;
|
||||||
Update;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSpkCollection.Count: integer;
|
function TSpkCollection.Count: integer;
|
||||||
begin
|
begin
|
||||||
result:=FList.Count;
|
result := FList.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TSpkCollection.Create(RootComponent : TComponent);
|
constructor TSpkCollection.Create(RootComponent : TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
FRootComponent:=RootComponent;
|
FRootComponent := RootComponent;
|
||||||
|
FNames := TStringList.create;
|
||||||
FNames:=TStringList.create;
|
FList := TFPObjectList.create(False);
|
||||||
|
FListState := lsReady;
|
||||||
FList:=TFPObjectList.create(False);
|
|
||||||
|
|
||||||
FListState:=lsReady;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.Delete(index: integer);
|
procedure TSpkCollection.Delete(index: integer);
|
||||||
begin
|
begin
|
||||||
if (index<0) or (index>=FList.count) then
|
if (index < 0) or (index >= FList.count) then
|
||||||
raise InternalException.Create('TSpkCollection.Delete: Nieprawid³owy indeks!');
|
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||||
|
//raise InternalException.Create('TSpkCollection.Delete: Nieprawid³owy indeks!');
|
||||||
|
|
||||||
Notify(TComponent(FList[index]), opRemove);
|
Notify(TComponent(FList[index]), opRemove);
|
||||||
|
FList.Delete(index);
|
||||||
FList.Delete(index);
|
Update;
|
||||||
|
|
||||||
Update;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TSpkCollection.Destroy;
|
destructor TSpkCollection.Destroy;
|
||||||
@ -139,46 +144,47 @@ end;
|
|||||||
|
|
||||||
procedure TSpkCollection.Exchange(item1, item2: integer);
|
procedure TSpkCollection.Exchange(item1, item2: integer);
|
||||||
begin
|
begin
|
||||||
FList.Exchange(item1, item2);
|
FList.Exchange(item1, item2);
|
||||||
Update;
|
Update;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSpkCollection.GetItems(index: integer): TComponent;
|
function TSpkCollection.GetItems(index: integer): TComponent;
|
||||||
begin
|
begin
|
||||||
if (index<0) or (index>=FList.Count) then
|
if (index < 0) or (index >= FList.Count) then
|
||||||
raise InternalException.create('TSpkCollection.GetItems: Nieprawid³owy indeks!');
|
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||||
|
//raise InternalException.create('TSpkCollection.GetItems: Nieprawid³owy indeks!');
|
||||||
|
|
||||||
result:=TComponent(FList[index]);
|
result := TComponent(FList[index]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSpkCollection.IndexOf(Item: TComponent): integer;
|
function TSpkCollection.IndexOf(Item: TComponent): integer;
|
||||||
begin
|
begin
|
||||||
result:=FList.IndexOf(Item);
|
result := FList.IndexOf(Item);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.InsertItem(index: integer; AItem: TComponent);
|
procedure TSpkCollection.InsertItem(index: integer; AItem: TComponent);
|
||||||
begin
|
begin
|
||||||
if (index<0) or (index>FList.Count) then
|
if (index < 0) or (index > FList.Count) then
|
||||||
raise InternalException.Create('TSpkCollection.Insert: Nieprawid³owy indeks!');
|
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||||
|
//raise InternalException.Create('TSpkCollection.Insert: Nieprawid³owy indeks!');
|
||||||
|
|
||||||
Notify(AItem, opInsert);
|
Notify(AItem, opInsert);
|
||||||
|
FList.Insert(index, AItem);
|
||||||
FList.Insert(index, AItem);
|
if AItem is TSpkComponent then
|
||||||
if AItem is TSpkComponent then
|
TSpkComponent(AItem).FCollection := self;
|
||||||
TSpkComponent(AItem).FCollection := self;
|
Update;
|
||||||
|
|
||||||
Update;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.Move(IndexFrom, IndexTo: integer);
|
procedure TSpkCollection.Move(IndexFrom, IndexTo: integer);
|
||||||
begin
|
begin
|
||||||
if (indexFrom<0) or (indexFrom>=FList.Count) or
|
if (indexFrom < 0) or (indexFrom >= FList.Count) or
|
||||||
(indexTo<0) or (indexTo>=FList.Count) then
|
(indexTo < 0) or (indexTo >= FList.Count)
|
||||||
raise InternalException.Create('TSpkCollection.Move: Nieprawid³owy indeks!');
|
then
|
||||||
|
raise InternalException.Create('TSpkCollection.Delete: Illegal index!');
|
||||||
|
//raise InternalException.Create('TSpkCollection.Move: Nieprawid³owy indeks!');
|
||||||
|
|
||||||
FList.Move(IndexFrom, IndexTo);
|
FList.Move(IndexFrom, IndexTo);
|
||||||
|
Update;
|
||||||
Update;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.Notify(Item: TComponent; Operation: TOperation);
|
procedure TSpkCollection.Notify(Item: TComponent; Operation: TOperation);
|
||||||
@ -186,67 +192,52 @@ begin
|
|||||||
//
|
//
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.ProcessNames(Owner : TComponent);
|
procedure TSpkCollection.ProcessNames(Owner: TComponent);
|
||||||
|
var
|
||||||
var s : string;
|
s: string;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FList.Clear;
|
FList.Clear;
|
||||||
|
if Owner <> nil then
|
||||||
if Owner<>nil then
|
for s in FNames do
|
||||||
for s in FNames do
|
AddItem(Owner.FindComponent(s));
|
||||||
AddItem(Owner.FindComponent(s));
|
FNames.Clear;
|
||||||
|
FListState := lsReady;
|
||||||
FNames.Clear;
|
|
||||||
FListState:=lsReady;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.ReadNames(Reader: TReader);
|
procedure TSpkCollection.ReadNames(Reader: TReader);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Reader.ReadListBegin;
|
Reader.ReadListBegin;
|
||||||
|
FNames.Clear;
|
||||||
FNames.Clear;
|
while not(Reader.EndOfList) do
|
||||||
while not(Reader.EndOfList) do
|
FNames.Add(Reader.ReadString);
|
||||||
FNames.Add(Reader.ReadString);
|
Reader.ReadListEnd;
|
||||||
|
FListState := lsNeedsProcessing;
|
||||||
Reader.ReadListEnd;
|
|
||||||
|
|
||||||
FListState:=lsNeedsProcessing;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.Remove(Item: TComponent);
|
procedure TSpkCollection.Remove(Item: TComponent);
|
||||||
|
var
|
||||||
var i : integer;
|
i: integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
i:=FList.IndexOf(Item);
|
i := FList.IndexOf(Item);
|
||||||
|
if i >= 0 then
|
||||||
if i>=0 then
|
begin
|
||||||
begin
|
Notify(Item, opRemove);
|
||||||
Notify(Item, opRemove);
|
FList.Delete(i);
|
||||||
|
Update;
|
||||||
FList.Delete(i);
|
end;
|
||||||
|
|
||||||
Update;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.RemoveReference(Item: TComponent);
|
procedure TSpkCollection.RemoveReference(Item: TComponent);
|
||||||
|
var
|
||||||
var i : integer;
|
i: integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
i:=FList.IndexOf(Item);
|
i := FList.IndexOf(Item);
|
||||||
|
if i >= 0 then
|
||||||
if i>=0 then
|
begin
|
||||||
begin
|
Notify(Item, opRemove);
|
||||||
Notify(Item, opRemove);
|
FList.Extract(Item);
|
||||||
|
Update;
|
||||||
FList.Extract(Item);
|
end;
|
||||||
|
|
||||||
Update;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkCollection.Update;
|
procedure TSpkCollection.Update;
|
||||||
@ -268,17 +259,17 @@ end;
|
|||||||
|
|
||||||
function TSpkComponent.GetParentComponent: TComponent;
|
function TSpkComponent.GetParentComponent: TComponent;
|
||||||
begin
|
begin
|
||||||
result:=FParent;
|
result := FParent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TSpkComponent.HasParent: boolean;
|
function TSpkComponent.HasParent: boolean;
|
||||||
begin
|
begin
|
||||||
result:=FParent<>nil;
|
result := FParent<>nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSpkComponent.SetParentComponent(Value: TComponent);
|
procedure TSpkComponent.SetParentComponent(Value: TComponent);
|
||||||
begin
|
begin
|
||||||
FParent:=Value;
|
FParent := Value;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Reference in New Issue
Block a user