You've already forked lazarus-ccr
TvPlanIt: Add Pause/Resume functionality and TimeResolution property to VpClock.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8219 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -58,6 +58,9 @@
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf2Set"/>
|
||||
</Debugging>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
|
@ -160,6 +160,7 @@ type
|
||||
FTimer: TTimer;
|
||||
{$ENDIF}
|
||||
FActive: Boolean;
|
||||
FHold: Boolean;
|
||||
FClockMode: TVpClockMode;
|
||||
FDigitalOptions: TVpDigitalOptions;
|
||||
FDisplayMode: TVpClockDisplayMode;
|
||||
@ -167,6 +168,7 @@ type
|
||||
FElapsedHours: Integer;
|
||||
FElapsedMinutes: LongInt;
|
||||
FElapsedSeconds: LongInt;
|
||||
FElapsedTime: TDateTime;
|
||||
FHandOptions: TVpHandOptions;
|
||||
FTime: TDateTime;
|
||||
FMilitaryTime: Boolean;
|
||||
@ -174,6 +176,7 @@ type
|
||||
FHourOffset: Integer; {Hours}
|
||||
FMinuteOffset: Integer; {Minutes}
|
||||
FSecondOffset: Integer; {Seconds}
|
||||
FTimeResolution: Integer; {interval of the internal timer, in ms }
|
||||
{event variables}
|
||||
FOnHourChange: TNotifyEvent;
|
||||
FOnMinuteChange: TNotifyEvent;
|
||||
@ -208,6 +211,7 @@ type
|
||||
procedure SetClockMode(Value: TVpClockMode);
|
||||
procedure SetDisplayMode(Value: TVpClockDisplayMode);
|
||||
procedure SetMinuteOffset(Value: Integer);
|
||||
procedure SetHold(Value: Boolean);
|
||||
procedure SetHourOffset(Value: Integer);
|
||||
procedure SetSecondOffset(Value: Integer);
|
||||
{internal methods}
|
||||
@ -243,6 +247,7 @@ type
|
||||
{virtual property methods}
|
||||
procedure SetTime(Value: TDateTime); virtual;
|
||||
property Active: Boolean read FActive write SetActive;
|
||||
property Hold: Boolean read FHold write SetHold;
|
||||
property ClockMode: TVpClockMode read FClockMode write SetClockMode;
|
||||
property DigitalOptions: TVpDigitalOptions
|
||||
read FDigitalOptions write FDigitalOptions;
|
||||
@ -251,6 +256,7 @@ type
|
||||
property MinuteOffset: Integer read FMinuteOffset write SetMinuteOffset;
|
||||
property HourOffset: Integer read FHourOffset write SetHourOffset;
|
||||
property SecondOffset: Integer read FSecondOffset write SetSecondOffset;
|
||||
property TimeResolution: Integer read FTimeResolution write FTimeResolution default 500;
|
||||
{events}
|
||||
property OnHourChange: TNotifyEvent read FOnHourChange write FOnHourChange;
|
||||
property OnMinuteChange: TNotifyEvent read FOnMinuteChange write FOnMinuteChange;
|
||||
@ -261,6 +267,12 @@ type
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
|
||||
|
||||
procedure Start;
|
||||
procedure Stop;
|
||||
procedure Pause;
|
||||
procedure Resume;
|
||||
|
||||
property DisplayMode: TVpClockDisplayMode read FDisplayMode write SetDisplayMode;
|
||||
property ElapsedDays: Integer read GetElapsedDays;
|
||||
property ElapsedHours: Integer read GetElapsedHours;
|
||||
@ -287,6 +299,7 @@ type
|
||||
property DigitalOptions;
|
||||
property DisplayMode;
|
||||
property Hint;
|
||||
property Hold;
|
||||
property AnalogOptions;
|
||||
property MinuteOffset;
|
||||
property ParentColor;
|
||||
@ -295,6 +308,7 @@ type
|
||||
property SecondOffset;
|
||||
property ShowHint;
|
||||
property HourOffset;
|
||||
property TimeResolution;
|
||||
property Visible;
|
||||
{events}
|
||||
property OnClick;
|
||||
@ -316,7 +330,6 @@ uses
|
||||
|
||||
const
|
||||
ckDToR = (Pi / 180);
|
||||
ckInterval = 500;
|
||||
|
||||
|
||||
{===== TVpLEDClockDisplay ===========================================}
|
||||
@ -575,12 +588,6 @@ begin
|
||||
|
||||
FClockMode := cmClock;
|
||||
|
||||
{$IFDEF DELPHI}
|
||||
FTimerPool := TVpTimerPool.Create(self);
|
||||
{$ELSE}
|
||||
FTimer := TTimer.Create(self);
|
||||
{$ENDIF}
|
||||
|
||||
FHandOptions := TVpHandOptions.Create;
|
||||
FHandOptions.OnChange := ckHandOptionChange;
|
||||
FHandOptions.HourHandColor := clBlack;
|
||||
@ -602,9 +609,13 @@ begin
|
||||
ckDraw.Width := Width;
|
||||
ckDraw.Height := Height;
|
||||
|
||||
FTimeResolution := 500;
|
||||
|
||||
{$IFDEF DELPHI}
|
||||
FTimerPool := TVpTimerPool.Create(self);
|
||||
ckClockHandle := -1;
|
||||
{$ELSE}
|
||||
FTimer := TTimer.Create(self);
|
||||
FTimer.Enabled := false;
|
||||
{$ENDIF}
|
||||
end;
|
||||
@ -720,7 +731,15 @@ var
|
||||
C, D: Integer;
|
||||
elapsed: TDateTime;
|
||||
begin
|
||||
if FHold then
|
||||
exit;
|
||||
|
||||
elapsed := now - FTimeStarted;
|
||||
|
||||
Write('Now: ', FormatDateTime('hh:nn:ss', now), ', Elapsed: ', FormatDateTime('hh:nn:ss', elapsed));
|
||||
Write(' TimeStarted: ', FormatDateTime('hh:nn:ss', FTimeStarted));
|
||||
WriteLn(' CountdownStartTime: ', FormatDateTime('hh:nn:ss', FCountdownStartTime));
|
||||
|
||||
case FClockMode of
|
||||
cmClock:
|
||||
begin { Clock }
|
||||
@ -738,7 +757,7 @@ begin
|
||||
cmTimer: { Count-up timer }
|
||||
SetTime(elapsed);
|
||||
cmCountDownTimer: { Count-down timer }
|
||||
if abs(FCountdownStartTime - elapsed) < 0.1 / SecondsInDay then
|
||||
if elapsed >= FCountdownStartTime then
|
||||
begin
|
||||
SetTime(0);
|
||||
Active := false;
|
||||
@ -1222,14 +1241,15 @@ begin
|
||||
if Value <> FActive then begin
|
||||
FActive := Value;
|
||||
if FActive then begin
|
||||
FElapsedTime := 0.0;
|
||||
if FDisplayMode = dmDigital then
|
||||
FMilitaryTime := DigitalOptions.MilitaryTime;
|
||||
{$IFDEF DELPHI}
|
||||
if ckClockHandle = -1 then
|
||||
ckClockHandle := FTimerPool.Add(ckTimerEvent, ckInterval);
|
||||
ckClockHandle := FTimerPool.Add(ckTimerEvent, FTimeResolution);
|
||||
{$ELSE}
|
||||
FTimeStarted := now;
|
||||
FTimer.Interval := ckInterval;
|
||||
FTimer.Interval := FTimeResolution;
|
||||
FTimer.Enabled := FActive;
|
||||
FTimer.OnTimer := ckTimerEvent;
|
||||
{$ENDIF}
|
||||
@ -1243,6 +1263,7 @@ begin
|
||||
end;
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF DELPHI}
|
||||
if ckClockHandle > -1 then begin
|
||||
FTimerPool.Remove(ckClockHandle);
|
||||
@ -1252,6 +1273,8 @@ begin
|
||||
if FTimer.Enabled then
|
||||
FTimer.Enabled := false;
|
||||
{$ENDIF}
|
||||
FHold := false;
|
||||
end;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
@ -1443,6 +1466,25 @@ begin
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpCustomClock.SetHold(Value: Boolean);
|
||||
begin
|
||||
if (Value <> FHold) then
|
||||
begin
|
||||
if FActive then
|
||||
begin
|
||||
FHold := Value;
|
||||
if FHold then
|
||||
FElapsedTime := Now() - FTimeStarted
|
||||
else
|
||||
begin
|
||||
FTimeStarted := Now() - FElapsedTime;
|
||||
// FCountdownTimeStarted := FCountdownTimeStarted -
|
||||
end;
|
||||
end else
|
||||
FHold := false;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TVpCustomClock.SetHourOffset(Value: Integer);
|
||||
begin
|
||||
if (Value <> FHourOffset) and (Abs(Value) <= 24) then begin
|
||||
@ -1465,6 +1507,26 @@ begin
|
||||
end;
|
||||
{=====}
|
||||
|
||||
procedure TVpCustomClock.Start;
|
||||
begin
|
||||
Active := true;
|
||||
end;
|
||||
|
||||
procedure TVpCustomClock.Stop;
|
||||
begin
|
||||
Active := false;
|
||||
end;
|
||||
|
||||
procedure TVpCustomClock.Pause;
|
||||
begin
|
||||
Hold := true;
|
||||
end;
|
||||
|
||||
procedure TVpCustomClock.Resume;
|
||||
begin
|
||||
Hold := false;
|
||||
end;
|
||||
|
||||
{$IFNDEF LCL}
|
||||
procedure TVpCustomClock.WMResize(var Msg: TWMSize);
|
||||
{$ELSE}
|
||||
|
Reference in New Issue
Block a user