unit showThecards;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, Windows;
type
TShowCard = class
myShapeA : TShape; // to hold a black bordered white rectangle
myShapeB : TShape; // to hold a non-bordered white overlay rectangle
myValue : TLabel; // to hold a card value e.g. A, K, 3, 10
mySuitImage : TImage; // to hold a suit image i.e. symbol for Club, Heart, Diamond, Spade
constructor init;
destructor zeroCard;
procedure place(tp,lft:integer); // to position a card corner on the form
end;
shwCrds = array[1..16] of TShowCard;
{ TfmCards }
TfmCards = class(TForm)
imClub: Timage;
// etc. etc.
end;
var
fmCards: TfmCards;
showAllTheCards : shwCrds;
implementation
{$R *.lfm}
{ TfmCards }
procedure TfmCards.FormShow(Sender: TObject);
var i : longInt;
begin
{build the display card corners}
for i := 1 to 16 do
begin
showAllTheCards[i] := TShowCard.Create();
showAllTheCards[i].init;
end;
{test display all card corners to show Ace of Spades}
for i := 1 to 16 do
with showAllTheCards[i] do
begin
myValue.caption := 'A';
mySuitImage.picture.assign(imSpade.picture); // is the problem here?
// mySuitImage.picture := imSpade.picture; // other
// mySuitImage.picture.bitmap := imSpade.picture.bitmap; // attempts
place(25,60*i - 30);
end;
{test remove the display of 3 card corners to visually split the display of
the four suits}
for i := 1 to 16 do
if i in [4,9,13] then
begin
with showAllTheCards[i] do
begin
myShapeA.hide;
myShapeB.hide;
myValue.hide;
mySuitImage.hide;
end;
end;
end;
constructor TShowCard.init;
begin
inherited;
myValue := TLabel.Create(fmCards);
myShapeA := TShape.Create(fmCards);
myShapeB := TShape.Create(fmCards);
mySuitImage := TImage.Create(fmCards);
with myShapeA do
begin
inherited;
parent := fmCards;
// etc. etc.
end;
with myShapeB do
begin
inherited;
parent := fmCards;
// etc. etc.
end;
with myValue do
begin
inherited;
parent := fmCards;
// etc. etc.
end;
with MySuitImage do
begin
inherited;
enabled := true;
height := 26;
proportional := true;
width := 20;
transparent := true;
visible := true;
end;
end;
procedure TShowCard.place(tp,lft:integer);
begin
myShapeA.top := tp;
myShapeA.Left := lft;
myShapeB.top := tp + 3;
myShapeB.left := lft + 3;
myValue.Top := tp + 6;
myValue.left := lft + 5;
mySuitImage.top := tp + 6;
mySuitImage.left := lft + 20;
end;
end.