Starts LazClock, right now only the cronometer works

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2302 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2012-02-20 10:27:34 +00:00
parent 4610b73091
commit 05adebc953
9 changed files with 303 additions and 0 deletions

View File

@ -0,0 +1,13 @@
unit clock_control;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils;
implementation
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,95 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="project1"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="3">
<Unit0>
<Filename Value="lazclock.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="lazclock"/>
</Unit0>
<Unit1>
<Filename Value="mainform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="mainform"/>
</Unit1>
<Unit2>
<Filename Value="clock_control.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="clock_control"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="lazclock"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CompilerMessages>
<MsgFileName Value=""/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,21 @@
program lazclock;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, mainform, clock_control
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

Binary file not shown.

View File

@ -0,0 +1,83 @@
object Form1: TForm1
Left = 337
Height = 444
Top = 225
Width = 400
Caption = 'LazClock'
ClientHeight = 444
ClientWidth = 400
LCLVersion = '0.9.31'
object Notebook: TNotebook
Left = 0
Height = 400
Top = 44
Width = 400
PageIndex = 1
Align = alBottom
TabOrder = 0
TabStop = True
object Page1: TPage
end
object pageCronometer: TPage
object btnStart: TButton
Left = 24
Height = 25
Top = 68
Width = 75
Caption = 'btnStart'
OnClick = btnStartClick
TabOrder = 0
end
object btnStop: TButton
Left = 24
Height = 25
Top = 100
Width = 75
Caption = 'btnStop'
OnClick = btnStopClick
TabOrder = 1
end
object btnReset: TButton
Left = 24
Height = 25
Top = 132
Width = 75
Caption = 'btnReset'
OnClick = btnResetClick
TabOrder = 2
end
object labelCronometer: TLabel
Left = 8
Height = 65
Top = -4
Width = 387
Caption = 'labelCronometer'
Font.Height = -53
ParentColor = False
ParentFont = False
end
end
end
object btnCronometer: TButton
Left = 10
Height = 25
Top = 11
Width = 75
Caption = 'Cronometer'
OnClick = btnCronometerClick
TabOrder = 1
end
object timerClock: TTimer
Enabled = False
OnTimer = timerClockTimer
left = 312
top = 110
end
object timerCronometer: TTimer
Enabled = False
Interval = 20
OnTimer = timerCronometerTimer
left = 312
top = 161
end
end

View File

@ -0,0 +1,91 @@
unit mainform;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, DateUtils;
type
{ TForm1 }
TForm1 = class(TForm)
btnCronometer: TButton;
btnStart: TButton;
btnStop: TButton;
btnReset: TButton;
labelCronometer: TLabel;
Notebook: TNotebook;
Page1: TPage;
pageCronometer: TPage;
timerCronometer: TTimer;
timerClock: TTimer;
procedure btnCronometerClick(Sender: TObject);
procedure btnResetClick(Sender: TObject);
procedure btnStartClick(Sender: TObject);
procedure btnStopClick(Sender: TObject);
procedure timerClockTimer(Sender: TObject);
procedure timerCronometerTimer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
CronometerStarted: Boolean;
CronometerTime, CronometerLastUpdate: TTime;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.timerClockTimer(Sender: TObject);
begin
end;
procedure TForm1.timerCronometerTimer(Sender: TObject);
var
lNow: TDateTime;
lFormatSettings: TFormatSettings;
begin
lNow := Now();
CronometerTime := CronometerTime + CronometerLastUpdate - lNow;
CronometerLastUpdate := lNow;
lFormatSettings := SysUtils.FormatSettings;
lFormatSettings.LongTimeFormat := 'hh:nn:ss:zzz';
labelCronometer.Caption := SysUtils.TimeToStr(CronometerTime, lFormatSettings);
end;
procedure TForm1.btnCronometerClick(Sender: TObject);
begin
Notebook.PageIndex := 1;
end;
procedure TForm1.btnResetClick(Sender: TObject);
begin
CronometerTime := DateUtils.EncodeTimeInterval(0, 0, 0, 0);
end;
procedure TForm1.btnStartClick(Sender: TObject);
begin
CronometerStarted := True;
timerCronometer.Enabled := True;
CronometerLastUpdate := Now();
end;
procedure TForm1.btnStopClick(Sender: TObject);
begin
CronometerStarted := False;
timerCronometer.Enabled := False;
end;
end.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB