1
0
lazarus-tutorials/drawing demo/drawingdisplay.pas

63 lines
904 B
ObjectPascal

unit drawingdisplay;
{$mode objfpc}{$H+}
interface
uses
Forms, ExtCtrls, drawing;
type
{ TForm1 }
TForm1 = class(TForm)
rgShape: TRadioGroup;
procedure FormCreate(Sender: TObject);
procedure rgShapeClick(Sender: TObject);
private
FDrawing: TDrawing;
procedure CreateANewDrawing;
public
end;
const extent = 50;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TForm1.CreateANewDrawing;
begin
if (rgShape.ItemIndex < 0) then Exit;
FDrawing.Free;
case rgShape.ItemIndex of
0: begin
FDrawing := TSquare.Create(Self, extent);
FDrawing.Left := 10;
end;
1: begin
FDrawing := TCircle.Create(Self, extent);
FDrawing.Left := 60;
end;
end;
FDrawing.Top := 10;
FDrawing.Parent := Self;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
CreateANewDrawing;
end;
procedure TForm1.rgShapeClick(Sender: TObject);
begin
CreateANewDrawing;
end;
end.