source: cprs/branches/tmg-cprs/CPRS-Chart/Orders/fODGen.pas@ 453

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

Initial upload of TMG-CPRS 1.0.26.69

File size: 22.7 KB
Line 
1//kt -- Modified with SourceScanner on 8/8/2007
2unit fODGen;
3
4interface
5
6uses
7 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
8 fODBase, ComCtrls, ExtCtrls, StdCtrls, ORDtTm, ORCtrls, ORFn, rODBase,
9 DKLang;
10
11type
12 TDialogCtrl = class
13 ID: string;
14 DataType: Char;
15 Required: Boolean;
16 Preserve: Boolean;
17 Prompt: TStaticText;
18 Editor: TWinControl;
19 IHidden: string;
20 EHidden: string;
21 end;
22
23 TfrmODGen = class(TfrmODBase)
24 sbxMain: TScrollBox;
25 procedure FormCreate(Sender: TObject);
26 procedure FormClose(Sender: TObject; var Action: TCloseAction);
27 private
28 //kt Begin Mod (change Consts to Vars) 8/8/2007
29 TX_STOPSTART : string; //kt
30 //kt End Mod -------------------
31 FilterOut: boolean;
32 TsID: string; //treating specialty id
33 TSDomain: string;
34 AttendID: string;
35 AttendDomain: string;
36 procedure ControlChange(Sender: TObject);
37 procedure LookupNeedData(Sender: TObject; const StartFrom: string;
38 Direction, InsertAt: Integer);
39 procedure PlaceControls;
40 procedure PlaceDateTime(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
41 procedure PlaceFreeText(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
42 procedure PlaceHidden(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
43 procedure PlaceNumeric(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
44 procedure PlaceSetOfCodes(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
45 procedure PlaceYesNo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
46 procedure PlaceLookup(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
47 procedure PlaceMemo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
48 procedure PlaceLabel(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
49 procedure SetupVars; //kt
50 protected
51 FCharHt: Integer;
52 FCharWd: Integer;
53 FDialogItemList: TList;
54 FDialogCtrlList: TList;
55 FEditorLeft: Integer;
56 FEditorTop: Integer;
57 FFirstCtrl: TWinControl;
58 FLabelWd: Integer;
59 procedure InitDialog; override;
60 procedure SetDialogIEN(Value: Integer); override;
61 procedure Validate(var AnErrMsg: string); override;
62 public
63 procedure SetupDialog(OrderAction: Integer; const ID: string); override;
64 end;
65
66var
67 frmODGen: TfrmODGen;
68
69implementation
70
71{$R *.DFM}
72
73uses rCore, rOrders, uConst;
74
75const
76 HT_FRAME = 8;
77 HT_LBLOFF = 3;
78 HT_SPACE = 6;
79 WD_MARGIN = 6;
80//TX_STOPSTART = 'The stop date must be after the start date.'; <-- original line. //kt 8/8/2007
81
82
83procedure TfrmODGen.SetupVars;
84//kt Added entire function to replace constant declarations 8/8/2007
85begin
86 TX_STOPSTART := DKLangConstW('fODGen_The_stop_date_must_be_after_the_start_datex');
87end;
88
89procedure TfrmODGen.FormCreate(Sender: TObject);
90var
91 TheEvtType: string;
92 IDs,TSstr, AttendStr: string;
93begin
94 inherited;
95 FilterOut := True;
96 if Self.EvtID < 1 then
97 FilterOut := False;
98 if Self.EvtID > 0 then
99 begin
100 TheEvtType := Piece(EventInfo1(IntToStr(Self.EvtId)), '^', 1);
101 if (TheEvtType = 'A') or (TheEvtType = 'T') or (TheEvtType = 'M') or (TheEvtType = 'O') then
102 FilterOut := False;
103 end;
104 FillerID := 'OR'; // does 'on Display' order check **KCM**
105 IDs := GetPromptIDs;
106 TSstr := Piece(IDs,'~',1);
107 TsDomain := Piece(TSstr,'^', 1);
108 TsID := Piece(TSstr,'^', 2);
109 AttendStr := Piece(IDs,'~',2);
110 AttendDomain := Piece(AttendStr,'^',1);
111 AttendID := Piece(AttendStr,'^',2);
112 FDialogItemList := TList.Create;
113 FDialogCtrlList := TList.Create;
114end;
115
116procedure TfrmODGen.FormClose(Sender: TObject; var Action: TCloseAction);
117var
118 i: Integer;
119 DialogCtrl: TDialogCtrl;
120begin
121 with FDialogItemList do for i := 0 to Count - 1 do TDialogItem(Items[i]).Free;
122 with FDialogCtrlList do for i := 0 to Count - 1 do
123 begin
124 DialogCtrl := TDialogCtrl(Items[i]);
125 with DialogCtrl do
126 begin
127 if Prompt <> nil then Prompt.Free;
128 if Editor <> nil then case DataType of
129 'D': TORDateBox(Editor).Free;
130 'F': TEdit(Editor).Free;
131 'N': TEdit(Editor).Free;
132 'P': TORComboBox(Editor).Free;
133 'R': TORDateBox(Editor).Free;
134 'S': TORComboBox(Editor).Free;
135 'W': TMemo(Editor).Free;
136 'Y': TORComboBox(Editor).Free;
137 else Editor.Free;
138 end;
139 Free;
140 end;
141 end;
142 FDialogItemList.Free;
143 FDialogCtrlList.Free;
144 inherited;
145end;
146
147procedure TfrmODGen.SetDialogIEN(Value: Integer);
148{ Sets up a generic ordering dialog on the fly. Called before SetupDialog. }
149var
150 DialogNames: TDialogNames;
151begin
152 inherited;
153//StatusText('Loading Dialog Definition'); <-- original line. //kt 8/8/2007
154 StatusText(DKLangConstW('fODGen_Loading_Dialog_Definition')); //kt added 8/8/2007
155 IdentifyDialog(DialogNames, DialogIEN);
156 Caption := DialogNames.Display;
157 Responses.Dialog := DialogNames.BaseName; // loads formatting info
158 LoadOrderPrompting(FDialogItemList, DialogNames.BaseIEN); // loads prompting info
159 PlaceControls;
160 StatusText('');
161end;
162
163procedure TfrmODGen.SetupDialog(OrderAction: Integer; const ID: string);
164var
165 i: Integer;
166 theEvtInfo: string;
167 thePromptIen: integer;
168 AResponse: TResponse;
169 AnEvtResponse: TResponse;
170begin
171 inherited;
172 if OrderAction in [ORDER_COPY, ORDER_EDIT, ORDER_QUICK] then with Responses do
173 begin
174 Changing := True;
175 // for copy & edit, SetDialogIEN hasn't been called yet
176 if (Length(ID) > 0) and (DialogIEN = 0) then SetDialogIEN(DialogForOrder(ID));
177 with FDialogCtrlList do for i := 0 to Count -1 do with TDialogCtrl(Items[i]) do
178 begin
179 if (ID = 'EVENT') and ( Responses.EventIFN > 0 ) then
180 begin
181 thePromptIen := GetIENForPrompt(ID);
182 if thePromptIen = 0 then
183 thePromptIen := GetEventPromptID;
184 AResponse := FindResponseByName('EVENT', 1);
185 if AResponse <> nil then
186 begin
187 theEvtInfo := EventInfo1(AResponse.IValue);
188 AResponse.EValue := Piece(theEvtInfo,'^',4);
189 end;
190 if AResponse = nil then
191 begin
192 AnEvtResponse := TResponse.Create;
193 AnEvtResponse.PromptID := 'EVENT';
194 AnEvtResponse.PromptIEN := thePromptIen;
195 AnEvtResponse.Instance := 1;
196 AnEvtResponse.IValue := IntToStr(Responses.EventIFN);
197 theEvtInfo := EventInfo1(AnEvtResponse.IValue);
198 AnEvtResponse.EValue := Piece(theEvtInfo,'^',4);
199 Responses.TheList.Add(AnEvtResponse);
200 end;
201 end;
202 if Editor <> nil then SetControl(Editor, ID, 1);
203 if DataType = 'H' then
204 begin
205 AResponse := FindResponseByName(ID, 1);
206 if AResponse <> nil then
207 begin
208 IHidden := AResponse.IValue;
209 EHidden := AResponse.EValue;
210 end; {if AResponse}
211 end; {if DataType}
212 end; {with TDialogCtrl}
213 Changing := False;
214 end; {if OrderAction}
215 ControlChange(Self);
216 if (FFirstCtrl <> nil) and (FFirstCtrl.Enabled) then SetFocusedControl(FFirstCtrl);
217end;
218
219procedure TfrmODGen.InitDialog;
220var
221 i: Integer;
222begin
223 inherited; // inherited does a ClearControls (probably never called since always quick order)
224 {NEED TO CLEAR CONTROLS HERE OR CHANGE ClearControls so can clear children of container}
225 with FDialogCtrlList do for i := 0 to Count -1 do
226 with TDialogCtrl(Items[i]) do if (Editor <> nil) and not Preserve then
227 begin
228 // treat the list & combo boxes differently so their lists aren't cleared
229 if (Editor is TListBox) then TListBox(Editor).ItemIndex := -1
230 else if (Editor is TComboBox) then
231 begin
232 TComboBox(Editor).Text := '';
233 TComboBox(Editor).ItemIndex := -1;
234 end
235 else if (Editor is TORComboBox) then
236 begin
237 TORComboBox(Editor).Text := '';
238 TORComboBox(Editor).ItemIndex := -1;
239 end
240 else ClearControl(Editor);
241 end;
242 if FFirstCtrl <> nil then ActiveControl := FFirstCtrl;
243end;
244
245procedure TfrmODGen.Validate(var AnErrMsg: string);
246var
247 i: Integer;
248 ALabel, AMsg: string;
249 AResponse: TResponse;
250 DialogCtrl: TDialogCtrl;
251 StartDT, StopDT: TFMDateTime;
252
253 procedure SetError(const x: string);
254 begin
255 if Length(AnErrMsg) > 0 then AnErrMsg := AnErrMsg + CRLF;
256 AnErrMsg := AnErrMsg + x;
257 end;
258
259begin
260 SetupVars; //kt added 8/8/2007 to replace constants with vars.
261 inherited;
262 with FDialogCtrlList do for i := 0 to Count -1 do
263 begin
264 DialogCtrl := TDialogCtrl(Items[i]);
265 with DialogCtrl do
266 begin
267// if Prompt <> nil then ALabel := Piece(Prompt.Caption, ':', 1) else ALabel := '<Unknown>'; <-- original line. //kt 8/8/2007
268 if Prompt <> nil then ALabel := Piece(Prompt.Caption, ':', 1) else ALabel := DKLangConstW('fODGen_xUnknownx'); //kt added 8/8/2007
269 if Required then
270 begin
271 AResponse := Responses.FindResponseByName(ID, 1);
272 if (AResponse = nil) or ((AResponse <> nil) and (AResponse.EValue = ''))
273// then SetError(ALabel + ' is required.'); <-- original line. //kt 8/8/2007
274 then SetError(ALabel + DKLangConstW('fODGen_is_requiredx')); //kt added 8/8/2007
275 end;
276 if ((DataType = 'D') or (DataType = 'R')) and (Editor <> nil) then
277 begin
278 TORDateBox(Editor).Validate(AMsg);
279 if Length(AMsg) > 0 then SetError('For ' + ALabel + ': ' + AMsg);
280 end;
281 if (DataType = 'N') then
282 begin
283 AResponse := Responses.FindResponseByName(ID, 1);
284 if (AResponse <> nil) and (Length(AResponse.EValue) > 0) then with AResponse do
285 begin
286 ValidateNumericStr(EValue, Piece(TEdit(Editor).Hint, '|', 2), AMsg);
287 if Length(AMsg) > 0 then SetError('For ' + ALabel + ': ' + AMsg);
288 end; {if AResponse}
289 end; {if DataType}
290 end; {with DialogCtrl}
291 end; {with FDialogCtrlList}
292 with Responses do
293 begin
294 AResponse := FindResponseByName('START', 1);
295 if AResponse <> nil then StartDT := StrToFMDateTime(AResponse.EValue) else StartDT := 0;
296 AResponse := FindResponseByName('STOP', 1);
297 if AResponse <> nil then StopDT := StrToFMDateTime(AResponse.EValue) else StopDT := 0;
298 if (StopDT > 0) and (StopDT <= StartDT) then SetError(TX_STOPSTART);
299 end;
300end;
301
302procedure TfrmODGen.PlaceControls;
303var
304 i: Integer;
305 DialogItem: TDialogItem;
306 DialogCtrl: TDialogCtrl;
307begin
308 FCharHt := MainFontHeight;
309 FCharWd := MainFontWidth;
310 FEditorTop := HT_SPACE;
311 FLabelWd := 0;
312 with FDialogItemList do for i := 0 to Count - 1 do with TDialogItem(Items[i]) do
313 if not Hidden then FLabelWd := HigherOf(FLabelWd, Canvas.TextWidth(Prompt));
314 FEditorLeft := FLabelWd + (WD_MARGIN * 2);
315 with FDialogItemList do for i := 0 to Count - 1 do
316 begin
317 DialogItem := TDialogItem(Items[i]);
318 if FilterOut then
319 begin
320 if ( compareText(TsID,DialogItem.Id)=0 ) or ( compareText(TSDomain,DialogItem.Domain)=0) then
321 Continue;
322// if (Pos('primary',LowerCase(DialogItem.Prompt)) > 0) then <-- original line. //kt 8/8/2007
323 if (Pos(DKLangConstW('fODGen_primary'),LowerCase(DialogItem.Prompt)) > 0) then //kt added 8/8/2007
324 Continue;
325 if (compareText(AttendID,DialogItem.ID) = 0) or ( compareText(AttendDomain,DialogItem.Domain)=0 ) then
326 Continue;
327 end;
328 DialogCtrl := TDialogCtrl.Create;
329 DialogCtrl.ID := DialogItem.ID;
330 DialogCtrl.DataType := DialogItem.DataType;
331 DialogCtrl.Required := DialogItem.Required;
332 DialogCtrl.Preserve := Length(DialogItem.EDefault) > 0;
333 case DialogItem.DataType of
334 'D': PlaceDateTime(DialogCtrl, DialogItem);
335 'F': PlaceFreeText(DialogCtrl, DialogItem);
336 'H': PlaceHidden(DialogCtrl, DialogItem);
337 'N': PlaceNumeric(DialogCtrl, DialogItem);
338 'P': PlaceLookup(DialogCtrl, DialogItem);
339 'R': PlaceDateTime(DialogCtrl, DialogItem);
340 'S': PlaceSetOfCodes(DialogCtrl, DialogItem);
341 'W': PlaceMemo(DialogCtrl, DialogItem);
342 'Y': PlaceYesNo(DialogCtrl, DialogItem);
343 end;
344 FDialogCtrlList.Add(DialogCtrl);
345 if (DialogCtrl.Editor <> nil) and (FFirstCtrl = nil) then FFirstCtrl := DialogCtrl.Editor;
346 end;
347end;
348
349procedure TfrmODGen.PlaceDateTime(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
350const
351 NUM_CHAR = 22;
352begin
353 with DialogCtrl do
354 begin
355 Editor := TORDateBox.Create(Self);
356 Editor.Parent := sbxMain;
357 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
358 TORDateBox(Editor).DateOnly := Pos('T', DialogItem.Domain) = 0;
359 with TORDateBox(Editor) do RequireTime := (not DateOnly) and (Pos('R', DialogItem.Domain) > 0); //v26.48 - RV PSI-05-002
360 TORDateBox(Editor).Text := DialogItem.EDefault;
361 TORDateBox(Editor).Hint := DialogItem.HelpText;
362 TORDateBox(Editor).Caption := DialogItem.Prompt;
363 if Length(DialogItem.HelpText) > 0 then TORDateBox(Editor).ShowHint := True;
364 TORDateBox(Editor).OnExit := ControlChange;
365 PlaceLabel(DialogCtrl, DialogItem);
366 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
367 end;
368end;
369
370procedure TfrmODGen.PlaceFreeText(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
371begin
372 with DialogCtrl do
373 begin
374 Editor := TCaptionEdit.Create(Self);
375 Editor.Parent := sbxMain;
376 Editor.SetBounds(FEditorLeft, FEditorTop,
377 sbxMain.Width - FEditorLeft - WD_MARGIN - GetSystemMetrics(SM_CXVSCROLL),
378 HT_FRAME * FCharHt);
379 TEdit(Editor).MaxLength := StrToIntDef(Piece(DialogItem.Domain, ':', 2), 0);
380 TEdit(Editor).Text := DialogItem.EDefault;
381 TEdit(Editor).Hint := DialogItem.HelpText;
382 TCaptionEdit(Editor).Caption := DialogItem.Prompt;
383 if Length(DialogItem.HelpText) > 0 then TEdit(Editor).ShowHint := True;
384 TEdit(Editor).OnChange := ControlChange;
385 PlaceLabel(DialogCtrl, DialogItem);
386 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
387 end;
388end;
389
390procedure TfrmODGen.PlaceNumeric(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
391const
392 NUM_CHAR = 16;
393begin
394 with DialogCtrl do
395 begin
396 Editor := TCaptionEdit.Create(Self);
397 Editor.Parent := sbxMain;
398 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
399 TEdit(Editor).MaxLength := NUM_CHAR;
400 TEdit(Editor).Text := DialogItem.EDefault;
401 TEdit(Editor).Hint := DialogItem.HelpText + '|' + DialogItem.Domain;
402 TCaptionEdit(Editor).Caption := DialogItem.Prompt;
403 if Length(DialogItem.HelpText) > 0 then TEdit(Editor).ShowHint := True;
404 TEdit(Editor).OnChange := ControlChange;
405 PlaceLabel(DialogCtrl, DialogItem);
406 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
407 end;
408end;
409
410procedure TfrmODGen.PlaceSetOfCodes(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
411const
412 NUM_CHAR = 32;
413var
414 x, y: string;
415begin
416 with DialogCtrl do
417 begin
418 Editor := TORComboBox.Create(Self);
419 Editor.Parent := sbxMain;
420 TORComboBox(Editor).Style := orcsDropDown;
421 TORComboBox(Editor).ListItemsOnly := True;
422 TORComboBox(Editor).Pieces := '2';
423 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
424 x := DialogItem.Domain;
425 repeat
426 y := Piece(x, ';', 1);
427 Delete(x, 1, Length(y) + 1);
428 y := Piece(y, ':', 1) + U + Piece(y, ':', 2);
429 TORComboBox(Editor).Items.Add(y);
430 until Length(x) = 0;
431 TORComboBox(Editor).SelectByID(DialogItem.IDefault);
432 //TORComboBox(Editor).Text := DialogItem.EDefault;
433 TORComboBox(Editor).Hint := DialogItem.HelpText;
434 if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
435 TORComboBox(Editor).OnChange := ControlChange;
436 PlaceLabel(DialogCtrl, DialogItem);
437 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
438 end;
439end;
440
441procedure TfrmODGen.PlaceYesNo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
442const
443 NUM_CHAR = 9;
444begin
445 with DialogCtrl do
446 begin
447 Editor := TORComboBox.Create(Self);
448 Editor.Parent := sbxMain;
449 TORComboBox(Editor).Style := orcsDropDown;
450 TORComboBox(Editor).ListItemsOnly := True;
451 TORComboBox(Editor).Pieces := '2';
452 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
453// TORComboBox(Editor).Items.Add('0^No'); <-- original line. //kt 8/8/2007
454 TORComboBox(Editor).Items.Add('0^'+DKLangConstW('fODGen_No')); //kt added 8/8/2007
455// TORComboBox(Editor).Items.Add('1^Yes'); <-- original line. //kt 8/8/2007
456 TORComboBox(Editor).Items.Add('1^'+DKLangConstW('fODGen_Yes')); //kt added 8/8/2007
457 TORComboBox(Editor).SelectByID(DialogItem.IDefault);
458 //TORComboBox(Editor).Text := DialogItem.EDefault;
459 TORComboBox(Editor).Hint := DialogItem.HelpText;
460 if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
461 TORComboBox(Editor).OnChange := ControlChange;
462 PlaceLabel(DialogCtrl, DialogItem);
463 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
464 end;
465end;
466
467procedure TfrmODGen.PlaceLookup(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
468const
469 NUM_CHAR = 32;
470var
471 idx,defidx,evtChars: integer;
472 GblRef, XRef: string;
473 TopTSList: TStringList;
474begin
475 with DialogCtrl do
476 begin
477 GblRef := DialogItem.Domain;
478 if CharAt(GblRef, 1) in ['0'..'9','.']
479 then GblRef := GlobalRefForFile(Piece(GblRef, ':', 1))
480 else GblRef := Piece(GblRef, ':', 1);
481 if CharAt(GblRef, 1) <> U then GblRef := U + GblRef;
482 if Length(DialogItem.CrossRef) > 0 then XRef := DialogItem.CrossRef else XRef := 'B';
483 XRef := GblRef + '"' + XRef + '")';
484 Editor := TORComboBox.Create(Self);
485 Editor.Parent := sbxMain;
486 TORComboBox(Editor).Style := orcsDropDown;
487 TORComboBox(Editor).ListItemsOnly := True;
488 TORComboBox(Editor).Pieces := '2';
489 TORComboBox(Editor).LongList := True;
490 // 2nd bar piece of hint is not visible, hide xref, global ref, & screen code in tab pieces
491 TORComboBox(Editor).Hint := DialogItem.HelpText + '|' + XRef + #9 + GblRef + #9 +
492 DialogItem.ScreenRef;
493 if ( compareText(TsID,DialogItem.Id)=0 ) or (compareText(TSDomain,DialogItem.Domain)=0)then
494 begin
495 TopTSList := TStringList.Create;
496 DialogItem.IDefault := Piece(GetDefaultTSForEvt(Self.EvtID),'^',1);
497 GetTSListForEvt(TStrings(TopTSList),Self.EvtID);
498 if TopTSList.Count > 0 then
499 begin
500 if Length(DialogItem.IDefault)>0 then
501 begin
502 defidx := -1;
503 for idx := 0 to topTSList.Count - 1 do
504 if Piece(TopTSList[idx],'^',1)= DialogItem.IDefault then
505 begin
506 defidx := idx;
507 break;
508 end;
509 if defidx >= 0 then
510 topTSList.Move(defidx,0);
511 end;
512 with TORComboBox(Editor) do
513 begin
514 Items.AddStrings(TStrings(TopTSList));
515 LongList := false;
516 end;
517 end else
518 TORComboBox(Editor).OnNeedData := LookupNeedData;
519 if Length(DialogItem.IDefault)<1 then
520 DialogItem.IDefault := '0';
521 end else
522 TORComboBox(Editor).OnNeedData := LookupNeedData;
523 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
524 TORComboBox(Editor).InitLongList(DialogItem.EDefault);
525 TORComboBox(Editor).SelectByID(DialogItem.IDefault);
526 if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
527 TORComboBox(Editor).OnChange := ControlChange;
528 if ( AnsiCompareText(ID,'EVENT')=0 ) and (Self.EvtID>0)then
529 begin
530 evtChars := length(Responses.EventName);
531 if evtChars > NUM_CHAR then
532 Editor.SetBounds(FEditorLeft, FEditorTop, (evtChars + 6) * FCharWd, HT_FRAME * FCharHt);
533 TORComboBox(Editor).Enabled := False;
534 end;
535 PlaceLabel(DialogCtrl, DialogItem);
536 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
537 end;
538end;
539
540procedure TfrmODGen.LookupNeedData(Sender: TObject; const StartFrom: string;
541 Direction, InsertAt: Integer);
542var
543 XRef, GblRef, ScreenRef: string;
544begin
545 inherited;
546 XRef := Piece(TORComboBox(Sender).Hint, '|', 2);
547 GblRef := Piece(XRef, #9, 2);
548 ScreenRef := Piece(XRef, #9, 3);
549 XRef := Piece(XRef, #9, 1);
550 TORComboBox(Sender).ForDataUse(SubsetOfEntries(StartFrom, Direction, XRef, GblRef, ScreenRef));
551end;
552
553procedure TfrmODGen.PlaceMemo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
554const
555 NUM_LINES = 3;
556begin
557 with DialogCtrl do
558 begin
559 Editor := TCaptionMemo.Create(Self);
560 Editor.Parent := sbxMain;
561 Editor.SetBounds(FEditorLeft, FEditorTop,
562 sbxMain.Width - FEditorLeft - WD_MARGIN - GetSystemMetrics(SM_CXVSCROLL),
563 (FCharHt * NUM_LINES) + HT_FRAME);
564 TMemo(Editor).Text := DialogItem.EDefault;
565 TMemo(Editor).Hint := DialogItem.HelpText;
566 TCaptionMemo(Editor).Caption := DialogItem.Prompt;
567 if Length(DialogItem.HelpText) > 0 then TMemo(Editor).ShowHint := True;
568 TMemo(Editor).ScrollBars := ssVertical;
569 TMemo(Editor).OnChange := ControlChange;
570 PlaceLabel(DialogCtrl, DialogItem);
571 FEditorTop := FEditorTop + HT_FRAME + (FCharHt * 3) + HT_SPACE;
572 end;
573end;
574
575procedure TfrmODGen.PlaceHidden(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
576begin
577 DialogCtrl.IHidden := DialogItem.IDefault;
578 DialogCtrl.EHidden := DialogItem.EDefault;
579end;
580
581procedure TfrmODGen.PlaceLabel(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
582begin
583 with DialogCtrl do
584 begin
585 Prompt := TStaticText.Create(Self);
586 Prompt.Parent := sbxMain;
587 Prompt.Caption := DialogItem.Prompt;
588 Prompt.AutoSize := False;
589 Prompt.SetBounds(WD_MARGIN, FEditorTop + HT_LBLOFF, FLabelWd, FCharHt);
590 Prompt.Alignment := taRightJustify;
591 Prompt.Visible := True;
592 end;
593end;
594
595procedure TfrmODGen.ControlChange(Sender: TObject);
596var
597 i: Integer;
598begin
599 inherited;
600 if Changing then Exit;
601 with FDialogCtrlList do for i := 0 to Count - 1 do with TDialogCtrl(Items[i]) do
602 begin
603 case DataType of
604 'D': Responses.Update(ID, 1, FloatToStr(TORDateBox(Editor).FMDateTime),
605 TORDateBox(Editor).Text);
606 'F': Responses.Update(ID, 1, TEdit(Editor).Text, TEdit(Editor).Text);
607 'H': Responses.Update(ID, 1, IHidden, EHidden);
608 'N': Responses.Update(ID, 1, TEdit(Editor).Text, TEdit(Editor).Text);
609 'P': Responses.Update(ID, 1, TORComboBox(Editor).ItemID, TORComboBox(Editor).Text);
610 'R': Responses.Update(ID, 1, TORDateBox(Editor).Text, TORDateBox(Editor).Text);
611 'S': Responses.Update(ID, 1, TORComboBox(Editor).ItemID, TORComboBox(Editor).Text);
612 'W': Responses.Update(ID, 1, TX_WPTYPE, TMemo(Editor).Text);
613 'Y': Responses.Update(ID, 1, TORComboBox(Editor).ItemID, TORComboBox(Editor).Text);
614 end;
615 end;
616 memOrder.Text := Responses.OrderText;
617end;
618
619end.
620
Note: See TracBrowser for help on using the repository browser.