From 100aa19f20291d7f4090f126b1f86b07d2299b2b Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Fri, 30 Apr 2010 15:23:24 +0200 Subject: Canvas Test demo: now the form is managed by the UI Designer. Also refactored the code to fit the normal GUI design standards. eg: using Create() and Destroy() etc.. --- examples/corelib/canvastest/fpgcanvas.lpi | 6 +++- examples/corelib/canvastest/fpgcanvas.lpr | 57 +++++++++++++++---------------- 2 files changed, 32 insertions(+), 31 deletions(-) (limited to 'examples/corelib/canvastest') diff --git a/examples/corelib/canvastest/fpgcanvas.lpi b/examples/corelib/canvastest/fpgcanvas.lpi index 66833b5b..577a2a8f 100644 --- a/examples/corelib/canvastest/fpgcanvas.lpi +++ b/examples/corelib/canvastest/fpgcanvas.lpi @@ -5,12 +5,13 @@ + + - </General> <VersionInfo> <ProjectVersion Value=""/> @@ -45,6 +46,9 @@ <SmartLinkUnit Value="True"/> </CodeGeneration> <Linking> + <Debugging> + <UseLineInfoUnit Value="False"/> + </Debugging> <LinkSmart Value="True"/> </Linking> <Other> diff --git a/examples/corelib/canvastest/fpgcanvas.lpr b/examples/corelib/canvastest/fpgcanvas.lpr index c5473ba9..c774a156 100644 --- a/examples/corelib/canvastest/fpgcanvas.lpr +++ b/examples/corelib/canvastest/fpgcanvas.lpr @@ -15,20 +15,18 @@ uses type - { TMainForm } - TMainForm = class(TfpgForm) private + {@VFD_HEAD_BEGIN: MainForm} + {@VFD_HEAD_END: MainForm} bmp: TfpgImage; dst: TfpgImage; - procedure FormPaint(Sender: TObject); - procedure CustomPaintJob; - protected - procedure HandlePaint; override; + procedure FormPaint(Sender: TObject); + procedure CustomPaintJob; public - procedure AfterCreate; override; - procedure AfterConstruction; override; - procedure BeforeDestruction; override; + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure AfterCreate; override; end; { TMainForm } @@ -186,47 +184,46 @@ begin // Gradient testing r.SetRect(265, 340, 185, 35); Canvas.GradientFill(r, clBlue, clMagenta, gdHorizontal); - -end; - -procedure TMainForm.HandlePaint; -begin - inherited HandlePaint; -// CustomPaintJob; end; -procedure TMainForm.AfterCreate; +constructor TMainForm.Create(AOwner: TComponent); begin - inherited AfterCreate; - SetPosition(100, 100, 500, 400); - WindowTitle := 'fpGFX Canvas Test'; + inherited Create(AOwner); bmp := LoadImage_BMP('button.bmp'); if not Assigned(bmp) then raise Exception.Create('Failed to load button.bmp'); bmp.CreateMaskFromSample(0,0); bmp.UpdateImage; - -// dst := TfpgImage.Create; -// dst.AllocateImage(bmp.ColorDepth, 200, 50); + dst := LoadImage_BMP('gears2.bmp'); dst.CreateMaskFromSample(0,0); dst.UpdateImage; end; -procedure TMainForm.AfterConstruction; +destructor TMainForm.Destroy; begin - inherited AfterConstruction; - OnPaint := @FormPaint; + dst.Free; + bmp.Free; + inherited Destroy; end; -procedure TMainForm.BeforeDestruction; +procedure TMainForm.AfterCreate; begin - dst.Free; - bmp.Free; - inherited BeforeDestruction; + {%region 'Auto-generated GUI code' -fold} + {@VFD_BODY_BEGIN: MainForm} + Name := 'MainForm'; + SetPosition(357, 214, 500, 400); + WindowTitle := 'fpGUI Canvas Test'; + Hint := ''; + WindowPosition := wpOneThirdDown; + OnPaint := @FormPaint; + + {@VFD_BODY_END: MainForm} + {%endregion} end; + procedure MainProc; var frm: TMainForm; -- cgit v1.2.3-70-g09d2