Blame lazarus/paint/unit1.pas

bbff98
unit Unit1;
bbff98
bbff98
{$mode objfpc}{$H+}
bbff98
bbff98
interface
bbff98
bbff98
uses
bbff98
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
bbff98
  StdCtrls;
bbff98
bbff98
type
bbff98
bbff98
  { TForm1 }
bbff98
bbff98
  TForm1 = class(TForm)
bbff98
    Button1: TButton;
bbff98
    Button2: TButton;
bbff98
    ColorDialog1: TColorDialog;
bbff98
    Image1: TImage;
bbff98
    Panel1: TPanel;
bbff98
    SaveDialog1: TSaveDialog;
bbff98
    procedure Button1Click(Sender: TObject);
bbff98
    procedure Button2Click(Sender: TObject);
bbff98
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
bbff98
      Shift: TShiftState; X, Y: Integer);
bbff98
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer
bbff98
      );
bbff98
  private
bbff98
    { private declarations }
bbff98
  public
bbff98
    { public declarations }
bbff98
  end;
bbff98
bbff98
var
bbff98
  Form1: TForm1;
bbff98
bbff98
implementation
bbff98
bbff98
{$R *.lfm}
bbff98
bbff98
procedure TForm1.Button1Click(Sender: TObject);
bbff98
begin
bbff98
  ColorDialog1.Execute;
bbff98
end;
bbff98
bbff98
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
bbff98
  Y: Integer);
bbff98
begin
bbff98
  if ssLeft in Shift then begin
bbff98
    Image1.Picture.Bitmap.Canvas.Pen.Color := ColorDialog1.Color;
bbff98
    Image1.Picture.Bitmap.Canvas.LineTo(x, y);
bbff98
  end;
bbff98
end;
bbff98
bbff98
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
bbff98
  Shift: TShiftState; X, Y: Integer);
bbff98
begin
bbff98
  if Button = mbLeft then begin
bbff98
    Image1.Picture.Bitmap.Canvas.MoveTo(x, y);
bbff98
  end;
bbff98
end;
bbff98
bbff98
procedure TForm1.Button2Click(Sender: TObject);
bbff98
begin
bbff98
  if SaveDialog1.Execute then begin
bbff98
    Image1.Picture.SaveToFile(SaveDialog1.FileName);
bbff98
  end;
bbff98
end;
bbff98
bbff98
end.
bbff98