From 82de8fa58c63d66048afa55ff9c8742900ac0cde Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Wed, 10 Nov 2010 00:01:53 -0500 Subject: Started implementing Icons in listview Fixed a crash in the listview example when it was closing Updated listview example to use icons --- examples/gui/listviewtest/listviewtest.lpr | 32 +++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/gui/listviewtest/listviewtest.lpr b/examples/gui/listviewtest/listviewtest.lpr index afb1fbdf..e97b86bd 100644 --- a/examples/gui/listviewtest/listviewtest.lpr +++ b/examples/gui/listviewtest/listviewtest.lpr @@ -4,7 +4,7 @@ program listviewtest; uses Classes, sysutils, - fpg_base, fpg_main, fpg_listview, fpg_form, fpg_button, fpg_edit, fpg_checkbox, fpg_splitter, fpg_panel; + fpg_base, fpg_main, fpg_listview, fpg_form, fpg_button, fpg_edit, fpg_checkbox, fpg_splitter, fpg_panel, fpg_imagelist; type @@ -30,6 +30,7 @@ type { TMainForm } + procedure TMainForm.CloseBttn(Sender: TObject); begin Close; @@ -81,12 +82,39 @@ var LVColumn: TfpgLVColumn; TopPanel, BottomPanel: TfpgPanel; + IL: TStringList; + i: Integer; + FImageList: TfpgImageList; + FSelectedImageList: TfpgImageList; + TmpImage: TfpgImage; begin inherited Create(AOwner); WindowTitle := 'ListView Test'; SetPosition(200, 200, 640, 480); + IL := TStringList.Create; + + fpgImages.ListImages(IL); + + FImageList := TfpgImageList.Create; + FSelectedImageList := TfpgImageList.Create; + + for i := 0 to IL.Count-1 do + FImageList.AddImage(fpgImages.GetImage(IL.Strings[i])); + + IL.Free; + + // invert the items for the 'selected' images + FImageList.Item[i].Image.ImageFromSource; + + for i := 0 to FImageList.Count-1 do + begin + TmpImage := FImageList.Item[i].Image.ImageFromSource; + TmpImage.Invert; + FSelectedImageList.AddImage(TmpImage); + + end; BottomPanel := TfpgPanel.Create(Self); BottomPanel.Align := alBottom; @@ -108,6 +136,8 @@ begin OnPaintItem := @PaintItem; OnSelectionChanged := @ItemSelectionChanged; MultiSelect := True; + Images := FImageList; + ImagesSelected := FSelectedImageList; end; FSplitter := TfpgSplitter.Create(TopPanel); -- cgit v1.2.3-70-g09d2