Procedure

TfrmTemplateDialog.BuildCB

Module

fTemplateDialog

Last Modified

7/15/2014 3:26:44 PM

Comments

StringIn, StringOut: string;

Visibility

Private

Owner

TfrmTemplateDialog

Declaration

procedure BuildCB(CBidx: integer; var Y: integer; FirstTime: boolean);

Calls Hierarchy


TfrmTemplateDialog.BuildCB
 ├TfrmTemplateDialog.FindObjectByID
 │ └TfrmTemplateDialog.GetObjectID
 ├GetDialogEntry
 │ └TTemplateDialogEntry.Create
 │   ├TDlgFieldPanel.Create
 │   ├GetTemplateField
 │   │ ├LoadTemplateFieldByIEN
 │   │ ├LoadTemplateField
 │   │ └TTemplateField.Create
 │   │   ├TemplateFieldCode2Field
 │   │   └TemplateDateCode2DateType
 │   ├TTemplateField.GetRequired
 │   └TTemplateField.CreateDialogControls
 │     ├TCPRSDialogFieldEdit.Create
 │     │ └TCPRSDialogComponent.Create
 │     ├TTemplateField.GetRequired
 │     ├ht
 │     ├wdth
 │     ├TTemplateField.Width
 │     │ └StripEmbedded
 │     ├TTemplateDialogEntry.DoChange
 │     ├TCPRSDialogComboBox.Create
 │     │ └TCPRSDialogComponent.Create
 │     ├StripEmbedded
 │     ├TfraTemplateFieldButton.Create
 │     │ ├TfraTemplateFieldButton.ButtonKeyDown
 │     │ │ └TfraTemplateFieldButton.pnlBtnMouseDown
 │     │ │   ├TfraTemplateFieldButton.GetButtonText
 │     │ │   └TfraTemplateFieldButton.SetButtonText
 │     │ ├TfraTemplateFieldButton.ButtonKeyUp
 │     │ │ └TfraTemplateFieldButton.pnlBtnMouseUp
 │     │ └TCPRSDialogComponent.Create
 │     ├TfraTemplateFieldButton.SetButtonText
 │     ├TCPRSDialogCheckBox.Create
 │     │ └TCPRSDialogComponent.Create
 │     ├UpdateIndents
 │     │ └wdth
 │     ├StrToFMDateTime
 │     ├TCPRSDialogDateCombo.Create
 │     │ └TCPRSDialogComponent.Create
 │     ├TCPRSDialogDateBox.Create
 │     │ └TCPRSDialogComponent.Create
 │     ├TCPRSDialogNumber.CreatePanel
 │     │ └TCPRSDialogComponent.Create
 │     ├TTemplateDialogEntry.UpDownChange
 │     │ ├EnsureText
 │     │ └TTemplateDialogEntry.DoChange
 │     ├TCPRSDialogHyperlinkLabel.Create
 │     │ ├TCPRSDialogComponent.Create
 │     │ └TCPRSDialogHyperlinkLabel.KeyPressed
 │     │   └TCPRSDialogHyperlinkLabel.Clicked
 │     │     └GotoWebPage
 │     ├TCPRSDialogHyperlinkLabel.Init
 │     │ └TCPRSDialogHyperlinkLabel.Clicked...
 │     └TCPRSDialogRichEdit.Create
 │       └TCPRSDialogComponent.Create
 ├TTemplateDialogEntry.SetAutoDestroyOnPanelFree
 │ └PanelDestroy
 ├TfrmTemplateDialog.EntryDestroyed
 ├TTemplateDialogEntry.GetPanel
 │ ├Init
 │ │ ├TTemplateDialogEntry.KillLabels
 │ │ └ScreenReaderSystem_CurrentCheckBox
 │ │   └ScreenReaderSystem_Stop
 │ │     ├UpdateCheckBox
 │ │     ├UpdatePending
 │ │     └ScreenReaderSystem_Clear
 │ ├Text508Work
 │ │ ├TTemplateDialogEntry.StripCode
 │ │ ├ScreenReaderSystem_Stop...
 │ │ ├StripSRCode
 │ │ └ScreenReaderSystem_Continue
 │ ├TTemplateDialogEntry.StripCode
 │ ├NextLine
 │ ├DoLabel
 │ │ ├Add2TabOrder
 │ │ ├ScreenReaderSystem_CurrentLabel
 │ │ │ └ScreenReaderSystem_Stop...
 │ │ └ScreenReaderSystem_AddText
 │ ├Ctrl508Work
 │ │ ├ScreenReaderSystem_CurrentLabel...
 │ │ ├ScreenReaderSystem_AddText
 │ │ ├ScreenReaderSystem_Stop...
 │ │ ├Add2TabOrder
 │ │ └ScreenReaderSystem_CurrentComponent
 │ │   ├UpdateCheckBox
 │ │   ├UpdatePending
 │ │   └ScreenReaderSystem_Stop...
 │ ├TTemplateDialogEntry.SetFieldValues
 │ │ └TTemplateDialogEntry.SetControlText
 │ │   └TfraTemplateFieldButton.SetButtonText
 │ └ScreenReaderSystem_Stop...
 ├TTemplateDialogEntry.GetText
 │ └ResolveTemplateFields
 │   ├TTemplateDialogEntry.GetControlText
 │   │ ├GetTemplateField...
 │   │ ├GetOriginalItem
 │   │ │ ├GetTemplateField...
 │   │ │ └StripEmbedded
 │   │ └TfraTemplateFieldButton.GetButtonText
 │   ├GetTemplateField...
 │   ├AddNewTxt
 │   └WordWrapText
 │     └WrappedText
 ├TfrmTemplateDialog.FieldChanged
 │ └TTemplateDialogEntry.GetText...
 ├TfrmTemplateDialog.ParentCBEnter
 ├TfrmTemplateDialog.ParentCBExit
 ├TfrmTemplateDialog.ItemChecked
 └NextTabCtrl

Called-By Hierarchy


                          TfrmTemplateDialog.BuildCB
               TfrmTemplateDialog.BuildAllControls┘ 
                                DoTemplateDialog┤   
                       CheckBoilerplate4Fields┤ │   
                         DoTemplateDialog...┤ │ │   
                            ShowTemplateData┘ │ │   
       TfrmDrawers.mnuPreviewTemplateClick┤   │ │   
      TfrmDCSumm.popSummMemoPreviewClick┤ │   │ │   
    TfrmConsults.popNoteMemoPreviewClick┤ │   │ │   
     TfrmSurgery.popNoteMemoPreviewClick┤ │   │ │   
       TfrmNotes.popNoteMemoPreviewClick┘ │   │ │   
          TfrmTemplateEditor.mnuBPTryClick┘   │ │   
        TfrmTemplateEditor.tvTreeKeyDown┘     │ │   
                             TTemplate.GetText┘ │   
                ExecuteTemplateOrBoilerPlate┤   │   
                      TfrmDrawers.InsertText┤   │   
           TfrmDrawers.tvTemplatesDblClick┤ │   │   
            TfrmDrawers.tvTemplatesKeyDown┤ │   │   
                TfrmDrawers.NewRECDragDrop┤ │   │   
          TfrmDrawers.SetRichEditControl┘ │ │   │   
                 TfrmDCSumm.FormCreate┤   │ │   │   
               TfrmConsults.FormCreate┤   │ │   │   
                TfrmSurgery.FormCreate┤   │ │   │   
                  TfrmNotes.FormCreate┘   │ │   │   
        TfrmDrawers.mnuInsertTemplateClick┘ │   │   
  TfrmDCSumm.popSummMemoInsTemplateClick┤   │   │   
TfrmConsults.popNoteMemoInsTemplateClick┤   │   │   
 TfrmSurgery.popNoteMemoInsTemplateClick┤   │   │   
   TfrmNotes.popNoteMemoInsTemplateClick┘   │   │   
      TfrmDrawers.mnuPreviewTemplateClick...┤   │   
            TfrmDrawers.mnuCopyTemplateClick┤   │   
         TfrmTemplateEditor.mnuBPTryClick...┘   │   
                    TfrmTemplateDialog.FormPaint┘   

Calls

Name Declaration Comments
TfrmTemplateDialog.EntryDestroyed procedure EntryDestroyed(Sender: TObject); -
TfrmTemplateDialog.FieldChanged procedure FieldChanged(Sender: TObject); -
TfrmTemplateDialog.FindObjectByID function FindObjectByID( id: string): TControl; -
GetDialogEntry function GetDialogEntry(AParent: TWinControl; AID, AText: string): TTemplateDialogEntry; -
TTemplateDialogEntry.GetPanel function GetPanel(MaxLen: integer; AParent: TWinControl; OwningCheckBox: TCPRSDialogParentCheckBox): TDlgFieldPanel; -
TTemplateDialogEntry.GetText function GetText: string; -
TfrmTemplateDialog.ItemChecked procedure ItemChecked(Sender: TObject); -
NextTabCtrl procedure NextTabCtrl(ACtrl: TControl); -
TfrmTemplateDialog.ParentCBEnter procedure ParentCBEnter(Sender: TObject); -
TfrmTemplateDialog.ParentCBExit procedure ParentCBExit(Sender: TObject); -
TTemplateDialogEntry.SetAutoDestroyOnPanelFree procedure SetAutoDestroyOnPanelFree(const Value: boolean); -

Called-By

Name Declaration Comments
TfrmTemplateDialog.BuildAllControls procedure BuildAllControls; -


Source

441   procedure TfrmTemplateDialog.BuildCB(CBidx: integer; var Y: integer; FirstTime: boolean);
442   var
443     bGap, Indent, i, idx, p1, p2: integer;
444     EID, ID, PID, DlgProps, tmp, txt, tmpID: string;
445     pctrl, ctrl: TControl;
446     pnl: TPanel;
447     KillCtrl, doHint, dsp, noTextParent: boolean;
448     Entry: TTemplateDialogEntry;
449   //  StringIn, StringOut: string;
450     cb: TCPRSDialogParentCheckBox;
451   
452     procedure NextTabCtrl(ACtrl: TControl);
453     begin
454       if(ACtrl is TWinControl) then
455       begin
456         inc(FTabPos);
457         TWinControl(ACtrl).TabOrder := FTabPos;
458       end;
459     end;
460   
461   begin
462     tmp := Piece(Index, U, CBidx);
463     p1 := StrToInt(Piece(tmp,'~',1));
464     p2 := StrToInt(Piece(tmp,'~',2));
465     DlgProps := Piece(tmp,'~',3);
466     ID := Piece(DlgProps, ';', 3);
467     PID := Piece(DlgProps, ';', 4);
468   
469     ctrl := nil;
470     pctrl := nil;
471     if(PID <> '') then
472       noTextParent := (NoTextID.IndexOf(PID) < 0)
473     else
474       noTextParent := TRUE;
475     if not FirstTime then
476       ctrl := FindObjectByID(ID);
477     if noTextParent and (PID <> '') then
478       pctrl := FindObjectByID(PID);
479     if(PID = '') then
480       KillCtrl := FALSE
481     else
482     begin
483       if(assigned(pctrl)) then
484       begin
485         if(not (pctrl is TORCheckBox)) or
486           (copy(DlgProps,3,1) = BOOLCHAR[TRUE]) then // show if parent is unchecked
487           KillCtrl := FALSE
488         else
489           KillCtrl := (not TORCheckBox(pctrl).Checked);
490       end
491       else
492         KillCtrl := noTextParent;
493     end;
494     if KillCtrl then
495     begin
496       if(assigned(ctrl)) then
497       begin
498         if(ctrl is TORCheckBox) and (assigned(TORCheckBox(ctrl).Associate)) then
499           TORCheckBox(ctrl).Associate.Hide;
500         idx := BuildIdx.IndexOfObject(TObject(ctrl.Tag));
501         if idx >= 0 then
502           BuildIdx.delete(idx);
503         ctrl.Free;
504       end;
505       exit;
506     end;
507     tmp := copy(SL.Text, p1, p2);
508     if(copy(tmp, length(tmp)-1, 2) = CRLF) then
509       delete(tmp, length(tmp)-1, 2);
510     bGap := StrToIntDef(copy(DlgProps,5,1),0);
511     while bGap > 0 do
512     begin
513       if(copy(tmp, 1, 2) = CRLF) then
514       begin
515         delete(tmp, 1, 2);
516         dec(bGap);
517       end
518       else
519         bGap := 0;
520     end;
521     if(tmp = NoTextMarker) then
522     begin
523       if(NoTextID.IndexOf(ID) < 0) then
524         NoTextID.Add(ID);
525       exit;
526     end;
527     if(not assigned(ctrl)) then
528     begin
529       dsp := (copy(DlgProps,1,1)=BOOLCHAR[TRUE]);
530       EID := 'DLG' + IntToStr(CBIdx);
531       idx := Entries.IndexOf(EID);
532       doHint := FALSE;
533       txt := tmp;
534       if(idx < 0) then
535       begin
536         if(copy(DlgProps,2,1)=BOOLCHAR[TRUE]) then // First Line Only
537         begin
538           i := pos(CRLF, tmp);
539           if(i > 0) then
540           begin
541             dec(i);
542             if i > 70 then
543             begin
544               i := 71;
545               while (i > 0) and (tmp[i] <> ' ') do dec(i);
546               if i = 0 then
547                 i := 70
548               else
549                 dec(i);
550             end;
551             doHint := TRUE;
552             tmp := copy(tmp, 1, i) + ' ...';
553           end;
554         end;
555         Entry := GetDialogEntry(sbMain, EID, tmp);
556         Entry.AutoDestroyOnPanelFree := TRUE;
557         Entry.OnDestroy := EntryDestroyed;
558         Entries.AddObject(EID, Entry);
559       end
560       else
561         Entry := TTemplateDialogEntry(Entries.Objects[idx]);
562   
563       if(dsp or OneOnly) then
564         cb := nil
565       else
566         cb := TCPRSDialogParentCheckBox.Create(Self);
567   
568       pnl := Entry.GetPanel(FMaxPnlWidth, sbMain, cb);
569       pnl.Show;
570       if(doHint and (not pnl.ShowHint)) then
571       begin
572         pnl.ShowHint := TRUE;
573         Entry.Obj := pnl;
574         Entry.Text := txt;
575         pnl.hint := Entry.GetText;
576         Entry.OnChange := FieldChanged;
577       end;
578       if not assigned(cb) then
579         ctrl := pnl
580       else
581       begin
582         ctrl := cb;
583         ctrl.Parent := sbMain;
584   
585         TORCheckbox(ctrl).OnEnter := frmTemplateDialog.ParentCBEnter;
586         TORCheckbox(ctrl).OnExit := frmTemplateDialog.ParentCBExit;
587   
588         TORCheckBox(ctrl).Height := TORCheckBox(ctrl).Height + 5;
589         TORCheckBox(ctrl).Width := 17;
590   
591       {Insert next line when focus fixed}
592       //  ctrl.Width := IndentGap;
593       {Remove next line when focus fixed}
594         TORCheckBox(ctrl).AutoSize := false;
595         TORCheckBox(ctrl).Associate := pnl;
596         pnl.Tag := Integer(ctrl);
597         tmpID := copy(ID, 1, (pos('.', ID) - 1)); {copy the ID without the decimal place}
598   //      if Templates.IndexOf(tmpID) > -1 then
599   //        StringIn := 'Sub-Template: ' + TTemplate(Templates.Objects[Templates.IndexOf(tmpID)]).PrintName
600   //      else
601   //        StringIn := 'Sub-Template:';
602   //      StringOut := StringReplace(StringIn, '&', '&&', [rfReplaceAll]);
603   //      TORCheckBox(ctrl).Caption := StringOut;
604         UpdateColorsFor508Compliance(ctrl);
605   
606       end;
607       ctrl.Tag := CBIdx;
608   
609       Indent := StrToIntDef(Piece(DlgProps, ';', 5),0) - FirstIndent;
610       if dsp then inc(Indent);
611       ctrl.Left := Gap + (Indent * IndentGap);
612       //ctrl.Width := sbMain.ClientWidth - Gap - ctrl.Left - ScrollBarWidth;
613       if(ctrl is TORCheckBox) then
614         pnl.Left := ctrl.Left + IndentGap;
615   
616       if(ctrl is TORCheckBox) then with TORCheckBox(ctrl) do
617       begin
618         GroupIndex := StrToIntDef(Piece(DlgProps, ';', 2),0);
619         if(GroupIndex <> 0) then
620           RadioStyle := TRUE;
621         OnClick := ItemChecked;
622         StringData := DlgProps;
623       end;
624       if BuildIdx.IndexOfObject(TObject(CBIdx)) < 0 then
625         BuildIdx.AddObject(Piece(Piece(Piece(Index, U, CBIdx),'~',3), ';', 3), TObject(CBIdx));
626     end;
627     ctrl.Top := Y;
628     NextTabCtrl(ctrl);
629     if(ctrl is TORCheckBox) then
630     begin
631       TORCheckBox(ctrl).Associate.Top := Y;
632       NextTabCtrl(TORCheckBox(ctrl).Associate);
633       inc(Y, TORCheckBox(ctrl).Associate.Height+1);
634     end
635     else
636       inc(Y, ctrl.Height+1);
637   end;