tvplanit: Fix TVpClock. Add example. Some refactoring and cosmetic changes.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5041 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-07-28 21:22:54 +00:00
parent 6e6d5a064a
commit ba7e8c8e0c
8 changed files with 833 additions and 272 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="laz_visualplanit"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
</Item2>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Unit1"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</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 project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Unit1, laz_visualplanit
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@@ -0,0 +1,165 @@
object Form1: TForm1
Left = 262
Height = 283
Top = 155
Width = 461
Caption = 'Form1'
ClientHeight = 283
ClientWidth = 461
Font.Color = clWindowText
OnCreate = FormCreate
LCLVersion = '1.7'
object VpLEDLabel1: TVpLEDLabel
Left = 9
Height = 60
Top = 6
Width = 442
Caption = 'Visual PlanIt'
Columns = 13
OffColor = 930866
OnColor = clLime
Size = 3
end
object VpClock1: TVpClock
Left = 11
Height = 200
Top = 72
Width = 200
Active = False
Color = clForm
ClockMode = cmClock
DigitalOptions.MilitaryTime = True
DigitalOptions.OnColor = clLime
DigitalOptions.OffColor = 930866
DigitalOptions.BgColor = clBlack
DigitalOptions.Size = 2
DigitalOptions.ShowSeconds = True
DisplayMode = dmAnalog
AnalogOptions.DrawMarks = True
AnalogOptions.HourHandColor = clBlack
AnalogOptions.HourHandLength = 60
AnalogOptions.HourHandWidth = 4
AnalogOptions.MinuteHandColor = clBlack
AnalogOptions.MinuteHandLength = 80
AnalogOptions.MinuteHandWidth = 3
AnalogOptions.SecondHandColor = clRed
AnalogOptions.SecondHandLength = 90
AnalogOptions.SecondHandWidth = 1
AnalogOptions.ShowSecondHand = True
AnalogOptions.SolidHands = True
MinuteOffset = 0
ParentColor = False
SecondOffset = 0
HourOffset = 0
OnCountdownDone = VpClock1CountdownDone
OnSecondChange = VpClockTimeChange
end
object BtnStartStop: TButton
Left = 351
Height = 51
Top = 80
Width = 99
Caption = 'Start'
OnClick = BtnStartStopClick
TabOrder = 1
end
object RgClockMode: TRadioGroup
Left = 224
Height = 89
Top = 151
Width = 116
AutoFill = True
Caption = 'Clock mode'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 69
ClientWidth = 112
ItemIndex = 0
Items.Strings = (
'Clock'
'Counter'
'Count-down'
)
OnClick = RgClockModeClick
TabOrder = 2
end
object EdCountDownTime: TTimeEdit
Left = 351
Height = 23
Top = 172
Width = 99
ButtonWidth = 23
NumGlyphs = 1
MaxLength = 0
OnChange = EdCountDownTimeChange
TabOrder = 3
Visible = False
Text = '00:30:00'
end
object LblCountDownTime: TLabel
Left = 351
Height = 15
Top = 152
Width = 98
Caption = 'Count-down time:'
FocusControl = EdCountDownTime
ParentColor = False
Visible = False
end
object CbNewClockFace: TCheckBox
Left = 351
Height = 19
Top = 221
Width = 100
Caption = 'New clock face'
OnChange = CbNewClockFaceChange
TabOrder = 4
end
object LblElapsedTime: TLabel
Left = 224
Height = 15
Top = 256
Width = 49
Caption = 'Elapsed...'
ParentColor = False
end
object RgDisplayMode: TRadioGroup
Left = 224
Height = 63
Top = 72
Width = 115
AutoFill = True
Caption = 'Display mode'
ChildSizing.LeftRightSpacing = 6
ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
ChildSizing.EnlargeVertical = crsHomogenousChildResize
ChildSizing.ShrinkHorizontal = crsScaleChilds
ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 43
ClientWidth = 111
ItemIndex = 0
Items.Strings = (
'Analog'
'Digital'
)
OnClick = RgDisplayModeClick
TabOrder = 5
end
object CbMilitaryTime: TCheckBox
Left = 351
Height = 19
Top = 208
Width = 87
Caption = 'Military time'
OnChange = CbMilitaryTimeChange
TabOrder = 6
Visible = False
end
end

View File

@@ -0,0 +1,179 @@
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, EditBtn, VpLEDLabel, VpClock;
type
{ TForm1 }
TForm1 = class(TForm)
BtnStartStop: TButton;
CbNewClockFace: TCheckBox;
CbMilitaryTime: TCheckBox;
LblCountDownTime: TLabel;
LblElapsedTime: TLabel;
RgDisplayMode: TRadioGroup;
RgClockMode: TRadioGroup;
VpClock1: TVpClock;
EdCountDownTime: TTimeEdit;
VpLEDLabel1: TVpLEDLabel;
procedure AnalogClockCountdownDone(Sender: TObject);
procedure CbMilitaryTimeChange(Sender: TObject);
procedure VpClockTimeChange(Sender: TObject);
procedure BtnStartStopClick(Sender: TObject);
procedure CbNewClockFaceChange(Sender: TObject);
procedure EdCountDownTimeChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RgClockModeClick(Sender: TObject);
procedure RgDisplayModeClick(Sender: TObject);
procedure VpClock1CountdownDone(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.AnalogClockCountdownDone(Sender: TObject);
begin
ShowMessage('Countdown finished.');
end;
procedure TForm1.VpClockTimeChange(Sender: TObject);
begin
LblElapsedTime.Caption := Format('Elapsed: %d hrs, %d min, %d sec', [
VpClock1.ElapsedHours, VpClock1.ElapsedMinutes, VpClock1.ElapsedSeconds
]);
end;
procedure TForm1.BtnStartStopClick(Sender: TObject);
var
isStarted: Boolean;
willStart: Boolean;
begin
isStarted := VpClock1.Active;
willStart := not isStarted;
if willStart and (RgClockMode.ItemIndex = ord(cmCountdownTimer)) then
RgClockModeClick(nil);
VpClock1.Active := willStart;
if VpClock1.Active then
BtnStartStop.Caption := 'Stop' else
BtnStartStop.Caption := 'Start';
end;
procedure TForm1.CbMilitaryTimeChange(Sender: TObject);
var
t: TDateTime;
begin
t := VpClock1.Time;
VpClock1.DigitalOptions.MilitaryTime := CbMilitaryTime.Checked;
VpClock1.Time := t;
end;
procedure TForm1.CbNewClockFaceChange(Sender: TObject);
begin
if CbNewClockFace.Checked then begin
VpClock1.AnalogOptions.ClockFace.LoadFromFile('clockface.bmp');
VpClock1.AnalogOptions.HourHandWidth := 2;
VpClock1.AnalogOptions.MinuteHandWidth := 2;
VpClock1.AnalogOptions.SecondHandWidth := 1;
VpClock1.Width := 100;
VpClock1.Height := 100;
end else begin
VpClock1.AnalogOptions.ClockFace := nil;
VpClock1.AnalogOptions.HourHandWidth := 4;
VpClock1.AnalogOptions.MinuteHandWidth := 3;
VpClock1.AnalogOptions.SecondHandWidth := 1;
VpClock1.Width := 200;
VpClock1.Height := 200;
end;
VpClock1.AnalogOptions.DrawMarks := not CbNewClockFace.Checked;
if RgDisplayMode.ItemIndex = ord(dmAnalog) then
VpClock1.Invalidate;
end;
procedure TForm1.EdCountDownTimeChange(Sender: TObject);
begin
if VpClock1.ClockMode = cmCountDownTimer then
VpClock1.Time := EdCountDownTime.Time;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
EdCountDownTime.Time := StrToTime(EdCountDownTime.Text);
CbMilitaryTime.Top := CbNewClockFace.Top;
end;
procedure TForm1.RgClockModeClick(Sender: TObject);
var
h,m,s,ms: Word;
begin
VpClock1.Active := false;
BtnStartStop.Caption := 'Start';
VpClock1.ClockMode := TVpClockMode(RgClockMode.ItemIndex);
case VpClock1.ClockMode of
cmClock:
begin
VpClock1.Time := now;
VpClock1.Active := true;
BtnStartStop.Caption := 'Stop';
end;
cmTimer:
VpClock1.Time := 0;
cmCountdownTimer:
begin
DecodeTime(EdCountDownTime.Time, h,m,s,ms);
VpClock1.HourOffset := h;
VpClock1.MinuteOffset := m;
VpClock1.SecondOffset := s;
end;
end;
EdCountDownTime.Visible := VpClock1.ClockMode = cmCountDownTimer;
LblCountDownTime.Visible := EdCountDownTime.Visible;
end;
procedure TForm1.RgDisplayModeClick(Sender: TObject);
var
t: TDateTime;
begin
t := VpClock1.Time;
VpClock1.DisplayMode := TVpClockDisplayMode(RgDisplayMode.ItemIndex);
case VpClock1.DisplayMode of
dmAnalog:
CbNewClockFaceChange(nil);
dmDigital:
begin
VpClock1.Width := 136;
VpClock1.Height := 30;
end;
end;
CbMilitaryTime.Visible := VpClock1.DisplayMode = dmDigital;
CbNewClockface.Visible := VpClock1.DisplayMode = dmAnalog;
VpClock1.Time := t;
end;
procedure TForm1.VpClock1CountdownDone(Sender: TObject);
begin
ShowMessage('Countdown completed.');
end;
end.

View File

@@ -1,16 +1,16 @@
object Form1: TForm1 object Form1: TForm1
Left = 262 Left = 262
Height = 400 Height = 406
Top = 155 Top = 155
Width = 588 Width = 567
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 400 ClientHeight = 406
ClientWidth = 588 ClientWidth = 567
OnCreate = FormCreate OnCreate = FormCreate
LCLVersion = '1.7' LCLVersion = '1.7'
object VpNavBar1: TVpNavBar object VpNavBar1: TVpNavBar
Left = 0 Left = 0
Height = 370 Height = 376
Top = 0 Top = 0
Width = 128 Width = 128
ActiveFolder = 0 ActiveFolder = 0
@@ -187,17 +187,17 @@ object Form1: TForm1
object Panel1: TPanel object Panel1: TPanel
Left = 0 Left = 0
Height = 30 Height = 30
Top = 370 Top = 376
Width = 588 Width = 567
Align = alBottom Align = alBottom
ClientHeight = 30 ClientHeight = 30
ClientWidth = 588 ClientWidth = 567
TabOrder = 2 TabOrder = 2
object Bevel1: TBevel object Bevel1: TBevel
Left = 1 Left = 1
Height = 3 Height = 3
Top = 1 Top = 1
Width = 586 Width = 565
Align = alTop Align = alTop
Shape = bsTopLine Shape = bsTopLine
end end

View File

@@ -35,12 +35,12 @@ interface
uses uses
{$IFDEF LCL} {$IFDEF LCL}
LMessages,LCLProc,LCLType,LCLIntf, LMessages, LCLProc, LCLType, LCLIntf, ExtCtrls,
{$ELSE} {$ELSE}
Windows, Messages, Windows, Messages, VpTimerPool,
{$ENDIF} {$ENDIF}
Classes, Controls, Dialogs, Forms, Graphics, Menus,Math, Classes, Controls, Dialogs, Forms, Graphics, Menus,Math,
SysUtils, VpBase, VpLEDLabel, VpTimerPool; SysUtils, VpBase, VpLEDLabel;
type type
TVpPercent = 0..100; TVpPercent = 0..100;
@@ -154,74 +154,86 @@ type
TVpCustomClock = class(TVpCustomControl) TVpCustomClock = class(TVpCustomControl)
protected {private} protected {private}
FTimerPool : TVpTimerPool; {$IFDEF DELPHI}
FActive : Boolean; FTimerPool: TVpTimerPool;
FClockMode : TVpClockMode; {$ELSE}
FDigitalOptions : TVpDigitalOptions; FTimer: TTimer;
FDisplayMode : TVpClockDisplayMode; {$ENDIF}
FElapsedDays : Integer; FActive: Boolean;
FElapsedHours : Integer; FClockMode: TVpClockMode;
FElapsedMinutes : LongInt; FDigitalOptions: TVpDigitalOptions;
FElapsedSeconds : LongInt; FDisplayMode: TVpClockDisplayMode;
FHandOptions : TVpHandOptions; FElapsedDays: Integer;
FTime : TDateTime; FElapsedHours: Integer;
FMilitaryTime : Boolean; FElapsedMinutes: LongInt;
FStartTime : TDateTime; FElapsedSeconds: LongInt;
FHourOffset : Integer; {Hours} FHandOptions: TVpHandOptions;
FMinuteOffset : Integer; {Minutes} FTime: TDateTime;
FSecondOffset : Integer; {Seconds} FMilitaryTime: Boolean;
FCountdownStartTime: TDateTime;
FHourOffset: Integer; {Hours}
FMinuteOffset: Integer; {Minutes}
FSecondOffset: Integer; {Seconds}
{event variables} {event variables}
FOnHourChange : TNotifyEvent; FOnHourChange: TNotifyEvent;
FOnMinuteChange : TNotifyEvent; FOnMinuteChange: TNotifyEvent;
FOnSecondChange : TNotifyEvent; FOnSecondChange: TNotifyEvent;
FOnCountdownDone: TNotifyEvent; FOnCountdownDone: TNotifyEvent;
{internal variables} {internal variables}
ckAnalogHeight : Integer; ckAnalogHeight: Integer;
ckAnalogWidth : Integer; ckAnalogWidth: Integer;
ckLEDDisplay : TVpLEDClockDisplay; ckLEDDisplay: TVpLEDClockDisplay;
ckDraw : TBitMap; ckDraw: TBitMap;
ckClockHandle : Integer; {$IFDEF DELPHI}
ckOldHour : Integer; ckClockHandle: Integer;
ckOldMinute : Integer; {$ELSE}
ckOldSecond : Integer; FTimeStarted: TDateTime; {time at which the timer is activated }
ckTimerTime : TDateTime; {$ENDIF}
ckDays : Integer; ckOldHour: Integer;
ckHours : Integer; ckOldMinute: Integer;
ckMinutes : Integer; ckOldSecond: Integer;
ckSeconds : Integer; ckTimerTime: TDateTime;
ckTotalSeconds : Integer; ckDays: Integer;
ckHours: Integer;
ckMinutes: Integer;
ckSeconds: Integer;
ckTotalSeconds: Integer;
{property methods} {property methods}
function GetElapsedDays : Integer; function GetElapsedDays: Integer;
function GetElapsedHours : Integer; function GetElapsedHours: Integer;
function GetElapsedMinutes : LongInt; function GetElapsedMinutes: LongInt;
function GetElapsedSeconds : LongInt; function GetElapsedSeconds: LongInt;
function GetElapsedSecondsTotal : LongInt; function GetElapsedSecondsTotal: LongInt;
procedure SetActive(Value : Boolean); procedure SetActive(Value: Boolean);
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 SetHourOffset(Value : Integer); procedure SetHourOffset(Value: Integer);
procedure SetSecondOffset(Value : Integer); procedure SetSecondOffset(Value: Integer);
{internal methods} {internal methods}
function ckConvertMsToDateTime(Value : LongInt) : TDateTime; function ckConvertMsToDateTime(Value: LongInt): TDateTime;
procedure ckHandOptionChange(Sender : TObject); procedure ckHandOptionChange(Sender: TObject);
procedure ckDigitalOptionChange(Sender : TObject); procedure ckDigitalOptionChange(Sender: TObject);
procedure SizeDigitalDisplay; procedure SizeDigitalDisplay;
{$IFDEF DELPHI}
procedure ckTimerEvent(Sender: TObject; Handle: Integer; Interval: Cardinal; procedure ckTimerEvent(Sender: TObject; Handle: Integer; Interval: Cardinal;
ElapsedTime: LongInt); ElapsedTime: LongInt);
{$ELSE}
procedure ckTimerEvent(Sender: TObject);
{$ENDIF}
procedure DoOnHourChange; procedure DoOnHourChange;
procedure DoOnMinuteChange; procedure DoOnMinuteChange;
procedure DoOnSecondChange; procedure DoOnSecondChange;
procedure DoOnCountdownDone; procedure DoOnCountdownDone;
procedure PaintHands(ACanvas : TCanvas); procedure PaintHands(ACanvas: TCanvas);
{windows message methods} {windows message methods}
{$IFDEF LCL} {$IFDEF LCL}
procedure WMResize (var Msg: TLMSize); message LM_SIZE; procedure WMResize(var Msg: TLMSize); message LM_SIZE;
procedure WMEraseBkgnd (var Msg: TLMEraseBkgnd); message LM_ERASEBKGND; procedure WMEraseBkgnd(var Msg: TLMEraseBkgnd); message LM_ERASEBKGND;
{$ELSE} {$ELSE}
procedure WMResize (var Msg: TWMSize); message WM_SIZE; procedure WMResize(var Msg: TWMSize); message WM_SIZE;
procedure WMEraseBkgnd (var Msg: TWMEraseBkgnd); message WM_ERASEBKGND; procedure WMEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;
procedure WMGetDlgCode (var Msg: TWMGetDlgCode); message WM_GETDLGCODE; procedure WMGetDlgCode(var Msg: TWMGetDlgCode); message WM_GETDLGCODE;
{$ENDIF} {$ENDIF}
protected protected
procedure Loaded; override; procedure Loaded; override;
@@ -229,36 +241,33 @@ type
procedure PaintAnalog; procedure PaintAnalog;
procedure PaintDigital; procedure PaintDigital;
{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 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;
property AnalogOptions : TVpHandOptions property AnalogOptions: TVpHandOptions
read FHandOptions write FHandOptions; read FHandOptions write FHandOptions;
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;
{events} {events}
property OnHourChange : TNotifyEvent read FOnHourChange write FOnHourChange; property OnHourChange: TNotifyEvent read FOnHourChange write FOnHourChange;
property OnMinuteChange : TNotifyEvent property OnMinuteChange: TNotifyEvent read FOnMinuteChange write FOnMinuteChange;
read FOnMinuteChange write FOnMinuteChange; property OnSecondChange: TNotifyEvent read FOnSecondChange write FOnSecondChange;
property OnSecondChange : TNotifyEvent property OnCountdownDone: TNotifyEvent read FOnCountdownDone write FOnCountdownDone;
read FOnSecondChange write FOnSecondChange;
property OnCountdownDone : TNotifyEvent
read FOnCountdownDone write FOnCountdownDone;
public public
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;
property DisplayMode: TVpClockDisplayMode property DisplayMode: TVpClockDisplayMode read FDisplayMode write SetDisplayMode;
read FDisplayMode write SetDisplayMode; property ElapsedDays: Integer read GetElapsedDays;
property ElapsedDays : Integer read GetElapsedDays; property ElapsedHours: Integer read GetElapsedHours;
property ElapsedHours : Integer read GetElapsedHours; property ElapsedMinutes: LongInt read GetElapsedMinutes;
property ElapsedMinutes : LongInt read GetElapsedMinutes; property ElapsedSeconds: LongInt read GetElapsedSeconds;
property ElapsedSeconds : LongInt read GetElapsedSeconds; property ElapsedSecondsTotal: LongInt read GetElapsedSecondsTotal;
property ElapsedSecondsTotal : LongInt read GetElapsedSecondsTotal; property Time: TDateTime read FTime write SetTime;
property Time : TDateTime read FTime write SetTime;
end; end;
TVpClock = class(TVpCustomClock) TVpClock = class(TVpCustomClock)
@@ -393,7 +402,6 @@ end;
constructor TVpHandOptions.Create; constructor TVpHandOptions.Create;
begin begin
inherited; inherited;
FClockFace := TBitMap.Create; FClockFace := TBitMap.Create;
FDrawMarks := True; FDrawMarks := True;
end; end;
@@ -403,12 +411,11 @@ destructor TVpHandOptions.Destroy;
begin begin
FClockFace.Free; FClockFace.Free;
FClockFace := nil; FClockFace := nil;
inherited; inherited;
end; end;
{=====} {=====}
procedure TVpHandOptions.Assign(Source : TPersistent); procedure TVpHandOptions.Assign(Source: TPersistent);
begin begin
if Source is TVpHandOptions then begin if Source is TVpHandOptions then begin
FHourHandColor := TVpHandOptions(Source).FHourHandColor; FHourHandColor := TVpHandOptions(Source).FHourHandColor;
@@ -428,7 +435,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetClockFace(Value : TBitMap); procedure TVpHandOptions.SetClockFace(Value: TBitMap);
begin begin
if Assigned(Value) then if Assigned(Value) then
FClockFace.Assign(Value) FClockFace.Assign(Value)
@@ -440,7 +447,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetDrawMarks(Value : Boolean); procedure TVpHandOptions.SetDrawMarks(Value: Boolean);
begin begin
if Value <> FDrawMarks then begin if Value <> FDrawMarks then begin
FDrawMarks := Value; FDrawMarks := Value;
@@ -456,7 +463,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetHourHandColor(Value : TColor); procedure TVpHandOptions.SetHourHandColor(Value: TColor);
begin begin
if Value <> FHourHandColor then begin if Value <> FHourHandColor then begin
FHourHandColor := Value; FHourHandColor := Value;
@@ -465,7 +472,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetHourHandLength(Value : TVpPercent); procedure TVpHandOptions.SetHourHandLength(Value: TVpPercent);
begin begin
if Value <> FHourHandLength then begin if Value <> FHourHandLength then begin
FHourHandLength := Value; FHourHandLength := Value;
@@ -474,7 +481,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetHourHandWidth(Value : Integer); procedure TVpHandOptions.SetHourHandWidth(Value: Integer);
begin begin
if (Value <> FHourHandWidth) and (Value > 0) then begin if (Value <> FHourHandWidth) and (Value > 0) then begin
FHourHandWidth := Value; FHourHandWidth := Value;
@@ -483,7 +490,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetMinuteHandColor(Value : TColor); procedure TVpHandOptions.SetMinuteHandColor(Value: TColor);
begin begin
if Value <> FMinuteHandColor then begin if Value <> FMinuteHandColor then begin
FMinuteHandColor := Value; FMinuteHandColor := Value;
@@ -492,7 +499,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetMinuteHandLength(Value : TVpPercent); procedure TVpHandOptions.SetMinuteHandLength(Value: TVpPercent);
begin begin
if Value <> FMinuteHandLength then begin if Value <> FMinuteHandLength then begin
FMinuteHandLength := Value; FMinuteHandLength := Value;
@@ -501,7 +508,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetMinuteHandWidth(Value : Integer); procedure TVpHandOptions.SetMinuteHandWidth(Value: Integer);
begin begin
if (Value <> FMinuteHandWidth) and (Value > 0) then begin if (Value <> FMinuteHandWidth) and (Value > 0) then begin
FMinuteHandWidth := Value; FMinuteHandWidth := Value;
@@ -510,7 +517,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetSecondHandColor(Value : TColor); procedure TVpHandOptions.SetSecondHandColor(Value: TColor);
begin begin
if Value <> FSecondHandColor then begin if Value <> FSecondHandColor then begin
FSecondHandColor := Value; FSecondHandColor := Value;
@@ -519,7 +526,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetSecondHandLength(Value : TVpPercent); procedure TVpHandOptions.SetSecondHandLength(Value: TVpPercent);
begin begin
if Value <> FSecondHandLength then begin if Value <> FSecondHandLength then begin
FSecondHandLength := Value; FSecondHandLength := Value;
@@ -528,7 +535,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetSecondHandWidth(Value : Integer); procedure TVpHandOptions.SetSecondHandWidth(Value: Integer);
begin begin
if (Value <> FSecondHandWidth) and (Value > 0) then begin if (Value <> FSecondHandWidth) and (Value > 0) then begin
FSecondHandWidth := Value; FSecondHandWidth := Value;
@@ -537,7 +544,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetShowSecondHand(Value : Boolean); procedure TVpHandOptions.SetShowSecondHand(Value: Boolean);
begin begin
if Value <> FShowSecondHand then begin if Value <> FShowSecondHand then begin
FShowSecondHand := Value; FShowSecondHand := Value;
@@ -546,7 +553,7 @@ begin
end; end;
{=====} {=====}
procedure TVpHandOptions.SetSolidHands(Value : Boolean); procedure TVpHandOptions.SetSolidHands(Value: Boolean);
begin begin
if Value <> FSolidHands then begin if Value <> FSolidHands then begin
FSolidHands := Value; FSolidHands := Value;
@@ -556,7 +563,7 @@ end;
{===== TOvcCustomClock ===============================================} {===== TOvcCustomClock ===============================================}
constructor TVpCustomClock.Create(AOwner : TComponent); constructor TVpCustomClock.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
@@ -565,7 +572,11 @@ begin
FClockMode := cmClock; FClockMode := cmClock;
{$IFDEF DELPHI}
FTimerPool := TVpTimerPool.Create(self); FTimerPool := TVpTimerPool.Create(self);
{$ELSE}
FTimer := TTimer.Create(self);
{$ENDIF}
FHandOptions := TVpHandOptions.Create; FHandOptions := TVpHandOptions.Create;
FHandOptions.OnChange := ckHandOptionChange; FHandOptions.OnChange := ckHandOptionChange;
@@ -588,7 +599,11 @@ begin
ckDraw.Width := Width; ckDraw.Width := Width;
ckDraw.Height := Height; ckDraw.Height := Height;
{$IFDEF DELPHI}
ckClockHandle := -1; ckClockHandle := -1;
{$ELSE}
FTimer.Enabled := false;
{$ENDIF}
end; end;
{=====} {=====}
@@ -608,10 +623,10 @@ begin
end; end;
{=====} {=====}
function TVpCustomClock.ckConvertMsToDateTime(Value : LongInt) : TDateTime; function TVpCustomClock.ckConvertMsToDateTime(Value: LongInt) : TDateTime;
var var
S, Days : LongInt; S, Days: LongInt;
Hour, Minute, Second : Word; Hour, Minute, Second: Word;
begin begin
S := Value div 1000; S := Value div 1000;
Days := S div SecondsInDay; Days := S div SecondsInDay;
@@ -624,14 +639,14 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomClock.ckHandOptionChange(Sender : TObject); procedure TVpCustomClock.ckHandOptionChange(Sender: TObject);
begin begin
if FDisplayMode = dmAnalog then if FDisplayMode = dmAnalog then
Invalidate; Invalidate;
end; end;
{=====} {=====}
procedure TVpCustomClock.ckDigitalOptionChange(Sender : TObject); procedure TVpCustomClock.ckDigitalOptionChange(Sender: TObject);
begin begin
if FDisplayMode = dmDigital then begin if FDisplayMode = dmDigital then begin
ckLEDDisplay.Size := FDigitalOptions.Size; ckLEDDisplay.Size := FDigitalOptions.Size;
@@ -660,6 +675,7 @@ begin
end; end;
{=====} {=====}
{$IFDEF DELPHI}
procedure TVpCustomClock.ckTimerEvent(Sender: TObject; Handle: Integer; procedure TVpCustomClock.ckTimerEvent(Sender: TObject; Handle: Integer;
Interval: Cardinal; ElapsedTime: LongInt); Interval: Cardinal; ElapsedTime: LongInt);
var var
@@ -694,6 +710,35 @@ begin
SetTime(FStartTime - ckConvertMsToDateTime(ElapsedTime)); SetTime(FStartTime - ckConvertMsToDateTime(ElapsedTime));
end; end;
end; end;
{$ELSE}
procedure TVpCustomClock.ckTimerEvent(Sender: TObject);
var
Hour, Minute, Second, MSecond: Word;
C, D: Integer;
elapsed: TDateTime;
begin
elapsed := now - FTimeStarted;
case FClockMode of
cmClock:
begin { Clock }
DecodeTime(Now, Hour, Minute, Second, MSecond);
D := Minute + FMinuteOffset;
Minute := Abs(D mod 60);
C := Hour + FHourOffset + D div 60;
if C > 23 then
Dec(C, 24);
if C < 0 then
Inc(C, 24);
Hour := C;
SetTime(EncodeTime(Hour, Minute, Second, MSecond));
end;
cmTimer: { Count-up timer }
SetTime(elapsed);
cmCountDownTimer: { Count-down timer }
SetTime(FCountdownStartTime - elapsed);
end;
end;
{$ENDIF}
{=====} {=====}
procedure TVpCustomClock.DoOnHourChange; procedure TVpCustomClock.DoOnHourChange;
@@ -728,70 +773,97 @@ function TVpCustomClock.GetElapsedDays: Integer;
var var
ClockDate : TDateTime; ClockDate : TDateTime;
begin begin
{$IFDEF DELPHI}
if ckClockHandle > -1 then begin if ckClockHandle > -1 then begin
ClockDate := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]); ClockDate := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]);
ckDays := Trunc(ClockDate); ckDays := Trunc(ClockDate);
end; end;
{$ELSE}
if FTimer.Enabled then begin
ClockDate := now - FTimeStarted;
ckDays := Trunc(ClockDate);
end;
{$ENDIF}
Result := ckDays; Result := ckDays;
end; end;
{=====} {=====}
function TVpCustomClock.GetElapsedHours: Integer; function TVpCustomClock.GetElapsedHours: Integer;
var var
Hour : Word; Hour, Min, Sec, MSec: Word;
Min : Word;
Sec : Word;
MSec : Word;
TempTime : TDateTime; TempTime : TDateTime;
begin begin
Result := 0;
{$IFDEF DELPHI}
if ckClockHandle > -1 then begin if ckClockHandle > -1 then begin
TempTime := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]); TempTime := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]);
DecodeTime(TempTime, Hour, Min, Sec, MSec); DecodeTime(TempTime, Hour, Min, Sec, MSec);
ckHours := Hour Result := Hour;
end; end;
Result := ckHours; {$ELSE}
if FTimer.Enabled then begin
Temptime := now - FTimeStarted;
DecodeTime(TempTime, Hour, Min, Sec, MSec);
Result := Hour;
end;
{$ENDIF}
end; end;
{=====} {=====}
function TVpCustomClock.GetElapsedMinutes: LongInt; function TVpCustomClock.GetElapsedMinutes: LongInt;
var var
Hour : Word; Hour, Min, Sec, MSec: Word;
Min : Word;
Sec : Word;
MSec : Word;
TempTime : TDateTime; TempTime : TDateTime;
begin begin
Result := 0;
{$IFDEF DELPHI}
if ckClockHandle > -1 then begin if ckClockHandle > -1 then begin
TempTime := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]); TempTime := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]);
DecodeTime(TempTime, Hour, Min, Sec, MSec); DecodeTime(TempTime, Hour, Min, Sec, MSec);
ckMinutes := Min; Result := Min;
end; end;
Result := ckMinutes; {$ELSE}
if FTimer.Enabled then begin
TempTime := now - FTimeStarted;
DecodeTime(TempTime, Hour, Min, Sec, MSec);
Result := Min;
end;
{$ENDIF}
end; end;
{=====} {=====}
function TVpCustomClock.GetElapsedSeconds : LongInt; function TVpCustomClock.GetElapsedSeconds : LongInt;
var var
Hour : Word; Hour, Min, Sec, MSec: Word;
Min : Word;
Sec : Word;
MSec : Word;
TempTime : TDateTime; TempTime : TDateTime;
begin begin
Result := 0;
{$IFDEF DELPHI}
if ckClockHandle > -1 then begin if ckClockHandle > -1 then begin
TempTime := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]); TempTime := ckConvertMsToDateTime(FTimerPool.ElapsedTime[ckClockHandle]);
DecodeTime(TempTime, Hour, Min, Sec, MSec); DecodeTime(TempTime, Hour, Min, Sec, MSec);
ckSeconds := Sec; Result := Sec;
end; end;
Result := ckSeconds; {$ELSE}
if FTimer.Enabled then begin
TempTime := now - FTimeStarted;
DecodeTime(TempTime, Hour, Min, Sec, MSec);
Result := Sec;
end;
{$ENDIF}
end; end;
{=====} {=====}
function TVpCustomClock.GetElapsedSecondsTotal : LongInt; function TVpCustomClock.GetElapsedSecondsTotal : LongInt;
begin begin
Result := 0;
{$IFDEF DELPHI}
if ckClockHandle > -1 then if ckClockHandle > -1 then
ckTotalSeconds := FTimerPool.ElapsedTime[ckClockHandle] div 1000; Result := FTimerPool.ElapsedTime[ckClockHandle] div 1000;
Result := ckTotalSeconds; {$ELSE}
if FTimer.Enabled then
Result := Round((now - FTimeStarted) * SecondsInDay);
{$ENDIF}
end; end;
{=====} {=====}
@@ -836,9 +908,8 @@ var
ElRgn : HRgn; ElRgn : HRgn;
R : TRect; R : TRect;
procedure DrawTickMark(MarkX, MarkY : Integer; procedure DrawTickMark(MarkX, MarkY: Integer; LColor, MColor, RColor: TColor;
LColor, MColor, RColor : TColor; FiveMinute: Boolean);
FiveMinute : Boolean);
begin begin
with ckDraw.Canvas do begin with ckDraw.Canvas do begin
Pixels[MarkX, MarkY] := MColor; Pixels[MarkX, MarkY] := MColor;
@@ -875,7 +946,7 @@ begin
finally finally
DeleteObject(ElRgn); DeleteObject(ElRgn);
end; end;
SelectClipRgn(ckDraw.Canvas.Handle, 0);{remove clipping region} SelectClipRgn(ckDraw.Canvas.Handle, 0); {remove clipping region}
end; end;
{draw marks} {draw marks}
@@ -909,7 +980,7 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomClock.PaintHands(ACanvas : TCanvas); procedure TVpCustomClock.PaintHands(ACanvas: TCanvas);
type type
HandType = (HourHand, MinuteHand, SecondHand); HandType = (HourHand, MinuteHand, SecondHand);
var var
@@ -940,10 +1011,8 @@ var
NewPoint.Y := NewPoint.Y + HalfHeight; NewPoint.Y := NewPoint.Y + HalfHeight;
end; end;
procedure DrawNewHand(PenColor : TColor; procedure DrawNewHand(PenColor: TColor; Hand: HandType;
Hand : HandType; HandLength, HipWidth: Integer);
HandLength : Integer;
HipWidth : Integer);
const const
MaxPoints = 7; MaxPoints = 7;
var var
@@ -956,7 +1025,7 @@ var
Var Var
CPoints : array[1..3] of TPoint; CPoints : array[1..3] of TPoint;
procedure LoadPoints(Pt1, Pt2, Pt3 : Integer); procedure LoadPoints(Pt1, Pt2, Pt3: Integer);
begin begin
CPoints[1] := HandPoints[Pt1]; CPoints[1] := HandPoints[Pt1];
CPoints[2] := HandPoints[Pt2]; CPoints[2] := HandPoints[Pt2];
@@ -967,71 +1036,78 @@ var
begin begin
ACanvas.Brush.Color := clWhite; ACanvas.Brush.Color := clWhite;
case Hand of case Hand of
HourHand : begin HourHand:
case Hour of case Hour of
0..3, 0..3, 12..15:
12..15 : begin begin
LoadPoints(2,3,4); LoadPoints(2,3,4);
LoadPoints(1,2,4); LoadPoints(1,2,4);
end; end;
4..5, 4..5, 16..17:
16..17 : begin begin
LoadPoints(1,2,4); LoadPoints(1,2,4);
LoadPoints(1,2,6); LoadPoints(1,2,6);
end; end;
6..9, 6..9, 18..21:
18..21 : begin begin
LoadPoints(1,2,6); LoadPoints(1,2,6);
LoadPoints(2,3,6); LoadPoints(2,3,6);
end; end;
10..11, 10..11, 22..23:
22..23 : begin begin
LoadPoints(2,3,4); LoadPoints(2,3,4);
LoadPoints(2,3,6); LoadPoints(2,3,6);
end; end;
end; end;
end;
MinuteHand: begin MinuteHand:
case Minute of case Minute of
0..15 : begin 0..15:
begin
LoadPoints(2,3,4); LoadPoints(2,3,4);
LoadPoints(1,2,4); LoadPoints(1,2,4);
end; end;
16..25: begin 16..25:
begin
LoadPoints(1,2,4); LoadPoints(1,2,4);
LoadPoints(1,2,6); LoadPoints(1,2,6);
end; end;
26..50: begin 26..50:
begin
LoadPoints(1,2,6); LoadPoints(1,2,6);
LoadPoints(2,3,6); LoadPoints(2,3,6);
end; end;
51..59: begin 51..59:
begin
LoadPoints(2,3,4); LoadPoints(2,3,4);
LoadPoints(2,3,6); LoadPoints(2,3,6);
end; end;
end; end;
end;
SecondHand: begin SecondHand:
case Second of case Second of
0..15 : begin 0..15:
begin
LoadPoints(2,3,4); LoadPoints(2,3,4);
LoadPoints(1,2,4); LoadPoints(1,2,4);
end; end;
16..25: begin 16..25:
begin
LoadPoints(1,2,4); LoadPoints(1,2,4);
LoadPoints(1,2,6); LoadPoints(1,2,6);
end; end;
26..50: begin 26..50:
begin
LoadPoints(1,2,6); LoadPoints(1,2,6);
LoadPoints(2,3,6); LoadPoints(2,3,6);
end; end;
51..59: begin 51..59:
begin
LoadPoints(2,3,4); LoadPoints(2,3,4);
LoadPoints(2,3,6); LoadPoints(2,3,6);
end; end;
end; end;
end; end; // case Hand of...
end;
ACanvas.Brush.Color := Color; ACanvas.Brush.Color := Color;
end; end;
@@ -1124,7 +1200,7 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomClock.SetActive(Value : Boolean); procedure TVpCustomClock.SetActive(Value: Boolean);
begin begin
if csLoading in ComponentState then begin if csLoading in ComponentState then begin
FActive := Value; FActive := Value;
@@ -1136,26 +1212,40 @@ begin
if FActive then begin if FActive then begin
if FDisplayMode = dmDigital then if FDisplayMode = dmDigital then
FMilitaryTime := DigitalOptions.MilitaryTime; FMilitaryTime := DigitalOptions.MilitaryTime;
{$IFDEF DELPHI}
if ckClockHandle = -1 then if ckClockHandle = -1 then
ckClockHandle := FTimerPool.Add(ckTimerEvent, ckInterval); ckClockHandle := FTimerPool.Add(ckTimerEvent, ckInterval);
if FClockMode = cmClock then {$ELSE}
FTime := Now FTimeStarted := now;
else if FClockMode = cmCountdownTimer then FTimer.Interval := ckInterval;
FStartTime := EncodeTime(FHourOffset, FMinuteOffset, FTimer.Enabled := FActive;
FSecondOffset, 0) FTimer.OnTimer := ckTimerEvent;
else {$ENDIF}
case FClockMode of
cmClock:
FTime := Now;
cmTimer:
FTime := 0; FTime := 0;
end else if ckClockHandle > -1 then begin cmCountdownTimer:
FCountdownStartTime := EncodeTime(FHourOffset, FMinuteOffset, FSecondOffset, 0);
end;
end
else
{$IFDEF DELPHI}
if ckClockHandle > -1 then begin
FTimerPool.Remove(ckClockHandle); FTimerPool.Remove(ckClockHandle);
ckClockHandle := -1; ckClockHandle := -1;
end; end;
{$ELSE}
if FTimer.Enabled then
FTimer.Enabled := false;
{$ENDIF}
Invalidate; Invalidate;
end; end;
end; end;
{=====} {=====}
procedure TVpCustomClock.SetBounds(ALeft, ATop, AWidth, AHeight : Integer); procedure TVpCustomClock.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin begin
inherited SetBounds(ALeft, ATop, AWidth, AHeight); inherited SetBounds(ALeft, ATop, AWidth, AHeight);
@@ -1168,7 +1258,7 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomClock.SetClockMode(Value : TVpClockMode); procedure TVpCustomClock.SetClockMode(Value: TVpClockMode);
begin begin
if Value <> FClockMode then begin if Value <> FClockMode then begin
if FActive then Active := false; if FActive then Active := false;
@@ -1222,22 +1312,34 @@ begin
{Initialize the LED display} {Initialize the LED display}
if FActive then begin if FActive then begin
if FClockMode = cmClock then case FClockMode of
{Clock} cmClock:
SetTime(Now) SetTime(Now);
else if FClockMode = cmTimer then cmTimer:
{Timer} {$IFDEF DELPHI}
SetTime(ckConvertMsToDateTime(FElapsedSeconds * 1000)) SetTime(ckConvertMsToDateTime(FElapsedSeconds * 1000));
else {$ELSE}
{Countdown Timer} SetTime(Now - FTimeStarted);
if (FStartTime - ckConvertMsToDateTime( {$ENDIF}
FElapsedSeconds * 1000) <= 0) then cmCountdownTimer:
{$IFDEF DELPHI}
if (FStartTime - ckConvertMsToDateTime(FElapsedSeconds * 1000) <= 0) then
begin begin
SetTime(0); SetTime(0);
Active := false; Active := false;
DoOnCountdownDone; DoOnCountdownDone;
end else end else
SetTime(FStartTime - ckConvertMsToDateTime(FElapsedSeconds * 1000)); SetTime(FStartTime - ckConvertMsToDateTime(FElapsedSeconds * 1000));
{$ELSE}
if (FCountdownStartTime - (now - FTimeStarted) <= 0) then
begin
SetTime(0);
Active := false;
DoOnCountdownDone;
end else
SetTime(FCountdownStartTime - (now - FTimeStarted));
{$ENDIF}
end;
end; end;
end; end;
@@ -1275,15 +1377,16 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomClock.SetTime(Value : TDateTime); procedure TVpCustomClock.SetTime(Value: TDateTime);
var var
Hour1, Minute1, Second1 : Word; Hour1, Minute1, Second1: Word;
Hour2, Minute2, Second2 : Word; Hour2, Minute2, Second2: Word;
MSecond : Word; MSecond: Word;
TimeStr: string; TimeStr: string;
begin begin
DecodeTime(Value, Hour1, Minute1, Second1, MSecond); DecodeTime(Value, Hour1, Minute1, Second1, MSecond);
DecodeTime(FTime, Hour2, Minute2, Second2, MSecond); DecodeTime(FTime, Hour2, Minute2, Second2, MSecond);
if (Hour1 <> Hour2) or (Minute1 <> Minute2) or (Second1 <> Second2) then begin if (Hour1 <> Hour2) or (Minute1 <> Minute2) or (Second1 <> Second2) then begin
FTime := Value; FTime := Value;
@@ -1300,11 +1403,14 @@ begin
if DisplayMode = dmDigital then begin if DisplayMode = dmDigital then begin
if FDigitalOptions.ShowSeconds and FMilitaryTime then if FDigitalOptions.ShowSeconds and FMilitaryTime then
TimeStr := FormatDateTime('hh:nn:ss', FTime) TimeStr := FormatDateTime('hh:nn:ss', FTime)
else if FDigitalOptions.ShowSeconds and not FMilitaryTime then else
if FDigitalOptions.ShowSeconds and not FMilitaryTime then
TimeStr := FormatDateTime('hh:nn:ss am/pm', FTime) TimeStr := FormatDateTime('hh:nn:ss am/pm', FTime)
else if not FDigitalOptions.ShowSeconds and FMilitaryTime then else
if not FDigitalOptions.ShowSeconds and FMilitaryTime then
TimeStr := FormatDateTime('hh:nn', FTime) TimeStr := FormatDateTime('hh:nn', FTime)
else if not FDigitalOptions.ShowSeconds and not FMilitaryTime then else
if not FDigitalOptions.ShowSeconds and not FMilitaryTime then
TimeStr := FormatDateTime('hh:nn am/pm', FTime); TimeStr := FormatDateTime('hh:nn am/pm', FTime);
ckLEDDisplay.Caption := TimeStr; ckLEDDisplay.Caption := TimeStr;
end; end;
@@ -1314,7 +1420,7 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomClock.SetMinuteOffset(Value : Integer); procedure TVpCustomClock.SetMinuteOffset(Value: Integer);
begin begin
if (Value <> FMinuteOffset) and (Abs(Value) <= 60) then begin if (Value <> FMinuteOffset) and (Abs(Value) <= 60) then begin
FMinuteOffset := Value; FMinuteOffset := Value;
@@ -1325,7 +1431,7 @@ begin
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
FHourOffset := Value; FHourOffset := Value;
@@ -1336,7 +1442,7 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomClock.SetSecondOffset(Value : Integer); procedure TVpCustomClock.SetSecondOffset(Value: Integer);
begin begin
if (Value <> FSecondOffset) and (Abs(Value) <= 59) then begin if (Value <> FSecondOffset) and (Abs(Value) <= 59) then begin
FSecondOffset := Value; FSecondOffset := Value;
@@ -1363,9 +1469,9 @@ begin
end; end;
{$IFNDEF LCL} {$IFNDEF LCL}
procedure TVpCustomClock.WMEraseBkgnd(var Msg : TWMEraseBkGnd); procedure TVpCustomClock.WMEraseBkgnd(var Msg: TWMEraseBkGnd);
{$ELSE} {$ELSE}
procedure TVpCustomClock.WMEraseBkgnd(var Msg : TLMEraseBkGnd); procedure TVpCustomClock.WMEraseBkgnd(var Msg: TLMEraseBkGnd);
{$ENDIF} {$ENDIF}
begin begin
Msg.Result := 1; Msg.Result := 1;
@@ -1373,7 +1479,7 @@ end;
{=====} {=====}
{$IFNDEF LCL} {$IFNDEF LCL}
procedure TVpCustomClock.WMGetDlgCode(var Msg : TWMGetDlgCode); procedure TVpCustomClock.WMGetDlgCode(var Msg: TWMGetDlgCode);
begin begin
{tell windows we are a static control to avoid receiving the focus} {tell windows we are a static control to avoid receiving the focus}
Msg.Result := DLGC_STATIC; Msg.Result := DLGC_STATIC;

View File

@@ -169,7 +169,11 @@ begin
tpList := TList.Create; tpList := TList.Create;
{allocate a window handle for the timer} {allocate a window handle for the timer}
//TODO: tpHandle := {$IFDEF VERSION6}Classes.{$ENDIF}AllocateHWnd(tpTimerWndProc); {$IFDEF DELPHI}
tpHandle := {$IFDEF VERSION6}Classes.{$ENDIF}AllocateHWnd(tpTimerWndProc);
{$ELSE}
// ToDo: tpHandle := AllocateHWnd(tpTimerWndProc);
{$ENDIF}
end; end;
destructor TVpTimerPool.Destroy; destructor TVpTimerPool.Destroy;
@@ -189,7 +193,11 @@ begin
tpList := nil; tpList := nil;
{deallocate our window handle} {deallocate our window handle}
//TODO: {$IFDEF VERSION6}Classes.{$ENDIF}DeallocateHWnd(tpHandle); {$IFDEF DELPHI}
{$IFDEF VERSION6}Classes.{$ENDIF}DeallocateHWnd(tpHandle);
{$ELSE}
// ToDo: DeallocateHWnd(tpHandle);
{$ENDIF}
inherited Destroy; inherited Destroy;
end; end;