doc improvements; added lazarus example
This commit is contained in:
parent
a6daf71520
commit
ef039a1325
12 changed files with 5556 additions and 58 deletions
140
examples/lazarus/nimlaz.lpi
Executable file
140
examples/lazarus/nimlaz.lpi
Executable file
|
|
@ -0,0 +1,140 @@
|
|||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<LRSInOutputDirectory Value="False"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="1"/>
|
||||
</General>
|
||||
<VersionInfo>
|
||||
<ProjectVersion Value=""/>
|
||||
<Language Value=""/>
|
||||
<CharSet Value=""/>
|
||||
</VersionInfo>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<IgnoreBinaries Value="False"/>
|
||||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
|
||||
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<local>
|
||||
<FormatVersion Value="1"/>
|
||||
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
|
||||
</local>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="1">
|
||||
<Item1>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item1>
|
||||
</RequiredPackages>
|
||||
<Units Count="2">
|
||||
<Unit0>
|
||||
<Filename Value="nimlaz.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="nimlaz"/>
|
||||
<CursorPos X="17" Y="21"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Unit1"/>
|
||||
<CursorPos X="26" Y="27"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="21"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
</Units>
|
||||
<JumpHistory Count="12" HistoryIndex="11">
|
||||
<Position1>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="27" Column="1" TopLine="1"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="15" Column="3" TopLine="1"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="17" Column="26" TopLine="1"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="16" Column="18" TopLine="1"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="20" Column="43" TopLine="2"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="21" Column="48" TopLine="16"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="nimlaz.lpr"/>
|
||||
<Caret Line="1" Column="1" TopLine="1"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="52" Column="17" TopLine="9"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="unit1.pas"/>
|
||||
<Caret Line="51" Column="12" TopLine="9"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="nimlaz.lpr"/>
|
||||
<Caret Line="21" Column="3" TopLine="1"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="nimlaz.lpr"/>
|
||||
<Caret Line="20" Column="1" TopLine="1"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="nimlaz.lpr"/>
|
||||
<Caret Line="21" Column="7" TopLine="1"/>
|
||||
</Position12>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)/"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
||||
21
examples/lazarus/nimlaz.lpr
Executable file
21
examples/lazarus/nimlaz.lpr
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
program nimlaz;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms
|
||||
{ you can add units after this }, Unit1, LResources;
|
||||
|
||||
{$IFDEF WINDOWS}{$R nimlaz.rc}{$ENDIF}
|
||||
|
||||
begin
|
||||
{$I nimlaz.lrs}
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TForm1, Form1);
|
||||
Application.Run;
|
||||
end.
|
||||
|
||||
5222
examples/lazarus/nimlaz.lrs
Executable file
5222
examples/lazarus/nimlaz.lrs
Executable file
File diff suppressed because it is too large
Load diff
8
examples/lazarus/readme.txt
Executable file
8
examples/lazarus/readme.txt
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
This example demonstrates how to use Nimrod with Lazarus. The GUI is generated
|
||||
with Lazarus, while the "backend" is written in Nimrod. To compile the example,
|
||||
use this command:
|
||||
|
||||
nimrod c --app:gui --no_main --no_linking backend.nim
|
||||
|
||||
Open the ``nimlaz.lpi`` file in Lazarus and run the program.
|
||||
|
||||
46
examples/lazarus/unit1.lfm
Executable file
46
examples/lazarus/unit1.lfm
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
object Form1: TForm1
|
||||
Left = 553
|
||||
Height = 111
|
||||
Top = 464
|
||||
Width = 448
|
||||
ActiveControl = SpinEdit1
|
||||
Caption = 'Sum'
|
||||
ClientHeight = 111
|
||||
ClientWidth = 448
|
||||
OnCreate = FormCreate
|
||||
LCLVersion = '0.9.28.2'
|
||||
object Label1: TLabel
|
||||
Left = 8
|
||||
Height = 18
|
||||
Top = 72
|
||||
Width = 34
|
||||
Caption = 'Sum:'
|
||||
ParentColor = False
|
||||
end
|
||||
object SpinEdit1: TSpinEdit
|
||||
Left = 8
|
||||
Height = 27
|
||||
Top = 8
|
||||
Width = 436
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
OnChange = SpinEdit1Change
|
||||
TabOrder = 0
|
||||
end
|
||||
object SpinEdit2: TSpinEdit
|
||||
Left = 8
|
||||
Height = 27
|
||||
Top = 40
|
||||
Width = 436
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
OnChange = SpinEdit1Change
|
||||
TabOrder = 1
|
||||
end
|
||||
object Edit1: TEdit
|
||||
Left = 48
|
||||
Height = 27
|
||||
Top = 72
|
||||
Width = 396
|
||||
Anchors = [akTop, akLeft, akRight]
|
||||
TabOrder = 2
|
||||
end
|
||||
end
|
||||
58
examples/lazarus/unit1.pas
Executable file
58
examples/lazarus/unit1.pas
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
unit Unit1;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
Spin, StdCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
TForm1 = class(TForm)
|
||||
Edit1: TEdit;
|
||||
Label1: TLabel;
|
||||
SpinEdit1: TSpinEdit;
|
||||
SpinEdit2: TSpinEdit;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure SpinEdit1Change(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
Form1: TForm1;
|
||||
|
||||
implementation
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
{$link nimcache/lib/system.o}
|
||||
{$link nimcache/backend.o}
|
||||
{$link nimcache/nim__dat.o}
|
||||
{$linklib c}
|
||||
|
||||
procedure NimMain; cdecl; external;
|
||||
function myAdd(x, y: longint): longint; cdecl; external;
|
||||
|
||||
procedure TForm1.FormCreate(Sender: TObject);
|
||||
begin
|
||||
// we initialize the Nimrod data structures here:
|
||||
NimMain();
|
||||
end;
|
||||
|
||||
procedure TForm1.SpinEdit1Change(Sender: TObject);
|
||||
begin
|
||||
Edit1.text := IntToStr(myAdd(SpinEdit1.Value, SpinEdit2.Value));
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I unit1.lrs}
|
||||
|
||||
end.
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue