source: cprs/trunk/CPRS-Lib/ORCtrlsVA508Compatibility.pas@ 1245

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

Upgrade to version 27

File size: 17.9 KB
RevLine 
[829]1unit ORCtrlsVA508Compatibility;
2
3interface
4
5uses
6 Forms, Controls, StdCtrls, SysUtils, Windows, VA508AccessibilityManager;
7
8type
9 TORCheckBox508Manager = class(TVA508ManagedComponentClass)
10 public
11 constructor Create; override;
12 function GetComponentName(Component: TWinControl): string; override;
13 function GetInstructions(Component: TWinControl): string; override;
14 function GetState(Component: TWinControl): string; override;
15 end;
16
17 TLBMgr = class
18 private
19 function GetIdx(Component: TWinControl): integer;
20 public
21 function GetComponentName(Component: TWinControl): string; virtual; abstract;
22 function GetState(Component: TWinControl): string; virtual; abstract;
23 function GetItemInstructions(Component: TWinControl): string; virtual; abstract;
24 end;
25
26 TORListBox508Manager = class(TVA508ManagedComponentClass)
27 var
28 FCheckBoxes: TLBMgr;
29 FMultiSelect: TLBMgr;
30 FStandard: TLBMgr;
31 FCurrent: TLBMgr;
32 function GetCurrent(Component: TWinControl): TLBMgr;
33 public
34 constructor Create; override;
35 destructor Destroy; override;
36 function GetComponentName(Component: TWinControl): string; override;
37 function GetState(Component: TWinControl): string; override;
38 function GetItem(Component: TWinControl): TObject; override;
39 function GetItemInstructions(Component: TWinControl): string; override;
40 function GetValue(Component: TWinControl): string; override;
41 end;
42
43 TVA508TORDateComboComplexManager = class(TVA508ComplexComponentManager)
44 public
45 constructor Create;
46 procedure Refresh(Component: TWinControl;
47 AccessibilityManager: TVA508AccessibilityManager); override;
48 end;
49
50// TVA508TORComboBoxComplexManager = class(TVA508ComplexComponentManager)
51// public
52// constructor Create;
53// procedure Refresh(Component: TWinControl;
54// AccessibilityManager: TVA508AccessibilityManager); override;
55// end;
56
57{ TVA508TORDateBoxComplexManager = class(TVA508ComplexComponentManager)
58 public
59 constructor Create;
60 procedure Refresh(Component: TWinControl;
61 AccessibilityManager: TVA508AccessibilityManager); override;
62 end;}
63
64 TORComboBox508Manager = class(TVA508ManagedComponentClass)
65 public
66 constructor Create; override;
67 function GetValue(Component: TWinControl): string; override;
68 end;
69
70 TORDayCombo508Manager = class(TORComboBox508Manager)
71 public
72 constructor Create; override;
73 function GetCaption(Component: TWinControl): string; override;
74 end;
75
76 TORMonthCombo508Manager = class(TORComboBox508Manager)
77 public
78 constructor Create; override;
79 function GetCaption(Component: TWinControl): string; override;
80 end;
81
82 TORYearEdit508Manager = class(TVA508ManagedComponentClass)
83 public
84 constructor Create; override;
85 function GetCaption(Component: TWinControl): string; override;
86 end;
87
88 TORDateButton508Manager = class(TVA508ManagedComponentClass)
89 public
90 constructor Create; override;
91 function GetCaption(Component: TWinControl): string; override;
92 end;
93
94// TORComboEdit508Manager = class(TVA508ManagedComponentClass)
95// public
96// constructor Create; override;
97// function Redirect(Component: TWinControl; var ManagedType: TManagedType): TWinControl; override;
98// end;
99
100implementation
101
102uses VA508DelphiCompatibility, ORCtrls, ORDtTm, VA508AccessibilityRouter,
103 VA508AccessibilityConst, ORDtTmRng;
104
105function GetEditBox(ComboBox: TORComboBox): TORComboEdit;
106var
107 i: integer;
108
109begin
110 Result := nil;
111 for i := 0 to ComboBox.ControlCount - 1 do
112 begin
113 if ComboBox.Controls[i] is TORComboEdit then
114 begin
115 Result := TORComboEdit(ComboBox.Controls[i]);
116 exit;
117 end;
118 end;
119end;
120
121function ORComboBoxAlternateHandle(Component: TWinControl): HWnd;
122var
123 eBox: TORComboEdit;
124 cBox: TORComboBox;
125
126begin
127 cBox := TORComboBox(Component);
128 eBox := GetEditBox(cBox);
129 if assigned(eBox) then
130 Result := eBox.Handle
131 else
132 Result := cBox.Handle;
133end;
134
135type
136 TVA508RegistrationScreenReader = class(TVA508ScreenReader);
137{ Registration }
138
139procedure RegisterORComponents;
140begin
141 RegisterAlternateHandleComponent(TORComboBox, ORComboBoxAlternateHandle);
142
143 RegisterManagedComponentClass(TORCheckBox508Manager.Create);
144 RegisterManagedComponentClass(TORComboBox508Manager.Create);
145 RegisterManagedComponentClass(TORListBox508Manager.Create);
146 RegisterManagedComponentClass(TORDayCombo508Manager.Create);
147 RegisterManagedComponentClass(TORMonthCombo508Manager.Create);
148 RegisterManagedComponentClass(TORYearEdit508Manager.Create);
149 RegisterManagedComponentClass(TORDateButton508Manager.Create);
150// RegisterManagedComponentClass(TORComboEdit508Manager.Create);
151
152 RegisterComplexComponentManager(TVA508TORDateComboComplexManager.Create);
153// RegisterComplexComponentManager(TVA508TORComboBoxComplexManager.Create);
154// RegisterComplexComponentManager(TVA508TORDateBoxComplexManager.Create);
155
156
157 with TVA508RegistrationScreenReader(GetScreenReader) do
158 begin
159//---TORCalendar ???
160//---TORPopupMenu ???
161//---TORMenuItem ???
162
163 RegisterCustomClassBehavior(TORTreeView.ClassName, CLASS_BEHAVIOR_TREE_VIEW);
164 RegisterCustomClassBehavior(TORAlignEdit.ClassName, CLASS_BEHAVIOR_EDIT);
165 RegisterCustomClassBehavior(TORAlignButton.ClassName, CLASS_BEHAVIOR_BUTTON);
166 RegisterCustomClassBehavior(TORAlignSpeedButton.ClassName, CLASS_BEHAVIOR_BUTTON);
167 RegisterCustomClassBehavior(TORCheckBox.ClassName, CLASS_BEHAVIOR_CHECK_BOX);
168 RegisterCustomClassBehavior(TKeyClickPanel.ClassName, CLASS_BEHAVIOR_BUTTON);
169 RegisterCustomClassBehavior(TKeyClickRadioGroup.ClassName, CLASS_BEHAVIOR_GROUP_BOX);
170 RegisterCustomClassBehavior(TCaptionTreeView.ClassName, CLASS_BEHAVIOR_TREE_VIEW);
171 RegisterCustomClassBehavior(TCaptionMemo.ClassName, CLASS_BEHAVIOR_EDIT);
172 RegisterCustomClassBehavior(TCaptionEdit.ClassName, CLASS_BEHAVIOR_EDIT);
173 RegisterCustomClassBehavior(TCaptionRichEdit.ClassName, CLASS_BEHAVIOR_EDIT);
174 RegisterCustomClassBehavior(TOROffsetLabel.ClassName, CLASS_BEHAVIOR_STATIC_TEXT);
175
176 RegisterCustomClassBehavior(TCaptionComboBox.ClassName, CLASS_BEHAVIOR_COMBO_BOX);
177 RegisterCustomClassBehavior(TORComboEdit.ClassName, CLASS_BEHAVIOR_EDIT_COMBO);
178 RegisterCustomClassBehavior(TORComboBox.ClassName, CLASS_BEHAVIOR_COMBO_BOX);
179 RegisterCustomClassBehavior(TORListBox.ClassName, CLASS_BEHAVIOR_LIST_BOX);
180 RegisterCustomClassBehavior(TCaptionCheckListBox.ClassName, CLASS_BEHAVIOR_LIST_BOX);
181 RegisterCustomClassBehavior(TCaptionStringGrid.ClassName, CLASS_BEHAVIOR_LIST_BOX);
182
183 RegisterCustomClassBehavior(TORDateEdit.ClassName, CLASS_BEHAVIOR_EDIT);
184 RegisterCustomClassBehavior(TORDayCombo.ClassName, CLASS_BEHAVIOR_COMBO_BOX);
185 RegisterCustomClassBehavior(TORMonthCombo.ClassName, CLASS_BEHAVIOR_COMBO_BOX);
186 RegisterCustomClassBehavior(TORYearEdit.ClassName, CLASS_BEHAVIOR_EDIT);
187 RegisterCustomClassBehavior(TORDateBox.ClassName, CLASS_BEHAVIOR_EDIT);
188 RegisterCustomClassBehavior(TORDateCombo.ClassName, CLASS_BEHAVIOR_GROUP_BOX);
189
190 RegisterCustomClassBehavior(TORListView.ClassName, CLASS_BEHAVIOR_LIST_VIEW);
191 RegisterCustomClassBehavior(TCaptionListView.ClassName, CLASS_BEHAVIOR_LIST_VIEW);
192 RegisterCustomClassBehavior(TCaptionListBox.ClassName, CLASS_BEHAVIOR_LIST_BOX);
193
194 RegisterCustomClassBehavior(TORDateRangeDlg.ClassName, CLASS_BEHAVIOR_DIALOG);
195 RegisterCustomClassBehavior(TORfrmDtTm.ClassName, CLASS_BEHAVIOR_DIALOG);//called by TORDateTimeDlg
196 end;
197end;
198
199{ TORCheckBox508Manager }
200
201constructor TORCheckBox508Manager.Create;
202begin
203 inherited Create(TORCheckBox, [mtComponentName, mtInstructions, mtState, mtStateChange], TRUE);
204end;
205
206function TORCheckBox508Manager.GetComponentName(Component: TWinControl): string;
207begin
208 with TORCheckBox(Component) do
209 begin
210 if RadioStyle then
211 Result := 'radio button'
212 else
213 Result := VA508DelphiCompatibility.GetCheckBoxComponentName(AllowGrayed);
214 end;
215end;
216
217function TORCheckBox508Manager.GetInstructions(Component: TWinControl): string;
218begin
219 Result := VA508DelphiCompatibility.GetCheckBoxInstructionMessage(TORCheckBox(Component).Checked);
220end;
221
222function TORCheckBox508Manager.GetState(Component: TWinControl): string;
223var
224 cb: TORCheckBox;
225begin
226 Application.ProcessMessages; // <<< needed to allow messages that set state to process
227 Result := '';
228 cb := TORCheckBox(Component);
229 if (cb.State = cbGrayed) and (cb.GrayedStyle in [gsQuestionMark, gsBlueQuestionMark]) then
230 Result := 'Question Mark'
231 else
232 Result := VA508DelphiCompatibility.GetCheckBoxStateText(cb.State);
233end;
234
235{ TORListBox508Manager }
236
237type
238 TORListBoxCheckBoxes508Manager = class(TLBMgr)
239 public
240 function GetComponentName(Component: TWinControl): string; override;
241 function GetState(Component: TWinControl): string; override;
242 function GetItemInstructions(Component: TWinControl): string; override;
243 end;
244
245 TORListBoxMultiSelect508Manager = class(TLBMgr)
246 public
247 function GetComponentName(Component: TWinControl): string; override;
248 function GetState(Component: TWinControl): string; override;
249 function GetItemInstructions(Component: TWinControl): string; override;
250 end;
251
252 TORListBoxStandard508Manager = class(TLBMgr)
253 public
254 function GetComponentName(Component: TWinControl): string; override;
255 function GetState(Component: TWinControl): string; override;
256 function GetItemInstructions(Component: TWinControl): string; override;
257 end;
258
259constructor TORListBox508Manager.Create;
260begin
261 inherited Create(TORListBox, [mtComponentName, mtValue, mtState, mtStateChange,
262 mtItemChange, mtItemInstructions]);
263end;
264
265destructor TORListBox508Manager.Destroy;
266begin
267 FCurrent := nil;
268 if assigned(FCheckBoxes) then
269 FreeAndNil(FCheckBoxes);
270 if assigned(FMultiSelect) then
271 FreeAndNil(FMultiSelect);
272 if assigned(FStandard) then
273 FreeAndNil(FStandard);
274 inherited;
275end;
276
277function TORListBox508Manager.GetComponentName(Component: TWinControl): string;
278begin
279 Result := GetCurrent(Component).GetComponentName(Component);
280end;
281
282function TORListBox508Manager.GetItem(Component: TWinControl): TObject;
283var
284 lb : TORListBox;
285 max, id: integer;
286begin
287 GetCurrent(Component);
288 lb := TORListBox(Component);
289 max := lb.items.Count + 2;
290 if max < 10000 then
291 max := 10000;
292 id := (lb.items.Count * max) + (lb.FocusIndex + 2);
293 if lb.FocusIndex < 0 then dec(id);
294 Result := TObject(id);
295end;
296
297function TORListBox508Manager.GetItemInstructions(
298 Component: TWinControl): string;
299begin
300 Result := GetCurrent(Component).GetItemInstructions(Component);
301end;
302
303function TORListBox508Manager.GetState(Component: TWinControl): string;
304begin
305 Result := GetCurrent(Component).GetState(Component);
306end;
307
308function TORListBox508Manager.GetValue(Component: TWinControl): string;
309var idx: integer;
310 lb: TORListBox;
311begin
312 lb := TORListBox(Component);
313 idx := lb.FocusIndex;
314 if idx < 0 then
315 idx := 0;
316 Result := lb.DisplayText[idx];
317end;
318
319function TORListBox508Manager.GetCurrent(Component: TWinControl): TLBMgr;
320var
321 lb : TORListBox;
322
323begin
324 lb := TORListBox(Component);
325 if lb.CheckBoxes then
326 begin
327 if not assigned(FCheckBoxes) then
328 FCheckBoxes := TORListBoxCheckBoxes508Manager.Create;
329 FCurrent := FCheckBoxes;
330 end
331 else if lb.MultiSelect then
332 begin
333 if not assigned(FMultiSelect) then
334 FMultiSelect := TORListBoxMultiSelect508Manager.Create;
335 FCurrent := FMultiSelect;
336 end
337 else
338 begin
339 if not assigned(FStandard) then
340 FStandard := TORListBoxStandard508Manager.Create;
341 FCurrent := FStandard;
342 end;
343 Result := FCurrent;
344end;
345
346{ TORListBoxCheckBoxes508Manager }
347
348function TORListBoxCheckBoxes508Manager.GetComponentName(
349 Component: TWinControl): string;
350begin
351 Result := 'Check List Box'
352end;
353
354function TORListBoxCheckBoxes508Manager.GetItemInstructions(
355 Component: TWinControl): string;
356var
357 lb: TORListBox;
358 idx: integer;
359begin
360 Result := '';
361 lb := TORListBox(Component);
362 idx := GetIdx(Component);
363 if (idx >= 0) then
364 Result := VA508DelphiCompatibility.GetCheckBoxInstructionMessage(lb.Checked[idx])
365 else
366 Result := '';
367end;
368
369function TORListBoxCheckBoxes508Manager.GetState(
370 Component: TWinControl): string;
371var
372 lb: TORListBox;
373 idx: integer;
374begin
375 lb := TORListBox(Component);
376 idx := GetIdx(Component);
377 if (idx >= 0) then
378 begin
379 Result := GetCheckBoxStateText(lb.CheckedState[idx]);
380 if lb.FocusIndex < 0 then
381 Result := 'not selected ' + Result;
382 end
383 else
384 Result := '';
385end;
386
387{ TORListBoxMultiSelect508Manager }
388
389function TORListBoxMultiSelect508Manager.GetComponentName(
390 Component: TWinControl): string;
391begin
392 Result := 'Multi Select List Box'
393end;
394
395function TORListBoxMultiSelect508Manager.GetItemInstructions(
396 Component: TWinControl): string;
397var
398 lb: TORListBox;
399 idx: integer;
400begin
401 Result := '';
402 lb := TORListBox(Component);
403 idx := GetIdx(Component);
404 if (idx >= 0) then
405 begin
406 if not lb.Selected[idx] then
407 Result := 'to select press space bar'
408 else
409 Result := 'to un select press space bar';
410 end;
411end;
412
413function TORListBoxMultiSelect508Manager.GetState(
414 Component: TWinControl): string;
415var
416 lb: TORListBox;
417 idx: Integer;
418begin
419 lb := TORListBox(Component);
420 idx := GetIdx(Component);
421 if (idx >= 0) then
422 begin
423 if lb.Selected[idx] then
424 Result := 'Selected'
425 else
426 Result := 'Not Selected';
427 end
428 else
429 Result := '';
430end;
431
432{ TORListBoxStandard508Manager }
433
434function TORListBoxStandard508Manager.GetComponentName(
435 Component: TWinControl): string;
436begin
437 Result := 'List Box';
438end;
439
440function TORListBoxStandard508Manager.GetItemInstructions(
441 Component: TWinControl): string;
442begin
443 Result := '';
444end;
445
446function TORListBoxStandard508Manager.GetState(Component: TWinControl): string;
447var
448 lb: TORListBox;
449begin
450 lb := TORListBox(Component);
451 if (lb.FocusIndex < 0) then
452 Result := 'Not Selected'
453 else
454 Result := '';
455end;
456
457{ TLBMgr }
458
459function TLBMgr.GetIdx(Component: TWinControl): integer;
460begin
461 Result := TORListBox(Component).FocusIndex;
462 if (Result < 0) and (TORListBox(Component).Count > 0) then
463 Result := 0;
464end;
465
466{ TVA508TORDateComboComplexManager }
467
468constructor TVA508TORDateComboComplexManager.Create;
469begin
470 inherited Create(TORDateCombo);
471end;
472
473type
474 TORDateComboFriend = class(TORDateCombo);
475
476procedure TVA508TORDateComboComplexManager.Refresh(Component: TWinControl;
477 AccessibilityManager: TVA508AccessibilityManager);
478begin
479 with TORDateComboFriend(Component) do
480 begin
481 ClearSubControls(Component);
482// if assigned(CalBtn) then
483// CalBtn.TabStop := TRUE;
484// if IncludeBtn then
485// AddSubControl(CalBtn, AccessibilityManager);
486 AddSubControl(Component, YearEdit, AccessibilityManager);
487// AddSubControl(YearUD, AccessibilityManager);
488 if IncludeMonth then
489 AddSubControl(Component, MonthCombo, AccessibilityManager);
490 if IncludeDay then
491 AddSubControl(Component, DayCombo, AccessibilityManager);
492 end;
493end;
494
495{ TORDayCombo508Manager }
496
497constructor TORDayCombo508Manager.Create;
498begin
499 inherited Create(TORDayCombo, [mtCaption, mtValue]);
500end;
501
502function TORDayCombo508Manager.GetCaption(Component: TWinControl): string;
503begin
504 Result := 'Day';
505end;
506
507{ TORMonthCombo508Manager }
508
509constructor TORMonthCombo508Manager.Create;
510begin
511 inherited Create(TORMonthCombo, [mtCaption, mtValue]);
512end;
513
514function TORMonthCombo508Manager.GetCaption(Component: TWinControl): string;
515begin
516 Result := 'Month';
517end;
518
519{ TORYearEdit508Manager }
520
521constructor TORYearEdit508Manager.Create;
522begin
523 inherited Create(TORYearEdit, [mtCaption]);
524end;
525
526function TORYearEdit508Manager.GetCaption(Component: TWinControl): string;
527begin
528 Result := 'Year';
529end;
530
531{ TORDateButton508Manager }
532
533constructor TORDateButton508Manager.Create;
534begin
535 inherited Create(TORDateButton, [mtCaption]);
536end;
537
538function TORDateButton508Manager.GetCaption(Component: TWinControl): string;
539begin
540 Result := 'Date';
541end;
542
543(*
544{ TVA508TORDateBoxComplexManager }
545
546constructor TVA508TORDateBoxComplexManager.Create;
547begin
548 inherited Create(TORDateBox);
549end;
550
551type
552 TORDateBoxFriend = class(TORDateBox);
553
554procedure TVA508TORDateBoxComplexManager.Refresh(Component: TWinControl;
555 AccessibilityManager: TVA508AccessibilityManager);
556begin
557 with TORDateBoxFriend(Component) do
558 begin
559 ClearSubControls;
560 if assigned(DateButton) then
561 begin
562 DateButton.TabStop := TRUE;
563 AddSubControl(DateButton, AccessibilityManager);
564 end;
565 end;
566end;
567*)
568
569{ TVA508ORComboManager }
570
571constructor TORComboBox508Manager.Create;
572begin
573 inherited Create(TORComboBox, [mtValue], TRUE);
574end;
575
576function TORComboBox508Manager.GetValue(Component: TWinControl): string;
577begin
578 Result := TORComboBox(Component).Text;
579end;
580
581{ TORComboEdit508Manager }
582
583//constructor TORComboEdit508Manager.Create;
584//begin
585// inherited Create(TORComboEdit, [mtComponentRedirect]);
586//end;
587//
588//function TORComboEdit508Manager.Redirect(Component: TWinControl;
589// var ManagedType: TManagedType): TWinControl;
590//begin
591// ManagedType := mtCaption;
592// Result := TWinControl(Component.Owner);
593//end;
594
595{ TVA508TORComboBoxComplexManager }
596
597//constructor TVA508TORComboBoxComplexManager.Create;
598//begin
599// inherited Create(TORComboBox);
600//end;
601//
602//procedure TVA508TORComboBoxComplexManager.Refresh(Component: TWinControl;
603// AccessibilityManager: TVA508AccessibilityManager);
604//var
605// eBox: TORComboEdit;
606//begin
607// begin
608// ClearSubControls;
609// eBox := GetEditBox(TORComboBox(Component));
610// if assigned(eBox) then
611// AddSubControl(eBox, AccessibilityManager);
612// end;
613//end;
614
615initialization
616 RegisterORComponents;
617
618end.
Note: See TracBrowser for help on using the repository browser.