diff --git a/components/tvplanit/languages/vpsr.de.po b/components/tvplanit/languages/vpsr.de.po index f833bf9a7..5a69e96db 100644 --- a/components/tvplanit/languages/vpsr.de.po +++ b/components/tvplanit/languages/vpsr.de.po @@ -159,6 +159,10 @@ msgctxt "vpsr.rscalendartoday" msgid "Today" msgstr "Heute" +#: vpsr.rscalendarweekabbr +msgid "CW" +msgstr "KW" + #: vpsr.rscancelbtn msgid "Cancel" msgstr "Abbrechen" diff --git a/components/tvplanit/languages/vpsr.po b/components/tvplanit/languages/vpsr.po index 6287cce6a..a69a6e5fa 100644 --- a/components/tvplanit/languages/vpsr.po +++ b/components/tvplanit/languages/vpsr.po @@ -149,6 +149,10 @@ msgctxt "vpsr.rscalendartoday" msgid "Today" msgstr "" +#: vpsr.rscalendarweekabbr +msgid "CW" +msgstr "" + #: vpsr.rscancelbtn msgid "Cancel" msgstr "" diff --git a/components/tvplanit/source/vpcontacteditdlg.pas b/components/tvplanit/source/vpcontacteditdlg.pas index 6156087b2..c8c26b2a8 100644 --- a/components/tvplanit/source/vpcontacteditdlg.pas +++ b/components/tvplanit/source/vpcontacteditdlg.pas @@ -113,10 +113,10 @@ type procedure DisplayCurrentCountry; procedure ResizeControls; public - Resource : TVpResource; - Contact : TVpContact; - ReturnCode : TVpEditorReturnCode; - ControlLink : TVpControlLink; + Resource: TVpResource; + Contact: TVpContact; + ReturnCode: TVpEditorReturnCode; + ControlLink: TVpControlLink; procedure PopulateSelf; procedure DePopulateSelf; procedure ArrangeControls; @@ -124,9 +124,9 @@ type TVpContactEditDialog = class(TVpBaseDialog) protected {private} - ceEditDlg : TContactEditForm; - ceContact : TVpContact; - ceResource : TVpResource; + ceEditDlg: TContactEditForm; + ceContact: TVpContact; + ceResource: TVpResource; public function Execute(Contact: TVpContact): Boolean; reintroduce; function AddNewContact: Boolean; @@ -150,7 +150,7 @@ uses {== Utility functions ===================================} -function Max(const a, b : Integer) : Integer; +function Max(const a, b: Integer): Integer; begin if a >= b then Result := a @@ -254,9 +254,9 @@ end; procedure TContactEditForm.PopulateSelf; var - CurCountry : Integer; - i : TVpPhoneType; - j : TVpCategoryType; + CurCountry: Integer; + pt: TVpPhoneType; + ct: TVpCategoryType; begin NameEdit.Text := AssembleName(Contact); @@ -296,12 +296,12 @@ begin cboxState.Text := Contact.State; - for i := Low (TVpPhoneType) to High (TVpPhoneType) do begin - cboxPhoneLbl1.Items.Add (PhoneLabel (i)); - cboxPhoneLbl2.Items.Add (PhoneLabel (i)); - cboxPhoneLbl3.Items.Add (PhoneLabel (i)); - cboxPhoneLbl4.Items.Add (PhoneLabel (i)); - cboxPhoneLbl5.Items.Add (PhoneLabel (i)); + for pt := Low (TVpPhoneType) to High (TVpPhoneType) do begin + cboxPhoneLbl1.Items.Add(PhoneLabel(pt)); + cboxPhoneLbl2.Items.Add(PhoneLabel(pt)); + cboxPhoneLbl3.Items.Add(PhoneLabel(pt)); + cboxPhoneLbl4.Items.Add(PhoneLabel(pt)); + cboxPhoneLbl5.Items.Add(PhoneLabel(pt)); end; cboxPhoneLbl1.ItemIndex := Contact.PhoneType1; cboxPhoneLbl2.ItemIndex := Contact.PhoneType2; @@ -309,8 +309,8 @@ begin cboxPhoneLbl4.ItemIndex := Contact.PhoneType4; cboxPhoneLbl5.ItemIndex := Contact.PhoneType5; - for j := Low (TVpCategoryType) to High (TVpCategoryType) do - cboxCategory.Items.Add (CategoryLabel (j)); + for ct := Low (TVpCategoryType) to High (TVpCategoryType) do + cboxCategory.Items.Add(CategoryLabel(ct)); cboxCategory.ItemIndex := Contact.Category; DisplayCurrentCountry; @@ -346,7 +346,7 @@ begin cboxState.Visible := False; end else begin - ControlLink.Localization.CountriesToTStrings (cboxCountry.Items); + ControlLink.Localization.CountriesToTStrings(cboxCountry.Items); CountryLbl.FocusControl := cboxCountry; cboxCountry.Visible := True; edtCountry.Visible := False; @@ -372,14 +372,13 @@ type TLabelArray = array[0..9] of TLabel; var - Labels : TLabelArray; - LargestLabel : Integer; - WidestField : Integer; - i : Integer; - j : Integer; - OldFont : TFont; - FieldTop : Integer; - delta : Integer; + Labels: TLabelArray; + LargestLabel: Integer; + WidestField: Integer; + i, j: Integer; + OldFont: TFont; + FieldTop: Integer; + delta: Integer; begin { Note: The resizing algorithm is dependent upon the labels having their @@ -413,21 +412,22 @@ begin try Canvas.Font.Assign (cboxCountry.Font); try - for j := 0 to cboxCountry.Items.Count - 1 do begin - i := Canvas.TextWidth (cboxCountry.Items[j]); - if i > WidestField then - WidestField := i; - end; - WidestField := WidestField + ComboArrowWidth; - cboxCountry.Width := WidestField; + for j := 0 to cboxCountry.Items.Count - 1 do begin + i := Canvas.TextWidth(cboxCountry.Items[j]); + if i > WidestField then + WidestField := i; + end; + WidestField := WidestField + ComboArrowWidth; + cboxCountry.Width := WidestField; finally - Canvas.Font.Assign (OldFont); + Canvas.Font.Assign(OldFont); end; finally OldFont.Free; end; if (cboxCountry.Left + cboxCountry.Width + FormRightBorder > MinFormWidth) and - (not cboxState.Visible) then + (not cboxState.Visible) + then Width := cboxCountry.Left + cboxCountry.Width + FormRightBorder else Width := MinFormWidth; @@ -438,23 +438,24 @@ begin OldFont := TFont.Create; try OldFont.Assign(Canvas.Font); - Canvas.Font.Assign (cboxCountry.Font); + Canvas.Font.Assign(cboxCountry.Font); try for j := 0 to cboxState.Items.Count - 1 do begin - i := Canvas.TextWidth (cboxState.Items[j]); + i := Canvas.TextWidth(cboxState.Items[j]); if i > WidestField then WidestField := i; end; WidestField := WidestField + ComboArrowWidth; cboxState.Width := WidestField; finally - Canvas.Font.Assign (OldFont); + Canvas.Font.Assign(OldFont); end; finally OldFont.Free; end; if (cboxState.Left + cboxState.Width + FormRightBorder > MinFormWidth) and - (not cboxCountry.Visible) then + (not cboxCountry.Visible) + then Width := cboxState.Left + cboxState.Width + FormRightBorder else Width := MinFormWidth; @@ -502,14 +503,13 @@ end; procedure TContactEditForm.DisplayCurrentCountry; var Idx : Integer; - begin - if not Assigned (ControlLink) then + if not Assigned(ControlLink) then Exit; - Idx := ControlLink.Localization.CountryNameToIndex (cboxCountry.Text); + Idx := ControlLink.Localization.CountryNameToIndex(cboxCountry.Text); if Idx > -1 then begin - ControlLink.Localization.StatesToTStrings (Idx, cboxState.Items); + ControlLink.Localization.StatesToTStrings(Idx, cboxState.Items); if ControlLink.Localization.Countries.Items[Idx].Address1Visible then begin AddrLbl.Visible := True; diff --git a/components/tvplanit/source/vpdbds.pas b/components/tvplanit/source/vpdbds.pas index 0beb709bf..f3c2c3405 100644 --- a/components/tvplanit/source/vpdbds.pas +++ b/components/tvplanit/source/vpdbds.pas @@ -44,10 +44,10 @@ type TVpCustomDBDataStore = class(TVpCustomDataStore) protected {private} FReadOnly : Boolean; - FAfterPostEvents : TNotifyEvent; - FAfterPostTasks : TNotifyEvent; - FAfterPostContacts : TNotifyEvent; - FAfterPostResources : TNotifyEvent; + FAfterPostEvents : TNotifyEvent; + FAfterPostTasks : TNotifyEvent; + FAfterPostContacts : TNotifyEvent; + FAfterPostResources : TNotifyEvent; { property getters } function GetResourceTable : TDataset; virtual; abstract; @@ -91,10 +91,10 @@ type procedure PostTasks; override; procedure PostResources; override; { - Added} - procedure PurgeResource(Res: TVpResource); override; - procedure PurgeEvents(Res: TVpResource); override; - procedure PurgeContacts(Res: TVpResource); override; - procedure PurgeTasks(Res: TVpResource); override; + procedure PurgeResource(Res: TVpResource); override; + procedure PurgeEvents(Res: TVpResource); override; + procedure PurgeContacts(Res: TVpResource); override; + procedure PurgeTasks(Res: TVpResource); override; { - End} procedure SetResourceByName(Value: string); override; procedure CreateFieldDefs(const TableName : string; @@ -102,18 +102,18 @@ type procedure CreateIndexDefs(const TableName : string; IndexDefs : TIndexDefs); virtual; - published - {events} - property AfterPostEvents : TNotifyEvent - read FAfterPostEvents write FAfterPostEvents; - property AfterPostContacts : TNotifyEvent - read FAfterPostContacts write FAfterPostContacts; - property AfterPostTasks : TNotifyEvent - read FAfterPostTasks write FAfterPostTasks; - property AfterPostResources : TNotifyEvent - read FAfterPostResources write FAfterPostResources; - end; - + published + {events} + property AfterPostEvents : TNotifyEvent + read FAfterPostEvents write FAfterPostEvents; + property AfterPostContacts : TNotifyEvent + read FAfterPostContacts write FAfterPostContacts; + property AfterPostTasks : TNotifyEvent + read FAfterPostTasks write FAfterPostTasks; + property AfterPostResources : TNotifyEvent + read FAfterPostResources write FAfterPostResources; + end; + { Constants for index names } const VpcIndexNameResID = 'ResID_ndx'; @@ -892,17 +892,17 @@ begin end; end else if TableName = EventsTableName then begin with IndexDefs do begin - { added a new index on the ResourceID and StartTime fields. } + { added a new index on the ResourceID and StartTime fields. } { this index is used by the FlashFiler 2 DataStore for setting ranges } { instead of using filters on the Events table. } { tables created with unpatched 1.0 or 1.01 versions of Visual PlanIt } { will not have this new index available so they will continue to use } { filters. } - with AddIndexDef do begin - Name := 'rid_st_ndx'; - Fields := 'ResourceID;StartTime'; - Options := [ixCaseInsensitive]; - end; + with AddIndexDef do begin + Name := 'rid_st_ndx'; + Fields := 'ResourceID;StartTime'; + Options := [ixCaseInsensitive]; + end; with AddIndexDef do begin Name := 'st_ndx'; Fields := 'StartTime'; @@ -982,7 +982,7 @@ begin ResourceTable.First; while not ResourceTable.EOF do begin { Load this resource into memory } - Res := Resources.AddResource(-1); + Res := Resources.AddResource(-1); Res.Loading := true; Res.ResourceID := ResourceTable.FieldByName('ResourceID').AsInteger; Res.Description := ResourceTable.FieldByName('Description').AsString; @@ -1084,8 +1084,9 @@ begin if (Resource <> nil) then with ContactsTable do begin SetFilterCriteria(ContactsTable, False, - ResourceTable.FieldByName('ResourceID').AsInteger, - 0, 0); + ResourceTable.FieldByName('ResourceID').AsInteger, + 0, 0 + ); First; while not EOF do begin Contact := Resource.Contacts.AddContact(GetNextID(ContactsTableName)); @@ -1146,8 +1147,9 @@ begin if (Resource <> nil) then with TasksTable do begin SetFilterCriteria(TasksTable, False, - ResourceTable.FieldByName('ResourceID').AsInteger, - 0, 0); + ResourceTable.FieldByName('ResourceID').AsInteger, + 0, 0 + ); First; while not EOF do begin Task := Resource.Tasks.AddTask(GetNextID(TasksTableName)); @@ -1187,25 +1189,24 @@ begin if (Resource <> nil) and Resource.ContactsDirty then begin { Dump this resource's dirty contacts to the DB } if ResourceTable.Locate('ResourceID', Resource.ResourceID, []) then begin - SetFilterCriteria(ContactsTable, False, Resource.ResourceID, - 0, 0); + SetFilterCriteria(ContactsTable, False, Resource.ResourceID, 0, 0); for I := pred(Resource.Contacts.Count) downto 0 do begin Contact := Resource.Contacts.GetContact(I); - { if the delete flag is set then delete the record } - { and free the event instance } - if Contact.Deleted then begin + { if the delete flag is set then delete the record } + { and free the event instance } + if Contact.Deleted then begin if ContactsTable.Locate('RecordID', Contact.RecordID, []) - then ContactsTable.Delete; - Contact.Free; - Continue; - end; + then ContactsTable.Delete; + Contact.Free; + Continue; + end; if Contact.Changed then begin if ContactsTable.Locate('RecordID', Contact.RecordID, []) then { this event already exists in the database so update it } - ContactsTable.Edit - else begin + ContactsTable.Edit + else begin { this record doesn't exist in the database, so it's a new event } ContactsTable.Append; end; @@ -1274,14 +1275,14 @@ begin Contact.Changed := false; end; end; - end; + end; Resource.ContactsDirty := false; if not Loading then NotifyDependents; - if Assigned(AfterPostContacts) then - FAfterPostContacts(self); + if Assigned(AfterPostContacts) then + FAfterPostContacts(self); end; end; {=====} @@ -1296,26 +1297,25 @@ begin { Dump this resource's dirty events to the DB } if ResourceTable.Locate('ResourceID', Resource.ResourceID, []) then begin - SetFilterCriteria(EventsTable, False, Resource.ResourceID, - 0, 0); + SetFilterCriteria(EventsTable, False, Resource.ResourceID, 0, 0); for J := pred(Resource.Schedule.EventCount) downto 0 do begin Event := Resource.Schedule.GetEvent(J); { if the delete flag is set then delete it from the database } - { and free the event instance } - if Event.Deleted then begin - if EventsTable.Locate('RecordID', Event.RecordID, []) then - EventsTable.Delete; - Event.Free; - Continue; - end; + { and free the event instance } + if Event.Deleted then begin + if EventsTable.Locate('RecordID', Event.RecordID, []) then + EventsTable.Delete; + Event.Free; + Continue; + end; if Event.Changed then begin if EventsTable.Locate('RecordID', Event.RecordID, []) then { this event already exists in the database so update it } - EventsTable.Edit - else begin + EventsTable.Edit + else begin EventsTable.Append; end; try @@ -1366,15 +1366,15 @@ begin Event.Changed := false; end; end; - end; + end; Resource.EventsDirty := false; - Resource.Schedule.Sort; + Resource.Schedule.Sort; if not Loading then NotifyDependents; - if Assigned(AfterPostEvents) then - FAfterPostEvents(self); + if Assigned(AfterPostEvents) then + FAfterPostEvents(self); end; end; {=====} @@ -1388,30 +1388,28 @@ begin { Dump this resource's dirty contacts to the DB } if ResourceTable.Locate('ResourceID', Resource.ResourceID, []) then begin - SetFilterCriteria(TasksTable, False, Resource.ResourceID, - 0, 0); + SetFilterCriteria(TasksTable, False, Resource.ResourceID, 0, 0); for I := pred(Resource.Tasks.Count) downto 0 do begin Task := Resource.Tasks.GetTask(I); - { if the delete flag is set then delete the record } - { and free the event instance } - if Task.Deleted then begin - if TasksTable.Locate('RecordID', Task.RecordID, []) then - TasksTable.Delete; - Task.Free; - Continue; - end; + { if the delete flag is set then delete the record } + { and free the event instance } + if Task.Deleted then begin + if TasksTable.Locate('RecordID', Task.RecordID, []) then + TasksTable.Delete; + Task.Free; + Continue; + end; if Task.Changed then begin if TasksTable.Locate('RecordID', Task.RecordID, []) - then - { this event already exists in the database so } - { update it } - TasksTable.Edit - else - { this record doesn't exist in the database, so } - { it's a new event } + then + { this event already exists in the database so update it } + TasksTable.Edit + else + { this record doesn't exist in the database, so } + { it's a new event } TasksTable.Append; try TasksTable.FieldByName('ResourceID').AsInteger := Resource.ResourceID; @@ -1445,11 +1443,11 @@ begin end; Resource.TasksDirty := false; - if not Loading then - NotifyDependents; + if not Loading then + NotifyDependents; - if Assigned(AfterPostTasks) then - FAfterPostTasks(self); + if Assigned(AfterPostTasks) then + FAfterPostTasks(self); end; end; {=====} @@ -1468,25 +1466,25 @@ begin for I := 0 to pred(Resources.Count) do begin Res := Resources.Items[I]; - if (Res <> nil) and Res.Deleted then begin - PurgeEvents(Res); - PurgeContacts(Res); - PurgeTasks(Res); + if (Res <> nil) and Res.Deleted then begin + PurgeEvents(Res); + PurgeContacts(Res); + PurgeTasks(Res); if ResourceTable.Locate('ResourceID', Res.ResourceID, []) - then ResourceTable.Delete; - if Resource = Res then - ResourceID := -1; - Res.Free; - Continue; - end; + then ResourceTable.Delete; + if Resource = Res then + ResourceID := -1; + Res.Free; + Continue; + end; { Dump this resource to the DB } if (Res <> nil) and Res.Changed then begin with ResourceTable do begin if Locate('ResourceID', Res.ResourceID, []) then - { existing record found } - Edit - else + { existing record found } + Edit + else { this is a new record} Append; @@ -1523,11 +1521,11 @@ begin Res.Changed := false; end; end; - if not Loading then - NotifyDependents; + if not Loading then + NotifyDependents; - if Assigned(AfterPostEvents) then - FAfterPostEvents(self); + if Assigned(AfterPostEvents) then + FAfterPostEvents(self); end; finally Loading := false; @@ -1536,37 +1534,37 @@ end; {=====} { - Added} -procedure TVpCustomDBDataStore.PurgeResource(Res: TVpResource); -begin - Res.Deleted := true; - PostResources; - Load; -end; -{=====} +procedure TVpCustomDBDataStore.PurgeResource(Res: TVpResource); +begin + Res.Deleted := true; + PostResources; + Load; +end; +{=====} -procedure TVpCustomDBDataStore.PurgeEvents(Res: TVpResource); -begin +procedure TVpCustomDBDataStore.PurgeEvents(Res: TVpResource); +begin { Purging the events from the database is done by the descendant !!.01} { classes !!.01} - inherited; -end; -{=====} + inherited; +end; +{=====} -procedure TVpCustomDBDataStore.PurgeContacts(Res: TVpResource); -begin +procedure TVpCustomDBDataStore.PurgeContacts(Res: TVpResource); +begin { Purging the contacts from the database is done by the descendant !!.01} { classes !!.01} - inherited; -end; -{=====} + inherited; +end; +{=====} -procedure TVpCustomDBDataStore.PurgeTasks(Res: TVpResource); -begin +procedure TVpCustomDBDataStore.PurgeTasks(Res: TVpResource); +begin { Purging the tasks from the database is done by the descendant !!.01} { classes !!.01} - inherited; -end; -{=====} + inherited; +end; +{=====} { - End} procedure TVpCustomDBDataStore.SetResourceByName(Value: string); @@ -1603,8 +1601,7 @@ begin SetFilterCriteria(ContactsTable, False, Resource.ResourceID, 0, 0); First; while not EOF do begin - Contact := Resource.Contacts.AddContact( - FieldByName('RecordID').AsInteger); + Contact := Resource.Contacts.AddContact(FieldByName('RecordID').AsInteger); Contact.Loading := true; // Contact.RecordID := FieldByName('RecordID').AsInteger; Contact.FirstName := FieldByName('FirstName').AsString; @@ -1668,17 +1665,16 @@ begin { Load this resource's events into memory } with EventsTable do begin - SetFilterCriteria(EventsTable, True, Resource.ResourceID, - TimeRange.StartTime, - TimeRange.EndTime); + SetFilterCriteria(EventsTable, True, Resource.ResourceID, TimeRange.StartTime, TimeRange.EndTime); First; while not EventsTable.EOF do begin - Event := Resource.Schedule.AddEvent( - FieldByName('RecordID').AsInteger, + Event := Resource.Schedule.AddEvent( + FieldByName('RecordID').AsInteger, FieldByName('StartTime').AsDateTime, - FieldByName('EndTime').AsDateTime); + FieldByName('EndTime').AsDateTime + ); if Event <> nil then begin Event.Loading := true; {prevents the events changed flag from being set} // Event.RecordID := FieldByName('RecordID').AsInteger; @@ -1729,8 +1725,7 @@ begin SetFilterCriteria(TasksTable, False, Resource.ResourceID, 0, 0); First; while not EOF do begin - Task := Resource.Tasks.AddTask( - FieldByName('RecordID').AsInteger); + Task := Resource.Tasks.AddTask(FieldByName('RecordID').AsInteger); Task.Loading := true; // Task.RecordID := FieldByName('RecordID').AsInteger; Task.Complete := FieldByName('Complete').AsBoolean; diff --git a/components/tvplanit/source/vpevnteditdlg.pas b/components/tvplanit/source/vpevnteditdlg.pas index c338e17ce..619bda03d 100644 --- a/components/tvplanit/source/vpevnteditdlg.pas +++ b/components/tvplanit/source/vpevnteditdlg.pas @@ -116,6 +116,7 @@ type procedure FormShow(Sender: TObject); procedure StartTimeExit(Sender: TObject); procedure EndTimeExit(Sender: TObject); + private { Private declarations } {$IFDEF LCL} StartTime: TTimeEdit; @@ -132,8 +133,10 @@ type procedure PopLists; procedure LoadCaptions; procedure DoPlaySound(Sender: TObject; const AWavFile: String; AMode: TVpPlaySoundMode); + protected property Datastore: TVpCustomDatastore read FDatastore write FDatastore; + public { Public declarations } Event: TVpEvent; CatColorMap: TVpCategoryColorMap; @@ -142,7 +145,7 @@ type Conflicts : Integer; TimeFormat: TVpTimeFormat; AlarmWavPath: string; - FLastEndTime : TDateTime; + FLastEndTime : TDateTime; procedure PopulateDialog; procedure DePopulateDialog; @@ -387,7 +390,7 @@ begin Category.ItemIndex := Event.Category; - FLastEndTime := Event.EndTime; + FLastEndTime := Event.EndTime; end; {=====} @@ -455,22 +458,21 @@ end; procedure TDlgEventEdit.EndTimeChange(Sender: TObject); function IsMidnight(ATime: TDateTime) : Boolean; - begin + begin Result := ATime = Trunc(ATime); - end; - -var - ET: TDateTime; + end; +var + ET: TDateTime; begin { Verify the value is valid } try ET := StrToTime(EndTime.Text); if (IsMidnight(ET)) and (not IsMidnight(FLastEndTime)) then - EndDate.Date := EndDate.Date + 1 + EndDate.Date := EndDate.Date + 1 else if (not IsMidnight(ET)) and (IsMidnight(FLastEndTime)) then - EndDate.Date := EndDate.Date - 1; - FLastEndTime := ET; + EndDate.Date := EndDate.Date - 1; + FLastEndTime := ET; except EndTime.Color := clRed; EndTime.SetFocus; @@ -512,7 +514,7 @@ begin Hour := (Minute div 15) div 4; MinStr := IntToStr(Minute mod 60); if MinStr = '0' then MinStr := '00'; - if TimeFormat = tf24Hour then + if TimeFormat = tf24Hour then StringList.Add(IntToStr(Hour) + ':' + MinStr) else begin if Hour > 12 then Hour := Hour - 12; @@ -643,7 +645,6 @@ begin if Visible then FCustomInterval.SetFocus; end; - end; {=====} @@ -709,7 +710,7 @@ begin inherited Create(AOwner); FPlacement.Position := mpCenterTop; FPlacement.Height := 415; - FPlacement.Width := 710; + FPlacement.Width := 710; end; {=====} @@ -746,7 +747,9 @@ begin Result := false; if DataStore <> nil then begin ceEvent := DataStore.Resource.Schedule.AddEvent( - DataStore.GetNextID(EventsTableName), StartTime, EndTime); + DataStore.GetNextID(EventsTableName), + StartTime, EndTime + ); if ceEvent <> nil then begin Result := Execute(ceEvent); if (not Result) or (ceEvent = nil) then @@ -756,18 +759,18 @@ begin end; {=====} -procedure TDlgEventEdit.StartTimeExit(Sender: TObject); -var - ST : TDateTime; -begin +procedure TDlgEventEdit.StartTimeExit(Sender: TObject); +var + ST : TDateTime; +begin { Verify the value is valid } - try + try ST := StartDate.Date + StrToTime(StartTime.Text); except StartTime.Color := clRed; StartTime.SetFocus; Exit; - end; + end; StartTime.Color := clWindow; { If the end time is less than the start time then change the end } @@ -775,12 +778,12 @@ begin if ST > EndDate.Date + StrToTime (EndTime.Text) then EndTime.Text := FormatDateTime('hh:nn', ST + 30 / MinutesInDay); -end; +end; -procedure TDlgEventEdit.EndTimeExit(Sender: TObject); -var +procedure TDlgEventEdit.EndTimeExit(Sender: TObject); +var ET: TDateTime; -begin +begin { Verify the value is valid } try ET := EndDate.Date + StrToTime(EndTime.Text); @@ -796,7 +799,7 @@ begin if ET < StartDate.Date + StrToTime (StartTime.Text) then StartTime.Text := FormatDateTime('hh:nn', ET - 30 / MinutesInDay); -end; +end; end. diff --git a/components/tvplanit/source/vpsr.inc b/components/tvplanit/source/vpsr.inc index 6f596a655..db171b90b 100644 --- a/components/tvplanit/source/vpsr.inc +++ b/components/tvplanit/source/vpsr.inc @@ -123,6 +123,7 @@ resourcestring RSMinutes = 'Minutes'; RSHours = 'Hours'; RSDays = 'Days'; + RSCalendarWeekAbbr = 'CW'; // Abbreviation of "calendar week" {WARNINGS} RSPermanent = 'This operation cannot be undone!'; diff --git a/components/tvplanit/source/vptaskeditdlg.pas b/components/tvplanit/source/vptaskeditdlg.pas index 451be1e7d..b0f498cdd 100644 --- a/components/tvplanit/source/vptaskeditdlg.pas +++ b/components/tvplanit/source/vptaskeditdlg.pas @@ -90,10 +90,10 @@ type TVpTaskEditDialog = class(TVpBaseDialog) protected {private} - teEditDlg : TTaskEditForm; - teTask : TVpTask; + teEditDlg: TTaskEditForm; + teTask: TVpTask; public - constructor Create(AOwner : TComponent); override; + constructor Create(AOwner: TComponent); override; function Execute(Task: TVpTask): Boolean; reintroduce; function AddNewTask: Boolean; published @@ -145,13 +145,11 @@ begin DetailsMemo.Text := Task.Details; CompleteCB.Checked := Task.Complete; if Task.CompletedOn <> 0 then - CompletedOnLbl.Caption := RSCompletedOn + ' ' + - FormatDateTime(ShortDateFormat, Task.CompletedOn) + CompletedOnLbl.Caption := RSCompletedOn + ' ' + FormatDateTime(ShortDateFormat, Task.CompletedOn) else CompletedOnLbl.Visible := False; CompletedOnLbl.Visible := CompleteCB.Checked; - CreatedOnLbl.Caption := RSCreatedOn + ' ' + - FormatDateTime(ShortDateFormat, Task.CreatedOn); + CreatedOnLbl.Caption := RSCreatedOn + ' ' + FormatDateTime(ShortDateFormat, Task.CreatedOn); DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + 8; end; @@ -188,8 +186,8 @@ end; constructor TVpTaskEditDialog.Create(AOwner : TComponent); begin inherited Create(AOwner); - FPlacement.Height := 340; - FPlacement.Width := 545; + FPlacement.Height := 340; + FPlacement.Width := 545; end; function TVpTaskEditDialog.Execute(Task: TVpTask): Boolean; @@ -198,8 +196,8 @@ var begin Result := false; teTask := Task; - if (teTask <> nil) and (DataStore <> nil) and - (DataStore.Resource <> nil) then begin + if (teTask <> nil) and (DataStore <> nil) and (DataStore.Resource <> nil) then + begin Application.CreateForm(TTaskEditForm, TaskEditForm); try DoFormPlacement(TaskEditForm); diff --git a/components/tvplanit/source/vpweekview.pas b/components/tvplanit/source/vpweekview.pas index ea83767b0..d989cdae8 100644 --- a/components/tvplanit/source/vpweekview.pas +++ b/components/tvplanit/source/vpweekview.pas @@ -58,8 +58,8 @@ uses type TVpWeekdayRec = packed record - Rec : TRect; - Day : TDateTime; + Rec: TRect; + Day: TDateTime; end; type @@ -99,9 +99,9 @@ type FDateFormat: string; FColor: TColor; FBordered: Boolean; - procedure SetColor (Value: TColor); - procedure SetFont (Value: TFont); - procedure SetBordered (Value: Boolean); + procedure SetColor(Value: TColor); + procedure SetFont(Value: TFont); + procedure SetBordered(Value: Boolean); procedure SetDateFormat(Value: string); public constructor Create(AOwner: TVpWeekView); @@ -120,45 +120,45 @@ type private procedure SetActiveEvent(AValue: TVpEvent); protected{ private } - FActiveDate : TDateTime; - FColumnWidth : Integer; - FColor : TColor; - FDateLabelFormat : string; - FDayHeadAttributes : TVpDayHeadAttr; - FDrawingStyle : TVpDrawingStyle; - FaActiveEvent : TVpEvent; - FHeadAttr : TVpWvHeadAttributes; - FEventFont : TFont; - FLineColor : TColor; - FLineCount : Integer; - FTimeFormat : TVpTimeFormat; - FShowEventTime : Boolean; - FVisibleLines : Integer; - FWeekStartsOn : TVpDayType; - FDefaultPopup : TPopupMenu; - FAllDayEventAttr : TVpAllDayEventAttributes; + FActiveDate: TDateTime; + FColumnWidth: Integer; + FColor: TColor; + FDateLabelFormat: string; + FDayHeadAttributes: TVpDayHeadAttr; + FDrawingStyle: TVpDrawingStyle; + FaActiveEvent: TVpEvent; + FHeadAttr: TVpWvHeadAttributes; + FEventFont: TFont; + FLineColor: TColor; + FLineCount: Integer; + FTimeFormat: TVpTimeFormat; + FShowEventTime: Boolean; + FVisibleLines: Integer; + FWeekStartsOn: TVpDayType; + FDefaultPopup: TPopupMenu; + FAllDayEventAttr: TVpAllDayEventAttributes; { event variables } - FBeforeEdit : TVpBeforeEditEvent; - FAfterEdit : TVpAfterEditEvent; - FOwnerEditEvent : TVpEditEvent; - FOnAddEvent : TVpOnAddNewEvent; + FBeforeEdit: TVpBeforeEditEvent; + FAfterEdit: TVpAfterEditEvent; + FOwnerEditEvent: TVpEditEvent; + FOnAddEvent: TVpOnAddNewEvent; { internal variables } - wvInLinkHandler : Boolean; - wvClickTimer : TTimer; - wvLoaded : Boolean; - wvRowHeight : Integer; - wvDayHeadHeight : Integer; - wvHeaderHeight : Integer; - wvStartDate : TDateTime; - wvSpinButtons : TUpDown; - wvEventList : TList; - wvEventArray : TVpEventArray; - wvWeekdayArray : TVpWeekdayArray; - wvActiveEventRec : TRect; - wvInPlaceEditor : TVpWvInPlaceEdit; - wvCreatingEditor : Boolean; - wvPainting : Boolean; - wvHotPoint : TPoint; + wvInLinkHandler: Boolean; + wvClickTimer: TTimer; + wvLoaded: Boolean; + wvRowHeight: Integer; + wvDayHeadHeight: Integer; + wvHeaderHeight: Integer; + wvStartDate: TDateTime; + wvSpinButtons: TUpDown; + wvEventList: TList; + wvEventArray: TVpEventArray; + wvWeekdayArray: TVpWeekdayArray; + wvActiveEventRec: TRect; + wvInPlaceEditor: TVpWvInPlaceEdit; + wvCreatingEditor: Boolean; + wvPainting: Boolean; + wvHotPoint: TPoint; { property methods } procedure SetDrawingStyle(Value: TVpDrawingStyle); @@ -173,16 +173,16 @@ type { internal methods } procedure wvEditInPlace(Sender: TObject); procedure wvHookUp; - procedure PopupAddEvent (Sender : TObject); - procedure PopupDeleteEvent (Sender : TObject); - procedure PopupEditEvent (Sender : TObject); - procedure PopupToday (Sender : TObject); - procedure PopupNextWeek (Sender : TObject); - procedure PopupPrevWeek (Sender : TObject); - procedure PopupNextMonth (Sender : TObject); - procedure PopupPrevMonth(Sender : TObject); - procedure PopupNextYear (Sender : TObject); - procedure PopupPrevYear (Sender : TObject); + procedure PopupAddEvent(Sender: TObject); + procedure PopupDeleteEvent(Sender: TObject); + procedure PopupEditEvent(Sender: TObject); + procedure PopupToday(Sender: TObject); + procedure PopupNextWeek(Sender: TObject); + procedure PopupPrevWeek(Sender: TObject); + procedure PopupNextMonth(Sender: TObject); + procedure PopupPrevMonth(Sender: TObject); + procedure PopupNextYear(Sender: TObject); + procedure PopupPrevYear(Sender: TObject); procedure InitializeDefaultPopup; procedure Paint; override; procedure Loaded; override; @@ -211,6 +211,7 @@ type //TODO: Bug 0020755 braks this in GTK2... procedure WMRButtonDown(var Msg : TLMRButtonDown); message LM_RBUTTONDOWN; {$ENDIF} + public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -218,77 +219,44 @@ type procedure DeleteActiveEvent(Verify: Boolean); procedure Invalidate; override; procedure LinkHandler(Sender: TComponent; - NotificationType: TVpNotificationType; - const Value: Variant); override; - function GetControlType : TVpItemType; override; + NotificationType: TVpNotificationType; const Value: Variant); override; + function GetControlType: TVpItemType; override; procedure EditSelectedEvent; - procedure PaintToCanvas (ACanvas : TCanvas; - ARect : TRect; - Angle : TVpRotationAngle; - ADate : TDateTime); - procedure RenderToCanvas (RenderCanvas : TCanvas; - RenderIn : TRect; - Angle : TVpRotationAngle; - Scale : Extended; - RenderDate : TDateTime; - StartLine : Integer; - StopLine : Integer; - UseGran : TVpGranularity; - DisplayOnly : Boolean); override; + procedure PaintToCanvas(ACanvas: TCanvas; ARect: TRect; + Angle: TVpRotationAngle; ADate: TDateTime); + procedure RenderToCanvas(RenderCanvas: TCanvas; RenderIn: TRect; + Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime; + StartLine: Integer; StopLine: Integer; UseGran: TVpGranularity; + DisplayOnly: Boolean); override; property ActiveEvent: TVpEvent read FaActiveEvent write SetActiveEvent; property Date: TDateTime read FActiveDate write SetActiveDate; property VisibleLines: Integer read FVisibleLines; + published property AllDayEventAttributes: TVpAllDayEventAttributes read FAllDayEventAttr write FAllDayEventAttr; + property Color: TColor read FColor write SetColor; + property DateLabelFormat: string read FDateLabelFormat write SetDateLabelFormat; + property DayHeadAttributes: TVpDayHeadAttr read FDayHeadAttributes write FDayHeadAttributes; + property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle stored True; + property EventFont: TFont read FEventFont write SetEventFont; + property HeadAttributes: TVpWvHeadAttributes read FHeadAttr write FHeadAttr; + property LineColor: TColor read FLineColor write SetLineColor; + property TimeFormat: TVpTimeFormat read FTimeFormat write SetTimeFormat; + property ShowEventTime: Boolean read FShowEventTime write SetShowEventTime; + property WeekStartsOn: TVpDayType read FWeekStartsOn write SetWeekStartsOn; + {inherited properties} property Align; property Anchors; property TabStop; property TabOrder; - property Color: TColor - read FColor write SetColor; - - property DateLabelFormat: string - read FDateLabelFormat write SetDateLabelFormat; - - property DayHeadAttributes: TVpDayHeadAttr - read FDayHeadAttributes write FDayHeadAttributes; - - property DrawingStyle: TVpDrawingStyle - read FDrawingStyle write SetDrawingStyle stored True; - - property EventFont: TFont - read FEventFont write SetEventFont; - - property HeadAttributes: TVpWvHeadAttributes - read FHeadAttr write FHeadAttr; - - property LineColor: TColor - read FLineColor write SetLineColor; - - property TimeFormat: TVpTimeFormat - read FTimeFormat write SetTimeFormat; - - property ShowEventTime: Boolean - read FShowEventTime write SetShowEventTime; - - property WeekStartsOn: TVpDayType - read FWeekStartsOn write SetWeekStartsOn; - {events} - property AfterEdit : TVpAfterEditEvent - read FAfterEdit write FAfterEdit; - - property BeforeEdit: TVpBeforeEditEvent - read FBeforeEdit write FBeforeEdit; - - property OnAddEvent: TVpOnAddNewEvent - read FOnAddEvent write FOnAddEvent; - - property OnOwnerEditEvent: TVpEditEvent - read FOwnerEditEvent write FOwnerEditEvent; + property AfterEdit : TVpAfterEditEvent read FAfterEdit write FAfterEdit; + property BeforeEdit: TVpBeforeEditEvent read FBeforeEdit write FBeforeEdit; + property OnAddEvent: TVpOnAddNewEvent read FOnAddEvent write FOnAddEvent; + property OnOwnerEditEvent: TVpEditEvent read FOwnerEditEvent write FOwnerEditEvent; end; @@ -320,30 +288,34 @@ end; procedure TVpWvInPlaceEdit.KeyDown(var Key: Word; Shift: TShiftState); var - Grid : TVpWeekView; + Grid: TVpWeekView; begin Grid := TVpWeekView(Owner); case Key of - VK_RETURN: begin - Key := 0; - Grid.EndEdit(Self); - end; + VK_RETURN: + begin + Key := 0; + Grid.EndEdit(Self); + end; - VK_UP: begin - Key := 0; - Grid.EndEdit(Self); - end; + VK_UP: + begin + Key := 0; + Grid.EndEdit(Self); + end; - VK_DOWN: begin - Key := 0; - Grid.EndEdit(Self); - end; + VK_DOWN: + begin + Key := 0; + Grid.EndEdit(Self); + end; - VK_ESCAPE: begin - Key := 0; - Grid.EndEdit(self); - end; + VK_ESCAPE: + begin + Key := 0; + Grid.EndEdit(self); + end; else inherited; @@ -455,7 +427,7 @@ begin FColumnWidth := 200; { set up fonts and colors } - FDayHeadAttributes.Font.Name := 'Tahoma'; +// FDayHeadAttributes.Font.Name := 'Tahoma'; FDayHeadAttributes.Font.Size := 10; FDayHeadAttributes.Font.Style := []; FDayHeadAttributes.Color := clBtnFace; @@ -515,11 +487,9 @@ begin wvInLinkHandler := true; try case NotificationType of - neDateChange: begin - Date := Value; - end; - neDataStoreChange: Invalidate; - neInvalidate: Invalidate; + neDateChange : Date := Value; + neDataStoreChange : Invalidate; + neInvalidate : Invalidate; end; finally wvInLinkHandler := false; @@ -558,81 +528,74 @@ end; procedure TVpWeekView.Paint; begin - RenderToCanvas (Canvas, // Paint Canvas - Rect (0, 0, Width, Height), // Paint Rectangle - ra0, - 1, // Scale - wvStartDate, // Date - -1, // Start At - -1, // End At - gr30Min, - False); // Display Only + RenderToCanvas( + Canvas, // Paint Canvas + Rect (0, 0, Width, Height), // Paint Rectangle + ra0, + 1, // Scale + wvStartDate, // Date + -1, // Start At + -1, // End At + gr30Min, + False // Display Only + ); end; {=====} -procedure TVpWeekView.PaintToCanvas (ACanvas : TCanvas; - ARect : TRect; - Angle : TVpRotationAngle; - ADate : TDateTime); + +procedure TVpWeekView.PaintToCanvas(ACanvas: TCanvas; ARect: TRect; + Angle: TVpRotationAngle; ADate: TDateTime); begin - RenderToCanvas (ACanvas, ARect, Angle, 1, ADate, - -1, -1, gr30Min, True); + RenderToCanvas(ACanvas, ARect, Angle, 1, ADate, -1, -1, gr30Min, True); end; {=====} -procedure TVpWeekView.RenderToCanvas (RenderCanvas : TCanvas; - RenderIn : TRect; - Angle : TVpRotationAngle; - Scale : Extended; - RenderDate : TDateTime; - StartLine : Integer; - StopLine : Integer; - UseGran : TVpGranularity; - DisplayOnly : Boolean); +procedure TVpWeekView.RenderToCanvas(RenderCanvas: TCanvas; RenderIn: TRect; + Angle: TVpRotationAngle; Scale: Extended; RenderDate: TDateTime; + StartLine: Integer; StopLine: Integer; UseGran: TVpGranularity; + DisplayOnly: Boolean); var - HeadRect : TRect; - SaveBrushColor : TColor; - SavePenStyle : TPenStyle; - SavePenColor : TColor; - DayRectHeight : Integer; - StrLn : Integer; - StartDate : TDateTime; - RealWidth : Integer; - RealHeight : Integer; - RealLeft : Integer; - RealRight : Integer; - RealTop : Integer; - RealBottom : Integer; - ADEventsRect : TRect; - Rgn : HRGN; + HeadRect: TRect; + SaveBrushColor: TColor; + SavePenStyle: TPenStyle; + SavePenColor: TColor; + DayRectHeight: Integer; + StrLn: Integer; + StartDate: TDateTime; + RealWidth: Integer; + RealHeight: Integer; + RealLeft: Integer; + RealRight: Integer; + RealTop: Integer; + RealBottom: Integer; + ADEventsRect: TRect; + Rgn: HRGN; - DotDotDotColor : TColor; - BevelHighlightColor : TColor; - BevelShadowColor : TColor; - BevelDarkShadow : TColor; - BevelButtonFace : TColor; - RealLineColor : TColor; - RealDayHeadAttrColor : TColor; - RealColor : TColor; - RealHeadAttrColor : TColor; - ADBackgroundColor : TColor; - ADEventBackgroundColor : TColor; - ADEventBorderColor : TColor; + DotDotDotColor: TColor; + BevelHighlightColor: TColor; + BevelShadowColor: TColor; + BevelDarkShadow: TColor; + BevelButtonFace: TColor; + RealLineColor: TColor; + RealDayHeadAttrColor: TColor; + RealColor: TColor; + RealHeadAttrColor: TColor; + ADBackgroundColor: TColor; + ADEventBackgroundColor: TColor; + ADEventBorderColor: TColor; - function DrawAllDayEvents ( ADate : TDateTime; - DayRect : TRect; - var EAIndex : Integer) : Boolean; + function DrawAllDayEvents(ADate: TDateTime; DayRect: TRect; + var EAIndex: Integer): Boolean; var - ADEventsList : TList; - TempList : TList; - I, J, K : Integer; - Event : TVpEvent; - ADEventRect : TRect; - StartsBeforeRange : Boolean; - MaxADEvents : Integer; - Skip : Boolean; - ADTextHeight : Integer; - EventStr : string; - + ADEventsList: TList; + TempList: TList; + I, J, K: Integer; + Event: TVpEvent; + ADEventRect: TRect; + StartsBeforeRange: Boolean; + MaxADEvents: Integer; + Skip: Boolean; + ADTextHeight: Integer; + EventStr: string; begin Result := False; { initialize the All Day Events area... } @@ -652,7 +615,7 @@ var { get the all day events for the day specified by ADate + I } DataStore.Resource.Schedule.AllDayEventsByDate(ADate, TempList); - { Iterate through these events and place them in ADEventsList } + { Iterate through these events and place them in ADEventsList } Skip := false; for J := 0 to pred(TempList.Count) do begin if AdEventsList.Count > 0 then begin @@ -677,19 +640,17 @@ var if MaxADEvents > 0 then begin { Set attributes } RenderCanvas.Brush.Color := ADBackgroundColor; - RenderCanvas.Font.Assign (AllDayEventAttributes.Font); + RenderCanvas.Font.Assign(AllDayEventAttributes.Font); { Measure the AllDayEvent TextHeight } - ADTextHeight := RenderCanvas.TextHeight(VpProductName) + - TextMargin + TextMargin div 2; + ADTextHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + TextMargin div 2; { Build the AllDayEvent rect based on the value of MaxADEvents } - if AdEventsRect.Top + (MaxADEvents * ADTextHeight) + - TextMargin * 2 > DayRect.Bottom then + if AdEventsRect.Top + (MaxADEvents * ADTextHeight) + TextMargin * 2 > DayRect.Bottom + then ADeventsrect.Bottom := DayRect.Bottom else - ADEventsRect.Bottom := AdEventsRect.Top + - (MaxADEvents * ADTextHeight) + TextMargin * 2; + ADEventsRect.Bottom := AdEventsRect.Top + (MaxADEvents * ADTextHeight) + TextMargin * 2; { Clear the AllDayEvents area } TpsFillRect(RenderCanvas, Angle, RenderIn, ADEventsRect); @@ -697,26 +658,21 @@ var StartsBeforeRange := false; { Cycle through the all day events and draw them appropriately } for I := 0 to pred(ADEventsList.Count) do begin - Event := ADEventsList[I]; { set the top of the event's rect } - AdEventRect.Top := ADEventsRect.Top + TextMargin + - (I * ADTextHeight); + AdEventRect.Top := ADEventsRect.Top + TextMargin + I * ADTextHeight; - if ADEventsRect.Top + TextMargin + ((I + 1) * ADTextHeight) - - TextMargin > DayRect.Bottom then begin + if ADEventsRect.Top + TextMargin + ((I + 1) * ADTextHeight) - TextMargin > DayRect.Bottom + then begin RenderCanvas.Brush.Color := DotDotDotColor; { draw dot dot dot } - TPSFillRect (RenderCanvas, Angle, RenderIn, - Rect (DayRect.Right - 20, DayRect.Bottom - 7, - DayRect.Right - 17, DayRect.Bottom - 4)); - TPSFillRect (RenderCanvas, Angle, RenderIn, - Rect (DayRect.Right - 13, DayRect.Bottom - 7, - DayRect.Right - 10, DayRect.Bottom - 4)); - TPSFillRect (RenderCanvas, Angle, RenderIn, - Rect (DayRect.Right - 6, DayRect.Bottom - 7, - DayRect.Right - 3, DayRect.Bottom - 4)); + TPSFillRect(RenderCanvas, Angle, RenderIn, + Rect(DayRect.Right - 20, DayRect.Bottom - 7, DayRect.Right - 17, DayRect.Bottom - 4)); + TPSFillRect(RenderCanvas, Angle, RenderIn, + Rect(DayRect.Right - 13, DayRect.Bottom - 7, DayRect.Right - 10, DayRect.Bottom - 4)); + TPSFillRect(RenderCanvas, Angle, RenderIn, + Rect(DayRect.Right - 6, DayRect.Bottom - 7, DayRect.Right - 3, DayRect.Bottom - 4)); break; end; @@ -737,22 +693,26 @@ var RenderCanvas.Brush.Color := ADEventBackgroundColor; RenderCanvas.Pen.Color := ADEventBorderColor; - TPSRectangle (RenderCanvas, Angle, RenderIn, - ADEventRect.Left + TextMargin, - ADEventRect.Top + TextMargin div 2, - ADEventRect.Right - TextMargin, - ADEventRect.Top + ADTextHeight + TextMargin div 2); - TPSTextOut (RenderCanvas,Angle, RenderIn, - AdEventRect.Left + TextMargin * 2 + TextMargin div 2, - AdEventRect.Top + TextMargin, - EventStr); + TPSRectangle(RenderCanvas, Angle, RenderIn, + ADEventRect.Left + TextMargin, + ADEventRect.Top + TextMargin div 2, + ADEventRect.Right - TextMargin, + ADEventRect.Top + ADTextHeight + TextMargin div 2 + ); + TPSTextOut(RenderCanvas,Angle, RenderIn, + AdEventRect.Left + TextMargin * 2 + TextMargin div 2, + AdEventRect.Top + TextMargin, + EventStr + ); Result := True; - wvEventArray[EAIndex].Rec := Rect (ADEventRect.Left + TextMargin, - ADEventRect.Top + TextMargin, - ADEventRect.Right - TextMargin, - ADEventRect.Bottom); + wvEventArray[EAIndex].Rec := Rect( + ADEventRect.Left + TextMargin, + ADEventRect.Top + TextMargin, + ADEventRect.Right - TextMargin, + ADEventRect.Bottom + ); wvEventArray[EAIndex].Event := Event; - Inc (EAIndex); + Inc(EAIndex); end; { for I := 0 to pred(ADEventsList.Count) do ... } end; { if MaxADEvents > 0 } @@ -764,11 +724,11 @@ var procedure DrawDays; var - DayRect : TRect; - TextRect : TRect; - I, J, SL : Integer; - EAIndex : Integer; - DayStr : string; + DayRect: TRect; + TextRect: TRect; + I, J, SL: Integer; + EAIndex: Integer; + DayStr: string; EventList: TList; TodayStartTime: Double; TodayEndTime: Double; @@ -794,13 +754,14 @@ var { build the first dayrect } DayRectHeight := (RealBottom - RealTop - wvHeaderHeight) div 3; if DrawingStyle = ds3D then - DayRect.TopLeft := Point (RealLeft + 1, - RealTop + wvHeaderHeight + 3) + DayRect.TopLeft := Point(RealLeft + 1, RealTop + wvHeaderHeight + 3) else - DayRect.TopLeft := Point (RealLeft + 1, - RealTop + wvHeaderHeight + 2); - DayRect.BottomRight := Point ((RealLeft + (RealRight - RealLeft) div 2) + 1, - RealTop + wvHeaderHeight + DayRectHeight); + DayRect.TopLeft := Point(RealLeft + 1, RealTop + wvHeaderHeight + 2); + DayRect.BottomRight := Point( + RealLeft + (RealRight - RealLeft) div 2 + 1, + RealTop + wvHeaderHeight + DayRectHeight + ); + { draw the day frames } for I := 0 to 6 do begin { draw day head} @@ -817,38 +778,31 @@ var DayStr := SysToUTF8(FormatDateTime(FDayHeadAttributes.DateFormat, StartDate + I)); {$ENDIF} SL := RenderCanvas.TextWidth(DayStr); - if SL > TextRect.Right - TextRect.Left then begin - DayStr := GetDisplayString(RenderCanvas, DayStr, 0, TextRect.Right - - TextRect.Left - TextMargin); - end; + if SL > TextRect.Right - TextRect.Left then + DayStr := GetDisplayString(RenderCanvas, DayStr, 0, TextRect.Right - TextRect.Left - TextMargin); SL := RenderCanvas.TextWidth(DayStr); TextRect.Left := TextRect.Right - SL - TextMargin; - TPSTextOut (RenderCanvas, Angle, RenderIn, - TextRect.Left, TextRect.Top + TextMargin - 1, DayStr); + TPSTextOut(RenderCanvas, Angle, RenderIn, + TextRect.Left, TextRect.Top + TextMargin - 1, DayStr + ); - if (DataStore <> nil) and (DataStore.Resource <> nil) - and (DataStore.Resource.Schedule.EventCountByDay(StartDate + I) > 0) - and (DayRect.Bottom - DayRect.Top >= (TextMargin * 2) + wvDayHeadHeight) then - begin + if (DataStore <> nil) and (DataStore.Resource <> nil) and + (DataStore.Resource.Schedule.EventCountByDay(StartDate + I) > 0) and + (DayRect.Bottom - DayRect.Top >= (TextMargin * 2) + wvDayHeadHeight) + then begin { events exist for this day } EventList := TList.Create; try { populate the eventlist with events for this day } DataStore.Resource.Schedule.EventsByDate(StartDate + I, EventList); { initialize TextRect for this day } - TextRect.TopLeft := Point (DayRect.Left, - DayRect.Top + wvDayHeadHeight); - TextRect.BottomRight := Point (DayRect.Right, - TextRect.Top + wvRowHeight); + TextRect.TopLeft := Point(DayRect.Left, DayRect.Top + wvDayHeadHeight); + TextRect.BottomRight := Point(DayRect.Right, TextRect.Top + wvRowHeight); { Handle All Day Events } - if DrawAllDayEvents (StartDate + I, - Rect (TextRect.Left, - TextRect.Top, - TextRect.Right, - DayRect.Bottom), - EAIndex) then begin - TextRect.Bottom := TextRect.Bottom + (ADEventsRect.Bottom - TextRect.Top); + if DrawAllDayEvents (StartDate + I, Rect(TextRect.Left, TextRect.Top, TextRect.Right, DayRect.Bottom), EAIndex) + then begin + TextRect.Bottom := TextRect.Bottom + ADEventsRect.Bottom - TextRect.Top; TextRect.Top := ADEventsRect.Bottom; end; @@ -865,15 +819,15 @@ var if TextRect.Bottom - TextMargin > DayRect.Bottom then begin RenderCanvas.Brush.Color := DotDotDotColor; { draw dot dot dot } - TPSFillRect (RenderCanvas, Angle, RenderIn, - Rect (DayRect.Right - 20, DayRect.Bottom - 7, - DayRect.Right - 17, DayRect.Bottom - 4)); - TPSFillRect (RenderCanvas, Angle, RenderIn, - Rect (DayRect.Right - 13, DayRect.Bottom - 7, - DayRect.Right - 10, DayRect.Bottom - 4)); - TPSFillRect (RenderCanvas, Angle, RenderIn, - Rect (DayRect.Right - 6, DayRect.Bottom - 7, - DayRect.Right - 3, DayRect.Bottom - 4)); + TPSFillRect(RenderCanvas, Angle, RenderIn, + Rect(DayRect.Right - 20, DayRect.Bottom - 7, DayRect.Right - 17, DayRect.Bottom - 4) + ); + TPSFillRect(RenderCanvas, Angle, RenderIn, + Rect(DayRect.Right - 13, DayRect.Bottom - 7, DayRect.Right - 10, DayRect.Bottom - 4) + ); + TPSFillRect(RenderCanvas, Angle, RenderIn, + Rect(DayRect.Right - 6, DayRect.Bottom - 7, DayRect.Right - 3, DayRect.Bottom - 4) + ); break; end; @@ -886,14 +840,14 @@ var if trunc(TodayEndTime) > trunc(StartDate + I) then //Last Event TodayEndTime := 0.9999; if ShowEventTime then - begin - if TimeFormat = tf24Hour then - DayStr := FormatDateTime('hh:nn',TodayStartTime) - + ' - ' + FormatDateTime('hh:nn',TodayEndTime) + ': ' + begin + if TimeFormat = tf24Hour then + DayStr := FormatDateTime('hh:nn',TodayStartTime) + ' - ' + + FormatDateTime('hh:nn',TodayEndTime) + ': ' else - DayStr := FormatDateTime('hh:nn AM/PM',TVpEvent(EventList.List^[j]).StartTime) - + ' - ' + FormatDateTime('hh:nn AM/PM',TVpEvent(EventList.List^[j]).EndTime) + ': '; - end; + DayStr := FormatDateTime('hh:nn AM/PM',TVpEvent(EventList.List^[j]).StartTime) + ' - ' + + FormatDateTime('hh:nn AM/PM',TVpEvent(EventList.List^[j]).EndTime) + ': '; + end; if DayStr = '' then DayStr := TVpEvent(EventList.List^[j]).Description else @@ -906,15 +860,13 @@ var StrLn := RenderCanvas.TextWidth(DayStr); if (StrLn > TextRect.Right - TextRect.Left - TextMargin) then - begin - DayStr := GetDisplayString(RenderCanvas, DayStr, 0, TextRect.Right - - TextRect.Left - (TextMargin * 2)); - end; + DayStr := GetDisplayString(RenderCanvas, DayStr, 0, TextRect.Right - TextRect.Left - (TextMargin * 2)); { write the event text } - TPSTextOut (RenderCanvas, Angle, RenderIn, - TextRect.Left + TextMargin, - TextRect.Top + (TextMargin div 2), DayStr); + TPSTextOut(RenderCanvas, Angle, RenderIn, + TextRect.Left + TextMargin, TextRect.Top + (TextMargin div 2), + DayStr + ); { update the EventArray } wvEventArray[EAIndex].Rec := TextRect; @@ -931,14 +883,14 @@ var { Draw focus rect if this is the current day } - if (not DisplayOnly) and - (StartDate + I = Trunc (FActiveDate)) and - (Focused) then - TPSDrawFocusRect (RenderCanvas, Angle, RenderIn, - Rect (DayRect.Left + 2, - DayRect.Top + wvDayHeadHeight + 2, - DayRect.Right - 2, - DayRect.Bottom - 2)); + if (not DisplayOnly) and (StartDate + I = Trunc (FActiveDate)) and Focused + then + TPSDrawFocusRect(RenderCanvas, Angle, RenderIn, Rect( + DayRect.Left + 2, + DayRect.Top + wvDayHeadHeight + 2, + DayRect.Right - 2, + DayRect.Bottom - 2 + )); { update WeekdayArray } wvWeekdayArray[I].Rec := DayRect; @@ -947,16 +899,24 @@ var if (I = 2) then begin { move the dayrect to the top of the next column } if DrawingStyle = ds3D then begin - DayRect.TopLeft := Point (RealLeft + (RealRight - RealLeft) div 2, - RealTop + wvHeaderHeight + 3); - DayRect.BottomRight := Point (RealRight - 2, - RealTop + wvHeaderHeight + DayRectHeight); + DayRect.TopLeft := Point( + RealLeft + (RealRight - RealLeft) div 2, + RealTop + wvHeaderHeight + 3 + ); + DayRect.BottomRight := Point( + RealRight - 2, + RealTop + wvHeaderHeight + DayRectHeight + ); end else begin - DayRect.TopLeft := Point (RealLeft + (RealRight - RealLeft) div 2, - RealTop + wvHeaderHeight + 2); - DayRect.BottomRight := Point (RealRight - 1, - RealTop + wvHeaderHeight + DayRectHeight); + DayRect.TopLeft := Point( + RealLeft + (RealRight - RealLeft) div 2, + RealTop + wvHeaderHeight + 2 + ); + DayRect.BottomRight := Point( + RealRight - 1, + RealTop + wvHeaderHeight + DayRectHeight + ); end; end @@ -975,47 +935,45 @@ var { Draw the center vertical line } RenderCanvas.Pen.Color := RealLineColor; - TPSMoveTo (RenderCanvas, Angle, RenderIn, - RealLeft + (RealRight - RealLeft) div 2, - RealTop + wvHeaderHeight + 2); - TPSLineTo (RenderCanvas, Angle, RenderIn, - RealLeft + (RealRight - RealLeft) div 2, - RealBottom - 1); + TPSMoveTo(RenderCanvas, Angle, RenderIn, + RealLeft + (RealRight - RealLeft) div 2, RealTop + wvHeaderHeight + 2 + ); + TPSLineTo(RenderCanvas, Angle, RenderIn, + RealLeft + (RealRight - RealLeft) div 2, RealBottom - 1 + ); - if (DataStore = nil) - or (DataStore.Resource = nil) - or (DataStore.Resource.Tasks.Count = 0) - then Exit; + if (DataStore = nil) or (DataStore.Resource = nil) or (DataStore.Resource.Tasks.Count = 0) + then Exit; end; {-} procedure Clear; begin RenderCanvas.Brush.Color := RealColor; - RenderCanvas.FillRect (RenderIn); + RenderCanvas.FillRect(RenderIn); end; {-} procedure SetMeasurements; begin - RealWidth := TPSViewportWidth (Angle, RenderIn); - RealHeight := TPSViewportHeight (Angle, RenderIn); - RealLeft := TPSViewportLeft (Angle, RenderIn); - RealRight := TPSViewportRight (Angle, RenderIn); - RealTop := TPSViewportTop (Angle, RenderIn); - RealBottom := TPSViewportBottom (Angle, RenderIn); + RealWidth := TPSViewportWidth(Angle, RenderIn); + RealHeight := TPSViewportHeight(Angle, RenderIn); + RealLeft := TPSViewportLeft(Angle, RenderIn); + RealRight := TPSViewportRight(Angle, RenderIn); + RealTop := TPSViewportTop(Angle, RenderIn); + RealBottom := TPSViewportBottom(Angle, RenderIn); if RenderDate = 0 then - StartDate := GetStartOfWeek (wvStartDate, FWeekStartsOn) + StartDate := GetStartOfWeek(wvStartDate, FWeekStartsOn) else - StartDate := GetStartOfWeek (RenderDate, FWeekStartsOn); + StartDate := GetStartOfWeek(RenderDate, FWeekStartsOn); RenderCanvas.Font.Assign(FDayHeadAttributes.Font); wvDayHeadHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin + 2 ; RenderCanvas.Font.Assign(FEventFont); - wvRowHeight := RenderCanvas.TextHeight(VpProductName) + (TextMargin div 2); + wvRowHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin div 2; RenderCanvas.Font.Assign(TFont(FHeadAttr.Font)); - wvHeaderHeight := RenderCanvas.TextHeight(VpProductName) + (TextMargin * 2); + wvHeaderHeight := RenderCanvas.TextHeight(VpProductName) + TextMargin * 2; end; {-} @@ -1024,15 +982,17 @@ var HeadTextRect: TRect; HeadStr: string; HeadStrLen : Integer; - function GetWeekOfYear(Datum:TDateTime):byte; + + function GetWeekOfYear(Datum: TDateTime): byte; var - AYear,dummy :word; - First :TDateTime; + AYear, dummy:word; + First: TDateTime; begin - DecodeDate(Datum+((8-DayOfWeek(Datum)) mod 7)-3, AYear, dummy,dummy); - First :=EncodeDate(AYear, 1, 1); - Result:=(trunc(Datum-First-3+(DayOfWeek(First)+1) mod 7) div 7)+1; + DecodeDate(Datum+((8-DayOfWeek(Datum)) mod 7) - 3, AYear, dummy,dummy); + First := EncodeDate(AYear, 1, 1); + Result := (trunc(Datum-First-3+(DayOfWeek(First)+1) mod 7) div 7) + 1; end; + begin RenderCanvas.Brush.Color := RealHeadAttrColor; RenderCanvas.Font.Assign(TFont(FHeadAttr.Font)); @@ -1057,10 +1017,10 @@ var HeadRect.Top := RealTop + 2; HeadRect.Right := RealRight - 3; HeadRect.Bottom := RealTop + wvHeaderHeight; - TPSFillRect (RenderCanvas, Angle, RenderIn, HeadRect); - DrawBevelRect (RenderCanvas, - TPSRotateRectangle (Angle, RenderIn, HeadRect), - BevelHighlightColor, BevelDarkShadow); + TPSFillRect(RenderCanvas, Angle, RenderIn, HeadRect); + DrawBevelRect(RenderCanvas, TPSRotateRectangle(Angle, RenderIn, HeadRect), + BevelHighlightColor, BevelDarkShadow + ); end else begin HeadRect.Left := RealLeft + 1; HeadRect.Top := RealTop + 1; @@ -1069,19 +1029,25 @@ var end; { build header caption } - HeadStr := HeadStr + RSWeekof + ' ' + FormatDateTime(DateLabelFormat, StartDate)+' (KW'+IntToStr(GetWeekOfYear(StartDate))+')'; + HeadStr := HeadStr + Format('%s %s (%s %d)', [ + RSWeekOf, FormatDateTime(DateLabelFormat, StartDate), RSCalendarWeekAbbr, GetWeekOfYear(StartDate) + ]); +// HeadStr := HeadStr + RSWeekof + ' ' + FormatDateTime(DateLabelFormat, StartDate)+' (KW'+IntToStr(GetWeekOfYear(StartDate))+')'; { draw the text } - if (DisplayOnly) and - (RenderCanvas.TextWidth (HeadStr) >= RenderIn.Right - RenderIn.Left) then - HeadTextRect.TopLeft:= Point (RealLeft + TextMargin * 2, - HeadRect.Top) - else if DisplayOnly then - HeadTextRect.TopLeft := Point (RealLeft + (RealRight - RealLeft - - RenderCanvas.TextWidth (HeadStr)) div 2, - HeadRect.Top) + if DisplayOnly and (RenderCanvas.TextWidth(HeadStr) >= RenderIn.Right - RenderIn.Left) + then + HeadTextRect.TopLeft:= Point(RealLeft + TextMargin * 2, HeadRect.Top) else - HeadTextRect.TopLeft := Point (RealLeft + Trunc(wvHeaderHeight * 0.8) * 2 + TextMargin * 2, - HeadRect.Top); + if DisplayOnly then + HeadTextRect.TopLeft := Point( + RealLeft + (RealRight - RealLeft - RenderCanvas.TextWidth(HeadStr)) div 2, + HeadRect.Top + ) + else + HeadTextRect.TopLeft := Point( + RealLeft + Trunc(wvHeaderHeight * 0.8) * 2 + TextMargin * 2, + HeadRect.Top + ); HeadTextRect.BottomRight := HeadRect.BottomRight; { Fix Header String } HeadStrLen := RenderCanvas.TextWidth(HeadStr); @@ -1095,8 +1061,11 @@ var wvSpinButtons.Width := wvSpinButtons.Height * 2; wvSpinButtons.Left := TextMargin; wvSpinButtons.Top := (wvHeaderHeight - wvSpinButtons.Height) div 2 + 2; - TPSTextOut (RenderCanvas, Angle, RenderIn, HeadTextRect.Left + TextMargin, - HeadTextRect.Top + TextMargin, HeadStr); + TPSTextOut(RenderCanvas, Angle, RenderIn, + HeadTextRect.Left + TextMargin, + HeadTextRect.Top + TextMargin, + HeadStr + ); end; {-} @@ -1104,78 +1073,75 @@ var begin if FDrawingStyle = dsFlat then begin { draw an outer and inner bevel } - DrawBevelRect (RenderCanvas, - TPSRotateRectangle (Angle, RenderIn, - Rect (RealLeft, RealTop, - RealRight - 1, RealBottom - 1)), - BevelShadowColor, - BevelHighlightColor); - DrawBevelRect (RenderCanvas, - TPSRotateRectangle (Angle, RenderIn, - Rect (RealLeft + 1, RealTop + 1, - RealRight - 2, RealBottom - 2)), - BevelShadowColor, - BevelHighlightColor); - end else if FDrawingStyle = ds3d then begin - { draw a 3d bevel } - DrawBevelRect (RenderCanvas, - TPSRotateRectangle (Angle, RenderIn, - Rect (RealLeft, RealTop, - RealRight - 1, RealBottom - 1)), - BevelShadowColor, - BevelShadowColor); - DrawBevelRect (RenderCanvas, - TPSRotateRectangle (Angle, RenderIn, - Rect (RealLeft + 1, RealTop + 1, - RealRight - 2, RealBottom - 2)), - BevelDarkShadow, - BevelButtonFace); + DrawBevelRect(RenderCanvas, + TPSRotateRectangle(Angle, RenderIn, Rect(RealLeft, RealTop, RealRight - 1, RealBottom - 1)), + BevelShadowColor, + BevelHighlightColor + ); + DrawBevelRect(RenderCanvas, + TPSRotateRectangle(Angle, RenderIn, Rect(RealLeft + 1, RealTop + 1, RealRight - 2, RealBottom - 2)), + BevelShadowColor, + BevelHighlightColor + ); + end else + if FDrawingStyle = ds3d then begin + { draw a 3d bevel } + DrawBevelRect(RenderCanvas, + TPSRotateRectangle(Angle, RenderIn, Rect(RealLeft, RealTop, RealRight - 1, RealBottom - 1)), + BevelShadowColor, + BevelShadowColor + ); + DrawBevelRect(RenderCanvas, + TPSRotateRectangle(Angle, RenderIn, Rect (RealLeft + 1, RealTop + 1, RealRight - 2, RealBottom - 2)), + BevelDarkShadow, + BevelButtonFace + ); end; end; {-} + begin if DisplayOnly then begin - BevelHighlightColor := clBlack; - BevelShadowColor := clBlack; - BevelDarkShadow := clBlack; - BevelButtonFace := clBlack; - RealLineColor := clBlack; - RealColor := clWhite; - RealDayHeadAttrColor := clSilver; - RealHeadAttrColor := clSilver; - ADBackgroundColor := clWhite; + BevelHighlightColor := clBlack; + BevelShadowColor := clBlack; + BevelDarkShadow := clBlack; + BevelButtonFace := clBlack; + RealLineColor := clBlack; + RealColor := clWhite; + RealDayHeadAttrColor := clSilver; + RealHeadAttrColor := clSilver; + ADBackgroundColor := clWhite; ADEventBackgroundColor := clWhite; - ADEventBorderColor := clSilver; + ADEventBorderColor := clSilver; end else begin - BevelHighlightColor := clBtnHighlight; - BevelShadowColor := clBtnShadow; - BevelDarkShadow := cl3DDkShadow; - BevelButtonFace := clBtnFace; - RealLineColor := LineColor; - RealColor := Color; - RealDayHeadAttrColor := FDayHeadAttributes.Color; - RealHeadAttrColor := FHeadAttr.Color; - ADBackgroundColor := AllDayEventAttributes.BackgroundColor; + BevelHighlightColor := clBtnHighlight; + BevelShadowColor := clBtnShadow; + BevelDarkShadow := cl3DDkShadow; + BevelButtonFace := clBtnFace; + RealLineColor := LineColor; + RealColor := Color; + RealDayHeadAttrColor := FDayHeadAttributes.Color; + RealHeadAttrColor := FHeadAttr.Color; + ADBackgroundColor := AllDayEventAttributes.BackgroundColor; ADEventBackgroundColor := AllDayEventAttributes.EventBackgroundColor; - ADEventBorderColor := AllDayEventAttributes.EventBorderColor; + ADEventBorderColor := AllDayEventAttributes.EventBorderColor; end; - DotDotDotColor := clBlack; + DotDotDotColor := clBlack; wvPainting := true; SavePenStyle := RenderCanvas.Pen.Style; SaveBrushColor := RenderCanvas.Brush.Color; SavePenColor := RenderCanvas.Pen.Color; - RenderCanvas.Pen.Style := psSolid; - RenderCanvas.Pen.Width := 1; - RenderCanvas.Pen.Mode := pmCopy; + RenderCanvas.Pen.Style := psSolid; + RenderCanvas.Pen.Width := 1; + RenderCanvas.Pen.Mode := pmCopy; RenderCanvas.Brush.Style := bsSolid; - Rgn := CreateRectRgn (RenderIn.Left, RenderIn.Top, - RenderIn.Right, RenderIn.Bottom); + Rgn := CreateRectRgn(RenderIn.Left, RenderIn.Top, RenderIn.Right, RenderIn.Bottom); try - SelectClipRgn (RenderCanvas.Handle, Rgn); + SelectClipRgn(RenderCanvas.Handle, Rgn); { clear client area } Clear; @@ -1192,11 +1158,10 @@ begin { draw the borders } DrawBorders; - { reinstate canvas settings} - finally - SelectClipRgn (RenderCanvas.Handle, 0); - DeleteObject (Rgn); + { reinstate canvas settings} + SelectClipRgn(RenderCanvas.Handle, 0); + DeleteObject(Rgn); end; RenderCanvas.Pen.Style := SavePenStyle; @@ -1226,9 +1191,8 @@ begin Str := '"' + ActiveEvent.Description + '"'; if Verify then - DoIt := (MessageDlg(RSDelete + ' ' + Str + ' ' + RSFromSchedule - + #13#10#10 + RSPermanent, mtconfirmation, - [mbYes, mbNo], 0) = mrYes); + DoIt := (MessageDlg(RSDelete + ' ' + Str + ' ' + RSFromSchedule + #13#10#10 + RSPermanent, + mtConfirmation, [mbYes, mbNo], 0) = mrYes); if DoIt then begin ActiveEvent.Deleted := true; @@ -1240,7 +1204,6 @@ begin end; {=====} - procedure TVpWeekView.wvSpinButtonClick(Sender: TObject; Button: TUDBtnType); begin if Button = btNext then @@ -1261,8 +1224,8 @@ end; procedure TVpWeekView.SetActiveEvent(AValue: TVpEvent); begin - if FaActiveEvent=AValue then Exit; - FaActiveEvent:=AValue; + if FaActiveEvent = AValue then Exit; + FaActiveEvent := AValue; end; procedure TVpWeekView.SetDrawingStyle(Value: TVpDrawingStyle); @@ -1366,7 +1329,7 @@ begin with Params do begin Style := Style or WS_TABSTOP; -{$IFNDEF LCL} +{$IFDEF DELPHI} WindowClass.style := CS_DBLCLKS; {$ENDIF} end; @@ -1381,9 +1344,9 @@ end; {=====} {$IFNDEF LCL} -procedure TVpWeekView.WMLButtonDown(var Msg : TWMLButtonDown); +procedure TVpWeekView.WMLButtonDown(var Msg: TWMLButtonDown); {$ELSE} -procedure TVpWeekView.WMLButtonDown(var Msg : TLMLButtonDown); +procedure TVpWeekView.WMLButtonDown(var Msg: TLMLButtonDown); {$ENDIF} begin inherited; @@ -1408,9 +1371,9 @@ end; {=====} {$IFNDEF LCL} -procedure TVpWeekView.WMLButtonDblClk(var Msg : TWMLButtonDblClk); +procedure TVpWeekView.WMLButtonDblClk(var Msg: TWMLButtonDblClk); {$ELSE} -procedure TVpWeekView.WMLButtonDblClk(var Msg : TLMLButtonDblClk); +procedure TVpWeekView.WMLButtonDblClk(var Msg: TLMLButtonDblClk); {$ENDIF} var StartTime, EndTime: TDateTime; @@ -1418,8 +1381,8 @@ begin inherited; wvClickTimer.Enabled := false; - if not CheckCreateResource then - Exit; + if not CheckCreateResource then + Exit; if DataStore = nil then Exit; @@ -1443,7 +1406,10 @@ begin StartTime := trunc(Date) + 1 / 2; { default to 12:00 noon } EndTime := StartTime + (30 / MinutesInDay); { StartTime + 30 minutes } ActiveEvent := DataStore.Resource.Schedule.AddEvent( - DataStore.GetNextID('Events'), StartTime, EndTime); + DataStore.GetNextID('Events'), + StartTime, + EndTime + ); { edit this new event } wvSpawnEventEditDialog(True); end; @@ -1452,9 +1418,9 @@ end; {=====} {$IFNDEF LCL} -procedure TVpWeekView.WMRButtonDown(var Msg : TWMRButtonDown); +procedure TVpWeekView.WMRButtonDown(var Msg: TWMRButtonDown); {$ELSE} -procedure TVpWeekView.WMRButtonDown(var Msg : TLMRButtonDown); +procedure TVpWeekView.WMRButtonDown(var Msg: TLMRButtonDown); {$ENDIF} var i: Integer; @@ -1481,9 +1447,8 @@ end; procedure TVpWeekView.InitializeDefaultPopup; var - NewItem : TMenuItem; - NewSubItem : TMenuItem; - + NewItem: TMenuItem; + NewSubItem: TMenuItem; begin if RSWeekPopupAdd <> '' then begin NewItem := TMenuItem.Create (Self); @@ -1574,42 +1539,47 @@ begin end; {=====} -procedure TVpWeekView.PopupAddEvent (Sender : TObject); +procedure TVpWeekView.PopupAddEvent(Sender: TObject); var - StartTime : TDateTime; - EndTime : TDateTime; + StartTime: TDateTime; + EndTime: TDateTime; begin - if ReadOnly then - Exit; - if not CheckCreateResource then - Exit; - if not Assigned (DataStore) then - Exit; - if not Assigned (DataStore.Resource) then - Exit; + if ReadOnly then + Exit; + if not CheckCreateResource then + Exit; + if not Assigned(DataStore) then + Exit; + if not Assigned(DataStore.Resource) then + Exit; + StartTime := trunc(Date) + 1 / 2; { default to 12:00 noon } EndTime := StartTime + (30 / MinutesInDay); { StartTime + 30 minutes } - ActiveEvent := DataStore.Resource.Schedule.AddEvent ( - DataStore.GetNextID ('Events'), StartTime, EndTime); + ActiveEvent := DataStore.Resource.Schedule.AddEvent( + DataStore.GetNextID('Events'), + StartTime, + EndTime + ); + { edit this new event } - wvSpawnEventEditDialog (True); + wvSpawnEventEditDialog(True); end; {=====} -procedure TVpWeekView.PopupDeleteEvent (Sender : TObject); +procedure TVpWeekView.PopupDeleteEvent(Sender: TObject); begin - if ReadOnly then - Exit; + if ReadOnly then + Exit; if ActiveEvent <> nil then DeleteActiveEvent (True); end; {=====} -procedure TVpWeekView.PopupEditEvent (Sender : TObject); +procedure TVpWeekView.PopupEditEvent(Sender: TObject); begin - if ReadOnly then - Exit; + if ReadOnly then + Exit; if ActiveEvent <> nil then { edit this Event } wvSpawnEventEditDialog(False); @@ -1623,28 +1593,27 @@ begin end; {=====} -procedure TVpWeekView.PopupToday (Sender : TObject); +procedure TVpWeekView.PopupToday(Sender: TObject); begin Date := Now; end; {=====} -procedure TVpWeekView.PopupNextWeek (Sender : TObject); +procedure TVpWeekView.PopupNextWeek(Sender: TObject); begin Date := Date + 7; end; {=====} -procedure TVpWeekView.PopupPrevWeek (Sender : TObject); +procedure TVpWeekView.PopupPrevWeek(Sender: TObject); begin Date := Date - 7; end; {=====} -procedure TVpWeekView.PopupNextMonth (Sender : TObject); +procedure TVpWeekView.PopupNextMonth(Sender: TObject); var - M, D, Y : Word; - + M, D, Y: Word; begin DecodeDate(Date, Y, M, D); if M = 12 then begin @@ -1661,7 +1630,7 @@ end; procedure TVpWeekView.PopupPrevMonth(Sender : TObject); var - M, D, Y : Word; + M, D, Y: Word; begin DecodeDate(Date, Y, M, D); if M = 1 then begin @@ -1676,23 +1645,21 @@ begin end; {=====} -procedure TVpWeekView.PopupNextYear (Sender : TObject); +procedure TVpWeekView.PopupNextYear(Sender: TObject); var - M, D, Y : Word; - + M, D, Y: Word; begin - DecodeDate (Date, Y, M, D); - Date := EncodeDate (Y + 1, M, 1); + DecodeDate(Date, Y, M, D); + Date := EncodeDate(Y + 1, M, 1); end; {=====} -procedure TVpWeekView.PopupPrevYear (Sender : TObject); +procedure TVpWeekView.PopupPrevYear(Sender: TObject); var M, D, Y : Word; - begin - DecodeDate (Date, Y, M, D); - Date := EncodeDate (Y - 1, M, 1); + DecodeDate(Date, Y, M, D); + Date := EncodeDate(Y - 1, M, 1); end; {=====} @@ -1719,7 +1686,7 @@ begin if AllowIt then begin ActiveEvent.Changed := true; DataStore.PostEvents; - if Assigned(FOnAddEvent) then + if Assigned(FOnAddEvent) then FOnAddEvent(self, ActiveEvent); Invalidate; end else begin @@ -1746,16 +1713,16 @@ procedure TVpWeekView.wvSetDateByCoord(Point: TPoint); var I: Integer; begin - for I := 0 to pred(Length(wvWeekdayArray)) do begin - if (Point.X >= wvWeekdayArray[I].Rec.Left) - and (Point.X <= wvWeekdayArray[I].Rec.Right) - and (Point.Y >= wvWeekdayArray[I].Rec.Top) - and (Point.Y <= wvWeekdayArray[I].Rec.Bottom) then begin - Date := wvWeekdayArray[I].Day; - Invalidate; - Exit; - end; - end; + for I := 0 to pred(Length(wvWeekdayArray)) do + if (Point.X >= wvWeekdayArray[I].Rec.Left) and + (Point.X <= wvWeekdayArray[I].Rec.Right) and + (Point.Y >= wvWeekdayArray[I].Rec.Top) and + (Point.Y <= wvWeekdayArray[I].Rec.Bottom) + then begin + Date := wvWeekdayArray[I].Day; + Invalidate; + Exit; + end; end; {=====} @@ -1776,10 +1743,11 @@ begin Exit; end; - if (Pt.X > wvEventArray[I].Rec.Left) - and (Pt.X < wvEventArray[I].Rec.Right) - and (Pt.Y > wvEventArray[I].Rec.Top) - and (Pt.Y < wvEventArray[I].Rec.Bottom) then begin + if (Pt.X > wvEventArray[I].Rec.Left) and + (Pt.X < wvEventArray[I].Rec.Right) and + (Pt.Y > wvEventArray[I].Rec.Top) and + (Pt.Y < wvEventArray[I].Rec.Bottom) + then begin { point falls inside this event's rectangle } wvHotPoint := Pt; ActiveEvent := TVpEvent(wvEventArray[I].Event); @@ -1787,7 +1755,6 @@ begin result := true; Exit; end - else begin { point is not within the boundaries of this event's rectangle. } ActiveEvent := nil; @@ -1828,10 +1795,12 @@ begin wvInPlaceEditor.Parent := self; wvInPlaceEditor.OnExit := EndEdit; end; - wvInPlaceEditor.SetBounds(wvActiveEventRec.Left + TextMargin, - wvActiveEventRec.Top, - wvActiveEventRec.Right - (TextMargin*2), - wvActiveEventRec.Bottom- (TextMargin*2)); + wvInPlaceEditor.SetBounds( + wvActiveEventRec.Left + TextMargin, + wvActiveEventRec.Top, + wvActiveEventRec.Right - TextMargin * 2, + wvActiveEventRec.Bottom - TextMargin * 2 + ); wvInplaceEditor.Show; wvInPlaceEditor.Text := ActiveEvent.Description; Invalidate; @@ -1844,7 +1813,6 @@ end; procedure TVpWeekView.KeyDown(var Key: Word; Shift: TShiftState); var PopupPoint : TPoint; - begin case Key of VK_DELETE : DeleteActiveEvent(true); @@ -1910,25 +1878,23 @@ begin end; Invalidate; end; - VK_INSERT : PopupAddEvent (Self); + VK_INSERT : PopupAddEvent(Self); {$IFNDEF LCL} VK_TAB : if ssShift in Shift then - Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, False)) + Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False)) else - Windows.SetFocus (GetNextDlgTabItem(GetParent(Handle), Handle, True)); + Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True)); {$ENDIF} - VK_F10 : - if (ssShift in Shift) and not (Assigned (PopupMenu)) then begin + VK_F10: + if (ssShift in Shift) and not Assigned(PopupMenu) then begin PopupPoint := GetClientOrigin; - FDefaultPopup.Popup (PopupPoint.x + 10, - PopupPoint.y + 10); + FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); end; - VK_APPS : + VK_APPS: if not Assigned (PopupMenu) then begin PopupPoint := GetClientOrigin; - FDefaultPopup.Popup (PopupPoint.x + 10, - PopupPoint.y + 10); + FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10); end; end; end;