-
Notifications
You must be signed in to change notification settings - Fork 5
/
TSDesign.pas
3247 lines (2787 loc) · 106 KB
/
TSDesign.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{*******************************************************}
{ }
{ ObjectSight Visual Components }
{ TopGrid Component Editor }
{ }
{ Copyright (c) 1997 - 2001 ObjectSight }
{ }
{*******************************************************}
unit TsDesign;
{$INCLUDE TSCmpVer}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, MMSystem,
ComCtrls, TSDBGrid, StdCtrls, Grids_ts, TSGrid, ExtCtrls, TypInfo, TSSetLib, ClipBrd,
RichEdit,
{$IFDEF TSVER_V6} Variants, IniFiles, DesignIntf, DesignEditors, {$ELSE} DsgnIntf, {$ENDIF}
{$IFDEF TSVER_V5} Contnrs, Menus, {$ENDIF} TSCommon;
type
TtsGridInspector = class;
TtsComponentEditor = class;
TtsPropertySet = class;
TtsPropertyElement = class;
TtsPropertyPointerElement = class;
TtsPropertyPointerSet = class;
TtsActualValueElement = class;
TtsActualValueSet = class;
TtsGroupSet = class;
TtsGroupElement = class;
tsScanObjectsState = (soStart, soScan, soEnd);
tsShowPropertyValueType = (pvShowAlways, pvShowNever, pvShowToggle1, pvShowToggle2);
tsShowPropertyValueSet = set of tsShowPropertyValueType;
tsInspectorElementType = (iePropertyElement, ieGroupElement);
tsPropertyNilType = (pnUnKnown, pnAuto, pnTrue, pnFalse);
tsValueSource = (vsComponent, vsValue, vsstrValue);
TtsGetComponentEvent = procedure (Sender: TObject; var Component: TPersistent) of object;
TtsGetComponentIdEvent = procedure (Sender: TObject; Component: TPersistent; var ComponentId: string) of object;
TtsGetComponentWithIdEvent = procedure (Sender: TObject; ComponentId: string; var Component: TPersistent) of object;
TtsGetComponentInfoEvent = procedure (Sender: TObject; DisplayMode: TtsGroupElement) of object;
TtsGetComponentSelectionEvent = procedure (Sender: TObject; var ComponentSelection: Pointer; var ComponentCount: integer) of object;
TtsGetComponentSelectionChangedEvent = procedure (Sender: TObject; CurSelection: Pointer; var Changed: Boolean) of object;
TtsDestroyComponentSelectionEvent = procedure (Sender: TObject; ComponentSelection: Pointer) of object;
TtsGetStringEvent = procedure (Sender: TObject; var Value: string) of object;
TtsScanObjectsEvent = procedure (Sender: TObject; State: tsScanObjectsState; Writing: Boolean; Count: Longint; var Cancel: Boolean) of object;
TtsSetValuesEvent = procedure (Sender: TObject; State: tsScanObjectsState; Component: Tpersistent; PropertyElement: TtsPropertyElement; strValue: string; Value: Variant; ValueSource: tsValueSource; ValueSet: Boolean; var Cancel: Boolean) of object;
{TtsInspectorRow}
{Contains information on each row in the TtsGridInspector}
TtsInspectorRow = record
Level: integer;
Opened: Boolean;
ButtonSet: Boolean;
Deleted: Boolean;
Selected: Boolean;
SelectedChanged: integer;
Parent: integer;
SubFullySelected: Boolean;
InspectorElementType: tsInspectorElementType;
PropertyElement: TtsPropertyElement;
GroupElement: TtsGroupElement;
end;
PtsInspectorRows = ^TtsInspectorRows;
TtsInspectorRows = array[0..(MaxListSize div ((SizeOf(TtsInspectorRow) div SizeOf(Longint)) + 1))] of TtsInspectorRow;
{TtsGridInspector}
{Object inspector type component. Used to display and set the component
properties and their values}
TtsGridInspector = class(TtsGrid)
protected
FComponentEditor: TtsComponentEditor;
CurrentComponentEditor: TtsComponentEditor;
PropertyValueList: TStringList;
FInspectorRows: PtsInspectorRows;
FCurMaxInspectorRowCount: integer;
FInspectorRowCount: integer;
SelectedLastChanged: integer;
SelectedLastUpdated: integer;
InspectorKeyIsDown: Boolean;
FComboOpen: Boolean;
FDisplayModeName: string;
procedure DoButtonClick(DataCol: Longint; DataRow: Variant); override;
procedure DoDblClickCell(DataCol: Longint; DataRow: Variant; Pos: TtsClickPosition); override;
procedure DoComboInit(DataCol: Longint; DataRow: Variant); override;
procedure DoComboCellLoaded(DataCol, DataRow: Longint; var Value: Variant); override;
procedure DoComboGetValue(GridDataCol: Longint; GridDataRow, ComboDataRow: Variant; var Value: Variant); override;
procedure DoComboRollUp(DataCol: Longint; DataRow: Variant); override;
procedure DoCellEdit(DataCol: Longint; DataRow: Variant; ByUser: Boolean); override;
procedure DoEndCellEdit(DataCol: Longint; DataRow: Variant; var Cancel: Boolean); override;
procedure DoKeyDown(var Key: Word; Shift: TShiftState); override;
procedure DoKeyUp(var Key: Word; Shift: TShiftState); override;
procedure DoComboDropDown(DataCol: Longint; DataRow: Variant); override;
procedure DoStartCellEdit(DataCol: Longint; DataRow: Variant; var Cancel: Boolean); override;
procedure DoColResized(RowColnr: Longint); override;
procedure DoRowChanged(OldDataRow, NewDataRow: Variant); override;
procedure DoExit; override;
procedure DoCellLoaded(DataCol, DataRow: Longint; var Value: Variant); override;
function ActivateDoGetDrawInfo: Boolean; override;
procedure DoGetDrawInfo(DataCol, DataRow: Longint; var DrawInfo: TtsDrawInfo); override;
procedure DoMouseStatusChanged(OldStatus, NewStatus: TtsMouseStatus); override;
procedure SetButton(DataRow: Integer);
procedure GetMultiValue;
procedure SetDisplayModeName(Value: string);
procedure SetRowProperties;
function GetInspectorRowCount: integer;
procedure SetInspectorRowCount(NewValue: integer);
procedure PlaceGroupSetInInspectorList(Node : TtsSetNode; Parent : integer);
procedure PlacePropertiesInInspectorList(Node : TtsSetNode; Parent : integer; SubProperties: Boolean);
procedure PlaceGroupElementInInspectorList(Group: TtsGroupElement; Parent: integer);
procedure PlaceMarkedPropertiesInInspectorList(Node : TtsSetNode; Parent: integer);
function GetInspectorRows: PtsInspectorRows;
procedure SetInspectorRows;
procedure GetDisplayName(InspectorRow: TtsInspectorRow; var DisplayName, IndentValue: string);
procedure GetPropertyValues(const Value: string);
procedure SetComponentEditor(Value: TtsComponentEditor);
procedure UpdateContents(PropertiesChanged, SelectedComponentsChanged: Boolean);
procedure RemoveEmptyGroups;
function IsEmptyGroup(GroupRow: integer): Boolean;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure UpdateComponents;
procedure UpdateSelectedRows;
procedure OpenCurPropertyElement(var CurPropertyDataRow: integer);
function GetPropertyDisplayValue(PropertyElement: TtsPropertyElement): string;
procedure SetValues(PropertyElement: TtsPropertyElement; strValue: string; Value: Variant; ValueSource: tsValueSource; FirstSet: Boolean);
function GetSubFullySelected(Row: integer): Boolean;
function Selected(Row: integer): Boolean;
property InspectorRows: PtsInspectorRows read GetInspectorRows write FInspectorRows;
property InspectorRowCount: integer read GetInspectorRowCount write SetInspectorRowCount;
property ComponentEditor: TtsComponentEditor read FComponentEditor write SetComponentEditor;
property DisplayModeName: string read FDisplayModeName write SetDisplayModeName;
end;
{TtsPropertyElement}
{Contains information for each property}
TtsPropertyElement = class(TtsSetElement)
protected
FName: string;
PropInfo: PPropInfo;
FEditor: TPropertyEditor;
FEditorComponent: TPersistent;
FShowPropertyValue: tsShowPropertyValueType;
DesignstrValue: string;
PropertyLevel: Integer;
FParent: TtsPropertyElement;
ComponentEditor: TtsComponentEditor;
FSubProperties: TtsPropertySet;
SubPropertiesUpdated: Boolean;
Mark: Boolean;
MultiValue: Boolean;
FPropertyNil: tsPropertyNilType;
SetElementNumber: integer;
function GetSubProperties: TtsPropertySet;
function GetEditor: TPropertyEditor;
function GetPropType: PTypeInfo;
{$IFDEF TSVER_V6}
procedure SetPropertyEditor(const Prop: IProperty);
{$ELSE}
procedure SetPropertyEditor(Prop: TPropertyEditor);
{$ENDIF}
function GetPropertyNil: tsPropertyNilType;
public
{$IFDEF TSVER_V6}
constructor Create(Prop: IProperty; CurComponentEditor: TtsComponentEditor; ParentProperty: TtsPropertyElement);
{$ELSE}
constructor Create(Prop: TPropertyEditor; CurComponentEditor: TtsComponentEditor; ParentProperty: TtsPropertyElement);
{$ENDIF}
destructor Destroy; override;
procedure SetPropertyValue(Component: TPersistent; Value: Variant);
function GetPropertyValue(Component: TPersistent; FirstFromActualValueSet: Boolean): Variant;
function Compare(NodeSet: TtsCustomSet; Value : TtsSetElement) : TtsSetOrder; override;
function CompareKey(NodeSet: TtsCustomSet; const KeyValue : array of const) : TtsSetOrder; override;
function ConvertDesignPropertystrValueToValue(const strValue: string): Variant;
function ConvertDesignPropertyValueTostrValue(const Value: Variant): string;
property Editor: TPropertyEditor read GetEditor write FEditor;
property PropType: PTypeInfo read GetPropType;
property SubProperties: TtsPropertySet read GetSubProperties write FSubProperties;
property PropertyNil: tsPropertyNilType read GetPropertyNil write FPropertyNil;
property Name: string read FName write FName;
property ShowPropertyValue: tsShowPropertyValueType read FShowPropertyValue write FShowPropertyValue;
property Parent: TtsPropertyElement read FParent write FParent;
end;
{TtsPropertySet}
{Contains TtsPropertyElement information for all properties of a component
or all subproperties of a property}
TtsPropertySet = class(TtsObjectSet)
protected
procedure MarkAll(Node : TtsSetNode);
public
function GetItem(KeyValue : array of const) : TtsPropertyElement;
end;
{TtsPropertyPointerElement}
{Containts a pointer to a TtsPropertyElement}
TtsPropertyPointerElement = class(TtsSetElement)
protected
FElement: TtsPropertyElement;
public
function Compare(NodeSet: TtsCustomSet; Value : TtsSetElement) : TtsSetOrder; override;
function CompareKey(NodeSet: TtsCustomSet; const KeyValue : array of const) : TtsSetOrder; override;
end;
{TtsPropertyPointerSet}
{Contains a set of TtsPropertyPointerElement-s, used within a group}
TtsPropertyPointerSet = class(TtsObjectSet)
public
function GetItem(KeyValue : array of const) : TtsPropertyPointerElement;
end;
{TtsGroupElement}
{Used within the TtsInspectorGrid is logical elements to logically group
properties. Also use to contain a display modes, such as 'alphbetical' or 'structured'}
TtsGroupElement = class(TtsSetElement)
protected
FName: string;
FSubGroups: TtsGroupSet;
FPropertySet: TtsPropertyPointerSet;
FGroupSet: TtsGroupSet;
FOpened: Boolean;
procedure SetName(NewName: string);
public
constructor Create;
destructor Destroy; override;
function Release(DestroyingSet : Boolean) : TtsSetElement; override;
function Compare(NodeSet: TtsCustomSet; Value : TtsSetElement) : TtsSetOrder; override;
function CompareKey(NodeSet: TtsCustomSet; const KeyValue : array of const) : TtsSetOrder; override;
function FindSubGroup(GroupName: string): TtsGroupElement;
procedure AddGroup(Parent: string; Name: string; Opened: boolean);
property Name: string read FName write SetName;
end;
{TtsGroupSet}
{Contains the subgroups of a group elements or the displaymodes of a
component editor}
TtsGroupSet = class(TtsObjectSet)
protected
FInSetName: Boolean;
public
function GetItem(KeyValue : array of const) : TtsGroupElement;
function Add(Element : TtsSetElement): Pointer; override;
end;
{TtsActualValueElement}
{Used to contain the actual value of a property, when the value in the
example component is not set directly always, such as the HeadingOn in the
grdExample}
TtsActualValueElement = class(TtsSetElement)
protected
FComponentId: string;
FProperty: TtsPropertyElement;
FActualstrValue: string;
public
property ActualValue: string read FActualstrValue;
function Compare(NodeSet: TtsCustomSet; Value : TtsSetElement) : TtsSetOrder; override;
function CompareKey(NodeSet: TtsCustomSet; const KeyValue : array of const) : TtsSetOrder; override;
end;
{TtsActualValueSet}
{Contains all property values of properties in the component which are not
always set in the example component}
TtsActualValueSet = class(TtsObjectSet)
protected
FNumberOfToggleValues: integer;
FNumberOfInvisibleValues: integer;
FComponentEditor: TtsComponentEditor;
procedure SetNumberOfToggleValues(Value: integer);
procedure SetNumberOfInvisibleValues(Value: integer);
public
constructor Create; override;
function Add(NodeValue : TtsSetElement) : Pointer; override;
function Remove(KeyValue : array of const) : Pointer; override;
function GetItem(KeyValue : array of const) : TtsActualValueElement;
property NumberOfToggleValues: integer read FNumberOfToggleValues write SetNumberOfToggleValues;
property NumberOfInvisibleValues: integer read FNumberOfInvisibleValues write SetNumberOfInvisibleValues;
end;
{TtsComponentEditor}
{Contains all the information for retrieving and setting the properties of
a component}
TtsComponentEditor = class(TComponent)
protected
FComponent: TPersistent;
FPropertySet: TtsPropertySet;
FDisplayModes: TtsGroupSet;
ComponentSelected: Boolean;
MultipleComponentSelected: Boolean;
FComponentAssigned: Boolean;
FOnGetComponentInfo: TtsGetComponentInfoEvent;
FOnGetFirstSelectedComponent: TtsGetComponentEvent;
FOnGetNextSelectedComponent: TtsGetComponentEvent;
FOnGetComponentWithId: TtsGetComponentWithIdEvent;
FOnGetComponentId: TtsGetComponentIdEvent;
FOnScanObjects: TtsScanObjectsEvent;
FOnSetValues: TtsSetValuesEvent;
FOnNumberofToggleValuesChanged: TNotifyEvent;
FOnNumberofInvisibleValuesChanged: TNotifyEvent;
FOnGetComponentSelection: TtsGetComponentSelectionEvent;
FOnDestroyComponentSelection: TtsDestroyComponentSelectionEvent;
FOnGetComponentSelectionChanged: TtsGetComponentSelectionChangedEvent;
FCurPropertyElement: TtsPropertyElement;
FComponentSelection: pointer;
FComponentCount: integer;
FActualValueSet: TtsActualValueSet;
FShowDesignValue: tsShowPropertyValueSet;
FDesignValuePropertiesInitialized: Boolean;
procedure SetShowDesignValue(Value: tsShowPropertyValueSet);
{$IFDEF TSVER_V6}
procedure SetPropertyEditor(const Prop: IProperty);
{$ELSE}
procedure SetPropertyEditor(Prop: TPropertyEditor);
{$ENDIF}
function AssignComponent: TPersistent;
function GetPropertySet: TtsPropertySet;
function GetDisplayModes: TtsGroupSet;
procedure DoGetComponentInfo(DisplayMode: TtsGroupElement); virtual;
procedure DoGetComponentWithId(ComponentId: string; var Component: TPersistent); virtual;
procedure DoGetComponentSelection(var ComponentSelection: Pointer; var ComponentCount: integer); virtual;
procedure DoGetComponentSelectionChanged(CurSelection: Pointer; var Changed: Boolean); virtual;
procedure DoDestroyComponentSelection(var ComponentSelection: Pointer; var ComponentCount: Integer);
procedure DoScanObjects(State: tsScanObjectsState; Writing: Boolean; Count: Longint; var Cancel: Boolean); virtual;
procedure DoSetValues(State: tsScanObjectsState; Component: Tpersistent; PropertyElement: TtsPropertyElement; strValue: string; Value: Variant; ValueSource: tsValueSource; ValueSet: Boolean; var Cancel: Boolean);
procedure DoNumberofToggleValuesChanged; virtual;
procedure DoNumberofInvisibleValuesChanged; virtual;
function GetActualValueSet: TtsActualValueSet;
procedure SetPropertyList;
function AddDisplayMode(DisplayModeName: string): TtsGroupElement;
property DisplayModes: TtsGroupSet read GetDisplayModes write FDisplayModes;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure DoGetFirstSelectedComponent(var Component: TPersistent); virtual;
procedure DoGetNextSelectedComponent(var Component: TPersistent); virtual;
procedure DoGetComponentId(Component: TPersistent; var ComponentId: string); virtual;
procedure AddProperty(DisplayMode: TtsGroupElement; GroupName: string; Name: string);
procedure SetDesignProperty(PropertyName: string; ShowPropertyValue: tsShowPropertyValueType; DesignstrValue: string);
procedure GetComponents;
procedure SetActualValue(ComponentId: string; PropertyElement: TtsPropertyElement; strValue: string);
property PropertySet: TtsPropertySet read GetPropertySet write FPropertySet;
property ShowDesignValue: tsShowPropertyValueSet read FShowDesignValue write SetShowDesignValue;
property DesignValuePropertiesInitialized: Boolean read FDesignValuePropertiesInitialized write FDesignValuePropertiesInitialized;
property CurPropertyElement: TtsPropertyElement read FCurPropertyElement write FCurPropertyElement;
property Component: TPersistent read AssignComponent write FComponent;
property ComponentCount: integer read FComponentCount;
property ActualValueSet: TtsActualValueSet read GetActualValueSet write FActualValueSet;
property ComponentAssigned: Boolean read FComponentAssigned write FComponentAssigned;
published
property OnGetComponentInfo: TtsGetComponentInfoEvent read FOnGetComponentInfo write FOnGetComponentInfo;
property OnGetFirstSelectedComponent: TtsGetComponentEvent read FOnGetFirstSelectedComponent write FOnGetFirstSelectedComponent;
property OnGetNextSelectedComponent: TtsGetComponentEvent read FOnGetNextSelectedComponent write FOnGetNextSelectedComponent;
property OnGetComponentWithId: TtsGetComponentWithIdEvent read FOnGetComponentWithId write FOnGetComponentWithId;
property OnGetComponentId: TtsGetComponentIdEvent read FOnGetComponentId write FOnGetComponentId;
property OnScanObjects: TtsScanObjectsEvent read FOnScanObjects write FOnScanObjects;
property OnSetValues: TtsSetValuesEvent read FOnSetValues write FOnSetValues;
property OnNumberofToggleValuesChanged: TNotifyEvent read FOnNumberofToggleValuesChanged write FOnNumberofToggleValuesChanged;
property OnNumberofInvisibleValuesChanged: TNotifyEvent read FOnNumberofInvisibleValuesChanged write FOnNumberofInvisibleValuesChanged;
property OnGetComponentSelection: TtsGetComponentSelectionEvent read FOnGetComponentSelection write FOnGetComponentSelection;
property OnGetComponentSelectionChanged: TtsGetComponentSelectionChangedEvent read FOnGetComponentSelectionChanged write FOnGetComponentSelectionChanged;
property OnDestroyComponentSelection: TtsDestroyComponentSelectionEvent read FOnDestroyComponentSelection write FOnDestroyComponentSelection;
end;
TtsComponentEditorClass = class of TtsComponentEditor;
{TDummyDesigner}
{Used only when the component editor is not in designtime to retrieve property
information. Delphi functions require a designer component to retrieve
property information. In design time a designer is supplied by Delphi itself}
{$IFNDEF TSVER_V4}
TDummyDesigner = class(IDesigner)
public
function CreateMethod(const Name: string; TypeData: PTypeData): TMethod; override;
function GetMethodName(const Method: TMethod): string; override;
procedure GetMethods(TypeData: PTypeData; Proc: TGetStrProc); override;
function GetPrivateDirectory: string; override;
procedure GetSelections(List: TComponentList); override;
function MethodExists(const Name: string): Boolean; override;
procedure RenameMethod(const CurName, NewName: string); override;
{$IFDEF TSVER_V3}
procedure SelectComponent(Instance: TPersistent); override;
{$ELSE}
procedure SelectComponent(Instance: TComponent); override;
{$ENDIF}
procedure SetSelections(List: TComponentList); override;
procedure ShowMethod(const Name: string); override;
function UniqueName(const BaseName: string): string; override;
procedure GetComponentNames(TypeData: PTypeData; Proc: TGetStrProc); override;
function GetComponent(const Name: string): TComponent; override;
function GetComponentName(Component: TComponent): string; override;
{$IFDEF TSVER_V3}
function GetObject(const Name: string): TPersistent; override;
function GetObjectName(Instance: TPersistent): string; override;
procedure GetObjectNames(TypeData: PTypeData; Proc: TGetStrProc); override;
{$ENDIF}
function MethodFromAncestor(const Method: TMethod): Boolean; override;
function CreateComponent(ComponentClass: TComponentClass; Parent: TComponent;
Left, Top, Width, Height: Integer): TComponent; override;
function IsComponentLinkable(Component: TComponent): Boolean; override;
procedure MakeComponentLinkable(Component: TComponent); override;
function GetRoot: TComponent; override;
procedure Revert(Instance: TPersistent; PropInfo: PPropInfo); override;
{$IFDEF TSVER_V3}
function GetIsDormant: Boolean; override;
function HasInterface: Boolean; override;
function HasInterfaceMember(const Name: string): Boolean; override;
{$IFNDEF TSVER_CBUILD}
procedure AddInterfaceMember(const MemberText: string); override;
{$ELSE} {$IFDEF TSVER_V3}
procedure AddToInterface(InvKind: Integer; const Name: string; VT: Word;
const TypeInfo: string); override;
procedure GetProjectModules(Proc: TGetModuleProc); override;
{$ENDIF} {$ENDIF}
{$ENDIF}
function IsDesignMsg(Sender: TControl; var Message: TMessage): Boolean;
override;
procedure Modified; override;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure PaintGrid; override;
procedure ValidateRename(AComponent: TComponent;
const CurName, NewName: string); override;
end;
{$ELSE} {TFormDesigner no longer present in Delphi 4. Use IFormDesigner instead}
{$IFDEF TSVER_V6}
TDummyDesigner = class(TInterfacedObject, IDesigner)
{$ELSE}
TDummyDesigner = class(TInterfacedObject, IFormDesigner)
{$ENDIF}
protected
FCustomForm: TCustomForm;
FIsControl: Boolean;
public
constructor Create;
{$IFDEF TSVER_V6}
procedure Activate;
function GetBaseRegKey: string;
function GetIDEOptions: TCustomIniFile;
function GetPathAndBaseExeName: string;
function CreateCurrentComponent(Parent: TComponent; const Rect: TRect): TComponent;
function IsComponentHidden(Component: TComponent): Boolean;
{$ENDIF}
function CreateMethod(const Name: string; TypeData: PTypeData): TMethod;
function GetMethodName(const Method: TMethod): string;
procedure GetMethods(TypeData: PTypeData; Proc: TGetStrProc);
function GetPrivateDirectory: string;
procedure GetSelections(const List: IDesignerSelections);
function MethodExists(const Name: string): Boolean;
procedure RenameMethod(const CurName, NewName: string);
procedure SelectComponent(Instance: TPersistent);
procedure SetSelections(const List: IDesignerSelections);
procedure ShowMethod(const Name: string);
function UniqueName(const BaseName: string): string;
procedure GetComponentNames(TypeData: PTypeData; Proc: TGetStrProc);
function GetComponent(const Name: string): TComponent;
function GetComponentName(Component: TComponent): string;
function GetObject(const Name: string): TPersistent;
function GetObjectName(Instance: TPersistent): string;
procedure GetObjectNames(TypeData: PTypeData; Proc: TGetStrProc);
function MethodFromAncestor(const Method: TMethod): Boolean;
function CreateComponent(ComponentClass: TComponentClass; Parent: TComponent;
Left, Top, Width, Height: Integer): TComponent;
function IsComponentLinkable(Component: TComponent): Boolean;
procedure MakeComponentLinkable(Component: TComponent);
function GetRoot: TComponent;
procedure Revert(Instance: TPersistent; PropInfo: PPropInfo);
function GetIsDormant: Boolean;
function HasInterface: Boolean;
function HasInterfaceMember(const Name: string): Boolean;
procedure AddInterfaceMember(const MemberText: string);
procedure AddToInterface(InvKind: Integer; const Name: string; VT: Word; const TypeInfo: string);
procedure GetProjectModules(Proc: TGetModuleProc);
{$IFDEF TSVER_V6}
function GetAncestorDesigner: IDesigner;
{$ELSE}
function GetAncestorDesigner: IFormDesigner;
{$ENDIF}
function IsSourceReadOnly: Boolean;
function GetCustomForm: TCustomForm;
procedure SetCustomForm(Value: TCustomForm);
function GetIsControl: Boolean;
procedure SetIsControl(Value: Boolean);
function IsDesignMsg(Sender: TControl; var Message: TMessage): Boolean;
{$IFDEF TSVER_V5}
function GetContainerWindow: TWinControl;
procedure SetContainerWindow(const NewContainer: TWinControl);
function GetScrollRanges(const ScrollPosition: TPoint): TPoint;
{$IFDEF TSVER_V6}
procedure Edit(const Component: TComponent);
function GetShiftState: TShiftState;
procedure ModalEdit(EditKey: Char; const ReturnWindow: IActivatable);
procedure SelectItemName(const PropertyName: string);
procedure Resurrect;
procedure DeleteSelection(ADoAll: Boolean = False);
{$ELSE}
procedure DeleteSelection;
procedure Edit(const Component: IComponent);
function BuildLocalMenu(Base: TPopupMenu; Filter: TLocalMenuFilters): TPopupMenu;
{$ENDIF}
procedure ChainCall(const MethodName, InstanceName, InstanceMethod: string;
TypeData: PTypeData);
procedure CopySelection;
procedure CutSelection;
function CanPaste: Boolean;
procedure PasteSelection;
procedure ClearSelection;
procedure ModuleFileNames(var ImplFileName, IntfFileName, FormFileName: string);
procedure NoSelection;
function GetRootClassName: string;
{$ENDIF}
procedure Modified;
procedure Notification(AnObject: TPersistent; Operation: TOperation);
procedure PaintGrid;
procedure ValidateRename(AComponent: TComponent;
const CurName, NewName: string);
property Form: TCustomForm read FCustomForm;
end;
{$ENDIF}
var
{$IFDEF TSVER_V6}
Designer: IDesigner = nil;
{$ELSE}
Designer: IFormDesigner = nil;
{$IFNDEF TSVER_V4}
Designer: TFormDesigner = nil;
{$ENDIF}
{$ENDIF}
ChangesMade: Boolean = False;
implementation
type
TIntegerSet = set of 0..SizeOf(Integer) * 8 - 1;
TtsBaseGrid_ = class(TtsBaseGrid) end;
TtsCustomGrid_ = class(TtsCustomGrid) end;
TtsCustomDBGrid_ = class(TtsCustomDBGrid) end;
const
StsGroupNameNotFound = 'GroupName ''%s'' not found.';
StsPropertyNotFound = 'Property ''%s'' not found.';
StsDeletePropertyNotAllowed = 'Properties may not be deleted.';
StsOkToDeleteSeletedGroups = 'You are about to delete %d group(s). Are you sure?';
var
ComboValueSelected: Boolean;
{TtsPropertyElement}
function TtsPropertyElement.GetSubProperties: TtsPropertySet;
begin
if Editor = nil then
result := nil
else if not (paSubProperties in Editor.GetAttributes) then
result := nil
else
begin
if (PropertyNil <> pnTrue) and (FSubProperties = nil) then
begin
FSubProperties := TtsPropertySet.Create;
Editor.GetProperties(SetPropertyEditor);
end;
result := FSubProperties;
end;
end;
function TtsPropertyElement.GetEditor: TPropertyEditor;
var
{$IFDEF TSVER_V5}
{$IFDEF TSVER_V6}
Components: TDesignerSelections;
{$ELSE}
Components: TDesignerSelectionList;
{$ENDIF}
{$ELSE}
Components: TComponentList;
{$ENDIF}
CreateEditor: Boolean;
ClassParent: TtsPropertyElement;
begin
ShowMessage('TtsPropertyElement.GetEditor');
if FEditor = nil then
CreateEditor := True
else if (Parent <> nil) then
begin
ClassParent := Parent;
ShowMessage('ClassParent.PropType.Kind');
while ClassParent.PropType.Kind <> tkClass do
begin
ClassParent := ClassParent.Parent;
if ClassParent = nil then break;
end;
ShowMessage('if ClassParent = nil then');
if ClassParent = nil then
begin
if FEditorComponent <> ComponentEditor.Component then
CreateEditor := True
else
CreateEditor := False;
end
else if FEditorComponent <> Pointer(integer(ClassParent.GetPropertyValue(ComponentEditor.Component, True))) then
CreateEditor := True
else
CreateEditor := False;
end
else if FEditorComponent <> ComponentEditor.Component then
CreateEditor := True
else
CreateEditor := False;
if CreateEditor then
begin
if Parent = nil then
begin
{$IFDEF TSVER_V5}
{$IFDEF TSVER_V6}
Components := TDesignerSelections.Create;
{$ELSE}
Components := TDesignerSelectionList.Create;
{$ENDIF}
{$ELSE}
Components := TComponentList.Create;
{$ENDIF}
try
ShowMessage('ComponentEditor.Component');
if ComponentEditor.Component <> nil then
begin
{$IFDEF TSVER_V6}
(Components as IDesignerSelections).Add(ComponentEditor.Component);
{$ELSE}
Components.Add(TComponent(ComponentEditor.Component));
{$ENDIF}
ShowMessage('GetComponentProperties');
GetComponentProperties(Components, tkProperties, Designer, ComponentEditor.SetPropertyEditor);
end;
finally
Components.Free;
end;
end
else if Parent.Editor <> nil then
begin
ShowMessage('Parent.Editor <> nil');
Parent.Editor.GetProperties(Parent.SetPropertyEditor);
end;
end;
result := FEditor;
end;
function TtsPropertyElement.GetPropType: PTypeInfo;
begin
if PropInfo = nil then
result := nil
else if PropInfo.PropType = nil then
result := nil
else
{$IFDEF TSVER_V3}
result := PropInfo.PropType^;
{$ELSE}
result := PropInfo.PropType;
{$ENDIF}
end;
procedure TtsPropertyElement.SetPropertyValue(Component: TPersistent; Value: Variant);
var
S: TIntegerSet;
ParentValue: Variant;
begin
if PropInfo = nil then
begin
if Parent = nil then
exit;
if Parent.PropType = nil then
exit;
if Parent.PropType^.Kind = tkSet then
begin
ParentValue := Parent.GetPropertyValue(Component, True);
if VarIsEmpty(ParentValue) then
begin
ParentValue := ParentValue;
exit;
end;
Integer(S) := ParentValue;
if Boolean(Value) then
Include(S, SetElementNumber)
else
Exclude(S, SetElementNumber);
Parent.SetPropertyValue(Component, Integer(S));
end;
end
else
begin
if Parent <> nil then
begin
ParentValue := Parent.GetPropertyValue(Component, True);
if VarIsEmpty(ParentValue) then
begin
ParentValue := ParentValue;
exit;
end;
Component := Pointer(integer(ParentValue));
if Component = nil then
begin
ParentValue := ParentValue;
exit;
end;
end;
if PropInfo.PropType = nil then
exit;
case PropInfo.PropType^.Kind of
tkChar, tkString, tkWChar, tkLString,
{$IFDEF TSVER_V3} tkWString {$ELSE} tkLWString {$ENDIF}:
SetStrProp(Component, PropInfo, VarToStr(Value));
tkFloat:
SetFloatProp(Component, PropInfo, Value);
tkVariant:
SetVariantProp(Component, PropInfo, Value);
else
SetOrdProp(Component, PropInfo, Value);
end;
end;
end;
function TtsPropertyElement.GetPropertyValue(Component: TPersistent; FirstFromActualValueSet: Boolean): Variant;
var
ComponentId: string;
ActualValueElement: TtsActualValueElement;
ParentValue: Variant;
begin
if FirstFromActualValueSet and (ShowPropertyValue <> pvShowAlways) then
begin
ComponentEditor.DoGetComponentId(Component, ComponentId);
ActualValueElement := ComponentEditor.ActualValueSet.GetItem([ComponentId, Name]);
if (ActualValueElement <> nil) then
begin
result := ConvertDesignPropertystrValueToValue(ActualValueElement.FActualstrValue);
exit;
end;
end;
if PropInfo = nil then
begin
if Parent = nil then
exit;
if Parent.PropType = nil then
exit;
if Parent.PropType^.Kind = tkSet then
begin
ParentValue := Parent.GetPropertyValue(Component, True);
if VarIsEmpty(ParentValue) then
result := Unassigned
else
result := SetElementNumber in TIntegerSet(integer(ParentValue));
end;
end
else
begin
if Parent <> nil then
begin
ParentValue := Parent.GetPropertyValue(Component, True);
if VarIsEmpty(ParentValue) then
begin
result := Unassigned;
exit;
end;
Component := Pointer(integer(ParentValue));
if Component = nil then
begin
result := Unassigned;
exit;
end;
end;
if PropInfo.PropType = nil then
exit;
case PropType.Kind of
tkChar, tkString, tkWChar, tkLString,
{$IFDEF TSVER_V3} tkWString {$ELSE} tkLWString {$ENDIF}:
result := GetStrProp(Component, PropInfo);
tkFloat:
result := GetFloatProp(Component, PropInfo);
tkVariant:
result := GetVariantProp(Component, PropInfo);
else
result := GetOrdProp(Component, PropInfo);
end;
end;
end;
{$IFDEF TSVER_V6}
procedure TtsPropertyElement.SetPropertyEditor(const Prop: IProperty);
{$ELSE}
procedure TtsPropertyElement.SetPropertyEditor(Prop: TPropertyEditor);
{$ENDIF}
var
Element: TtsPropertyElement;
begin
if SubProperties = nil then
begin
TPropertyEditor(Prop).Free;
exit;
end;
Element := SubProperties.GetItem([Prop.GetName]);
if Element = nil then
begin
Element := TtsPropertyElement.Create(Prop, ComponentEditor, Self);
SubProperties.Add(Element);
end
else
begin
Element.FEditor.Free;
Element.Editor := TPropertyEditor(Prop);
Element.FEditorComponent := TPropertyEditor(Prop).GetComponent(0);
end;
end;
function TtsPropertyElement.GetPropertyNil: tsPropertyNilType;
begin
if FPropertyNil = pnUnKnown then
begin
FPropertyNil := pnFalse;
if PropInfo <> nil then
begin
if PropType <> nil then
begin
if (PropInfo.PropType^.Kind = tkClass) then
begin
if GetOrdProp(FEditor.GetComponent(0), PropInfo) = 0 then
FPropertyNil := pnTrue
else if (PropInfo.PropType^.Name = 'TFont') and not (FEditor.GetComponent(0) is TtsBaseGrid) then
FPropertyNil := pnAuto;
end;
end;
end;
end;
result := FPropertyNil;
end;
function TtsPropertyElement.ConvertDesignPropertystrValueToValue(const strValue: string): Variant;
var
IntValue: Longint;
begin
case PropInfo.PropType^.Kind of
tkChar, tkString, tkWChar, tkLString,
{$IFDEF TSVER_V3} tkWString {$ELSE} tkLWString {$ENDIF}:
result := strValue;
tkFloat:
result := StrToFloat(strValue);
tkVariant:
result := strValue;
tkEnumeration:
begin
result := GetEnumValue(GetPropType, strValue);
if result = -1 then
raise EPropertyError.Create('Invalid property value')
end
else
begin
if PropInfo.PropType^.Name = 'TColor' then
begin
if IdentToColor(strValue, IntValue) then
result := IntValue
else
result := StrToInt(strValue);
end
else
result := StrToInt(strValue);
end;
end;
end;
function TtsPropertyElement.ConvertDesignPropertyValueTostrValue(const Value: Variant): string;
var
IntValue: integer;
begin
case PropInfo.PropType^.Kind of
tkChar, tkString, tkWChar, tkLString,
{$IFDEF TSVER_V3} tkWString {$ELSE} tkLWString {$ENDIF}:
result := Value;
tkFloat:
result := FloatToStr(Value);
tkVariant:
result := Value;
tkEnumeration:
begin
if PropInfo.PropType^.Name = 'Boolean' then
begin
if Value = 0 then
result := 'False'
else
result := 'True';
end
else
result := GetEnumName(GetPropType, Value);
end;
else
begin
if PropInfo.PropType^.Name = 'TColor' then
begin
IntValue := Value;
result := ColorToString(TColor(IntValue));
end
else
result := IntToStr(Value);
end;
end;
end;
{$IFDEF TSVER_V6}
constructor TtsPropertyElement.Create(Prop: IProperty; CurComponentEditor: TtsComponentEditor; ParentProperty: TtsPropertyElement);
{$ELSE}
constructor TtsPropertyElement.Create(Prop: TPropertyEditor; CurComponentEditor: TtsComponentEditor; ParentProperty: TtsPropertyElement);
{$ENDIF}
var
i: integer;
begin
inherited Create;
Name := Prop.GetName;
FEditor := TPropertyEditor(Prop);
FEditorComponent := TPropertyEditor(Prop).GetComponent(0);
PropInfo := GetPropInfo(FEditor.GetComponent(0).ClassInfo, Name);
Parent := ParentProperty;
ComponentEditor := CurComponentEditor;
SetElementNumber := 0;
PropertyNil := pnUnknown;
if Parent = nil then
PropertyLevel := 0
else
begin
PropertyLevel := Parent.PropertyLevel + 1;
if Parent.PropType <> nil then
begin
if Parent.PropType^.Kind = tkSet then
begin
{$IFDEF TSVER_V3}
with GetTypeData(GetTypeData(Parent.PropType)^.CompType^)^ do
{$ELSE}