fcCollection.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:3k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. {
  2. //
  3. // Components : IfcCollection
  4. //
  5. // Copyright (c) 1998 by Woll2Woll Software
  6. //
  7. }
  8. unit fcCollection;
  9. interface
  10. {$i fcIfDef.pas}
  11. uses Classes, Controls, Windows, ActiveX, SysUtils, Dialogs;
  12. type
  13.   TfcCollectionItem = class;
  14.   TfcCollection = class;
  15.   TfcSelectionMethod = procedure(Item: TfcCollectionItem) of object;
  16.   TfcCollectionItem = class(TCollectionItem)
  17.   private
  18.     FPointerTag: Pointer;
  19.     FSelectionMethod: TfcSelectionMethod;
  20.     FTag: Integer;
  21.     FOnRefreshDesign: TNotifyEvent;
  22.   protected
  23.     procedure SetSelectionMethod(Value: TfcSelectionMethod); virtual;
  24.     procedure RefreshDesign; virtual;
  25.   public
  26.     function GetInstance(const PropertyName: string): TPersistent; virtual;
  27.     procedure GotSelected; virtual;
  28.     procedure SetButtonName(Sender: TObject);
  29.     property PointerTag: Pointer read FPointerTag write FPointerTag;
  30.     property SelectionMethod: TfcSelectionMethod read FSelectionMethod write SetSelectionMethod;
  31.     property Tag: Integer read FTag write FTag;
  32.     property OnRefreshDesign: TNotifyEvent read FOnRefreshDesign write FOnRefreshDesign;
  33.   end;
  34.   TfcCollection = class(TCollection)
  35.   private
  36.     FDesigner: TControl;
  37.     function GetItems(Index: Integer): TfcCollectionItem;
  38.   protected
  39.     procedure SetDesigner(Value: TControl); virtual;
  40.   public
  41.     destructor Destroy; override;
  42.     function AddItem: TfcCollectionItem; virtual;
  43.     property Designer: TControl read FDesigner write SetDesigner;
  44.     property Items[Index: Integer]: TfcCollectionItem read GetItems;
  45.   end;
  46. implementation
  47. procedure TfcCollectionItem.RefreshDesign;
  48. begin
  49.    if Assigned(FOnRefreshDesign) then FOnRefreshDesign(self);
  50. end;
  51. function TfcCollectionItem.GetInstance(const PropertyName: string): TPersistent;
  52. begin
  53.   result := self;
  54. end;
  55. procedure TfcCollectionItem.GotSelected;
  56. begin
  57. end;
  58. procedure TfcCollectionItem.SetSelectionMethod(Value: TfcSelectionMethod);
  59. begin
  60. end;
  61. destructor TfcCollection.Destroy;
  62. begin
  63.   if Designer <> nil then Designer.Free;
  64.   inherited;
  65. end;
  66. procedure TfcCollectionItem.SetButtonName(Sender: TObject);
  67. begin
  68.   with (Collection as TfcCollection) do
  69.     if Designer <> nil then Designer.Update;
  70. end;
  71. function TfcCollection.AddItem: TfcCollectionItem;
  72. begin
  73.   result := Add as TfcCollectionItem;
  74. end;
  75. function TfcCollection.GetItems(Index: Integer): TfcCollectionItem;
  76. begin
  77.   result := TfcCollectionItem(inherited Items[Index]);
  78. end;
  79. procedure TfcCollection.SetDesigner(Value: TControl);
  80. begin
  81.   FDesigner := Value;
  82. end;
  83. end.