summaryrefslogtreecommitdiff
path: root/examples/gui/listbox
diff options
context:
space:
mode:
Diffstat (limited to 'examples/gui/listbox')
-rw-r--r--examples/gui/listbox/frm_main.pas160
-rw-r--r--examples/gui/listbox/listboxtest.lpi58
-rw-r--r--examples/gui/listbox/listboxtest.lpr29
3 files changed, 247 insertions, 0 deletions
diff --git a/examples/gui/listbox/frm_main.pas b/examples/gui/listbox/frm_main.pas
new file mode 100644
index 00000000..9757bfc9
--- /dev/null
+++ b/examples/gui/listbox/frm_main.pas
@@ -0,0 +1,160 @@
+unit frm_main;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ SysUtils, Classes, gfxbase, fpgfx, gui_edit,
+ gfx_widget, gui_form, gui_label, gui_button,
+ gui_listbox, gui_memo, gui_combobox, gui_basegrid, gui_grid,
+ gui_dialogs, gui_checkbox, gui_tree, gui_trackbar,
+ gui_progressbar, gui_radiobutton, gui_tab, gui_menu,
+ gui_panel, gui_popupcalendar, gui_gauge;
+
+type
+
+ TMainForm = class(TfpgForm)
+ private
+ procedure cbHotTrackChanged(Sender: TObject);
+ procedure btnAdd1Clicked(Sender: TObject);
+ procedure btnFocusClicked(Sender: TObject);
+ procedure btnClearClicked(Sender: TObject);
+ procedure btnAdd10Clicked(Sender: TObject);
+ public
+ {@VFD_HEAD_BEGIN: MainForm}
+ lstName1: TfpgListBox;
+ btnAdd10: TfpgButton;
+ btnClear: TfpgButton;
+ btnFocus: TfpgButton;
+ btnAdd1: TfpgButton;
+ memName1: TfpgMemo;
+ cbHotTrack: TfpgCheckBox;
+ {@VFD_HEAD_END: MainForm}
+ procedure AfterCreate; override;
+ end;
+
+{@VFD_NEWFORM_DECL}
+
+implementation
+
+{@VFD_NEWFORM_IMPL}
+
+procedure TMainForm.cbHotTrackChanged(Sender: TObject);
+begin
+ lstName1.HotTrack := cbHotTrack.Checked;
+end;
+
+procedure TMainForm.btnAdd1Clicked(Sender: TObject);
+begin
+ lstName1.Items.Add(Format('Item %2d', [lstName1.ItemCount]));
+end;
+
+procedure TMainForm.btnFocusClicked(Sender: TObject);
+begin
+ if lstName1.ItemCount > 1 then
+ lstName1.FocusItem := 2;
+end;
+
+procedure TMainForm.btnClearClicked(Sender: TObject);
+begin
+ lstName1.Items.Clear;
+end;
+
+procedure TMainForm.btnAdd10Clicked(Sender: TObject);
+var
+ i: integer;
+begin
+ for i := 1 to 10 do
+ lstName1.Items.Add(Format('Item %2d', [lstName1.ItemCount]));
+end;
+
+procedure TMainForm.AfterCreate;
+begin
+ {@VFD_BODY_BEGIN: MainForm}
+ Name := 'MainForm';
+ SetPosition(345, 220, 300, 270);
+ WindowTitle := 'ListBox test';
+ WindowPosition := wpScreenCenter;
+
+ lstName1 := TfpgListBox.Create(self);
+ with lstName1 do
+ begin
+ Name := 'lstName1';
+ SetPosition(12, 12, 128, 168);
+ FontDesc := '#List';
+ end;
+
+ btnAdd10 := TfpgButton.Create(self);
+ with btnAdd10 do
+ begin
+ Name := 'btnAdd10';
+ SetPosition(204, 28, 92, 23);
+ Text := 'Add 10 items';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 1;
+ OnClick := @btnAdd10Clicked;
+ end;
+
+ btnClear := TfpgButton.Create(self);
+ with btnClear do
+ begin
+ Name := 'btnClear';
+ SetPosition(204, 56, 92, 23);
+ Text := 'Clear Items';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 2;
+ OnClick := @btnClearClicked;
+ end;
+
+ btnFocus := TfpgButton.Create(self);
+ with btnFocus do
+ begin
+ Name := 'btnFocus';
+ SetPosition(204, 84, 92, 23);
+ Text := 'FocusItem = 2';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 3;
+ OnClick := @btnFocusClicked;
+ end;
+
+ btnAdd1 := TfpgButton.Create(self);
+ with btnAdd1 do
+ begin
+ Name := 'btnAdd1';
+ SetPosition(204, 112, 92, 23);
+ Text := 'Add 1 item';
+ FontDesc := '#Label1';
+ ImageName := '';
+ TabOrder := 4;
+ OnClick := @btnAdd1Clicked;
+ end;
+
+ memName1 := TfpgMemo.Create(self);
+ with memName1 do
+ begin
+ Name := 'memName1';
+ SetPosition(12, 188, 280, 77);
+ FontDesc := '#Edit1';
+ TabOrder := 5;
+ end;
+
+ cbHotTrack := TfpgCheckBox.Create(self);
+ with cbHotTrack do
+ begin
+ Name := 'cbHotTrack';
+ SetPosition(204, 140, 120, 19);
+ FontDesc := '#Label1';
+ TabOrder := 6;
+ Text := 'Track Focus';
+ OnChange := @cbHotTrackChanged;
+ end;
+
+ {@VFD_BODY_END: MainForm}
+end;
+
+
+end.
diff --git a/examples/gui/listbox/listboxtest.lpi b/examples/gui/listbox/listboxtest.lpi
new file mode 100644
index 00000000..f80a70b0
--- /dev/null
+++ b/examples/gui/listbox/listboxtest.lpi
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="/"/>
+ <Version Value="6"/>
+ <General>
+ <Flags>
+ <SaveOnlyProjectUnits Value="True"/>
+ </Flags>
+ <SessionStorage Value="InProjectDir"/>
+ <MainUnit Value="0"/>
+ <IconPath Value="./"/>
+ <TargetFileExt Value=""/>
+ </General>
+ <VersionInfo>
+ <ProjectVersion Value=""/>
+ </VersionInfo>
+ <PublishOptions>
+ <Version Value="2"/>
+ <IgnoreBinaries Value="False"/>
+ <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="1">
+ <Item1>
+ <PackageName Value="fpgui_package"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="2">
+ <Unit0>
+ <Filename Value="listboxtest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="listboxtest"/>
+ </Unit0>
+ <Unit1>
+ <Filename Value="frm_main.pas"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="frm_main"/>
+ </Unit1>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gui/listbox/listboxtest.lpr b/examples/gui/listbox/listboxtest.lpr
new file mode 100644
index 00000000..dd14a408
--- /dev/null
+++ b/examples/gui/listbox/listboxtest.lpr
@@ -0,0 +1,29 @@
+program listboxtest;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, fpgfx, frm_main, fpgui_package;
+
+procedure MainProc;
+var
+ frm: TMainForm;
+begin
+ fpgApplication.Initialize;
+ frm := TMainForm.Create(nil);
+ try
+ frm.Show;
+ fpgApplication.Run;
+ finally
+ frm.Free;
+ end;
+end;
+
+begin
+ MainProc;
+end.
+
+