source: cprs/trunk/CPRS-Chart/Orders/fODGen.pas@ 836

Last change on this file since 836 was 829, checked in by Kevin Toppenberg, 14 years ago

Upgrade to version 27

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