2011-06-17 20:53:01 +00:00
|
|
|
unit spkt_Items;
|
|
|
|
|
2011-06-18 17:48:28 +00:00
|
|
|
{$mode delphi}
|
|
|
|
{.$Define EnhancedRecordSupport}
|
|
|
|
|
2011-06-17 20:53:01 +00:00
|
|
|
(*******************************************************************************
|
|
|
|
* *
|
|
|
|
* Plik: spkt_Items.pas *
|
2011-06-17 21:12:21 +00:00
|
|
|
* Opis: Modu³ zawiera klasê kolekcji elementów tafli. *
|
|
|
|
* Copyright: (c) 2009 by Spook. Jakiekolwiek u¿ycie komponentu bez *
|
|
|
|
* uprzedniego uzyskania licencji od autora stanowi z³amanie *
|
2011-06-17 20:53:01 +00:00
|
|
|
* prawa autorskiego! *
|
|
|
|
* *
|
|
|
|
*******************************************************************************)
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
2011-06-18 17:48:28 +00:00
|
|
|
uses Classes, Controls, SysUtils, Dialogs,
|
|
|
|
spkt_Appearance, spkt_Dispatch, spkt_BaseItem, spkt_Types,
|
2012-06-04 00:49:51 +00:00
|
|
|
spkt_Buttons, spkt_Checkboxes;
|
2011-06-17 20:53:01 +00:00
|
|
|
|
|
|
|
type TSpkItems = class(TSpkCollection)
|
|
|
|
private
|
|
|
|
FToolbarDispatch : TSpkBaseToolbarDispatch;
|
|
|
|
FAppearance : TSpkToolbarAppearance;
|
|
|
|
FImages : TImageList;
|
|
|
|
FDisabledImages : TImageList;
|
|
|
|
FLargeImages : TImageList;
|
|
|
|
FDisabledLargeImages : TImageList;
|
|
|
|
|
|
|
|
// *** Gettery i settery ***
|
|
|
|
procedure SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
|
|
|
|
function GetItems(index: integer): TSpkBaseItem; reintroduce;
|
|
|
|
procedure SetAppearance(const Value: TSpkToolbarAppearance);
|
|
|
|
procedure SetImages(const Value: TImageList);
|
|
|
|
procedure SetDisabledImages(const Value : TImageList);
|
|
|
|
procedure SetLargeImages(const Value : TImageList);
|
|
|
|
procedure SetDisabledLargeImages(const Value : TImageList);
|
|
|
|
public
|
|
|
|
function AddLargeButton : TSpkLargeButton;
|
|
|
|
function AddSmallButton : TSpkSmallButton;
|
2012-06-04 00:49:51 +00:00
|
|
|
function AddCheckbox: TSpkCheckbox;
|
|
|
|
function AddRadioButton: TSpkRadioButton;
|
2011-06-17 20:53:01 +00:00
|
|
|
|
|
|
|
// *** Reakcja na zmiany listy ***
|
|
|
|
procedure Notify(Item: TComponent; Operation : TOperation); override;
|
|
|
|
procedure Update; override;
|
|
|
|
|
|
|
|
property Items[index : integer] : TSpkBaseItem read GetItems; default;
|
|
|
|
property ToolbarDispatch : TSpkBaseToolbarDispatch read FToolbarDispatch write SetToolbarDispatch;
|
|
|
|
property Appearance : TSpkToolbarAppearance read FAppearance write SetAppearance;
|
|
|
|
property Images : TImageList read FImages write SetImages;
|
|
|
|
property DisabledImages : TImageList read FDisabledImages write SetDisabledImages;
|
|
|
|
property LargeImages : TImageList read FLargeImages write SetLargeImages;
|
|
|
|
property DisabledLargeImages : TImageList read FDisabledLargeImages write SetDisabledLargeImages;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{ TSpkItems }
|
|
|
|
|
|
|
|
function TSpkItems.AddLargeButton: TSpkLargeButton;
|
|
|
|
begin
|
2012-06-09 16:11:47 +00:00
|
|
|
Result := TSpkLargeButton.Create(FRootComponent);
|
|
|
|
Result.Parent := FRootComponent;
|
|
|
|
AddItem(Result);
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TSpkItems.AddSmallButton: TSpkSmallButton;
|
|
|
|
begin
|
2012-06-09 16:11:47 +00:00
|
|
|
Result := TSpkSmallButton.Create(FRootComponent);
|
|
|
|
Result.Parent := FRootComponent;
|
|
|
|
AddItem(Result);
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
2012-06-04 00:49:51 +00:00
|
|
|
function TSpkItems.AddCheckbox: TSpkCheckbox;
|
|
|
|
begin
|
2012-06-09 16:11:47 +00:00
|
|
|
Result := TSpkCheckbox.Create(FRootComponent);
|
|
|
|
Result.Parent := FRootComponent;
|
|
|
|
AddItem(Result);
|
2012-06-04 00:49:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TSpkItems.AddRadioButton: TSpkRadioButton;
|
2011-06-17 20:53:01 +00:00
|
|
|
begin
|
2012-06-09 16:11:47 +00:00
|
|
|
Result := TSpkRadioButton.Create(FRootComponent);
|
|
|
|
Result.Parent := FRootComponent;
|
|
|
|
AddItem(Result);
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TSpkItems.GetItems(index: integer): TSpkBaseItem;
|
|
|
|
begin
|
|
|
|
result:=TSpkBaseItem(inherited Items[index]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.Notify(Item: TComponent;
|
|
|
|
Operation : TOperation);
|
|
|
|
begin
|
|
|
|
inherited Notify(Item, Operation);
|
|
|
|
|
|
|
|
case Operation of
|
|
|
|
opInsert: begin
|
2011-06-17 21:12:21 +00:00
|
|
|
// Ustawienie dyspozytora na nil spowoduje, ¿e podczas
|
|
|
|
// przypisywania w³asnoœci nie bêd¹ wo³ane metody Notify*
|
2011-06-17 20:53:01 +00:00
|
|
|
TSpkBaseItem(Item).ToolbarDispatch:=nil;
|
|
|
|
|
|
|
|
TSpkBaseItem(Item).Appearance:=FAppearance;
|
|
|
|
TSpkBaseItem(Item).Images:=FImages;
|
|
|
|
TSpkBaseItem(Item).DisabledImages:=FDisabledImages;
|
|
|
|
TSpkBaseItem(Item).LargeImages:=FLargeImages;
|
|
|
|
TSpkBaseItem(Item).DisabledLargeImages:=FDisabledLargeImages;
|
|
|
|
TSpkBaseItem(Item).ToolbarDispatch:=FToolbarDispatch;
|
|
|
|
end;
|
|
|
|
opRemove: begin
|
|
|
|
if not(csDestroying in Item.ComponentState) then
|
|
|
|
begin
|
|
|
|
TSpkBaseItem(Item).ToolbarDispatch:=nil;
|
|
|
|
TSpkBaseItem(Item).Appearance:=nil;
|
|
|
|
TSpkBaseItem(Item).Images:=nil;
|
|
|
|
TSpkBaseItem(Item).DisabledImages:=nil;
|
|
|
|
TSpkBaseItem(Item).LargeImages:=nil;
|
|
|
|
TSpkBaseItem(Item).DisabledLargeImages:=nil;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.SetAppearance(const Value: TSpkToolbarAppearance);
|
|
|
|
|
|
|
|
var i: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
FAppearance := Value;
|
2012-06-09 16:11:47 +00:00
|
|
|
for i := 0 to Count - 1 do
|
|
|
|
Items[i].Appearance := Value;
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.SetDisabledImages(const Value: TImageList);
|
|
|
|
|
|
|
|
var i: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
FDisabledImages := Value;
|
2012-06-09 16:11:47 +00:00
|
|
|
for i := 0 to Count - 1 do
|
|
|
|
Items[i].DisabledImages := Value;
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.SetDisabledLargeImages(const Value: TImageList);
|
|
|
|
|
|
|
|
var i: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
FDisabledLargeImages := Value;
|
2012-06-09 16:11:47 +00:00
|
|
|
for i := 0 to Count - 1 do
|
|
|
|
Items[i].DisabledLargeImages := Value;
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.SetImages(const Value: TImageList);
|
|
|
|
|
|
|
|
var i: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
FImages := Value;
|
2012-06-09 16:11:47 +00:00
|
|
|
for i := 0 to Count - 1 do
|
|
|
|
Items[i].Images := Value;
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.SetLargeImages(const Value: TImageList);
|
|
|
|
|
|
|
|
var i: Integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
FLargeImages := Value;
|
2012-06-09 16:11:47 +00:00
|
|
|
for i := 0 to Count - 1 do
|
|
|
|
Items[i].LargeImages := Value;
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.SetToolbarDispatch(const Value: TSpkBaseToolbarDispatch);
|
|
|
|
|
|
|
|
var i : integer;
|
|
|
|
|
|
|
|
begin
|
|
|
|
FToolbarDispatch := Value;
|
2012-06-09 16:11:47 +00:00
|
|
|
for i := 0 to Count - 1 do
|
|
|
|
Items[i].ToolbarDispatch := Value;
|
2011-06-17 20:53:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TSpkItems.Update;
|
|
|
|
begin
|
|
|
|
inherited Update;
|
|
|
|
|
|
|
|
if assigned(FToolbarDispatch) then
|
|
|
|
FToolbarDispatch.NotifyItemsChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|