summaryrefslogtreecommitdiff
path: root/prototypes/fpgui2/tests
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-06 22:46:50 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-06 22:46:50 +0000
commitc3cd981fa5692460b807ca064cedea553fcd837d (patch)
treece1568e8956bf3aa20fd2d633b2f9b9de8e0142d /prototypes/fpgui2/tests
parent342d49d4249e9f2e6bef86cec00fd865cfd890b2 (diff)
downloadfpGUI-c3cd981fa5692460b807ca064cedea553fcd837d.tar.xz
Refactored a lot of the Canvas class. Only tested under Linux, but should work under Windows.
Minor performance improvement in the fpgcanvas test project. Minor changes to the edittest test project.
Diffstat (limited to 'prototypes/fpgui2/tests')
-rw-r--r--prototypes/fpgui2/tests/edittest.lpi7
-rw-r--r--prototypes/fpgui2/tests/fpgcanvas.lpr48
2 files changed, 32 insertions, 23 deletions
diff --git a/prototypes/fpgui2/tests/edittest.lpi b/prototypes/fpgui2/tests/edittest.lpi
index 269ce784..3e9244a7 100644
--- a/prototypes/fpgui2/tests/edittest.lpi
+++ b/prototypes/fpgui2/tests/edittest.lpi
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
- <PathDelim Value="\"/>
+ <PathDelim Value="/"/>
<Version Value="5"/>
<General>
<Flags>
@@ -9,7 +9,7 @@
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
- <IconPath Value=".\"/>
+ <IconPath Value="./"/>
<TargetFileExt Value=""/>
</General>
<VersionInfo>
@@ -23,7 +23,7 @@
<RunParams>
<local>
<FormatVersion Value="1"/>
- <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
+ <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
@@ -46,7 +46,6 @@
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
- <PathDelim Value="\"/>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
diff --git a/prototypes/fpgui2/tests/fpgcanvas.lpr b/prototypes/fpgui2/tests/fpgcanvas.lpr
index f26167d6..7cae700f 100644
--- a/prototypes/fpgui2/tests/fpgcanvas.lpr
+++ b/prototypes/fpgui2/tests/fpgcanvas.lpr
@@ -6,7 +6,7 @@ uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
- Classes,
+ Classes, SysUtils,
fpgfx,
gfxbase,
gui_form,
@@ -21,11 +21,17 @@ const
clBlack = $000000;
type
+
+ { TMainForm }
+
TMainForm = class(TfpgForm)
+ private
+ bmp: TfpgImage;
protected
procedure HandlePaint; override;
public
procedure AfterCreate; override;
+ procedure BeforeDestruction; override;
end;
{ TMainForm }
@@ -34,7 +40,6 @@ procedure TMainForm.HandlePaint;
var
r: TfpgRect;
fnt: TfpgFont;
- bmp: TfpgImage;
y: integer;
begin
// Enable double buffering. Must be before 'inherited' to prevent form
@@ -53,16 +58,16 @@ begin
r.Left := 60;
r.Width := 50;
r.Height := 50;
- Canvas.DrawRect(r);
+ Canvas.DrawRectangle(r);
r.Left := 120;
Canvas.SetLineStyle(2, lsDash);
- Canvas.DrawRect(r);
+ Canvas.DrawRectangle(r);
r.Left := 180;
Canvas.SetColor(clGreen);
Canvas.SetLineStyle(1, lsDot);
- Canvas.DrawRect(r);
+ Canvas.DrawRectangle(r);
r.Left := 240;
Canvas.SetColor(clBlue);
@@ -107,20 +112,13 @@ begin
// Testing Bitmap painting
- bmp := LoadImage_BMP('button.bmp');
- try
- bmp.CreateMaskFromSample(0,0);
- bmp.UpdateImage;
- Canvas.DrawString(5, 180, 'Single BMP file:');
- Canvas.DrawString(300, 210, '(mask enabled for all images)');
- Canvas.DrawImage(150, 180, bmp);
- Canvas.DrawString(5, 210, 'Parts of BMP file:');
- Canvas.DrawImagePart(150, 210, bmp, 0, 0, 32, 21);
- Canvas.DrawImagePart(190, 210, bmp, 32, 0, 32, 21);
- Canvas.DrawImagePart(230, 210, bmp, 64, 0, 32, 21);
- finally
- bmp.Free;
- end;
+ Canvas.DrawString(5, 180, 'Single BMP file:');
+ Canvas.DrawString(300, 210, '(mask enabled for all images)');
+ Canvas.DrawImage(150, 180, bmp);
+ Canvas.DrawString(5, 210, 'Parts of BMP file:');
+ Canvas.DrawImagePart(150, 210, bmp, 0, 0, 32, 21);
+ Canvas.DrawImagePart(190, 210, bmp, 32, 0, 32, 21);
+ Canvas.DrawImagePart(230, 210, bmp, 64, 0, 32, 21);
Canvas.EndDraw;
@@ -131,6 +129,18 @@ begin
inherited AfterCreate;
SetPosition(100, 100, 500, 400);
WindowTitle := 'fpGFX Canvas Test';
+
+ bmp := LoadImage_BMP('button.bmp');
+ if not Assigned(bmp) then
+ raise Exception.Create('Failed to load button.bmp');
+ bmp.CreateMaskFromSample(0,0);
+ bmp.UpdateImage;
+end;
+
+procedure TMainForm.BeforeDestruction;
+begin
+ bmp.Free;
+ inherited BeforeDestruction;
end;
procedure MainProc;