unit untMessageBoard;
interface
uses
System.SysUtils,
System.Classes,
System.Types,
System.UIConsts,
FMX.Filter.Effects,
FMX.StdCtrls,
FMX.Types,
FMX.Ani,
FMX.Controls,
FMX.Objects;
type
TMessageBoard = class
private
FOwnerImage: TImage;
FBGImage: TImage;
FTitleLabel: TLabel;
FContentsText: TText;
FFloatAnimation: TFloatAnimation;
procedure setBGBitmap(const Value: TBitmap);
procedure ReSize();
property BGBitmap: TBitmap write setBGBitmap;
public
constructor Create(AOwner: TImage);
destructor Destroy; override;
procedure Hide();
procedure Show(aBGBitmap: TBitmap; aTitle: String; aContents: String);
procedure RePosition();
end;
implementation
{ TMessageBoard }
constructor TMessageBoard.Create(AOwner: TImage);
begin
FOwnerImage := AOwner;
//
Self.FBGImage := TImage.Create(AOwner);
Self.FBGImage.Parent := TFmxObject(AOwner);
Self.FBGImage.HitTest := False;
//
Self.FTitleLabel := TLabel.Create(AOwner);
Self.FTitleLabel.Parent := FBGImage;
Self.FTitleLabel.HitTest := False;
//
Self.FContentsText := TText.Create(AOwner);
Self.FContentsText.Parent := FBGImage;
Self.FContentsText.HitTest := False;
//
Self.FFloatAnimation := TFloatAnimation.Create(AOwner);
end;
destructor TMessageBoard.Destroy;
begin
Self.FTitleLabel.Free;
Self.FContentsText.Free;
Self.FBGImage.Free;
// Self.FFloatAnimation.Free;
inherited;
end;
procedure TMessageBoard.Hide;
begin
Self.FBGImage.Visible := false;
end;
procedure TMessageBoard.RePosition;
begin
Self.FBGImage.Position.X := (FOwnerImage.Width - Self.FBGImage.Width) / 2;
Self.FBGImage.Position.Y := (FOwnerImage.Height - Self.FBGImage.Height) / 2;
end;
procedure TMessageBoard.ReSize;
begin
Self.FBGImage.Width := Self.FBGImage.Bitmap.Width;
Self.FBGImage.Height := Self.FBGImage.Bitmap.Height;
Self.FBGImage.Padding.Left := Self.FBGImage.Width * 0.1;
Self.FBGImage.Padding.Right := Self.FBGImage.Width * 0.1;
Self.FBGImage.Padding.Top := Self.FBGImage.Height * 0.1;
Self.FBGImage.Padding.Bottom := Self.FBGImage.Height * 0.1;
self.FTitleLabel.StyledSettings := [];
self.FTitleLabel.Font.Size := Self.FBGImage.Height * 0.08;
self.FTitleLabel.FontColor := claWhite;
self.FTitleLabel.TextAlign := TTextAlign.taCenter;
self.FTitleLabel.Height := Self.FBGImage.Height * 0.2;
self.FTitleLabel.Align := TAlignLayout.alTop;
self.FContentsText.Align := TAlignLayout.alClient;
self.FContentsText.Font.Size := Self.FBGImage.Height * 0.05;
end;
procedure TMessageBoard.setBGBitmap(const Value: TBitmap);
begin
Self.FBGImage.Bitmap.Assign(Value);
Self.ReSize();
Self.RePosition();
end;
procedure TMessageBoard.Show(aBGBitmap: TBitmap; aTitle: String; aContents: String);
begin
self.BGBitmap := aBGBitmap;
Self.FTitleLabel.Text := aTitle;
Self.FContentsText.Text := aContents;
Self.FFloatAnimation.Delay := 0;
Self.FFloatAnimation.Duration := 1;
Self.FFloatAnimation.StartValue := 0;
Self.FFloatAnimation.StopValue := 1;
Self.FFloatAnimation.Parent := FBGImage;
Self.FFloatAnimation.PropertyName := 'Opacity';
Self.FBGImage.Opacity := Self.FFloatAnimation.StartValue;
Self.FBGImage.Visible := True;
Self.FFloatAnimation.Start();
end;
end.
メッセージボード
コメントをどうぞ