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

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

Adding foia-cprs branch

File size: 21.2 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 TORDateBox(Editor).Text := DialogItem.EDefault;
342 TORDateBox(Editor).Hint := DialogItem.HelpText;
343 TORDateBox(Editor).Caption := DialogItem.Prompt;
344 if Length(DialogItem.HelpText) > 0 then TORDateBox(Editor).ShowHint := True;
345 TORDateBox(Editor).OnExit := ControlChange;
346 PlaceLabel(DialogCtrl, DialogItem);
347 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
348 end;
349end;
350
351procedure TfrmODGen.PlaceFreeText(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
352begin
353 with DialogCtrl do
354 begin
355 Editor := TCaptionEdit.Create(Self);
356 Editor.Parent := sbxMain;
357 Editor.SetBounds(FEditorLeft, FEditorTop,
358 sbxMain.Width - FEditorLeft - WD_MARGIN - GetSystemMetrics(SM_CXVSCROLL),
359 HT_FRAME * FCharHt);
360 TEdit(Editor).MaxLength := StrToIntDef(Piece(DialogItem.Domain, ':', 2), 0);
361 TEdit(Editor).Text := DialogItem.EDefault;
362 TEdit(Editor).Hint := DialogItem.HelpText;
363 TCaptionEdit(Editor).Caption := DialogItem.Prompt;
364 if Length(DialogItem.HelpText) > 0 then TEdit(Editor).ShowHint := True;
365 TEdit(Editor).OnChange := ControlChange;
366 PlaceLabel(DialogCtrl, DialogItem);
367 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
368 end;
369end;
370
371procedure TfrmODGen.PlaceNumeric(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
372const
373 NUM_CHAR = 16;
374begin
375 with DialogCtrl do
376 begin
377 Editor := TCaptionEdit.Create(Self);
378 Editor.Parent := sbxMain;
379 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
380 TEdit(Editor).MaxLength := NUM_CHAR;
381 TEdit(Editor).Text := DialogItem.EDefault;
382 TEdit(Editor).Hint := DialogItem.HelpText + '|' + DialogItem.Domain;
383 TCaptionEdit(Editor).Caption := DialogItem.Prompt;
384 if Length(DialogItem.HelpText) > 0 then TEdit(Editor).ShowHint := True;
385 TEdit(Editor).OnChange := ControlChange;
386 PlaceLabel(DialogCtrl, DialogItem);
387 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
388 end;
389end;
390
391procedure TfrmODGen.PlaceSetOfCodes(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
392const
393 NUM_CHAR = 32;
394var
395 x, y: string;
396begin
397 with DialogCtrl do
398 begin
399 Editor := TORComboBox.Create(Self);
400 Editor.Parent := sbxMain;
401 TORComboBox(Editor).Style := orcsDropDown;
402 TORComboBox(Editor).ListItemsOnly := True;
403 TORComboBox(Editor).Pieces := '2';
404 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
405 x := DialogItem.Domain;
406 repeat
407 y := Piece(x, ';', 1);
408 Delete(x, 1, Length(y) + 1);
409 y := Piece(y, ':', 1) + U + Piece(y, ':', 2);
410 TORComboBox(Editor).Items.Add(y);
411 until Length(x) = 0;
412 TORComboBox(Editor).SelectByID(DialogItem.IDefault);
413 //TORComboBox(Editor).Text := DialogItem.EDefault;
414 TORComboBox(Editor).Hint := DialogItem.HelpText;
415 if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
416 TORComboBox(Editor).OnChange := ControlChange;
417 PlaceLabel(DialogCtrl, DialogItem);
418 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
419 end;
420end;
421
422procedure TfrmODGen.PlaceYesNo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
423const
424 NUM_CHAR = 9;
425begin
426 with DialogCtrl do
427 begin
428 Editor := TORComboBox.Create(Self);
429 Editor.Parent := sbxMain;
430 TORComboBox(Editor).Style := orcsDropDown;
431 TORComboBox(Editor).ListItemsOnly := True;
432 TORComboBox(Editor).Pieces := '2';
433 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
434 TORComboBox(Editor).Items.Add('0^No');
435 TORComboBox(Editor).Items.Add('1^Yes');
436 TORComboBox(Editor).SelectByID(DialogItem.IDefault);
437 //TORComboBox(Editor).Text := DialogItem.EDefault;
438 TORComboBox(Editor).Hint := DialogItem.HelpText;
439 if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
440 TORComboBox(Editor).OnChange := ControlChange;
441 PlaceLabel(DialogCtrl, DialogItem);
442 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
443 end;
444end;
445
446procedure TfrmODGen.PlaceLookup(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
447const
448 NUM_CHAR = 32;
449var
450 idx,defidx,evtChars: integer;
451 GblRef, XRef: string;
452 TopTSList: TStringList;
453begin
454 with DialogCtrl do
455 begin
456 GblRef := DialogItem.Domain;
457 if CharAt(GblRef, 1) in ['0'..'9','.']
458 then GblRef := GlobalRefForFile(Piece(GblRef, ':', 1))
459 else GblRef := Piece(GblRef, ':', 1);
460 if CharAt(GblRef, 1) <> U then GblRef := U + GblRef;
461 if Length(DialogItem.CrossRef) > 0 then XRef := DialogItem.CrossRef else XRef := 'B';
462 XRef := GblRef + '"' + XRef + '")';
463 Editor := TORComboBox.Create(Self);
464 Editor.Parent := sbxMain;
465 TORComboBox(Editor).Style := orcsDropDown;
466 TORComboBox(Editor).ListItemsOnly := True;
467 TORComboBox(Editor).Pieces := '2';
468 TORComboBox(Editor).LongList := True;
469 // 2nd bar piece of hint is not visible, hide xref, global ref, & screen code in tab pieces
470 TORComboBox(Editor).Hint := DialogItem.HelpText + '|' + XRef + #9 + GblRef + #9 +
471 DialogItem.ScreenRef;
472 if ( compareText(TsID,DialogItem.Id)=0 ) or (compareText(TSDomain,DialogItem.Domain)=0)then
473 begin
474 TopTSList := TStringList.Create;
475 DialogItem.IDefault := Piece(GetDefaultTSForEvt(Self.EvtID),'^',1);
476 GetTSListForEvt(TStrings(TopTSList),Self.EvtID);
477 if TopTSList.Count > 0 then
478 begin
479 if Length(DialogItem.IDefault)>0 then
480 begin
481 defidx := -1;
482 for idx := 0 to topTSList.Count - 1 do
483 if Piece(TopTSList[idx],'^',1)= DialogItem.IDefault then
484 begin
485 defidx := idx;
486 break;
487 end;
488 if defidx >= 0 then
489 topTSList.Move(defidx,0);
490 end;
491 with TORComboBox(Editor) do
492 Items.AddStrings(TStrings(TopTSList));
493 end else
494 TORComboBox(Editor).OnNeedData := LookupNeedData;
495 if Length(DialogItem.IDefault)<1 then
496 DialogItem.IDefault := '0';
497 end else
498 TORComboBox(Editor).OnNeedData := LookupNeedData;
499 Editor.SetBounds(FEditorLeft, FEditorTop, NUM_CHAR * FCharWd, HT_FRAME * FCharHt);
500 TORComboBox(Editor).InitLongList(DialogItem.EDefault);
501 TORComboBox(Editor).SelectByID(DialogItem.IDefault);
502 if Length(DialogItem.HelpText) > 0 then TORComboBox(Editor).ShowHint := True;
503 TORComboBox(Editor).OnChange := ControlChange;
504 if ( AnsiCompareText(ID,'EVENT')=0 ) and (Self.EvtID>0)then
505 begin
506 evtChars := length(Responses.EventName);
507 if evtChars > NUM_CHAR then
508 Editor.SetBounds(FEditorLeft, FEditorTop, (evtChars + 6) * FCharWd, HT_FRAME * FCharHt);
509 TORComboBox(Editor).Enabled := False;
510 end;
511 PlaceLabel(DialogCtrl, DialogItem);
512 FEditorTop := FEditorTop + HT_FRAME + FCharHt + HT_SPACE;
513 end;
514end;
515
516procedure TfrmODGen.LookupNeedData(Sender: TObject; const StartFrom: string;
517 Direction, InsertAt: Integer);
518var
519 XRef, GblRef, ScreenRef: string;
520begin
521 inherited;
522 XRef := Piece(TORComboBox(Sender).Hint, '|', 2);
523 GblRef := Piece(XRef, #9, 2);
524 ScreenRef := Piece(XRef, #9, 3);
525 XRef := Piece(XRef, #9, 1);
526 TORComboBox(Sender).ForDataUse(SubsetOfEntries(StartFrom, Direction, XRef, GblRef, ScreenRef));
527end;
528
529procedure TfrmODGen.PlaceMemo(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
530const
531 NUM_LINES = 3;
532begin
533 with DialogCtrl do
534 begin
535 Editor := TCaptionMemo.Create(Self);
536 Editor.Parent := sbxMain;
537 Editor.SetBounds(FEditorLeft, FEditorTop,
538 sbxMain.Width - FEditorLeft - WD_MARGIN - GetSystemMetrics(SM_CXVSCROLL),
539 (FCharHt * NUM_LINES) + HT_FRAME);
540 TMemo(Editor).Text := DialogItem.EDefault;
541 TMemo(Editor).Hint := DialogItem.HelpText;
542 TCaptionMemo(Editor).Caption := DialogItem.Prompt;
543 if Length(DialogItem.HelpText) > 0 then TMemo(Editor).ShowHint := True;
544 TMemo(Editor).ScrollBars := ssVertical;
545 TMemo(Editor).OnChange := ControlChange;
546 PlaceLabel(DialogCtrl, DialogItem);
547 FEditorTop := FEditorTop + HT_FRAME + (FCharHt * 3) + HT_SPACE;
548 end;
549end;
550
551procedure TfrmODGen.PlaceHidden(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
552begin
553 DialogCtrl.IHidden := DialogItem.IDefault;
554 DialogCtrl.EHidden := DialogItem.EDefault;
555end;
556
557procedure TfrmODGen.PlaceLabel(DialogCtrl: TDialogCtrl; DialogItem: TDialogItem);
558begin
559 with DialogCtrl do
560 begin
561 Prompt := TStaticText.Create(Self);
562 Prompt.Parent := sbxMain;
563 Prompt.Caption := DialogItem.Prompt;
564 Prompt.AutoSize := False;
565 Prompt.SetBounds(WD_MARGIN, FEditorTop + HT_LBLOFF, FLabelWd, FCharHt);
566 Prompt.Alignment := taRightJustify;
567 Prompt.Visible := True;
568 end;
569end;
570
571procedure TfrmODGen.ControlChange(Sender: TObject);
572var
573 i: Integer;
574begin
575 inherited;
576 if Changing then Exit;
577 with FDialogCtrlList do for i := 0 to Count - 1 do with TDialogCtrl(Items[i]) do
578 begin
579 case DataType of
580 'D': Responses.Update(ID, 1, FloatToStr(TORDateBox(Editor).FMDateTime),
581 TORDateBox(Editor).Text);
582 'F': Responses.Update(ID, 1, TEdit(Editor).Text, TEdit(Editor).Text);
583 'H': Responses.Update(ID, 1, IHidden, EHidden);
584 'N': Responses.Update(ID, 1, TEdit(Editor).Text, TEdit(Editor).Text);
585 'P': Responses.Update(ID, 1, TORComboBox(Editor).ItemID, TORComboBox(Editor).Text);
586 'R': Responses.Update(ID, 1, TORDateBox(Editor).Text, TORDateBox(Editor).Text);
587 'S': Responses.Update(ID, 1, TORComboBox(Editor).ItemID, TORComboBox(Editor).Text);
588 'W': Responses.Update(ID, 1, TX_WPTYPE, TMemo(Editor).Text);
589 'Y': Responses.Update(ID, 1, TORComboBox(Editor).ItemID, TORComboBox(Editor).Text);
590 end;
591 end;
592 memOrder.Text := Responses.OrderText;
593end;
594
595end.
596
Note: See TracBrowser for help on using the repository browser.