-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirectum_view.pas
1065 lines (916 loc) · 35.8 KB
/
directum_view.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
unit directum_view;
interface
uses classes, Menus, routine_directum_specific, SysUtils, directum_metadata, routine_strings, Dialogs, Controls, Forms, ComCtrls, ExtCtrls, StdCtrls, DBCtrls, Grids, Graphics, VirtualTrees,ShellApi, Windows, Clipbrd;
//Ïðåäñòàâëåíèå-------------------------------------------------------------------------
type
TStringGricCellSelectProc = procedure(Sender: TObject; ACol, ARow:
Integer; var CanSelect: Boolean);
type TViewControlParam = class(TObject)
name:string;
value:string;
end;
type TControlParams = class( TList )
constructor Create();
//÷ëåíû
public
//ìåòîäû
function GetNameValue(index:integer):string;
function GetValueAsInteger( name:string ):integer;
function GetValueAsString( name:string ):string;
function IndexByName( name:string ):integer;
procedure AddParam( name,value:string );
function GetParamCount():integer;
end;
//Ýëåìåíò ôîðìû ïðåäñòàâëåíèÿ
type
TViewFormControl = class(TObject)
parent : ^TViewFormControl;
ref_requisite : TPointerDIRReferenceRequisite;
params : TControlParams;
name : string;
control_type : string;
required : boolean;
index : Integer;
tag : integer;
controls_count: integer;
controls : array of ^TViewFormControl;
metadata_type : TMetadataObjectType;
protected
// function GetParamCount():integer;
public
//ñëóæåáíîå
constructor Create();
//ñâîéñòâà
// property param_count: integer read GetParamCount;
end;
//Ýëåìåíò ôîðìû ïðåäñòàâëåíèÿ
type
PViewFormDescription = ^TViewFormDescription;
TViewFormDescription = class( TViewFormControl )
Reference : TPointerDIRReference;
TextHeight : integer;
end;
//ðåêâèçèò èç ñïðàâî÷íèêà ðåêâèçèòîâ
type
TPointerDirView = ^TDIRView;
TDIRView = class(TObject)
view_form : TViewFormDescription;
name : string;
code : string;
form_reference : pointer;
viewForm : TForm;
dfm_text : TStringList;
main : boolean;
TagCount : integer;
comment : string;
dir_reference : TPointerDIRReference;
requisites_list : TList;
actions_list : TList;
private
function ExplainType(control:TViewFormControl): string;
function RecursiveFindControlTag(view_form:TViewFormDescription;
control:TViewFormControl; searchCode:string): integer;
public
constructor Create();
procedure HightlightControl(requisiteCode : string);
procedure ParseDFMTextView();
function RecursiveDrawForm(view_form:TViewFormDescription;
control:TViewFormControl; parent:TWinControl; theForm:TForm): TForm;
procedure ShowForm();
procedure ShowYourCaption(Sender:TObject);
procedure RecursiveDrawStructure( parent_node:PVirtualNode; control:TViewFormControl; treeview: TVirtualStringTree );
end;
type
TEventHandlers = class // create a dummy class
procedure StringGridSelectCell(Sender: TObject; ACol, ARow: Integer; var CanSelect: Boolean);
end;
//------------------------------------------------------------------------------
var EvHandler:TEventHandlers;
implementation
uses unit1, routine_debug, requisites_list, virtual_tree_routine, main;
procedure TEventHandlers.StringGridSelectCell(Sender: TObject; ACol, ARow: Integer; var
CanSelect: Boolean);
var
cellvalue: string;
begin
cellvalue := (Sender as TStringGrid).Cells[ACol, ARow];
Clipboard.AsText := cellvalue;
window.TrayIcon.BalloonHint('Çíà÷åíèå ñêîïèðîâàíî â áóôåð', cellvalue );
end;
constructor TViewFormControl.Create();
begin
Inherited Create;
params := TControlParams.Create;
controls_count := 0;
end;
constructor TControlParams.Create();
begin
Inherited Create;
end;
procedure TControlParams.AddParam( name, value:string );
var
param : TViewControlParam;
begin
param := TViewControlParam.Create;
param.name := name;
param.value := value;
Add( param );
end;
function TControlParams.GetNameValue( index:integer ):string;
begin
result := TViewControlParam( Items[ index ] ).name + '=' + TViewControlParam( Items[ index ] ).value;
end;
function TControlParams.IndexByName( name:string ):integer;
var
i:integer;
begin
result := -1;
for i:= 0 to Count - 1 do
begin
if LowerCase( TViewControlParam( Items[ i ] ).name ) = LowerCase( name )
then result := i;
end;
end;
function TControlParams.GetParamCount():integer;
begin
result := Count;
end;
function TControlParams.GetValueAsString( name:string ):string;
var
index:integer;
begin
result := '';
index := IndexByName( name );
if index <> -1 then
result := TViewControlParam( Items[ index ] ).value;
end;
function TControlParams.GetValueAsInteger( name:string ):integer;
var
index:integer;
begin
result := 0;
index := IndexByName( name );
if index <> -1 then
result := StrToInt( TViewControlParam( Items[ index ] ).value );
end;
constructor TDirView.Create;
begin
inherited Create;
dfm_text := TStringList.Create;
view_form := TViewFormDescription.Create;
requisites_list := TList.Create;
actions_list := TList.Create;
TagCount := 0;
end;
function dfm_extract_control_name( str:string ):string;
var
control_name:string;
begin
control_name := SubString( str, ' ', 2 );
control_name := Replace( control_name, ':', '' );
control_name := Replace( control_name, '''', '' );
Result := control_name;
end;
function dfm_extract_control_index( str:string ):string;
var
controlIndex : string;
begin
controlIndex := ExtractString( str, '[',']' );
result := controlIndex;
end;
function dfm_extract_param_value( str:string ):string;
var
param_value:string;
begin
param_value := Trim( SubString( str, '=', 2 ) );
param_value := ConvertString( param_value );
param_value := Replace( param_value, '''','' );
param_value := Replace( param_value, '¦', '¹' );
Result := param_value;
end;
function MetaDataTypeByControlType( control_type_str:string ) : TMetadataObjectType;
begin
Result := control_type;
if ( control_type_str = 'TSLDBEdit' ) or
( control_type_str = 'TSLDBComboBox' ) or
( control_type_str = 'TSLDBMemo' ) or
( control_type_str = 'TSLcxGridDBColumn' ) or
( control_type_str = 'TSLDBEllipsis' ) or
( control_type_str = 'TSLDBCheckBox' )
then
result := requisite_type;
if ( control_type_str = 'TSLButton' ) or
( control_type_str = 'TSLHyperLinkLabel' ) or
( control_type_str = 'TSLStandardAction' )
then
result := action_type;
end;
//Äîëæåí ëè ñîçäàâàòü óçåë è ïàðñèòü ïîä÷èíåííûõ?
function ShouldCreateNodeWithControlAndParseChildren( control_type_str:string ):boolean;
begin
result := true;
if ( control_type_str = 'TDataSource' ) or
( control_type_str = 'TStatusBar' ) or
( control_type_str = 'TStatusBar' ) or
( control_type_str = 'TSLDBNavigator' ) or
( control_type_str = 'TSLDBStatusLabel' ) or
( control_type_str = 'TcxGridLevel' ) or
( control_type_str = 'TSLNoControlExitAction' ) or
( control_type_str = 'TSLRecordAction' )
then
result := false;
end;
//Äîëæåí ëè ñîçäàâàòü óçåë äëÿ êîíòðîëà? Ïàðñèíã äåòåé áóäåò âûïîëíåí â ëþáîì ñëó÷àå.
function ShouldCreateNodeForControl_ParseChildrenAnyWay( control_type:string ):Boolean;
begin
result := true;
if ( control_type = 'TSBForm' ) or
( control_type = 'TSBLifeTimeTemplateForm' ) then
begin
result := false;
end;
end;
function TDIRView.ExplainType(control:TViewFormControl): string;
var
controlRequisite: TPointerDIRRequisite;
isReference : boolean;
typeExplained : string;
begin
typeExplained := '';
controlRequisite := control.ref_requisite.the_requisite;
isReference := controlRequisite.isReference;
if isReference then
begin
typeExplained := typeExplained + ' {' + controlRequisite.reftypeString + '}';
end;
typeExplained := typeExplained + ' [' + controlRequisite.typeStr + ']';
Result := typeExplained; // TODO:
end;
function TDIRView.RecursiveFindControlTag(view_form:TViewFormDescription;
control:TViewFormControl; searchCode:string): integer;
var
i: Integer;
nextTag: integer;
begin
result := -1;
if Assigned( control.ref_requisite ) then
if control.ref_requisite.code = searchCode then
result := control.tag;
if result = -1 then
for i:= 0 to control.controls_count -1 do
begin
nextTag := RecursiveFindControlTag( view_form, control.controls[i]^, searchCode );
if nextTag <> -1 then
result := nextTag;
end;
end;
procedure TDIRView.HightlightControl( requisiteCode : string );
var
component : TComponent;
componentsCount : integer;
i : integer;
caption : string;
tag : integer;
backColor : TColor;
labelColor : TColor;
begin
backColor := clSkyBlue;
labelColor := clBlue;
tag := RecursiveFindControlTag( view_form, view_form, requisiteCode );
caption := self.viewForm.Caption;
componentsCount := self.viewForm.ComponentCount - 1;
for i:=0 to componentsCount do
begin
component := viewForm.Components[i];
if component.Tag = tag then
begin
if component IS TEdit then
(component as Tedit).Color := BackColor;
// íàäïèñü
if component IS TLabeledEdit then
begin
(component as TLabeledEdit).Color := BackColor;
(component as TLabeledEdit).EditLabel.Font.Color := labelColor;
(component as TLabeledEdit).EditLabel.Font.Style := [fsBold];
end;
if component IS TLabel then
begin
(component as TLabel).Font.Color := labelColor;
(component as TLabel).Font.Style := [fsBold];
end;
if component IS TCheckBox then
begin
(component as TCheckBox).Color := BackColor;
(component as TCheckBox).Font.Color := labelColor;
(component as TCheckBox).Font.Style := [fsBold];
end;
if component IS TMemo then
begin
(component as TMemo).Color := BackColor;
end;
end;
end;
end;
procedure TDIRView.RecursiveDrawStructure( parent_node:PVirtualNode; control:TViewFormControl; treeview: TVirtualStringTree );
var
control_node : PVirtualNode;
node_data : PVSTRecord;
i : integer;
begin
if ShouldCreateNodeWithControlAndParseChildren( control.control_type ) then
begin
if ShouldCreateNodeForControl_ParseChildrenAnyWay( control.control_type ) then
begin
control_node := treeview.AddChild( parent_node );
node_data := treeview.GetNodeData( control_node );
node_data.object_pointer := control;
node_data.node_type := control_type;
end
else
control_node := parent_node;
for i:=0 to control.controls_count - 1 do
RecursiveDrawStructure( control_node, control.controls[i]^, treeview );
end
end;
procedure TDIRView.ParseDFMTextView();
var
view_form_control : ^TViewFormControl;
action_list : ^TViewFormControl;
cur_parrent : ^TViewFormControl;
dir_ref_requisite : TPointerDIRReferenceRequisite;
that_requisite : TPointerDIRRequisite;
i : integer;
cur_string : string;
controls_count : Integer;
control_name,
control_type,
control_index : string;
object_params : TStringList;
form_params : TStringList;
foundView: Boolean;
i_view: Integer;
param_name : string;
param_value : string;
viewString: string;
// form_node : TTreeNode;
// control_node : TTreeNode;
begin
controls_count := 0;
form_params := TStringList.Create;
object_params := TStringList.Create;
try
for i:=0 to dfm_text.Count - 1 do
begin
cur_string := dfm_text.Strings[ i ];
cur_string := Trim( cur_string );
//ÔÎÐÌÀ. Îáúÿâëåíèå ôîðìû----------------------------------------------------------
if Pos( 'inherited', ' ' + cur_string ) > 0 then
begin
//object StatusBar1: TStatusBar [0]
control_name := dfm_extract_control_name( cur_string );
control_type := SubString( cur_string, ' ', 3 );
if ( control_type = 'TSBForm' ) or ( control_type = 'TSBLifeTimeTemplateForm' ) then
begin
view_form.name := control_name;
view_form.control_type := control_type;
view_form.parent := @view_form;
view_form_control := @view_form;
continue;
end;
end;
//ÊÎÍÒÐÎË. Îáúÿâëåíèå íîâîãî êîíòðîëà íà ôîðìå---------------------------------------
if ( FindSubString( cur_string, ' object ') ) or
( FindSubString( cur_string, 'inherited' ) ) then
begin
//Âûãëÿäèò ýòî òàê: object OurFirmStatusLabel: TSLDBStatusLabel [2]
cur_parrent := @view_form_control^;
//ñîçäàòü è ïðèâÿçàòü êîìïîíåíò ê ôîðìå-----------------------------------
try
New( view_form_control );
view_form_control^ := TViewFormControl.Create;
view_form_control^.tag := Self.TagCount;
Inc( Self.TagCount );
view_form_control^.parent := @cur_parrent^;
// if FindSubString( cur_string, 'object TSLDBNavigator [2]' ) then
// begin
// sleep(1);
// end;
// äëÿ ñòðîê âèäà
// object StatusBar1: TStatusBar [3]
if findSubString( cur_string, ':' ) then
begin
control_name := dfm_extract_control_name( cur_string );
control_type := SubString( cur_string, ' ', 3 );
control_index := dfm_extract_control_index( cur_string );
end;
// äëÿ ñòðîê âèäà
// object TSLDBNavigator [2]
if not findSubString( cur_string, ':' ) then
begin
control_name := dfm_extract_control_name( cur_string );
control_type := control_name;
control_index := dfm_extract_control_index( cur_string );
end;
if not StringAssigned( control_index ) then
control_index := '-1';
if not StringAssigned( control_type ) then
control_type := control_name;
view_form_control^.control_type := control_type;
view_form_control^.name := control_name;
view_form_control^.index := StrToInt( control_index );
view_form_control^.metadata_type := MetaDataTypeByControlType( control_type );
except
ShowMessage('Âîçíèêëà îøèáêà ïðè îáðàáîòêå ïðåäñòàâëåíèÿ. ' + #13 +
'Âîçíèêëà îøèáêà ïðè îáðàáîòêå îáúÿâëåíèÿ íîâîãî êîíòðîëà: ' + control_name );
EditText( dfm_text.Text );
end;
//Ïðèöåïèòü äàííûé êîíòðîë ê ðîäèòåëþ-------------------------------------
try
controls_count := view_form_control.parent.controls_count + 1;
SetLength( view_form_control^.parent.controls, controls_count );
view_form_control^.parent.controls[ controls_count - 1] := Addr( view_form_control^ );
view_form_control^.parent.controls_count := controls_count;
except
dfm_text.SaveToFile( work_dir + '\debug\' + 'dfm.txt' );
DebugMessage(' Îøèáêà ïðè îáðàáîòêå îïèñàíèÿ ïðåäñòàâëåíèÿ. Òåêñò îïèñàíèÿ ñîõðàíåí â êàòàëîã ïðîãðàììû. ');
DebugMessage( 'Îïèñàíèå: èìÿ êîíòðîëà: ' + control_name + ' ñòðîêà: ' + IntToStr(i) );
ShowDebug();
exit;
end;
//------------------------------------------------------------------------
end;
if ( Pos( ' end', ' ' + cur_string ) > 0 ) and ( Pos( 'end>', ' ' + cur_string ) = 0 ) then
begin
view_form_control := @view_form_control.parent^;
cur_parrent := @view_form_control^.parent^ ;
end;
//ÏÀÐÀÌÅÒÐÛ ÊÎÍÒÐÎËÀ. Ïîëó÷èòü çíà÷åíèÿ ïàðàìåòðîâ--------------------------
if Pos( '=', cur_string ) > 0 then
begin
param_value := '';
param_name := Trim( SubString( cur_string, '=', 1 ) );
param_value := dfm_extract_param_value( cur_string );
if assigned( view_form_control ) then
begin
try
//äîáàâèòü ïàðàìåòð â ñïèñîê
view_form_control^.params.AddParam( param_name, param_value );
//äîï. îáðàáîòêà----------------------------------------------------
//Åñëè ïàðàìåòð ýòî RequisiteCode, òîãäà íóæíî êîíòðîë ñâÿçàòü ñ ðåêâèçèòîâ
try
if ( param_name = 'RequisiteCode' ) then
if view_form_control^.metadata_type = requisite_type then
begin
//åñëè ýòî îáû÷íûé ðåêâèçèò ó êîòîðîãî åñòü ïðèâÿçêà ê ðåêâèçèòó ñïðàâî÷íèêà
dir_ref_requisite := TRefRequisitesList( dir_reference^.requisites ).GetRequisiteByCode( param_value );
if Assigned( dir_ref_requisite ) then
begin
dir_ref_requisite.on_form := true;
// äîáàâèòü íîâîå Âüþ åñëè åùå íå áûëî äîáàâëåíî
// ïðîâåðêà íóæíà òàê êàê îäèí ðåêâèçèò ìîæåò áûòü èñïîëüçîâàí âî Âüþ ìíîãî ðàç.
// ñäåëàòü ýêñòðàêò ìåòîäà
viewString := name + ':' + code;
foundView := false;
for i_view := 0 to dir_ref_requisite.viewsOn.Count - 1 do
if viewString = dir_ref_requisite.viewsOn.Strings[i_view] then
foundView := true;
if not foundView then
dir_ref_requisite.viewsOn.AddObject( viewString, Self );
view_form_control.ref_requisite := @dir_ref_requisite^;
view_form_control.required := dir_ref_requisite.required;
requisites_list.Add( dir_ref_requisite );
end;
//Åñëè ýòî ðåêâèçèò Íîìåð ñòðîêè òàáëè÷íîé ÷àñòè, òîãäà
if ( not Assigned( dir_ref_requisite ) ) and ( param_value = 'ÍîìÑòð' ) then
begin
New( dir_ref_requisite );
dir_ref_requisite.name := 'ÍîìÑòð';
dir_ref_requisite.code := 'ÍîìÑòð';
dir_ref_requisite.on_form := True;
dir_ref_requisite.readonly := true;
dir_ref_requisite.filter := false;
dir_ref_requisite.sources := false;
dir_ref_requisite.leader := false;
dir_ref_requisite.the_requisite := nil;
dir_ref_requisite.required := false;
view_form_control.ref_requisite := @dir_ref_requisite^;
new( that_requisite );
that_requisite.code := 'ÍîìÑòð';
that_requisite.name := 'ÍîìÑòð';
that_requisite.fieldname := 'ÍîìÑòð'; //íåêîððåêòíî
dir_ref_requisite.the_requisite := @that_requisite^;
requisites_list.Add( dir_ref_requisite );
end;
end;
except
ShowMessage('Âîçíèêëà îøèáêà ïðè ïîïûòêå ïðèâÿçàòü êîíòðîë ê ðåêâèçèòó.');
exit();
end;
//------------------------------------------------------------------
try
//Äåéñòâèÿ òîæå íóæíî ñâÿçûâàòü ñ ðåêâèçèòàìè-----------------------
if view_form_control^.metadata_type = action_type then
begin
if ( ( param_name = 'Code' ) and ( view_form_control^.control_type = 'TSLStandardAction' ) ) or
( ( param_name = 'RequisiteCode' ) and ( view_form_control^.control_type = 'TSLButton' ) )
then
begin
dir_ref_requisite := TRefRequisitesList( dir_reference^.requisites ).GetRequisiteByCode( param_value );
if Assigned( dir_ref_requisite ) then
begin
view_form_control.ref_requisite := @dir_ref_requisite^;
requisites_list.Add( dir_ref_requisite );
end;
end;
end;
//------------------------------------------------------------------
except
ShowMessage('Âîçíèêëà îøèáêà ïðè ïîïûòêå ïðèâÿçàòü äåéñòâèå ê ðåêâèçèòó.');
exit();
end;
//------------------------------------------------------------------
except
ShowMessage('Âîçíèêëà îøèáêà ïðè îáðàáîòêå ïðåäñòàâëåíèÿ. Îøèáêà ïðè ïîëó÷åíèè çíà÷åíèÿ ñâîéñòâà êîíòðîëà.');
exit();
end;
end
else
ShowMessage( 'Ïàðàìåòð åñòü à êîíòðîëà íåò' );
end;
//------------------------------------------------------------------------
end;
except
ShowMessage('Âîçíèêëà îáùàÿ îøèáêà ïðè îáðàáîòêå DFM ïðåäñòàâëåíèÿ. Ïðåäñòàâëåíèå "' + name + '", ñïðàâî÷íèê "' + dir_reference.name + '"' );
EditText( dfm_text.Text );
exit();
end;
end;
function TDIRView.RecursiveDrawForm(view_form:TViewFormDescription;
control:TViewFormControl; parent:TWinControl; theForm:TForm): TForm;
var
i : integer;
handled : boolean;
label_spacing : integer;
active_page : string;
this_component: TWinControl;
form : TForm;
page_control : TPageControl;
tab_sheet : TTabSheet;
groupbox : TGroupBox;
button : TButton;
dbedit : TEdit;
memo : TMemo;
navigator : TDBNavigator;
editlabel : TLabel;
hyperlabel : TLabel;
grid : TStringGrid;
browser : TPanel;
image_panel : TPanel;
checkbox : TCheckBox;
controlRequisite: TPointerDIRRequisite;
gridCellProc : TStringGricCellSelectProc;
gridPopup: TPopupMenu;
isReference : boolean;
menuItem: TMenuItem;
tempStr : string;
begin
handled := false;
if ( control.control_type = 'TSBForm' ) or ( control.control_type = 'TSBLifeTimeTemplateForm' ) then
begin
form := TForm.Create( DIRAssistant );
form.Width := view_form.params.GetValueAsInteger( 'ClientWidth' ) + 15;
form.Height := view_form.params.GetValueAsInteger( 'ClientHeight' ) + 15;
// form.Width := view_form.params.GetValueAsInteger( 'ExplicitWidth' ) + 15;
// form.Height := view_form.params.GetValueAsInteger( 'ExplicitHeight' ) + 15;
form.BorderStyle := bsSizeable;
form.Caption := view_form.params.GetValueAsString( 'Caption' );
this_component := form;
result := form;
form_reference := Addr( form );
// Self.form := Addr( form );
tempStr := Self.viewForm.Caption;
theForm := form;
// Ïîâåðõ âñåõ îêîí
SetWindowLong(form.handle, GWL_EXSTYLE, WS_EX_APPWINDOW);
SetWindowLong(form.Handle, GWL_HWNDPARENT, GetDesktopWindow);
SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE);
// form.Show;
handled := true;
end;
// ÐÅÊÂÈÇÈÒ ïîëå
if ( control.control_type = 'TSLDBEdit' ) or
( control.control_type = 'TSLDBEllipsis' ) or
( control.control_type = 'TSLDBComboBox' ) then
begin
dbedit := TEdit.Create( theForm );
dbedit.Left := control.params.GetValueAsInteger('Left');
dbedit.Tag := control.Tag;
dbedit.Top := control.params.GetValueAsInteger('Top');
dbedit.Width := control.params.GetValueAsInteger('Width');
dbedit.Height := control.params.GetValueAsInteger('Height');
dbedit.Text := control.params.GetValueAsString('RequisiteCode');
dbedit.Parent := parent;
dbedit.Text := dbedit.Text + ExplainType( control );
this_component := dbedit;
//Ñîçäàíèå ïîäïèñè---------------------------------------------------------
editlabel := TLabel.Create( theForm );
editlabel.Caption := control.params.GetValueAsString('EditLabel.Caption') + ':';
editlabel.Tag := control.Tag;
if control.required then
begin
editlabel.Caption := '*' + editlabel.Caption;
editLabel.Font.Style := [fsBold];
end;
editlabel.Parent := parent;
label_spacing := control.params.GetValueAsInteger('LabelSpacing');
if control.params.GetValueAsString( 'LabelPosition' ) <> 'lpAbove' then
begin
editlabel.Left := this_component.Left - label_spacing;
editlabel.Top := this_component.Top + 2;
end;
if control.params.GetValueAsString( 'LabelPosition' ) = 'lpAbove' then
begin
editlabel.Left := this_component.Left;
editlabel.Top := this_component.Top - label_spacing;
end;
editlabel.OnClick := ShowYourCaption;
//-------------------------------------------------------------------------
handled := true;
end;
// ÐÅÊÂÈÇÈÒ ïîëå ÒÅÊÑÒÀ
if ( control.control_type = 'TSLDBMemo' ) then
begin
memo := TMemo.Create( theForm );
memo.Left := control.params.GetValueAsInteger('Left');
memo.Top := control.params.GetValueAsInteger('Top');
memo.Width := control.params.GetValueAsInteger('Width');
memo.Tag := control.Tag;
memo.Height := control.params.GetValueAsInteger('Height');
memo.Text := control.params.GetValueAsString('RequisiteCode');
memo.Parent := parent;
memo.Text := memo.Text + ExplainType( control );
this_component := memo;
//Ñîçäàíèå ïîäïèñè---------------------------------------------------------
editlabel := TLabel.Create( theForm );
editlabel.Caption := control.params.GetValueAsString('EditLabel.Caption') + ':';
editlabel.Parent := parent;
editlabel.Tag := control.Tag;
label_spacing := control.params.GetValueAsInteger('LabelSpacing');
if control.params.GetValueAsString( 'LabelPosition' ) <> 'lpAbove' then
begin
editlabel.Left := this_component.Left - label_spacing;
editlabel.Top := this_component.Top + 2;
end;
if control.params.GetValueAsString( 'LabelPosition' ) = 'lpAbove' then
begin
editlabel.Left := this_component.Left;
editlabel.Top := this_component.Top - label_spacing;
end;
//-------------------------------------------------------------------------
if control.required then
begin
editlabel.Caption := '*' + editlabel.Caption;
editlabel.Font.Style := [fsBold];
end;
handled := true;
end;
// ÐÅÊÂÈÇÈÒ ïðèçíàê Äà/Íåò
if control.control_type = 'TSLDBCheckBox' then
begin
checkbox := TCheckBox.Create( theForm );
checkbox.Left := control.params.GetValueAsInteger('left');
checkbox.Top := control.params.GetValueAsInteger('top');
checkbox.Height := control.params.GetValueAsInteger('Height');
checkbox.Width := control.params.GetValueAsInteger('Width');
checkbox.Caption := control.params.GetValueAsString('Caption');
checkbox.Parent := parent;
checkbox.Tag := control.tag;
checkbox.Caption := checkbox.Caption + ExplainType( control );
if control.required then
begin
checkbox.Caption := '*' + checkbox.Caption;
checkbox.Font.Style := [fsBold];
end;
this_component := checkbox;
handled := true;
end;
// ÄÅÉÑÒÂÈÅ ññûëêà
if control.control_type = 'TSLHyperLinkLabel' then
begin
hyperlabel := TLabel.Create( theForm );
hyperlabel.Left := control.params.GetValueAsInteger('left');
hyperlabel.Top := control.params.GetValueAsInteger('top');
hyperlabel.Height := control.params.GetValueAsInteger('Height');
hyperlabel.Width := control.params.GetValueAsInteger('Width');
hyperlabel.Caption := control.params.GetValueAsString('Caption');
hyperlabel.Font.Style :=[fsUnderline];
hyperlabel.Font.Color := clBlue;
hyperlabel.Parent := parent;
hyperlabel.Tag := control.tag;
this_component := parent;
handled := true;
end;
if control.control_type = 'TSLWebBrowserControl' then
begin
browser := TPanel.Create( theForm );
browser.Left := control.params.GetValueAsInteger('left');
browser.Top := control.params.GetValueAsInteger('top');
browser.Height := control.params.GetValueAsInteger('Height');
browser.Width := control.params.GetValueAsInteger('Width');
browser.Parent := parent;
browser.Caption := 'Âåá-áðàóçåð';
browser.Tag := control.tag;
this_component := browser;
// Ñîçäàíèå ïîäïèñè---------------------------------------------------------
editlabel := TLabel.Create( theForm );
editlabel.Caption := control.params.GetValueAsString('EditLabel.Caption') + ':';
editlabel.Parent := parent;
editlabel.Tag := control.tag;
label_spacing := control.params.GetValueAsInteger('LabelSpacing');
if control.params.GetValueAsString( 'LabelPosition' ) <> 'lpAbove' then
begin
editlabel.Left := this_component.Left - label_spacing;
editlabel.Top := this_component.Top + 2;
end;
if control.params.GetValueAsString( 'LabelPosition' ) = 'lpAbove' then
begin
editlabel.Left := this_component.Left;
editlabel.Top := this_component.Top - label_spacing;
end;
//-------------------------------------------------------------------------
handled := true;
end;
if control.control_type = 'TSLDBImageControl' then
begin
image_panel := TPanel.Create( theForm );
image_panel.Left := control.params.GetValueAsInteger('left');
image_panel.Top := control.params.GetValueAsInteger('top');
image_panel.Height := control.params.GetValueAsInteger('Height');
image_panel.Width := control.params.GetValueAsInteger('Width');
image_panel.Parent := parent;
image_panel.Tag := control.tag;
image_panel.Caption := 'Èçîáðàæåíèå';
this_component := image_panel;
handled := true;
end;
if control.control_type = 'TSLPageControl' then
begin
page_control := TPageControl.Create( theForm );
page_control.Left := control.params.GetValueAsInteger('left');
page_control.Top := control.params.GetValueAsInteger('top');
page_control.Height := control.params.GetValueAsInteger('Height');
page_control.Width := control.params.GetValueAsInteger('Width');
page_control.Parent := parent;
page_control.Tag := control.tag;
this_component := page_control;
handled := true;
end;
if control.control_type = 'TSLcxGrid' then
begin
grid := TStringGrid.Create( theForm );
grid.Left := control.params.GetValueAsInteger('left');
grid.Top := control.params.GetValueAsInteger('top');
grid.Height := control.params.GetValueAsInteger('Height');
grid.Width := control.params.GetValueAsInteger('Width');
grid.OnSelectCell := EvHandler.StringGridSelectCell;
grid.Tag := control.tag;
grid.RowCount := 2;
grid.FixedRows := 1;
grid.FixedCols := 0;
grid.ColCount := 0;
grid.ColWidths[0] := 0;
grid.Ctl3D := false;
grid.BorderStyle := bsSingle;
grid.DefaultRowHeight := 15;
grid.Parent := parent;
grid.Options := [goColSizing, goVertLine, goHorzLine];
this_component := grid;
handled := true;
end;
if control.control_type = 'TSLcxGridDBTableView' then
begin
grid := TStringGrid( parent );
this_component := parent;
handled := true;
end;
// ÐÅÊÂÈÇÈÒ â ÒÀÁËÈÖÅ
if control.control_type = 'TSLcxGridDBColumn' then
begin
grid := TStringGrid( parent );
this_component := parent;
grid.ColCount := grid.ColCount + 1;
grid.Cells[ grid.ColCount -1, 0] := control.params.GetValueAsString('Caption');
grid.Cells[ grid.ColCount -1, 1] := control.params.GetValueAsString('RequisiteCode');
grid.ColWidths[ grid.ColCount -1 ] := control.params.GetValueAsInteger('Width');
grid.Cells[ grid.ColCount -1, 1] := grid.Cells[ grid.ColCount -1, 1] + ExplainType( control );
handled := true;
end;
try
if control.control_type = 'TSLTabSheet' then
begin
tab_sheet := TTabSheet.Create( theForm );
tab_sheet.Caption := control.params.GetValueAsString('Caption');
tab_sheet.Parent := parent;
tab_sheet.Tag := control.Tag;
tab_sheet.PageControl := TPageControl( parent );
tab_sheet.Visible := true;
// tab_sheet.Name := control.name;
this_component := tab_sheet;
handled := true;
end;
except
ShowMessage( 'Îøèáêà ïðè ñîçäàíèè ñòðàíèöû PageControl' );
end;
if control.control_type = 'TSLGroupBox' then
begin
groupbox := TGroupBox.Create( theForm );
groupbox.Left := control.params.GetValueAsInteger('Left');
groupbox.Top := control.params.GetValueAsInteger('Top');
groupbox.Width := control.params.GetValueAsInteger('Width');
groupbox.Tag := control.Tag;
groupbox.Height := control.params.GetValueAsInteger('Height');
groupbox.Caption := control.params.GetValueAsString('Caption');
groupbox.Parent := parent;
this_component := groupbox;
handled := true;
end;
// ÄÅÉÑÒÂÈß êíîïêà
if control.control_type = 'TSLButton' then
begin
button := TButton.Create( theForm );
button.Left := control.params.GetValueAsInteger('Left');
button.Top := control.params.GetValueAsInteger('Top');
button.Width := control.params.GetValueAsInteger('Width');
button.Height := control.params.GetValueAsInteger('Height');
button.ShowHint := true;
button.Hint := control.params.GetValueAsString('RequisiteCode');
button.Tag := control.Tag;
if Assigned( control.ref_requisite ) then
button.Caption := control.ref_requisite.name
else
button.Caption := control.params.GetValueAsString('RequisiteCode');
if control.params.GetValueAsString('Action') = 'AddAction' then
begin
button.Caption := 'Äîáàâèòü';
button.Hint := 'AddAction';
end;
if control.params.GetValueAsString('Action') = 'SaveRecordAction' then
begin
button.Caption := 'Ñîõðàíèòü';
button.Hint := 'SaveRecordAction';
end;
if control.params.GetValueAsString('Action') = 'DeleteAction' then
begin
button.Caption := 'Óäàëèòü';
button.Hint := 'DeleteAction';