source: cprs/trunk/CPRS-Chart/Templates/fTemplateAutoGen.pas@ 499

Last change on this file since 499 was 456, checked in by Kevin Toppenberg, 16 years ago

Initial Upload of Official WV CPRS 1.0.26.76

File size: 4.1 KB
Line 
1unit fTemplateAutoGen;
2
3interface
4
5uses
6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7 StdCtrls, ORCtrls, ExtCtrls, ORFn;
8
9type
10 TfrmTemplateAutoGen = class(TForm)
11 rgSource: TKeyClickRadioGroup;
12 cbxObjects: TORComboBox;
13 btnOK: TButton;
14 btnCancel: TButton;
15 lblTop: TMemo;
16 cbxTitles: TORComboBox;
17 lblSelect: TStaticText;
18 procedure rgSourceClick(Sender: TObject);
19 procedure cbxTitlesNeedData(Sender: TObject; const StartFrom: String;
20 Direction, InsertAt: Integer);
21 procedure cbxTitlesDblClick(Sender: TObject);
22 procedure cbxObjectsDblClick(Sender: TObject);
23 procedure FormShow(Sender: TObject);
24 private
25 FTitlesDone: boolean;
26 FObjectsDone: boolean;
27 public
28 { Public declarations }
29 end;
30
31procedure GetAutoGenText(var AName, AText: string; InList: TStringList);
32
33implementation
34
35uses dShared, rTemplates, uTemplates;
36
37{$R *.DFM}
38
39var
40 PersObjects: TStringList;
41
42const
43 idxTitle = 0;
44 idxObject = 1;
45
46procedure GetAutoGenText(var AName, AText: string; InList: TStringList);
47var
48 frmTemplateAutoGen: TfrmTemplateAutoGen;
49
50begin
51 AName := '';
52 AText := '';
53 PersObjects := InList;
54 frmTemplateAutoGen := TfrmTemplateAutoGen.Create(Application);
55 try
56 ResizeAnchoredFormToFont(frmTemplateAutoGen);
57 with frmTemplateAutoGen do
58 begin
59 ShowModal;
60 if(ModalResult = mrOK) then
61 begin
62 if(rgSource.ItemIndex = idxTitle) then
63 begin
64 if(cbxTitles.ItemID <> '') then
65 begin
66 AName := MixedCase(cbxTitles.DisplayText[cbxTitles.ItemIndex]);
67 AText := GetTitleBoilerplate(cbxTitles.ItemID);
68 end;
69 end
70 else
71 if(rgSource.ItemIndex = idxObject) then
72 begin
73 if(cbxObjects.Text <> '') then
74 begin
75 AName := cbxObjects.Text;
76 AText := '|'+Piece(cbxObjects.Items[cbxObjects.ItemIndex],U,3)+'|'
77 end;
78 end;
79 end;
80 end;
81 finally
82 frmTemplateAutoGen.Free;
83 end;
84end;
85
86procedure TfrmTemplateAutoGen.rgSourceClick(Sender: TObject);
87var
88 idx,i: integer;
89 DoIt: boolean;
90
91begin
92 idx := rgSource.ItemIndex;
93 rgSource.TabStop := (idx < 0);
94 if(idx < 0) then exit;
95 if(idx = idxTitle) then
96 begin
97 cbxTitles.Visible := TRUE;
98 cbxObjects.Visible := FALSE;
99 if(not FTitlesDone) then
100 begin
101 cbxTitles.InitLongList('');
102 FTitlesDone := TRUE
103 end;
104 cbxTitles.SetFocus;
105 end
106 else
107 if(idx = idxObject) then
108 begin
109 cbxObjects.Visible := TRUE;
110 cbxTitles.Visible := FALSE;
111 if(not FObjectsDone) then
112 begin
113 DoIt := TRUE; //10/31/01 S Monson-- Added
114 if (UserTemplateAccessLevel <> taEditor) then //UserTemplateAccessLevel check and
115 if PersObjects.Count > 0 then //PersObjects modification of the list
116 begin //in response to NOIS HUN-0701-22052
117 DoIt := FALSE;
118 for i := 0 to dmodShared.TIUObjects.Count-1 do
119 if PersObjects.IndexOf(Piece(dmodShared.TIUObjects[i],U,2)) >= 0 then
120 cbxObjects.Items.Add(dmodShared.TIUObjects[i]);
121 end;
122 if DoIt then
123 cbxObjects.Items.Assign(dmodShared.TIUObjects);
124 FObjectsDone := TRUE;
125 end;
126 cbxObjects.SetFocus;
127 end;
128end;
129
130procedure TfrmTemplateAutoGen.cbxTitlesNeedData(Sender: TObject;
131 const StartFrom: String; Direction, InsertAt: Integer);
132begin
133 cbxTitles.ForDataUse(SubSetOfBoilerplatedTitles(StartFrom, Direction));
134end;
135
136procedure TfrmTemplateAutoGen.cbxTitlesDblClick(Sender: TObject);
137begin
138 if(cbxTitles.ItemIndex >= 0) then
139 ModalResult := mrOK;
140end;
141
142procedure TfrmTemplateAutoGen.cbxObjectsDblClick(Sender: TObject);
143begin
144 if(cbxObjects.ItemIndex >= 0) then
145 ModalResult := mrOK;
146end;
147
148procedure TfrmTemplateAutoGen.FormShow(Sender: TObject);
149begin
150 //pre-select the first radio item
151 rgSource.ItemIndex := 0;
152end;
153
154end.
Note: See TracBrowser for help on using the repository browser.