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

63 lines
904 B
ObjectPascal
Raw Permalink Normal View History

unit drawingdisplay;
{$mode objfpc}{$H+}
interface
uses
2021-10-07 17:15:42 -04:00
Forms, ExtCtrls, drawing;
type
{ TForm1 }
TForm1 = class(TForm)
2021-10-07 17:15:42 -04:00
rgShape: TRadioGroup;
procedure FormCreate(Sender: TObject);
procedure rgShapeClick(Sender: TObject);
private
FDrawing: TDrawing;
procedure CreateANewDrawing;
public
end;
const extent = 50;
var
Form1: TForm1;
implementation
2021-10-07 17:15:42 -04:00
{$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.