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