git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2457 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2012-06-09 16:11:47 +00:00
parent e1b8b548d7
commit e333deef99
5 changed files with 42 additions and 270 deletions

View File

@ -22,7 +22,7 @@ type TSpkItemSize = (isLarge, isNormal);
TSpkItemTableBehaviour = (tbBeginsRow, tbBeginsColumn, tbContinuesRow); TSpkItemTableBehaviour = (tbBeginsRow, tbBeginsColumn, tbContinuesRow);
TSpkItemGroupBehaviour = (gbSingleItem, gbBeginsGroup, gbContinuesGroup, gbEndsGroup); TSpkItemGroupBehaviour = (gbSingleItem, gbBeginsGroup, gbContinuesGroup, gbEndsGroup);
type TSpkBaseItem = class abstract(TSpkComponent) TSpkBaseItem = class abstract(TSpkComponent)
private private
protected protected
FRect : T2DIntRect; FRect : T2DIntRect;

View File

@ -37,10 +37,6 @@ type TSpkItems = class(TSpkCollection)
procedure SetLargeImages(const Value : TImageList); procedure SetLargeImages(const Value : TImageList);
procedure SetDisabledLargeImages(const Value : TImageList); procedure SetDisabledLargeImages(const Value : TImageList);
public public
// *** Konstruktor, destruktor ***
constructor Create(RootComponent : TComponent); override;
destructor Destroy; override;
function AddLargeButton : TSpkLargeButton; function AddLargeButton : TSpkLargeButton;
function AddSmallButton : TSpkSmallButton; function AddSmallButton : TSpkSmallButton;
function AddCheckbox: TSpkCheckbox; function AddCheckbox: TSpkCheckbox;
@ -64,133 +60,31 @@ implementation
{ TSpkItems } { TSpkItems }
function TSpkItems.AddLargeButton: TSpkLargeButton; function TSpkItems.AddLargeButton: TSpkLargeButton;
var Owner, Parent : TComponent;
i: Integer;
begin begin
if FRootComponent<>nil then Result := TSpkLargeButton.Create(FRootComponent);
begin Result.Parent := FRootComponent;
Owner:=FRootComponent.Owner; AddItem(Result);
Parent:=FRootComponent;
end
else
begin
Owner:=nil;
Parent:=nil;
end;
result:=TSpkLargeButton.Create(Owner);
result.Parent:=Parent;
if FRootComponent<>nil then
begin
i:=0;
while FRootComponent.Owner.FindComponent('SpkLargeButton'+inttostr(i))<>nil do
inc(i);
result.Name:='SpkLargeButton'+inttostr(i);
end;
AddItem(result);
end; end;
function TSpkItems.AddSmallButton: TSpkSmallButton; function TSpkItems.AddSmallButton: TSpkSmallButton;
var Owner, Parent : TComponent;
i: Integer;
begin begin
if FRootComponent<>nil then Result := TSpkSmallButton.Create(FRootComponent);
begin Result.Parent := FRootComponent;
Owner:=FRootComponent.Owner; AddItem(Result);
Parent:=FRootComponent;
end
else
begin
Owner:=nil;
Parent:=nil;
end;
result:=TSpkSmallButton.Create(Owner);
result.Parent:=Parent;
if FRootComponent<>nil then
begin
i:=0;
while FRootComponent.Owner.FindComponent('SpkSmallButton'+inttostr(i))<>nil do
inc(i);
result.Name:='SpkSmallButton'+inttostr(i);
end;
AddItem(result);
end; end;
function TSpkItems.AddCheckbox: TSpkCheckbox; function TSpkItems.AddCheckbox: TSpkCheckbox;
var
Owner, Parent : TComponent;
i: Integer;
begin begin
if FRootComponent <> nil then begin Result := TSpkCheckbox.Create(FRootComponent);
Owner := FRootComponent.Owner; Result.Parent := FRootComponent;
Parent := FRootComponent; AddItem(Result);
end else begin
Owner := nil;
Parent := nil;
end;
result := TSpkCheckbox.Create(Owner);
result.Parent := Parent;
if FRootComponent <> nil then begin
i := 0;
while FRootComponent.Owner.FindComponent('SpkCheckbox'+IntToStr(i)) <> nil do
inc(i);
result.Name := 'SpkCheckbox' + IntToStr(i);
end;
AddItem(result);
end; end;
function TSpkItems.AddRadioButton: TSpkRadioButton; function TSpkItems.AddRadioButton: TSpkRadioButton;
var
Owner, Parent : TComponent;
i: Integer;
begin begin
if FRootComponent <> nil then begin Result := TSpkRadioButton.Create(FRootComponent);
Owner := FRootComponent.Owner; Result.Parent := FRootComponent;
Parent := FRootComponent; AddItem(Result);
end else begin
Owner := nil;
Parent := nil;
end;
result := TSpkRadioButton.Create(Owner);
result.Parent := Parent;
if FRootComponent <> nil then begin
i := 0;
while FRootComponent.Owner.FindComponent('SpkRadioButton'+IntToStr(i)) <> nil do
inc(i);
result.Name := 'SpkRadioButton' + IntToStr(i);
end;
AddItem(result);
end;
constructor TSpkItems.Create(RootComponent : TComponent);
begin
inherited Create(RootComponent);
FToolbarDispatch:=nil;
FAppearance:=nil;
FImages:=nil;
FDisabledImages:=nil;
FLargeImages:=nil;
FDisabledLargeImages:=nil;
end;
destructor TSpkItems.Destroy;
begin
inherited Destroy;
end; end;
function TSpkItems.GetItems(index: integer): TSpkBaseItem; function TSpkItems.GetItems(index: integer): TSpkBaseItem;
@ -236,9 +130,8 @@ var i: Integer;
begin begin
FAppearance := Value; FAppearance := Value;
if self.Count>0 then for i := 0 to Count - 1 do
for i := 0 to self.count - 1 do Items[i].Appearance := Value;
Items[i].Appearance:=FAppearance;
end; end;
procedure TSpkItems.SetDisabledImages(const Value: TImageList); procedure TSpkItems.SetDisabledImages(const Value: TImageList);
@ -247,9 +140,8 @@ var i: Integer;
begin begin
FDisabledImages := Value; FDisabledImages := Value;
if self.Count>0 then for i := 0 to Count - 1 do
for i := 0 to self.count - 1 do Items[i].DisabledImages := Value;
Items[i].DisabledImages:=FDisabledImages;
end; end;
procedure TSpkItems.SetDisabledLargeImages(const Value: TImageList); procedure TSpkItems.SetDisabledLargeImages(const Value: TImageList);
@ -258,9 +150,8 @@ var i: Integer;
begin begin
FDisabledLargeImages := Value; FDisabledLargeImages := Value;
if self.Count>0 then for i := 0 to Count - 1 do
for i := 0 to self.count - 1 do Items[i].DisabledLargeImages := Value;
Items[i].DisabledLargeImages:=FDisabledLargeImages;
end; end;
procedure TSpkItems.SetImages(const Value: TImageList); procedure TSpkItems.SetImages(const Value: TImageList);
@ -269,9 +160,8 @@ var i: Integer;
begin begin
FImages := Value; FImages := Value;
if self.Count>0 then for i := 0 to Count - 1 do
for i := 0 to self.count - 1 do Items[i].Images := Value;
Items[i].Images:=FImages;
end; end;
procedure TSpkItems.SetLargeImages(const Value: TImageList); procedure TSpkItems.SetLargeImages(const Value: TImageList);
@ -280,9 +170,8 @@ var i: Integer;
begin begin
FLargeImages := Value; FLargeImages := Value;
if self.Count>0 then for i := 0 to Count - 1 do
for i := 0 to self.count - 1 do Items[i].LargeImages := Value;
Items[i].LargeImages:=FLargeImages;
end; end;
procedure TSpkItems.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch); procedure TSpkItems.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
@ -291,9 +180,8 @@ var i : integer;
begin begin
FToolbarDispatch := Value; FToolbarDispatch := Value;
if self.Count>0 then for i := 0 to Count - 1 do
for i := 0 to self.count - 1 do Items[i].ToolbarDispatch := Value;
Items[i].ToolbarDispatch:=FToolbarDispatch;
end; end;
procedure TSpkItems.Update; procedure TSpkItems.Update;

View File

@ -126,10 +126,6 @@ type TSpkPanes = class(TSpkCollection)
procedure SetLargeImages(const Value: TImageList); procedure SetLargeImages(const Value: TImageList);
procedure SetDisabledLargeImages(const Value : TImageList); procedure SetDisabledLargeImages(const Value : TImageList);
public public
// *** Konstruktor, destruktor ***
constructor Create(RootComponent : TComponent); override;
destructor Destroy; override;
// *** Dodawanie i wstawianie elementów *** // *** Dodawanie i wstawianie elementów ***
function Add : TSpkPane; function Add : TSpkPane;
function Insert(index : integer) : TSpkPane; function Insert(index : integer) : TSpkPane;
@ -908,51 +904,10 @@ end;
{ TSpkPanes } { TSpkPanes }
function TSpkPanes.Add: TSpkPane; function TSpkPanes.Add: TSpkPane;
var Owner, Parent : TComponent;
i: Integer;
begin begin
if FRootComponent<>nil then Result:=TSpkPane.Create(FRootComponent);
begin Result.Parent:=FRootComponent;
Owner:=FRootComponent.Owner; AddItem(Result);
Parent:=FRootComponent;
end
else
begin
Owner:=nil;
Parent:=nil;
end;
result:=TSpkPane.Create(Owner);
result.Parent:=Parent;
if FRootComponent<>nil then
begin
i:=0;
while FRootComponent.Owner.FindComponent('SpkPane'+inttostr(i))<>nil do
inc(i);
result.Name:='SpkPane'+inttostr(i);
end;
AddItem(result);
end;
constructor TSpkPanes.Create(RootComponent : TComponent);
begin
inherited Create(RootComponent);
FToolbarDispatch:=nil;
FAppearance:=nil;
FImages:=nil;
FDisabledImages:=nil;
FLargeImages:=nil;
FDisabledLargeImages:=nil;
end;
destructor TSpkPanes.Destroy;
begin
inherited Destroy;
end; end;
function TSpkPanes.GetItems(index: integer): TSpkPane; function TSpkPanes.GetItems(index: integer): TSpkPane;

View File

@ -149,9 +149,6 @@ type TSpkTabs = class(TSpkCollection)
procedure SetLargeImages(const Value : TImageList); procedure SetLargeImages(const Value : TImageList);
procedure SetDisabledLargeImages(const Value : TImageList); procedure SetDisabledLargeImages(const Value : TImageList);
public public
constructor Create(RootComponent : TComponent); override;
destructor Destroy; override;
function Add : TSpkTab; function Add : TSpkTab;
function Insert(index : integer) : TSpkTab; function Insert(index : integer) : TSpkTab;
@ -616,51 +613,10 @@ end;
{ TSpkTabs } { TSpkTabs }
function TSpkTabs.Add: TSpkTab; function TSpkTabs.Add: TSpkTab;
var Owner, Parent : TComponent;
i: Integer;
begin begin
if FRootComponent<>nil then Result:=TSpkTab.create(FRootComponent);
begin Result.Parent:=FRootComponent;
Owner:=FRootComponent.Owner; AddItem(Result);
Parent:=FRootComponent;
end
else
begin
Owner:=nil;
Parent:=nil;
end;
result:=TSpkTab.create(Owner);
result.Parent:=Parent;
if FRootComponent<>nil then
begin
i:=0;
while FRootComponent.Owner.FindComponent('SpkTab'+inttostr(i))<>nil do
inc(i);
result.Name:='SpkTab'+inttostr(i);
end;
AddItem(result);
end;
constructor TSpkTabs.Create(RootComponent : TComponent);
begin
inherited Create(RootComponent);
FToolbarDispatch:=nil;
FAppearance:=nil;
FImages:=nil;
FDisabledImages:=nil;
FLargeImages:=nil;
FDisabledLargeImages:=nil;
end;
destructor TSpkTabs.Destroy;
begin
inherited Destroy;
end; end;
function TSpkTabs.GetItems(index: integer): TSpkTab; function TSpkTabs.GetItems(index: integer): TSpkTab;

View File

@ -22,7 +22,7 @@ type TSpkListState = (lsNeedsProcessing, lsReady);
type TSpkCollection = class(TPersistent) type TSpkCollection = class(TPersistent)
private private
protected protected
FList : TObjectList; FList : TFPObjectList;
FNames : TStringList; FNames : TStringList;
FListState : TSpkListState; FListState : TSpkListState;
FRootComponent : TComponent; FRootComponent : TComponent;
@ -32,9 +32,6 @@ type TSpkCollection = class(TPersistent)
procedure Update; virtual; procedure Update; virtual;
// *** Wewnêtrzne metody dodawania i wstawiania elementów *** // *** Wewnêtrzne metody dodawania i wstawiania elementów ***
procedure AddItem(AItem : TComponent);
procedure InsertItem(index : integer; AItem : TComponent);
// *** Gettery i settery *** // *** Gettery i settery ***
function GetItems(index: integer): TComponent; virtual; function GetItems(index: integer): TComponent; virtual;
public public
@ -43,6 +40,8 @@ type TSpkCollection = class(TPersistent)
destructor Destroy; override; destructor Destroy; override;
// *** Obs³uga listy *** // *** Obs³uga listy ***
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;
@ -67,20 +66,13 @@ type TSpkComponent = class(TComponent)
protected protected
FParent : TComponent; FParent : TComponent;
FCollection: TSpkCollection; FCollection: TSpkCollection;
// *** Gettery i settery ***
function GetParent: TComponent;
procedure SetParent(const Value: TComponent);
public public
// *** Konstruktor ***
constructor Create(AOwner : TComponent); override;
// *** Obs³uga parenta *** // *** Obs³uga parenta ***
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;
property Parent : TComponent read GetParent write SetParent; property Parent : TComponent read FParent write SetParentComponent;
property Collection: TSpkCollection read FCollection; property Collection: TSpkCollection read FCollection;
end; end;
@ -121,7 +113,7 @@ FRootComponent:=RootComponent;
FNames:=TStringList.create; FNames:=TStringList.create;
FList:=TObjectList.create(False); FList:=TFPObjectList.create(False);
FListState:=lsReady; FListState:=lsReady;
end; end;
@ -263,31 +255,17 @@ begin
end; end;
procedure TSpkCollection.WriteNames(Writer: TWriter); procedure TSpkCollection.WriteNames(Writer: TWriter);
var
var Item : pointer; i: Integer;
begin begin
Writer.WriteListBegin; Writer.WriteListBegin;
for i := 0 to FList.Count - 1 do
for Item in FList do Writer.WriteString(TComponent(FList[i]).Name);
Writer.WriteString(TComponent(Item).Name); Writer.WriteListEnd;
Writer.WriteListEnd;
end; end;
{ TSpkComponent } { TSpkComponent }
constructor TSpkComponent.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FParent:=nil;
end;
function TSpkComponent.GetParent: TComponent;
begin
result:=GetParentComponent;
end;
function TSpkComponent.GetParentComponent: TComponent; function TSpkComponent.GetParentComponent: TComponent;
begin begin
result:=FParent; result:=FParent;
@ -298,11 +276,6 @@ begin
result:=FParent<>nil; result:=FParent<>nil;
end; end;
procedure TSpkComponent.SetParent(const Value: TComponent);
begin
SetParentComponent(Value);
end;
procedure TSpkComponent.SetParentComponent(Value: TComponent); procedure TSpkComponent.SetParentComponent(Value: TComponent);
begin begin
FParent:=Value; FParent:=Value;