diff --git a/lazarus/lamps/project1.ico b/lazarus/lamps/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/lamps/project1.ico differ diff --git a/lazarus/lamps/project1.lpi b/lazarus/lamps/project1.lpi new file mode 100644 index 0000000..3afe492 --- /dev/null +++ b/lazarus/lamps/project1.lpi @@ -0,0 +1,79 @@ + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N LFM="False"/> + </i18n> + <VersionInfo> + <StringTable ProductVersion=""/> + </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="LCL"/> + </Item1> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="project1.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="project1"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/lazarus/lamps/project1.lpr b/lazarus/lamps/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/lamps/project1.lpr @@ -0,0 +1,21 @@ +program project1; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, Unit1 + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/lazarus/lamps/project1.res b/lazarus/lamps/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/lamps/project1.res differ diff --git a/lazarus/lamps/unit1.lfm b/lazarus/lamps/unit1.lfm new file mode 100644 index 0000000..a2e475b --- /dev/null +++ b/lazarus/lamps/unit1.lfm @@ -0,0 +1,21 @@ +object Form1: TForm1 + Left = 373 + Height = 314 + Top = 306 + Width = 354 + Caption = 'Form1' + ClientHeight = 314 + ClientWidth = 354 + OnMouseDown = FormMouseDown + OnPaint = FormPaint + LCLVersion = '1.6.2.0' + object Button1: TButton + Left = 272 + Height = 25 + Top = 8 + Width = 75 + Caption = 'Button1' + OnClick = Button1Click + TabOrder = 0 + end +end diff --git a/lazarus/lamps/unit1.pas b/lazarus/lamps/unit1.pas new file mode 100644 index 0000000..e4a4a1c --- /dev/null +++ b/lazarus/lamps/unit1.pas @@ -0,0 +1,87 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + Button1: TButton; + procedure Button1Click(Sender: TObject); + procedure FormMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure FormPaint(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +const + columns = 4; + rows = 4; + diameter = 40; + +var + Form1: TForm1; + board: array[0..rows, 0..columns] of boolean; + +implementation + +{$R *.lfm} + +procedure TForm1.FormPaint(Sender: TObject); +var + r, c: integer; +begin + for r := 0 to rows-1 do begin + for c := 0 to columns-1 do begin + if board[r, c] then begin + Canvas.Brush.Color := clBlue; + end else begin + Canvas.Brush.Color := clYellow; + end; + Canvas.Ellipse(c*diameter, r*diameter, (c+1)*diameter, (r+1)*diameter); + end; + end; +end; + +procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +var + r, c: integer; +begin + c := X div diameter; + r := Y div diameter; + + if (r>=0) and (c>=0) and (r<rows) and (c<columns) then begin + board[r, c] := not board[r, c]; + if r > 0 then board[r-1, c] := not board[r-1, c]; + if r < rows-1 then board[r+1, c] := not board[r+1, c]; + if c > 0 then board[r, c-1] := not board[r, c-1]; + if c < columns-1 then board[r, c+1] := not board[r, c+1]; + end; + + Refresh; +end; + +procedure TForm1.Button1Click(Sender: TObject); +var + i: integer; + x, y: integer; +begin + for i := 0 to 100 do begin + x := round(Random * columns * diameter); + y := round(Random * rows * diameter); + FormMouseDown(nil, mbLeft, [], x, y); + end; +end; + +end. +