(************************************************************************
*    This File is Part of the AHM Triton Tools                          *
*    for Borland Delphi and C++ Builder.                                *
*************************************************************************
* Copyright © 1995-1999 Alexander H. Mehlhorn (AHM) and Tritontools.com *
* All Rights reserved.                                                  *
*                                                                       *
*    For more Information contact us at                                 *
*    E-Mail : support@tritontools.com                                   *
*    URL : http://www.tritontools.com                                   *
*                                                                       *
*    AHM is copyright by Alexander H. Mehlhorn                          *
*    All Parts of this Collection were developed,                       *
*    designed and implemented by AHM                                    *
*                                                                       *
*    Under no Circumstances may you distribute this file                *
*    in this or any other format. This File is supplied                 *
*    as Evaluation of Source only. No Delphi Components may be developed*
*    using extracts or subsets of this code without expressed permission*
*    by AHM.                                                            *
*                                                                       *
*************************************************************************)
unit AHMTFillBackground;

interface

uses
  SysUtils, Windows, Messages, Classes, Graphics, Controls,
  Forms,AHMControls,AHMEnhancedClass,AHMTBackground;

type
  TAHMFillBackground = class(TAHMGraphicControl)
  private
    FAutoSize: Boolean;
    fback : TAHMBackground;
    procedure SetAutoSize(Value: Boolean);
    procedure SetBack(value : TAHMBackground);
  protected
    procedure Paint; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Notification(AComponent: TComponent;Operation: TOperation); override;
  published
    property AutoSize: Boolean read FAutoSize write SetAutoSize default False;
    property Background : TAHMBackground read fback write Setback;
    property Align;
    property DragCursor;
    property DragMode;
    property Enabled;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property Visible;
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
  end;

implementation

procedure TAHMFillBackground.Notification(AComponent: TComponent;Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and  (AComponent = Background) then SetBack(nil);
end;


constructor TAHMFillBackground.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Height:=150;
  Width:=150;
end;

destructor TAHMFillBackground.Destroy;
begin
  if fback<>nil then fback.OList.remove(self);
  inherited Destroy;
end;


procedure TAHMFillBackground.Setback(Value: TAHMBackground);
begin
  if fback<>nil then fback.OList.remove(self);
  if value<>nil then value.additem(self);
  fback:=value;
  Invalidate;
end;

procedure TAHMFillBackground.SetAutoSize(Value: Boolean);
begin
  FAutoSize := Value;
  Invalidate;
end;

procedure TAHMFillBackground.Paint;
begin
  if assigned(fback) then fback.Draw(canvas.Handle,width,height,true);
end;

end.
