source: cprs/branches/tmg-cprs/CPRS-Chart/Templates/fTemplateAutoGen.pas@ 1099

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

Initial upload of TMG-CPRS 1.0.26.69

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