summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prototypes/fpgui2/examples/gui/timertest/timertest.lpi53
-rw-r--r--prototypes/fpgui2/examples/gui/timertest/timertest.lpr125
-rw-r--r--prototypes/fpgui2/source/core/gfx_widget.pas2
-rw-r--r--prototypes/fpgui2/source/gui/gui_form.pas4
4 files changed, 181 insertions, 3 deletions
diff --git a/prototypes/fpgui2/examples/gui/timertest/timertest.lpi b/prototypes/fpgui2/examples/gui/timertest/timertest.lpi
new file mode 100644
index 00000000..27a478f6
--- /dev/null
+++ b/prototypes/fpgui2/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"/>
+ <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="fpGFX2"/>
+ </Item1>
+ </RequiredPackages>
+ <Units Count="1">
+ <Unit0>
+ <Filename Value="timertest.lpr"/>
+ <IsPartOfProject Value="True"/>
+ <UnitName Value="timertest"/>
+ </Unit0>
+ </Units>
+ </ProjectOptions>
+ <CompilerOptions>
+ <Version Value="5"/>
+ <CodeGeneration>
+ <Generate Value="Faster"/>
+ </CodeGeneration>
+ <Other>
+ <CustomOptions Value="-FUunits"/>
+ <CompilerPath Value="$(CompPath)"/>
+ </Other>
+ </CompilerOptions>
+</CONFIG>
diff --git a/prototypes/fpgui2/examples/gui/timertest/timertest.lpr b/prototypes/fpgui2/examples/gui/timertest/timertest.lpr
new file mode 100644
index 00000000..7c4209df
--- /dev/null
+++ b/prototypes/fpgui2/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.
+
diff --git a/prototypes/fpgui2/source/core/gfx_widget.pas b/prototypes/fpgui2/source/core/gfx_widget.pas
index f949c98c..34fa73af 100644
--- a/prototypes/fpgui2/source/core/gfx_widget.pas
+++ b/prototypes/fpgui2/source/core/gfx_widget.pas
@@ -75,7 +75,7 @@ type
procedure MoveAndResizeBy(dx, dy, dw, dh: TfpgCoord);
procedure SetPosition(aleft, atop, awidth, aheight: TfpgCoord);
procedure RePaint;
-
+ { property events }
property OnPaint: TPaintEvent read FOnPaint write FOnPaint;
property OnMouseExit: TNotifyEvent read FOnMouseExit write FOnMouseExit;
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
diff --git a/prototypes/fpgui2/source/gui/gui_form.pas b/prototypes/fpgui2/source/gui/gui_form.pas
index 67e14f3c..8dff1aad 100644
--- a/prototypes/fpgui2/source/gui/gui_form.pas
+++ b/prototypes/fpgui2/source/gui/gui_form.pas
@@ -44,7 +44,7 @@ type
procedure AfterConstruction; override;
procedure BeforeDestruction; override;
public
- constructor Create(aowner: TComponent); override;
+ constructor Create(AOwner: TComponent); override;
procedure AfterCreate; virtual;
procedure Show;
procedure Hide;
@@ -139,7 +139,7 @@ begin
DoSetWindowTitle(FWindowTitle);
end;
-constructor TfpgForm.Create(aowner: TComponent);
+constructor TfpgForm.Create(AOwner: TComponent);
begin
inherited;
FWindowPosition := wpUser;