[453] | 1 | //kt -- Modified with SourceScanner on 7/24/2007
|
---|
| 2 | unit fPage;
|
---|
| 3 |
|
---|
| 4 | {$OPTIMIZATION OFF} // REMOVE AFTER UNIT IS DEBUGGED
|
---|
| 5 |
|
---|
| 6 | interface
|
---|
| 7 |
|
---|
| 8 | uses
|
---|
| 9 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, uConst,
|
---|
| 10 | rOrders, DKLang;
|
---|
| 11 |
|
---|
| 12 | type
|
---|
| 13 | TfrmPage = class(TForm)
|
---|
| 14 | shpPageBottom: TShape;
|
---|
| 15 | DKLanguageController1: TDKLanguageController;
|
---|
| 16 | procedure FormCreate(Sender: TObject);
|
---|
| 17 | procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 18 | private
|
---|
| 19 | FDisplayCount: Integer; // number of times page displayed
|
---|
| 20 | FPatientCount: Integer; // number of times page displayed for given pt
|
---|
| 21 | FCallingContext: Integer;
|
---|
| 22 | FOldEnter: TNotifyEvent;
|
---|
| 23 | FPageID: integer;
|
---|
| 24 | function GetInitPage: Boolean;
|
---|
| 25 | function GetInitPatient: Boolean;
|
---|
| 26 | function GetPatientViewed: Boolean;
|
---|
| 27 | protected
|
---|
| 28 | procedure Loaded; override;
|
---|
| 29 | procedure frmPageEnter(Sender: TObject);
|
---|
| 30 | public
|
---|
| 31 | function AllowContextChange(var WhyNot: string): Boolean; virtual;
|
---|
| 32 | procedure ClearPtData; virtual;
|
---|
| 33 | procedure DisplayPage; virtual;
|
---|
| 34 | procedure NotifyOrder(OrderAction: Integer; AnOrder: TOrder); virtual;
|
---|
| 35 | procedure RequestPrint; virtual;
|
---|
| 36 | procedure SetFontSize(NewFontSize: Integer); virtual;
|
---|
| 37 | procedure FocusFirstControl;
|
---|
| 38 | property CallingContext: Integer read FCallingContext;
|
---|
| 39 | property InitPage: Boolean read GetInitPage;
|
---|
| 40 | property InitPatient: Boolean read GetInitPatient;
|
---|
| 41 | property PatientViewed: Boolean read GetPatientViewed;
|
---|
| 42 | property PageID: integer read FPageID write FPageID default CT_UNKNOWN;
|
---|
| 43 | end;
|
---|
| 44 |
|
---|
| 45 | var
|
---|
| 46 | frmPage: TfrmPage;
|
---|
| 47 |
|
---|
| 48 | implementation
|
---|
| 49 |
|
---|
| 50 | uses ORFn, fFrame, uInit;
|
---|
| 51 |
|
---|
| 52 | {$R *.DFM}
|
---|
| 53 |
|
---|
| 54 | procedure TfrmPage.FormCreate(Sender: TObject);
|
---|
| 55 | { set counters to 0 }
|
---|
| 56 | begin
|
---|
| 57 | HelpFile := Application.HelpFile + '>' + HelpFile;
|
---|
| 58 | FDisplayCount := 0;
|
---|
| 59 | FPatientCount := 0;
|
---|
| 60 | FOldEnter := OnEnter;
|
---|
| 61 | OnEnter := frmPageEnter;
|
---|
| 62 | end;
|
---|
| 63 |
|
---|
| 64 | procedure TfrmPage.Loaded;
|
---|
| 65 | { make the form borderless to allow it to be a child window }
|
---|
| 66 | begin
|
---|
| 67 | inherited Loaded;
|
---|
| 68 | Visible := False;
|
---|
| 69 | Position := poDefault;
|
---|
| 70 | BorderIcons := [];
|
---|
| 71 | BorderStyle := bsNone;
|
---|
| 72 | HandleNeeded;
|
---|
| 73 | SetBounds(0, 0, Width, Height);
|
---|
| 74 | end;
|
---|
| 75 |
|
---|
| 76 | function TfrmPage.AllowContextChange(var WhyNot: string): Boolean;
|
---|
| 77 | begin
|
---|
| 78 | Result := True;
|
---|
| 79 | end;
|
---|
| 80 |
|
---|
| 81 | procedure TfrmPage.ClearPtData;
|
---|
| 82 | { clear all patient related data on a page }
|
---|
| 83 | begin
|
---|
| 84 | FPatientCount := 0;
|
---|
| 85 | end;
|
---|
| 86 |
|
---|
| 87 | procedure TfrmPage.DisplayPage;
|
---|
| 88 | { cause the page to be displayed and update the display counters }
|
---|
| 89 | begin
|
---|
| 90 | BringToFront;
|
---|
| 91 | if ActiveControl <> nil then
|
---|
| 92 | FocusControl(ActiveControl)
|
---|
| 93 | else
|
---|
| 94 | FocusFirstControl;
|
---|
| 95 | //SetFocus;
|
---|
| 96 | Inc(FDisplayCount);
|
---|
| 97 | Inc(FPatientCount);
|
---|
| 98 | FCallingContext := frmFrame.ChangeSource;
|
---|
| 99 | if (FCallingContext = CC_CLICK) and (FPatientCount = 1)
|
---|
| 100 | then FCallingContext := CC_INIT_PATIENT;
|
---|
| 101 | end;
|
---|
| 102 |
|
---|
| 103 | procedure TfrmPage.NotifyOrder(OrderAction: Integer; AnOrder: TOrder);
|
---|
| 104 | begin
|
---|
| 105 | end;
|
---|
| 106 |
|
---|
| 107 | procedure TfrmPage.RequestPrint;
|
---|
| 108 | begin
|
---|
| 109 | end;
|
---|
| 110 |
|
---|
| 111 | procedure TfrmPage.SetFontSize(NewFontSize: Integer);
|
---|
| 112 | begin
|
---|
| 113 | ResizeAnchoredFormToFont( self );
|
---|
| 114 | if Assigned(Parent) then begin
|
---|
| 115 | Width := Parent.ClientWidth;
|
---|
| 116 | Height := Parent.ClientHeight;
|
---|
| 117 | end;
|
---|
| 118 | Resize;
|
---|
| 119 | end;
|
---|
| 120 |
|
---|
| 121 | function TfrmPage.GetInitPage: Boolean;
|
---|
| 122 | { if the count is one, this is the first time the page is being displayed }
|
---|
| 123 | begin
|
---|
| 124 | Result := FDisplayCount = 1;
|
---|
| 125 | end;
|
---|
| 126 |
|
---|
| 127 | function TfrmPage.GetInitPatient: Boolean;
|
---|
| 128 | { if the count is one, this is the first time the page is being displayed for a given patient }
|
---|
| 129 | begin
|
---|
| 130 | Result := FPatientCount = 1;
|
---|
| 131 | end;
|
---|
| 132 |
|
---|
| 133 | function TfrmPage.GetPatientViewed: Boolean;
|
---|
| 134 | { returns false if the tab has never been clicked for this patient }
|
---|
| 135 | begin
|
---|
| 136 | Result := FPatientCount > 0;
|
---|
| 137 | end;
|
---|
| 138 |
|
---|
| 139 | procedure TfrmPage.FormClose(Sender: TObject; var Action: TCloseAction);
|
---|
| 140 | begin
|
---|
| 141 | Action := caFree;
|
---|
| 142 | end;
|
---|
| 143 |
|
---|
| 144 | procedure TfrmPage.frmPageEnter(Sender: TObject);
|
---|
| 145 | begin
|
---|
| 146 | if Assigned(frmFrame) then
|
---|
| 147 | FrmFrame.tabPage.TabIndex := FrmFrame.PageIDToTab(PageID);
|
---|
| 148 | if Assigned(FOldEnter) then
|
---|
| 149 | FOldEnter(Sender);
|
---|
| 150 | end;
|
---|
| 151 |
|
---|
| 152 | procedure TfrmPage.FocusFirstControl;
|
---|
| 153 | var
|
---|
| 154 | NextControl: TWinControl;
|
---|
| 155 | begin
|
---|
| 156 | if Assigned(frmFrame) and frmFrame.Enabled and frmFrame.Visible and not uInit.Timedout then begin
|
---|
| 157 | NextControl := FindNextControl(nil, True, True, False);
|
---|
| 158 | if NextControl <> nil then
|
---|
| 159 | NextControl.SetFocus;
|
---|
| 160 | end;
|
---|
| 161 | end;
|
---|
| 162 |
|
---|
| 163 | end.
|
---|