summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authordrewski207 <drewski207@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-06 00:05:07 +0000
committerdrewski207 <drewski207@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2007-08-06 00:05:07 +0000
commit4bd8d8738022685001d2b1d801ef00088e2a69bf (patch)
tree4fa9300a539400802ea1c52fe8f5936fce832651 /examples
parent842be2507dbf85dd5d91b464f19d6945772a753f (diff)
downloadfpGUI-4bd8d8738022685001d2b1d801ef00088e2a69bf.tar.xz
* Added basic listview
* Added a test project for the listview widget * made the Scrollbar more robust * changed canvas.color and canvas.textcolor to be read/write A cool feature of a listview is to be able to share it's .Items property with other listviews so the list doesn't have to exits in memory. The test project uses that feature.
Diffstat (limited to 'examples')
-rw-r--r--examples/gui/listviewtest/listviewtest.lpi51
-rw-r--r--examples/gui/listviewtest/listviewtest.lpr178
2 files changed, 229 insertions, 0 deletions
diff --git a/examples/gui/listviewtest/listviewtest.lpi b/examples/gui/listviewtest/listviewtest.lpi
new file mode 100644
index 00000000..8e8f6e62
--- /dev/null
+++ b/examples/gui/listviewtest/listviewtest.lpi
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="5"/>
+ <General>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=""/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <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="2">
+ <Item1>
+ <PackageName Value="fpgui_package"/>
+ </Item1>
+ <Item2>
+ <PackageName Value="fpgfx_package"/>
+ </Item2>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="listviewtest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="listviewtest"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gui/listviewtest/listviewtest.lpr b/examples/gui/listviewtest/listviewtest.lpr
new file mode 100644
index 00000000..9d503590
--- /dev/null
+++ b/examples/gui/listviewtest/listviewtest.lpr
@@ -0,0 +1,178 @@
+program listviewtest;
+
+{$mode objfpc}{$H+}
+
+uses
+ Classes, fpgui_package, fpgfx_package, fpgfx, sysutils ,
+ gui_listview, gui_form, gui_button, gui_edit, gfxbase, gui_checkbox;
+
+type
+
+ { TMainForm }
+
+ TMainForm = class(TfpgForm)
+ private
+ FEdit: TfpgEdit;
+ FAddButton: TfpgButton;
+ FListView: TfpgListView;
+ FQuitButton: TfpgButton;
+ FCheck: TfpgCheckBox;
+
+ procedure CloseBttn(Sender: TObject);
+ procedure AddBttn(Sender: TObject);
+ procedure ShowHeadersChange(Sender: TObject);
+ procedure PaintItem(ListView: TfpgListView; ACanvas: TfpgCanvas; Item: TfpgLVItem;
+ Area:TRect; var PaintPart: TfpgLVItemPaintPart);
+
+ public
+ constructor Create(AOwner: TComponent); override;
+ destructor Destroy; override;
+ end;
+
+{ TMainForm }
+
+procedure TMainForm.CloseBttn(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TMainForm.AddBttn(Sender: TObject);
+var
+ Item: TfpgLVItem;
+begin
+ FListView.BeginUpdate;
+ Item := FListView.ItemAdd;
+ Item.Caption :=FEdit.Text+IntToStr(FListView.Items.Count);
+ Item.SubItems.Add('0');
+ Item.SubItems.Add('1');
+ Item.SubItems.Add('2');
+ Item.SubItems.Add('3');
+ Item.SubItems.Add('4');
+ FListView.EndUpdate;
+
+end;
+
+procedure TMainForm.ShowHeadersChange(Sender: TObject);
+begin
+ FListView.ShowHeaders := TfpgCheckBox(Sender).Checked;
+end;
+
+procedure TMainForm.PaintItem(ListView: TfpgListView; ACanvas: TfpgCanvas;
+ Item: TfpgLVItem; Area: TRect; var PaintPart: TfpgLVItemPaintPart);
+begin
+ if ListView.Items.IndexOf(Item) mod 2 = 0 then ACanvas.TextColor := clRed;;
+end;
+
+constructor TMainForm.Create(AOwner: TComponent);
+var
+ LVColumn: TfpgLVColumn;
+ TmpListView : TfpgListView;
+begin
+ inherited Create(AOwner);
+
+ WindowTitle := 'ListView Test';
+ SetPosition(200, 200, 610, 455);
+
+ FListView := TfpgListView.Create(Self);
+ with FListView do begin
+ Parent := Self;
+ Top := 10;
+ Left := 10;
+ Width := 320;
+ Height := 400;
+ OnPaintItem := @PaintItem;
+ MultiSelect := True;
+ end;
+
+ TmpListView := TfpgListView.Create(Self);
+ with TmpListView do begin
+ Parent := Self;
+ Top := 10;
+ Left := 335;
+ Width := 270;
+ Height := 400;
+ //OnPaintItem := @PaintItem;
+ Items := FListView.Items;
+ end;
+
+
+ LVColumn := TfpgLVColumn.Create(FListView.Columns);
+ LVColumn.Caption := 'Column 1';
+ LVColumn.Width := 150;
+ LVColumn.Height := 50;
+ FListView.Columns.Add(LVColumn);
+ TmpListView.Columns.Add(LVColumn);
+
+ LVColumn := TfpgLVColumn.Create(FListView.Columns);
+ LVColumn.Caption := 'Column 2';
+ LVColumn.Width := 100;
+ LVColumn.Height := 50;
+ //LVColumn.Visible := False;
+ FListView.Columns.Add(LVColumn);
+ //TmpListView.Columns.Add(LVColumn);
+
+ LVColumn := TfpgLVColumn.Create(FListView.Columns);
+ LVColumn.Caption := 'Column 3';
+ LVColumn.Width := 200;
+ LVColumn.Height := 50;
+ //LVColumn.Visible := False;
+ FListView.Columns.Add(LVColumn);
+ TmpListView.Columns.Add(LVColumn);
+ LVColumn.ColumnIndex := 2;
+
+
+ FEdit := TfpgEdit.Create(Self);
+ with FEdit do begin
+ Parent := Self;
+ Top := 420;
+ Left := 10;
+ Width := 100;
+ end;
+
+ FAddButton := TfpgButton.Create(Self);
+ with FAddButton do begin
+ Parent := Self;
+ Top := 420;
+ Left := 120;
+ Width := 80;
+ Text := 'Add';
+ OnClick := @AddBttn;
+ end;
+
+ FQuitButton := TfpgButton.Create(Self);
+ with FQuitButton do begin
+ Parent := Self;
+ Top := 420;
+ Left := 210;
+ Width := 80;
+ Text := 'Quit';
+ OnClick := @CloseBttn;
+ end;
+
+ FCheck := TfpgCheckBox.Create(Self);
+ with FCheck do begin
+ Parent := Self;
+ Top := 420;
+ Left := 290;
+ Width := 110;
+ Checked := True;
+ Text := 'ShowHeaders';
+ OnChange := @ShowHeadersChange;
+ end;
+
+end;
+
+destructor TMainForm.Destroy;
+begin
+ inherited Destroy;
+end;
+
+begin
+ fpgApplication.Initialize;
+ with TMainForm.Create(nil) do begin
+ Show;
+ fpgApplication.Run;
+ Free;
+ end;
+end.
+