source: cprs/branches/foia-cprs/CPRS-Chart/Orders/fODGen.pas@ 1547

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

Uploading from OR_30_258

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