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,6 +44,7 @@ type TSpkCollection = class(TPersistent)
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
// *** Obs³uga listy ***
|
// *** Obs³uga listy ***
|
||||||
|
// *** List operations ***
|
||||||
procedure AddItem(AItem: TComponent);
|
procedure AddItem(AItem: TComponent);
|
||||||
procedure InsertItem(index: integer; AItem: TComponent);
|
procedure InsertItem(index: integer; AItem: TComponent);
|
||||||
procedure Clear;
|
procedure Clear;
|
||||||
@@ -52,6 +57,7 @@ type TSpkCollection = class(TPersistent)
|
|||||||
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 ***
|
||||||
|
// *** Reader, writer and operation designtime and DFM
|
||||||
procedure WriteNames(Writer: TWriter); virtual;
|
procedure WriteNames(Writer: TWriter); virtual;
|
||||||
procedure ReadNames(Reader: TReader); virtual;
|
procedure ReadNames(Reader: TReader); virtual;
|
||||||
procedure ProcessNames(Owner: TComponent); virtual;
|
procedure ProcessNames(Owner: TComponent); virtual;
|
||||||
@@ -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,6 +92,9 @@ 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)
|
||||||
|
|
||||||
|
// This method can be recalling untreated names (in particular, the method
|
||||||
|
// uses the name przetwarzaj¹ca AddItem) --- ???
|
||||||
|
|
||||||
Notify(AItem, opInsert);
|
Notify(AItem, opInsert);
|
||||||
FList.Add(AItem);
|
FList.Add(AItem);
|
||||||
|
|
||||||
@@ -97,7 +107,6 @@ end;
|
|||||||
procedure TSpkCollection.Clear;
|
procedure TSpkCollection.Clear;
|
||||||
begin
|
begin
|
||||||
FList.Clear;
|
FList.Clear;
|
||||||
|
|
||||||
Update;
|
Update;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@@ -110,23 +119,19 @@ 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);
|
FList := TFPObjectList.create(False);
|
||||||
|
|
||||||
FListState := lsReady;
|
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;
|
||||||
|
|
||||||
@@ -146,7 +151,8 @@ 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;
|
||||||
@@ -159,25 +165,25 @@ 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;
|
||||||
|
|
||||||
@@ -187,64 +193,49 @@ 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;
|
FNames.Clear;
|
||||||
FListState := lsReady;
|
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;
|
Reader.ReadListEnd;
|
||||||
|
|
||||||
FListState := lsNeedsProcessing;
|
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);
|
FList.Delete(i);
|
||||||
|
|
||||||
Update;
|
Update;
|
||||||
end;
|
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);
|
FList.Extract(Item);
|
||||||
|
|
||||||
Update;
|
Update;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user