summaryrefslogtreecommitdiff
path: root/examples/gui/timertest
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/timertest
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/timertest')
-rw-r--r--examples/gui/timertest/timertest.lpi53
-rw-r--r--examples/gui/timertest/timertest.lpr125
2 files changed, 178 insertions, 0 deletions
diff --git a/examples/gui/timertest/timertest.lpi b/examples/gui/timertest/timertest.lpi
new file mode 100644
index 00000000..0dfae648
--- /dev/null
+++ b/examples/gui/timertest/timertest.lpi
@@ -0,0 +1,53 @@
+<?xml version="1.0"?>
+<CONFIG>
+ <ProjectOptions>
+ <PathDelim Value="\"/>
+ <Version Value="5"/>
+ <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"/>
+ <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="fpGFX2"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="timertest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="timertest"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <PathDelim Value="\"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/examples/gui/timertest/timertest.lpr b/examples/gui/timertest/timertest.lpr
new file mode 100644
index 00000000..7c4209df
--- /dev/null
+++ b/examples/gui/timertest/timertest.lpr
@@ -0,0 +1,125 @@
+program timertest;
+
+{$mode objfpc}{$H+}
+
+uses
+ {$IFDEF UNIX}{$IFDEF UseCThreads}
+ cthreads,
+ {$ENDIF}{$ENDIF}
+ Classes, SysUtils, fpgfx, gfxbase, gui_form, gui_button, gui_label;
+
+type
+ TMainForm = class(TfpgForm)
+ private
+ btnClose: TfpgButton;
+ btnStopStart: TfpgButton;
+ timer1: TfpgTimer;
+ timer2: TfpgTimer;
+ timer3: TfpgTimer;
+ lblTimer1: TfpgLabel;
+ lblTimer2: TfpgLabel;
+ lblTimer3: TfpgLabel;
+ cnt1: integer;
+ cnt2: integer;
+ procedure MyTimer1(Sender: TObject);
+ procedure MyTimer2(Sender: TObject);
+ procedure MyTimer3(Sender: TObject);
+ procedure btnCloseClick(Sender: TObject);
+ procedure btnStopStartClick(Sender: TObject);
+ public
+ constructor Create(AOwner: TComponent); override;
+ end;
+
+
+{ TMainForm }
+
+procedure TMainForm.MyTimer1(Sender: TObject);
+begin
+ lblTimer1.Text := FormatDateTime('hh:nn:ss.zzz', now);
+end;
+
+procedure TMainForm.MyTimer2(Sender: TObject);
+begin
+ Inc(cnt1);
+ lblTimer2.Text := IntToStr(cnt1);
+end;
+
+procedure TMainForm.MyTimer3(Sender: TObject);
+begin
+ Inc(cnt2);
+ lblTimer3.Text := IntToStr(cnt2);
+end;
+
+procedure TMainForm.btnCloseClick(Sender: TObject);
+begin
+ Close;
+end;
+
+procedure TMainForm.btnStopStartClick(Sender: TObject);
+begin
+ if btnStopStart.Text = 'Stop' then
+ btnStopStart.Text := 'Start'
+ else
+ btnStopStart.Text := 'Stop';
+
+ timer1.Enabled := not timer1.Enabled;
+end;
+
+constructor TMainForm.Create(AOwner: TComponent);
+begin
+ inherited Create(AOwner);
+ WindowTitle := 'fpGUI Timer test';
+ WindowPosition := wpScreenCenter;
+ Width := 400;
+ Height := 250;
+
+ cnt1 := 0;
+ cnt2 := 0;
+
+ btnClose := CreateButton(self, 320, 220, 75, 'Close', @btnCloseClick);
+ btnStopStart := CreateButton(self, 200, 50, 75, 'Stop', @btnStopStartClick);
+
+ lblTimer1 := CreateLabel(self, 50, 50, '---');
+ lblTimer1.FontDesc := 'Arial-14:bold';
+ lblTimer1.Height := lblTimer1.Font.Height;
+ lblTimer1.Width := 150;
+
+ lblTimer2 := CreateLabel(self, 50, 80, '---');
+ lblTimer2.FontDesc := 'Arial-14:bold';
+ lblTimer2.Height := lblTimer2.Font.Height;
+ lblTimer2.Width := 150;
+
+ lblTimer3 := CreateLabel(self, 50, 110, '---');
+ lblTimer3.FontDesc := 'Arial-14:bold';
+ lblTimer3.Height := lblTimer3.Font.Height;
+ lblTimer3.Width := 150;
+
+ timer1 := TfpgTimer.Create(50);
+ timer1.OnTimer := @MyTimer1;
+ timer1.Enabled := True;
+
+ timer2 := TfpgTimer.Create(200);
+ timer2.OnTimer := @MyTimer2;
+ timer2.Enabled := True;
+
+ timer3 := TfpgTimer.Create(1000);
+ timer3.OnTimer := @MyTimer3;
+ timer3.Enabled := True;
+end;
+
+
+procedure MainProc;
+var
+ frm: TMainForm;
+begin
+ fpgApplication.Initialize;
+ frm := TMainForm.Create(nil);
+ frm.Show;
+ fpgApplication.Run;
+end;
+
+
+begin
+ MainProc;
+end.
+