jvcllaz: Add alarm form to JvTimeFramework demo

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7132 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-08-15 16:32:26 +00:00
parent 5aa5b8cfe2
commit 44e2beddca
6 changed files with 1181 additions and 761 deletions

View File

@ -48,7 +48,7 @@
<PackageName Value="LCL"/>
</Item6>
</RequiredPackages>
<Units Count="7">
<Units Count="8">
<Unit0>
<Filename Value="JvTimeFrameDemo.lpr"/>
<IsPartOfProject Value="True"/>
@ -101,6 +101,13 @@
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfSettings"/>
</Unit6>
<Unit7>
<Filename Value="tfalarm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="AlarmForm"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="tfAlarm"/>
</Unit7>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -9,7 +9,7 @@ uses
tfVisibleResources in 'VisibleResourcesUnit.pas' {VisibleResources},
tfShare in 'ShareUnit.pas' {Share},
tfApptEdit in 'ApptEditUnit.pas' {ApptEdit},
tfPrintProgress in 'PrintProgressUnit.pas', tfSettings {PrintProgress};
tfPrintProgress in 'PrintProgressUnit.pas', tfSettings, tfAlarm {PrintProgress};
{$R *.res}
@ -31,5 +31,6 @@ begin
Application.CreateForm(TApptEdit, ApptEdit);
Application.CreateForm(TPrintProgress, PrintProgress);
Application.CreateForm(TSettingsForm, SettingsForm);
Application.CreateForm(TAlarmForm, AlarmForm);
Application.Run;
end.

View File

@ -0,0 +1,158 @@
object AlarmForm: TAlarmForm
Left = 800
Height = 178
Top = 250
Width = 303
AutoSize = True
Caption = 'Reminder'
ClientHeight = 178
ClientWidth = 303
Position = poMainFormCenter
LCLVersion = '2.1.0.0'
object Panel1: TPanel
Left = 0
Height = 132
Top = 0
Width = 303
Align = alClient
AutoSize = True
BevelOuter = bvNone
ClientHeight = 132
ClientWidth = 303
TabOrder = 0
object Label1: TLabel
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 16
Height = 15
Top = 16
Width = 51
BorderSpacing.Left = 16
BorderSpacing.Top = 16
Caption = 'The event'
ParentColor = False
end
object EventLabel: TLabel
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom
Left = 16
Height = 15
Top = 39
Width = 271
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 8
BorderSpacing.Right = 16
BorderSpacing.Bottom = 8
Caption = 'EventLabel'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object IsDueLabel: TLabel
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = EventLabel
AnchorSideTop.Side = asrBottom
Left = 16
Height = 15
Top = 62
Width = 37
Caption = 'is due: '
ParentColor = False
end
object TimeLabel: TLabel
AnchorSideLeft.Control = IsDueLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = IsDueLabel
Left = 53
Height = 15
Top = 62
Width = 57
Caption = 'TimeLabel'
Font.Style = [fsBold]
ParentColor = False
ParentFont = False
end
object Label5: TLabel
AnchorSideLeft.Control = Label1
AnchorSideTop.Control = IsDueLabel
AnchorSideTop.Side = asrBottom
Left = 16
Height = 15
Top = 101
Width = 86
BorderSpacing.Top = 24
Caption = 'Remind again in'
ParentColor = False
end
object seSnoozeTime: TSpinEdit
AnchorSideLeft.Control = Label5
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label5
AnchorSideTop.Side = asrCenter
Left = 110
Height = 23
Top = 97
Width = 74
Alignment = taRightJustify
BorderSpacing.Left = 8
BorderSpacing.Bottom = 16
TabOrder = 0
end
object cmbTimeUnits: TComboBox
AnchorSideLeft.Control = seSnoozeTime
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label5
AnchorSideTop.Side = asrCenter
Left = 192
Height = 23
Top = 97
Width = 76
BorderSpacing.Left = 8
BorderSpacing.Right = 8
ItemHeight = 15
ItemIndex = 0
Items.Strings = (
'minutes'
'hours'
'days'
)
Style = csDropDownList
TabOrder = 1
Text = 'minutes'
end
object Label6: TLabel
AnchorSideLeft.Control = cmbTimeUnits
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Label5
Left = 276
Height = 15
Top = 101
Width = 5
BorderSpacing.Right = 16
Caption = '?'
ParentColor = False
end
end
object ButtonPanel1: TButtonPanel
Left = 6
Height = 34
Top = 138
Width = 291
OKButton.Name = 'OKButton'
OKButton.Caption = 'Yes'
OKButton.DefaultCaption = False
OKButton.OnClick = OKButtonClick
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CancelButton.Name = 'CancelButton'
CancelButton.Caption = 'No'
CancelButton.DefaultCaption = False
TabOrder = 1
ShowButtons = [pbOK, pbCancel]
end
end

View File

@ -0,0 +1,95 @@
unit tfAlarm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ButtonPanel, StdCtrls,
Spin, ExtCtrls,
JvTFManager;
type
{ TAlarmForm }
TAlarmForm = class(TForm)
ButtonPanel1: TButtonPanel;
cmbTimeUnits: TComboBox;
Label1: TLabel;
EventLabel: TLabel;
IsDueLabel: TLabel;
Panel1: TPanel;
TimeLabel: TLabel;
Label5: TLabel;
Label6: TLabel;
seSnoozeTime: TSpinEdit;
procedure OKButtonClick(Sender: TObject);
private
FSnooze: Boolean;
FSnoozeMins: Integer;
function GetSnoozeMins: Integer;
procedure SetSnoozeMins(const AValue: Integer);
public
procedure SetAppt(AAppt: TJvTFAppt);
property SnoozeMins: Integer read GetSnoozeMins write SetSnoozeMins;
property Snooze: Boolean read FSnooze;
end;
var
AlarmForm: TAlarmForm;
implementation
{$R *.lfm}
{ TAlarmForm }
function TAlarmForm.GetSnoozeMins: Integer;
begin
case cmbTimeUnits.ItemIndex of
0: Result := seSnoozeTime.Value;
1: Result := seSnoozeTime.Value * 60;
2: Result := seSnoozeTime.Value * 60 * 24;
end;
end;
procedure TAlarmForm.OKButtonClick(Sender: TObject);
begin
FSnooze := true;
end;
procedure TAlarmForm.SetAppt(AAppt: TJvTFAppt);
var
deltaMins: Integer;
begin
EventLabel.Caption := AAppt.Description;
if AAppt.StartDate = Date() then begin
IsDueLabel.caption := 'is due at ';
TimeLabel.Caption := FormatDateTime(FormatSettings.ShortTimeFormat, AAppt.StartTime);
end else begin
IsDueLabel.Caption := 'is due on ';
TimeLabel.Caption := FormatDateTime('dddddd', AAppt.StartDateTime);
end;
end;
procedure TAlarmForm.SetSnoozeMins(const AValue: Integer);
begin
FSnoozeMins := AValue;
if FSnoozeMins <= 60 then begin
cmbTimeUnits.ItemIndex := 0; // minutes
seSnoozeTime.Value := FSnoozeMins;
end else
if FSnoozeMins <= 24*60 then begin
cmbTimeUnits.ItemIndex := 1; // hours;
seSnoozeTime.Value := FSnoozeMins div 24;
end else begin
cmbTimeUnits.ItemIndex := 2; // days
seSnoozeTime.Value := FSnoozeMins div (24*60);
end;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -36,13 +36,15 @@ uses
db, sqldb, sqlite3conn,
ComCtrls, StdCtrls, Buttons, ExtCtrls, ImgList, DateTimePicker, PrintersDlgs,
JvTFManager, JvTFDays, JvTFGlance, JvTFGlanceTextViewer, JvTFMonths,
JvTFWeeks;
JvTFWeeks, JvTFAlarm;
type
{ TMainForm }
TMainForm = class(TForm)
JvTFAlarm1: TJvTFAlarm;
TodayButton: TSpeedButton;
WeeksCombo: TComboBox;
StrokeImages: TImageList;
JvTFDaysPrinter1: TJvTFDaysPrinter;
@ -89,10 +91,13 @@ type
procedure IconsLinkClick(Sender: TObject);
procedure IconsLinkMouseEnter(Sender: TObject);
procedure IconsLinkMouseLeave(Sender: TObject);
procedure JvTFAlarm1Alarm(Sender: TObject; AAppt: TJvTFAppt;
var SnoozeMins: Integer; var Dismiss: Boolean);
procedure ModeComboChange(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure SettingsButtonClick(Sender: TObject);
procedure TodayButtonClick(Sender: TObject);
procedure ViewSchedsButtonClick(Sender: TObject);
procedure HideSchedButtonClick(Sender: TObject);
procedure ResourceComboChange(Sender: TObject);
@ -151,7 +156,7 @@ implementation
uses
IniFiles,
tfVisibleResources, tfShare, tfApptEdit, tfPrintProgress, tfSettings;
tfVisibleResources, tfShare, tfApptEdit, tfPrintProgress, tfSettings, tfAlarm;
{$R *.lfm}
@ -175,6 +180,7 @@ begin
images[1] := StrokeImages;
PrevDateButton.Images := images[IconSet];
NextDateButton.Images := images[IconSet];
TodayButton.Images := images[IconSet];
NewApptButton.Images := images[IconSet];
EditApptButton.Images := images[IconSet];
DeleteApptButton.Images := images[IconSet];
@ -476,6 +482,13 @@ begin
End;
end;
procedure TMainForm.TodayButtonClick(Sender: TObject);
begin
JvTFDays1.GotoDate(Date());
JvTFMonths1.DisplayDate := JvTFDays1.CurrentDate;
JvTFWeeks1.DisplayDate := JvTFDays1.CurrentDate;
end;
procedure TMainForm.NewApptButtonClick(Sender: TObject);
begin
// Simply open the EditAppt window. The Appt var of the
@ -732,6 +745,40 @@ begin
Screen.Cursor := crDefault;
end;
procedure TMainForm.JvTFAlarm1Alarm(Sender: TObject; AAppt: TJvTFAppt;
var SnoozeMins: Integer; var Dismiss: Boolean);
var
F: TAlarmForm;
begin
F := TAlarmForm.Create(nil);
try
F.SetAppt(AAppt);
F.SnoozeMins := SnoozeMins;
F.ShowModal;
Dismiss := not F.Snooze;
SnoozeMins := F.SnoozeMins;
finally
F.Free;
end;
end;
{
var
msg: String;
res: Integer;
s: String;
begin
msg := Format('The event "%s" is due', [AAppt.Description]);
if AAppt.StartDate = Date then
msg := msg + ' at ' + TimeToStr(AAppt.StartTime)
else
msg := msg + ' on ' + FormatDateTime('dddddd', AAppt.StartTime);
msg := msg + LineEnding + 'Remind in ' + IntToStr(SnoozeMins) + ' minutes?';
res := MessageDlg(msg, mtInformation, [mbYes, mbNo], 0);
Dismiss := res = mrYes;
end;
}
procedure TMainForm.utfScheduleManager1LoadBatch(Sender: TObject;
BatchName: String; BatchStartDate, BatchEndDate: TDate);
var