-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathODCalenReg.pas
147 lines (125 loc) · 4.09 KB
/
ODCalenReg.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
unit ODCalenReg;
{
My Power Station Technology (Pty) Ltd - was Orbital Decisions
P.O.Box 1080, Milnerton 7435, South Africa
http://www.orbital.co.za/text/prodlist.htm
Copyright (c) 1998-2019
Use at your own risk!
}
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.Menus, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, Vcl.Mask,
Data.DB, DesignIntf, DesignEditors,
ODCalend, ODPopcal, ODDBCal, ODTime;
Type
TODCalendarAboutProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
TODPopupCalendarEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
TODDateFieldProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
end;
procedure Register;
implementation
procedure Register;
begin
// ODCalend
RegisterComponents('Orbital', [TODCalendar]);
RegisterPropertyEditor(TypeInfo(string),
TODCustomCalendar, 'About', TODCalendarAboutProperty);
// ODPopCal
RegisterComponents('Orbital', [TODCalendarDialog, TODPopupCalendar]);
RegisterPropertyEditor(TypeInfo(string),
TODCalendarDialog, 'About', TODCalendarAboutProperty);
RegisterPropertyEditor(TypeInfo(string),
TODPopupCalendar, 'About', TODCalendarAboutProperty);
RegisterComponentEditor(TODPopupCalendar, TODPopupCalendarEditor);
// ODDBCal
RegisterComponents('Orbital',
[TODDBCalendar, TODDBPopupCalendar]);
RegisterPropertyEditor(TypeInfo(string), TODDBCalendar,
'StartDateName', TODDateFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TODDBCalendar,
'FinishDateName', TODDateFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TODDBPopupCalendar,
'StartDateName', TODDateFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TODDBPopupCalendar,
'FinishDateName', TODDateFieldProperty);
// ODTime
RegisterComponents('Orbital', [TODTimePicker, TODDBTimePicker]);
end;
// TODCalendarAboutProperty Implementation
function TODCalendarAboutProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
procedure TODCalendarAboutProperty.Edit;
begin
MessageDlg('Orbital Decisions Calendar Components ' + ODCalendarVersion +
#13#13 + 'By: My Power Station Technology (Pty) Ltd'#13 +
'Delphi development, solutions and business components'#13#13 +
'Addr.: P.O.Box 1080, Milnerton, 7435, South Africa'#13 +
'EMail: [email protected]'#13 +
'URL: http://www.orbital.co.za',
mtInformation, [mbOK], 0);
end;
//TODPopupCalendarEditor
procedure TODPopupCalendarEditor.ExecuteVerb(Index: Integer);
begin
if Index = 0 then
with (Component as TODPopupCalendar) do
begin
StartDate := 0;
FinishDate := 0;
end;
end;
function TODPopupCalendarEditor.GetVerb(Index: Integer): string;
begin
if Index = 0 then
Result := 'Clear &Dates';
end;
function TODPopupCalendarEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
//TODDateFieldProperty
function TODDateFieldProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paRevertable];
end;
procedure TODDateFieldProperty.GetValues(Proc: TGetStrProc);
var
ix: Integer;
ac: Boolean;
ds: TDataSource;
begin
if GetComponent(0) is TODDBCalendar then
ds := TODDBCalendar(GetComponent(0)).DataSource
else if GetComponent(0) is TODDBPopupCalendar then
ds := TODDBPopupCalendar(GetComponent(0)).DataSource
else
raise EComponentError.Create('Unknown component');
if ds.DataSet <> nil then
with ds.DataSet do
begin
ac := Active;
if not ac and (FieldCount = 0) then //if closed & no static fields
Open; //then open to get dynamic fields
for ix := 0 to FieldCount-1 do
Proc(Fields[ix].FieldName);
Active := ac;
end;
end;
end.