summaryrefslogtreecommitdiff
path: root/examples/gui/stdimages/stdimglist.lpr
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-23 09:40:43 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-07-23 09:40:43 +0000
commit652ba160012b1eda3a1f6dafb9311b0dcade476c (patch)
tree8abf8d7cc6246484c646b8160b8ab0179ac5b069 /examples/gui/stdimages/stdimglist.lpr
parent6bda2054c8dda9b98f9958c54fce9f27927642c5 (diff)
downloadfpGUI-652ba160012b1eda3a1f6dafb9311b0dcade476c.tar.xz
Restructure Part 3.
* Moved all the examples over from the prototype directory. * Removed obsolete GFX examples.
Diffstat (limited to 'examples/gui/stdimages/stdimglist.lpr')
-rw-r--r--examples/gui/stdimages/stdimglist.lpr93
1 files changed, 93 insertions, 0 deletions
diff --git a/examples/gui/stdimages/stdimglist.lpr b/examples/gui/stdimages/stdimglist.lpr
new file mode 100644
index 00000000..06212cfc
--- /dev/null
+++ b/examples/gui/stdimages/stdimglist.lpr
@@ -0,0 +1,93 @@
+program stdimglist;
+
+{$mode objfpc}{$H+}
+
+uses
+ Classes, SysUtils,
+ fpgfx, gfxbase, gui_form, gfx_imgfmt_bmp, gui_button;
+
+type
+
+ TMainForm = class(TfpgForm)
+ private
+ btnClose: TfpgButton;
+ procedure btnCloseClick(Sender: TObject);
+ protected
+ procedure HandlePaint; override;
+ public
+ constructor Create(aowner: TComponent); override;
+ procedure AfterCreate; override;
+ end;
+
+{ TMainForm }
+
+procedure TMainForm.AfterCreate;
+begin
+ SetPosition(100,100,700,500);
+ WindowTitle := 'fpGUI Standard Image Listing';
+end;
+
+procedure TMainForm.btnCloseClick(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TMainForm.HandlePaint;
+var
+ n: integer;
+ x: TfpgCoord;
+ y: TfpgCoord;
+ sl: TStringList;
+ img: TfpgImage;
+begin
+ Canvas.BeginDraw; // begin double buffering
+ inherited HandlePaint;
+
+ sl := TStringList.Create;
+ x := 8;
+ y := 8;
+ fpgImages.ListImages(sl);
+
+ for n := 0 to sl.Count-1 do
+ begin
+ Canvas.DrawString(x, y, sl[n]+':');
+
+ img := TfpgImage(sl.Objects[n]);
+ if img <> nil then
+ Canvas.DrawImage(x+150, y, img);
+
+ inc(y, img.Height+8);
+ if y > Height-32 then // largest images are 32 in height
+ begin
+ inc(x, 200);
+ y := 8;
+ end;
+ end;
+
+ Canvas.EndDraw;
+ sl.Free;
+end;
+
+constructor TMainForm.Create(aowner: TComponent);
+begin
+ inherited Create(aowner);
+ // Place button in bottom right corner.
+ btnClose := CreateButton(self, Width-90, Height-35, 75, 'Quit', @btnCloseClick);
+ btnClose.ImageName := 'stdimg.quit';
+// btnClose.Focusable := False;
+ btnClose.Anchors := [anRight, anBottom];
+end;
+
+procedure MainProc;
+var
+ frm : TMainForm;
+begin
+ fpgApplication.Initialize;
+ frm := TMainForm.Create(nil);
+ frm.Show;
+ fpgApplication.Run;
+end;
+
+begin
+ MainProc;
+end.