unit mypicturepanel;
{$mode objfpc}{$H+}
interface
uses
Classes, Controls, Graphics, ExtCtrls;
type
{ TMyPicturePanel }
TMyPicturePanel = class(TCustomControl)
private
procedure SetBorderWidth(AValue : Integer);
function GetBorderWidth : Integer;
procedure SetBorderAround(AValue : Integer);
function GetBorderAround : Integer;
procedure SetBorderColor(AValue : TColor);
function GetBorderColor : TColor;
procedure SetStretch(AValue : Boolean);
function GetStretch : Boolean;
procedure SetPicture(AValue : TPicture);
function GetPicture : TPicture;
public
MyImage: TImage;
MyPanel: TPanel;
constructor Create(AOwner : TComponent); override;
published
property Color;
property BorderWidth: Integer read GetBorderWidth write SetBorderWidth;
property BorderAround: Integer read GetBorderAround write SetBorderAround;
property BorderColor: TColor read GetBorderColor write SetBorderColor;
property Stretch: Boolean read GetStretch write SetStretch;
property Picture: TPicture read GetPicture write SetPicture;
end;
procedure Register;
implementation
constructor TMyPicturePanel.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
MyPanel := TPanel.Create(Self);
with MyPanel do
begin;
Parent := Self;
Align := alClient;
BevelOuter := bvSpace;
BevelWidth := 1;
Color := clBlack;
end;
MyImage := TImage.Create(Self);
with MyImage do
begin
Align := alClient;
Parent := MyPanel;
Stretch := False;
end;
Color := clBtnFace;
Constraints.MinHeight := 10;
Constraints.MinWidth := 10;
SetBounds(0, 0, 96, 96);
end;
procedure TMyPicturePanel.SetBorderWidth(AValue : Integer);
begin
if MyPanel.BevelWidth = AValue then Exit;
MyPanel.BevelWidth := AValue;
end;
function TMyPicturePanel.GetBorderWidth : Integer;
begin
Result := MyPanel.BevelWidth;
end;
procedure TMyPicturePanel.SetBorderAround(AValue : Integer);
begin
// Sorry I have idea what BorderAround for
end;
function TMyPicturePanel.GetBorderAround : Integer;
begin
// Sorry I have idea what BorderAround for
end;
procedure TMyPicturePanel.SetBorderColor(AValue : TColor);
begin
if MyPanel.BevelColor = AValue then Exit;
MyPanel.BevelColor := AValue;
end;
function TMyPicturePanel.GetBorderColor : TColor;
begin
Result := MyPanel.BevelColor;
end;
procedure TMyPicturePanel.SetStretch(AValue : Boolean);
begin
if MyImage.Stretch = AValue then Exit;
MyImage.Stretch := AValue;
end;
function TMyPicturePanel.GetStretch : Boolean;
begin
Result := MyImage.Stretch;
end;
procedure TMyPicturePanel.SetPicture(AValue : TPicture);
begin
if MyImage.Picture = AValue then Exit;
MyImage.Picture.Assign(AValue);
end;
function TMyPicturePanel.GetPicture : TPicture;
begin
Result := MyImage.Picture;
end;
procedure Register;
begin
RegisterComponents('Misc', [TMyPicturePanel]);
end;
end.