unit muodot; interface uses extctrls,controls,Classes,graphics; type TFigure = class(TPaintBox) private Fx: double; Fy: double; Fw: double; Fh: double; FPen: TPen; procedure Seth(const Value: double); virtual; procedure Setw(const Value: double); virtual; procedure Setx(const Value: double); virtual; procedure Sety(const Value: double); virtual; procedure SetPen(const Value: TPen); public constructor Create(AOwner:TComponent); override; procedure zoom(f:double); virtual; procedure move(f:double); virtual; procedure paint; override; procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; published property x : double read Fx write Setx; property y : double read Fy write Sety; property h : double read Fh write Seth; property w : double read Fw write Setw; property Pen : TPen read FPen write SetPen; end; TKolmio = class(TFigure) public procedure Paint; override; end; TNelio = class(TFigure) public procedure Paint; override; end; TAlusta = class(TPanel) public procedure zoom(f:double); virtual; end; TOrsi = class(TPanel) public procedure Monista(par:TWinControl;x,y:integer; f:TFigure); end; procedure Register; implementation { TFigure } procedure Register; begin RegisterComponents('GKO99', [TKolmio,TNelio,TAlusta,TOrsi]); end; procedure TFigure.move(f: double); begin SetBounds(Round(left * f), Round(top * f), width, height) end; procedure TFigure.Seth(const Value: double); begin fh := Value; Height := Round(Value) // inherited SetBounds(Top,Left,Round(Value),Width); end; procedure TFigure.Setw(const Value: double); begin Width := Round(value) end; procedure TFigure.Setx(const Value: double); begin Left := Round(value-w/2) end; procedure TFigure.Sety(const Value: double); begin Top := Round(value-h/2) end; procedure TFigure.zoom(f: double); begin SetBounds(left,top,Round(width * f), Round(height * f)) end; procedure TFigure.paint; begin Canvas.Pen.Assign(Pen); Canvas.Brush.Style := bssolid; Canvas.Brush.Color := Color end; procedure TFigure.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); begin inherited; fx := left + (width Shr 1); fw := width; fy := top + (height Shr 1); if ( height <> Round(fh) ) then fh := height; end; procedure TFigure.SetPen(const Value: TPen); begin FPen.Assign(Value); Invalidate; end; constructor TFigure.Create(AOwner: TComponent); begin inherited; FPen := TPen.Create; end; { TKolmio } procedure TKolmio.Paint; begin inherited; Canvas.Polygon([Point(0, Pred(Height)), Point(Pred(Width), Pred(Height)), Point(width Shr 1, 0), Point(0, Pred(Height)) ]); { Canvas.MoveTo(0,Height-1); Canvas.LineTo(Width-1,Height-1); Canvas.LineTo(Width div 2,0); Canvas.LineTo(0,Height-1);} end; { TNelio } procedure TNelio.Paint; begin inherited; Canvas.Rectangle(0,0,Width-1,Height-1); end; { TAlusta } procedure TAlusta.zoom(f: double); var i:integer; c : TControl; fig : TFigure; begin for i:= 0 to ControlCount-1 do begin c := Controls[i]; if not ( c is TFigure ) then continue; fig := TFigure(c); fig.move(f); fig.zoom(f); end; end; { TOrsi } procedure TOrsi.Monista(par:TWinControl;x, y: integer; f: TFigure); var uusi : TFigure; begin uusi := TFigure(f.NewInstance); uusi.Create(par); uusi.Parent := par; uusi.x := x; uusi.y := y; end; end.