source: cprs/trunk/CPRS-Chart/uVA508CPRSCompatibility.pas@ 924

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

Upgrading to version 27

File size: 16.5 KB
Line 
1unit uVA508CPRSCompatibility;
2
3interface
4
5uses
6 SysUtils, Windows, Classes, Controls, Forms, StdCtrls;
7
8procedure QuickCopyWith508Msg(AFrom, ATo: TObject; docType: string = '');
9procedure QuickAddWith508Msg(AFrom, ATo: TObject; docType: string = '');
10procedure FastAssignWith508Msg(source, destination: TStrings; docType: string = '');
11
12procedure SpeakTextInserted(docType: string = '');
13function GetTabText: string;
14procedure SpeakPatient;
15procedure SpeakTabAndPatient;
16
17implementation
18
19uses VA508AccessibilityRouter, VA508AccessibilityManager, ORFn, uDlgComponents,
20 VA508DelphiCompatibility, ORCtrls, fReminderDialog, fTemplateDialog, fFrame,
21 uCore, ORCtrlsVA508Compatibility, mTemplateFieldButton, VA508AccessibilityConst;
22
23type
24 TCPRSParentDialogCheckBox508Manager = class(TORCheckBox508Manager)
25 public
26 constructor Create; override;
27 function GetCaption(Component: TWinControl): string; override;
28 end;
29
30 TCPRSBaseDialogComponent508Manager = class(TVA508ManagedComponentClass)
31 public
32 function GetCaption(Component: TWinControl): string; override;
33 end;
34
35{ TCPRSDialogStaticLabel508Manager = class(TVA508StaticTextManager)
36 public
37 constructor Create; override;
38 function GetCaption(Component: TWinControl): string; override;
39 end;
40 }
41
42 TCPRSDialogEdit508Manager = class(TCPRSBaseDialogComponent508Manager)
43 public
44 constructor Create; override;
45 end;
46
47 TCPRSDialogFieldComboBox508Manager = class(TCPRSBaseDialogComponent508Manager)
48 public
49 constructor Create; override;
50 end;
51
52 TCPRSDialogDateBox508Manager = class(TCPRSBaseDialogComponent508Manager)
53 public
54 constructor Create; override;
55 end;
56
57 TCPRSDialogCheckBox508Manager = class(TORCheckBox508Manager)
58 public
59 constructor Create; override;
60 function GetCaption(Component: TWinControl): string; override;
61 end;
62
63 TCPRSDialogRichEdit508Manager = class(TCPRSBaseDialogComponent508Manager)
64 public
65 constructor Create; override;
66 end;
67
68 TCPRSDialogLabel508Manager = class(TCPRSBaseDialogComponent508Manager)
69 public
70 constructor Create; override;
71 function GetValue(Component: TWinControl): string; override;
72 end;
73
74 TCPRSDialogHyperlink508Manager = class(TCPRSBaseDialogComponent508Manager)
75 public
76 constructor Create; override;
77 function GetValue(Component: TWinControl): string; override;
78 function GetInstructions(Component: TWinControl): string; override;
79 end;
80
81 TCPRSDialogNumberComplexManager = class(TVA508ComplexComponentManager)
82 public
83 constructor Create;
84 procedure Refresh(Component: TWinControl;
85 AccessibilityManager: TVA508AccessibilityManager); override;
86 end;
87
88 TCPRSDialogYearEdit508Manager = class(TVA508ManagedComponentClass)
89 public
90 constructor Create; override;
91 function Redirect(Component: TWinControl; var ManagedType: TManagedType): TWinControl; override;
92 end;
93
94 TCPRSNumberField508Manager = class(TVA508ManagedComponentClass)
95 public
96 constructor Create; override;
97 function GetCaption(Component: TWinControl): string; override;
98 end;
99
100 TCPRSDialogDateCombo508Manager = class(TCPRSBaseDialogComponent508Manager)
101 public
102 constructor Create; override;
103 end;
104
105 TfraTemplateFieldButtonComplexManager = class(TVA508ComplexComponentManager)
106 public
107 constructor Create;
108 procedure Refresh(Component: TWinControl;
109 AccessibilityManager: TVA508AccessibilityManager); override;
110 end;
111
112 TfraTemplateFieldButton508Manager = class(TVA508ManagedComponentClass)
113 public
114 constructor Create; override;
115 function GetValue(Component: TWinControl): string; override;
116 function GetCaption(Component: TWinControl): string; override;
117 function GetComponentName(Component: TWinControl): string; override;
118 function GetInstructions(Component: TWinControl): string; override;
119 end;
120
121 TMentalHealthMemo508Manager = class(TVA508ManagedComponentClass)
122 public
123 constructor Create; override;
124 function GetComponentName(Component: TWinControl): string; override;
125 function GetInstructions(Component: TWinControl): string; override;
126 end;
127
128procedure SpeakTextInserted(docType: string = '');
129begin
130 if docType = '' then
131 GetScreenReader.Speak('text inserted')
132 else
133 GetScreenReader.Speak('text inserted in to ' + docType);
134end;
135
136procedure QuickCopyWith508Msg(AFrom, ATo: TObject; docType: string = '');
137begin
138 QuickCopy(AFrom, ATo);
139 if (AFrom is TStrings) and (TStrings(AFrom).Count > 0) then
140 SpeakTextInserted(docType);
141end;
142
143procedure QuickAddWith508Msg(AFrom, ATo: TObject; docType: string = '');
144begin
145 QuickAdd(AFrom, ATo);
146 if (AFrom is TStrings) and (TStrings(AFrom).Count > 0) then
147 SpeakTextInserted(docType);
148end;
149
150procedure FastAssignWith508Msg(source, destination: TStrings; docType: string = '');
151begin
152 FastAssign(source, destination);
153 if source.Count > 0 then
154 SpeakTextInserted(docType);
155end;
156
157procedure ControlShiftTOverride; forward;
158procedure ControlTabOverride; forward;
159procedure ControlShiftTabOverride; forward;
160
161type
162 TVA508RegistrationScreenReader = class(TVA508ScreenReader);
163
164procedure Register508CompatibilityChanges;
165begin
166 with GetScreenReader do
167 begin
168 RegisterDictionaryChange('<unknown>','unknown');
169 RegisterDictionaryChange('VistA','Vist a');
170 RegisterDictionaryChange('VA','V A');
171 RegisterDictionaryChange('VHA','V H A');
172 RegisterDictionaryChange('HealtheVet','Health E Vet');
173 end;
174 RegisterManagedComponentClass(TCPRSParentDialogCheckBox508Manager.Create);
175// RegisterManagedComponentClass(TCPRSDialogStaticLabel508Manager.Create);
176 RegisterManagedComponentClass(TCPRSDialogEdit508Manager.Create);
177 RegisterManagedComponentClass(TCPRSDialogFieldComboBox508Manager.Create);
178 RegisterManagedComponentClass(TCPRSDialogCheckBox508Manager.Create);
179 RegisterManagedComponentClass(TCPRSDialogRichEdit508Manager.Create);
180 RegisterManagedComponentClass(TCPRSDialogLabel508Manager.Create);
181 RegisterManagedComponentClass(TCPRSNumberField508Manager.Create);
182 RegisterManagedComponentClass(TCPRSDialogHyperlink508Manager.Create);
183 RegisterManagedComponentClass(TfraTemplateFieldButton508Manager.Create);
184 RegisterManagedComponentClass(TCPRSDialogDateBox508Manager.Create);
185 RegisterManagedComponentClass(TCPRSDialogDateCombo508Manager.Create);
186 RegisterManagedComponentClass(TCPRSDialogYearEdit508Manager.Create);
187 RegisterManagedComponentClass(TMentalHealthMemo508Manager.Create);
188
189 RegisterComplexComponentManager(TCPRSDialogNumberComplexManager.Create);
190
191 GetScreenReader.RegisterCustomKeyMapping('Control+Tab', ControlTabOverride,
192 'Advances to the next tab in a tab control',
193 'advances to the next tab in a tab control, when you are inside a control with tabs');
194 GetScreenReader.RegisterCustomKeyMapping('Control+Shift+Tab', ControlShiftTabOverride,
195 'Advances to the previous tab in a tab control',
196 'advances to the previous tab in a tab control, when you are inside a control with tabs');
197 GetScreenReader.RegisterCustomKeyMapping('Control+Shift+T', ControlShiftTOverride,
198 'Announces Chart Tab and Patient Name',
199 'Announces the current CPRS Chart tab and the current patient');
200
201 with TVA508RegistrationScreenReader(GetScreenReader) do
202 begin
203 RegisterCustomClassBehavior(TCPRSDialogParentCheckBox.ClassName, CLASS_BEHAVIOR_CHECK_BOX);
204 RegisterCustomClassBehavior(TCPRSDialogCheckBox.ClassName, CLASS_BEHAVIOR_CHECK_BOX);
205 RegisterCustomClassBehavior(TCPRSDialogRichEdit.ClassName, CLASS_BEHAVIOR_EDIT);
206 RegisterCustomClassBehavior(TCPRSDialogFieldEdit.ClassName, CLASS_BEHAVIOR_EDIT);
207 RegisterCustomClassBehavior(TCPRSDialogComboBox.ClassName, CLASS_BEHAVIOR_EDIT_COMBO);
208 RegisterCustomClassBehavior(TCPRSDialogButton.ClassName, CLASS_BEHAVIOR_BUTTON);
209 RegisterCustomClassBehavior(TCPRSDialogDateBox.ClassName, CLASS_BEHAVIOR_EDIT);
210 RegisterCustomClassBehavior(TCPRSDialogNumber.ClassName, CLASS_BEHAVIOR_EDIT);
211 RegisterCustomClassBehavior(TCPRSNumberField.ClassName, CLASS_BEHAVIOR_EDIT);
212 end;
213
214end;
215
216{ TCPRSDialogCheckBox }
217
218constructor TCPRSParentDialogCheckBox508Manager.Create;
219begin
220 inherited Create(TCPRSDialogParentCheckBox, [mtCaption, mtComponentName, mtInstructions, mtState, mtStateChange]);
221end;
222
223function TCPRSParentDialogCheckBox508Manager.GetCaption(Component: TWinControl): string;
224begin
225 Result := TCPRSDialogParentCheckBox(Component).AccessText;
226end;
227
228type
229 ExposedControl = class(TWinControl);
230
231// CQ #14984
232procedure ControlTabOverride;
233begin
234 if assigned(Screen.ActiveControl) and (Screen.ActiveControl is TCustomMemo) then
235 ExposedControl(Screen.FocusedForm).SelectNext(Screen.ActiveControl, TRUE, TRUE)
236 else
237 begin
238 keybd_event(VK_TAB, 0, 0, VK_CONTROL);
239 keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, VK_CONTROL);
240 end;
241end;
242
243procedure ControlShiftTabOverride;
244begin
245 if assigned(Screen.ActiveControl) and (Screen.ActiveControl is TCustomMemo) then
246 ExposedControl(Screen.FocusedForm).SelectNext(Screen.ActiveControl, FALSE, TRUE)
247 else
248 begin
249 keybd_event(VK_TAB, 0, 0, (VK_SHIFT * 256) + VK_CONTROL);
250 keybd_event(VK_TAB, 0, KEYEVENTF_KEYUP, (VK_SHIFT * 256) + VK_CONTROL);
251 end;
252end;
253
254procedure ControlShiftTOverride;
255begin
256 SpeakTabAndPatient;
257end;
258
259function GetTabText: string;
260var
261 idx: integer;
262begin
263 Result := '';
264 if assigned(frmFrame) and assigned(frmFrame.tabPage) then
265 begin
266 idx := frmFrame.tabPage.TabIndex;
267 if (idx >= 0) and (idx < uTabList.Count) then
268 begin
269 Result := frmFrame.tabPage.Tabs[idx];
270 if Result = 'D/C Summ' then
271 Result := 'Discharge Summary';
272 end;
273 end;
274end;
275
276procedure SpeakPatient;
277begin
278 if assigned(Patient) and (Patient.Name <> '') then
279 GetScreenReader.Speak(Patient.Name);
280end;
281
282procedure SpeakTabAndPatient;
283var
284 text: string;
285begin
286 text := GetTabText;
287 if text <> '' then
288 text := text + ' tab';
289 if text <> '' then
290 text := text + ', ';
291 if assigned(Patient) and (Patient.Name <> '') then
292 text := text + Patient.Name
293 else
294 text := text + 'no patient selected';
295 if text <> '' then
296 GetScreenReader.Speak(text);
297end;
298
299{ TCPRSDialogComponent508Manager }
300
301function TCPRSBaseDialogComponent508Manager.GetCaption(
302 Component: TWinControl): string;
303begin
304 if Supports(Component, ICPRSDialogComponent) then
305 begin
306 Result := (Component as ICPRSDialogComponent).AccessText;
307 end
308 else
309 Result := '';
310end;
311
312(*
313{ TCPRSDialogStaticLabel508Manager }
314
315constructor TCPRSDialogStaticLabel508Manager.Create;
316begin
317 inherited Create(TCPRSDialogStaticLabel, [mtCaption]);
318end;
319
320function TCPRSDialogStaticLabel508Manager.GetCaption(
321 Component: TWinControl): string;
322var
323 txt: string;
324begin
325 if Supports(Component, ICPRSDialogComponent) then
326 begin
327 Result := (Component as ICPRSDialogComponent).AccessText;
328 end
329 else
330 Result := '';
331 txt := inherited GetCaption(Component);
332 if txt <> '' then
333 begin
334 if Result <> '' then
335 Result := Result + ' ';
336 Result := Result + txt;
337 end;
338end;
339*)
340
341{ TCPRSTemplateFieldEdit508Manager }
342
343constructor TCPRSDialogEdit508Manager.Create;
344begin
345 inherited Create(TCPRSDialogFieldEdit, [mtCaption]);
346end;
347
348{ TCPRSTemplateFieldComboBox508Manager }
349
350constructor TCPRSDialogFieldComboBox508Manager.Create;
351begin
352 inherited Create(TCPRSDialogComboBox, [mtCaption]);
353end;
354
355{ TCPRSTemplateFieldCheckBox508Manager }
356
357constructor TCPRSDialogCheckBox508Manager.Create;
358begin
359 inherited Create(TCPRSDialogCheckBox, [mtCaption, mtComponentName, mtInstructions, mtState, mtStateChange]);
360end;
361
362function TCPRSDialogCheckBox508Manager.GetCaption(
363 Component: TWinControl): string;
364begin
365 if Supports(Component, ICPRSDialogComponent) then
366 begin
367 Result := (Component as ICPRSDialogComponent).AccessText;
368 end
369 else
370 Result := '';
371 Result := Result + ' ' + TCheckBox(Component).Caption;
372end;
373
374{ TCPRSTemplateFieldRichEdit508Manager }
375
376constructor TCPRSDialogRichEdit508Manager.Create;
377begin
378 inherited Create(TCPRSDialogRichEdit, [mtCaption]);
379end;
380
381{ TCPRSTemplateFieldDateCombo508Manager }
382
383constructor TCPRSDialogLabel508Manager.Create;
384begin
385 inherited Create(TCPRSTemplateFieldLabel, [mtCaption, mtValue]);
386end;
387
388function TCPRSDialogLabel508Manager.GetValue(
389 Component: TWinControl): string;
390begin
391 Result := TCPRSTemplateFieldLabel(Component).Caption;
392end;
393
394{ TCPRSTemplateFieldWebLabel508Manager }
395
396constructor TCPRSDialogHyperlink508Manager.Create;
397begin
398 inherited Create(TCPRSDialogHyperlinkLabel, [mtCaption, mtValue, mtInstructions]);
399end;
400
401function TCPRSDialogHyperlink508Manager.GetInstructions(
402 Component: TWinControl): string;
403begin
404 Result := 'To activate press space bar';
405end;
406
407function TCPRSDialogHyperlink508Manager.GetValue(
408 Component: TWinControl): string;
409begin
410 Result := TCPRSDialogHyperlinkLabel(Component).Caption;
411end;
412
413{ TCPRSTemplateFieldNumberComplexManager }
414
415constructor TCPRSDialogNumberComplexManager.Create;
416begin
417 inherited Create(TCPRSDialogNumber);
418end;
419
420procedure TCPRSDialogNumberComplexManager.Refresh(Component: TWinControl;
421 AccessibilityManager: TVA508AccessibilityManager);
422begin
423 with TCPRSDialogNumber(Component) do
424 begin
425 ClearSubControls(Component);
426 if assigned(Edit) then
427 AddSubControl(Component, Edit, AccessibilityManager);
428 end;
429end;
430
431{ TCPRSNumberField508Manager }
432
433constructor TCPRSNumberField508Manager.Create;
434begin
435 inherited Create(TCPRSNumberField, [mtCaption]);
436end;
437
438function TCPRSNumberField508Manager.GetCaption(Component: TWinControl): string;
439begin
440 if assigned(Component.Owner) and Supports(Component.Owner, ICPRSDialogComponent) then
441 begin
442 Result := (Component.Owner as ICPRSDialogComponent).AccessText;
443 end
444 else
445 Result := '';
446end;
447
448{ TfraTemplateFieldButtonComplexManager }
449
450constructor TfraTemplateFieldButtonComplexManager.Create;
451begin
452 inherited Create(TfraTemplateFieldButton);
453end;
454
455procedure TfraTemplateFieldButtonComplexManager.Refresh(Component: TWinControl;
456 AccessibilityManager: TVA508AccessibilityManager);
457begin
458 with TfraTemplateFieldButton(Component) do
459 begin
460 ClearSubControls(Component);
461 AddSubControl(Component, pnlBtn, AccessibilityManager);
462 end;
463end;
464
465{ TfraTemplateFieldButton508Manager }
466
467constructor TfraTemplateFieldButton508Manager.Create;
468begin
469 inherited Create(TfraTemplateFieldButton, [mtComponentName, mtCaption, mtInstructions, mtValue]);
470end;
471
472function TfraTemplateFieldButton508Manager.GetCaption(
473 Component: TWinControl): string;
474begin
475 if assigned(Component) and Supports(Component, ICPRSDialogComponent) then
476 begin
477 Result := (Component as ICPRSDialogComponent).AccessText;
478 end
479 else
480 Result := '';
481end;
482
483function TfraTemplateFieldButton508Manager.GetComponentName(
484 Component: TWinControl): string;
485begin
486 Result := 'multi value button';
487end;
488
489function TfraTemplateFieldButton508Manager.GetInstructions(
490 Component: TWinControl): string;
491begin
492 Result := 'to cycle through values press space bar';
493end;
494
495function TfraTemplateFieldButton508Manager.GetValue(
496 Component: TWinControl): string;
497begin
498 Result := TfraTemplateFieldButton(Component).ButtonText;
499 if Trim(Result) = '' then
500 Result := 'blank';
501end;
502
503{ TCPRSTemplateFieldDateBox508Manager }
504
505constructor TCPRSDialogDateBox508Manager.Create;
506begin
507 inherited Create(TCPRSDialogDateBox, [mtCaption]);
508end;
509
510{ TCPRSDialogYearEdit508Manager }
511
512constructor TCPRSDialogYearEdit508Manager.Create;
513begin
514 inherited Create(TCPRSDialogYearEdit, [mtComponentRedirect]);
515end;
516
517function TCPRSDialogYearEdit508Manager.Redirect(Component: TWinControl;
518 var ManagedType: TManagedType): TWinControl;
519begin
520 ManagedType := mtCaption;
521 Result := TWinControl(Component.Owner);
522end;
523
524{ TCPRSDialogDateCombo508Manager }
525
526constructor TCPRSDialogDateCombo508Manager.Create;
527begin
528 inherited Create(TCPRSDialogDateCombo, [mtCaption]);
529end;
530
531{ TMentalHealthMemo508Manager }
532
533constructor TMentalHealthMemo508Manager.Create;
534begin
535 inherited Create(TMentalHealthMemo, [mtComponentName, mtInstructions]);
536end;
537
538function TMentalHealthMemo508Manager.GetComponentName(
539 Component: TWinControl): string;
540begin
541 Result := ' ';
542end;
543
544function TMentalHealthMemo508Manager.GetInstructions(
545 Component: TWinControl): string;
546begin
547 Result := ' ';
548end;
549
550initialization
551 Register508CompatibilityChanges;
552
553
554end.
Note: See TracBrowser for help on using the repository browser.