-
Notifications
You must be signed in to change notification settings - Fork 1
/
VCL.ODCalenReg.pas
147 lines (125 loc) · 4.23 KB
/
VCL.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 VCL.ODCalenReg;
{
My Power Station Technology (Pty) Ltd - was Orbital Decisions
P.O.Box 1080, Milnerton 7435, South Africa
components@mypowerstation.biz
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,
VCL.ODCalend, VCL.ODPopcal, VCL.ODDBCal, VCL.ODTime;
Type
TODVCLCalendarAboutProperty = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
TODVCLPopupCalendarEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
TODVCLDateFieldProperty = class(TStringProperty)
public
function GetAttributes: TPropertyAttributes; override;
procedure GetValues(Proc: TGetStrProc); override;
end;
procedure Register;
implementation
procedure Register;
begin
// ODCalend
RegisterComponents('Orbital', [TODVCLCalendar]);
RegisterPropertyEditor(TypeInfo(string),
TODVCLCustomCalendar, 'About', TODVCLCalendarAboutProperty);
// ODPopCal
RegisterComponents('Orbital', [TODVCLCalendarDialog, TODVCLPopupCalendar]);
RegisterPropertyEditor(TypeInfo(string),
TODVCLCalendarDialog, 'About', TODVCLCalendarAboutProperty);
RegisterPropertyEditor(TypeInfo(string),
TODVCLPopupCalendar, 'About', TODVCLCalendarAboutProperty);
RegisterComponentEditor(TODVCLPopupCalendar, TODVCLPopupCalendarEditor);
// ODDBCal
RegisterComponents('Orbital',
[TODVCLDBCalendar, TODVCLDBPopupCalendar]);
RegisterPropertyEditor(TypeInfo(string), TODVCLDBCalendar,
'StartDateName', TODVCLDateFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TODVCLDBCalendar,
'FinishDateName', TODVCLDateFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TODVCLDBPopupCalendar,
'StartDateName', TODVCLDateFieldProperty);
RegisterPropertyEditor(TypeInfo(string), TODVCLDBPopupCalendar,
'FinishDateName', TODVCLDateFieldProperty);
// ODTime
RegisterComponents('Orbital', [TODVCLTimePicker, TODVCLDBTimePicker]);
end;
// TODVCLCalendarAboutProperty Implementation
function TODVCLCalendarAboutProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end;
procedure TODVCLCalendarAboutProperty.Edit;
begin
MessageDlg('Orbital Decisions Calendar Components ' + ODVCLCalendarVersion +
#13#13 + '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: components@mypowerstation.biz'#13 +
'URL: http://www.orbital.co.za',
mtInformation, [mbOK], 0);
end;
//TODVCLPopupCalendarEditor
procedure TODVCLPopupCalendarEditor.ExecuteVerb(Index: Integer);
begin
if Index = 0 then
with (Component as TODVCLPopupCalendar) do
begin
StartDate := 0;
FinishDate := 0;
end;
end;
function TODVCLPopupCalendarEditor.GetVerb(Index: Integer): string;
begin
if Index = 0 then
Result := 'Clear &Dates';
end;
function TODVCLPopupCalendarEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
//TODVCLDateFieldProperty
function TODVCLDateFieldProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paMultiSelect, paValueList, paRevertable];
end;
procedure TODVCLDateFieldProperty.GetValues(Proc: TGetStrProc);
var
ix: Integer;
ac: Boolean;
ds: TDataSource;
begin
if GetComponent(0) is TODVCLDBCalendar then
ds := TODVCLDBCalendar(GetComponent(0)).DataSource
else if GetComponent(0) is TODVCLDBPopupCalendar then
ds := TODVCLDBPopupCalendar(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.