Index: cprs/trunk/CPRS-Chart/fDrawers.pas
===================================================================
--- cprs/trunk/CPRS-Chart/fDrawers.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/fDrawers.pas	(revision 830)
@@ -10,5 +10,6 @@
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   ExtCtrls, StdCtrls, Buttons, ORCtrls, ComCtrls, ImgList, uTemplates,
-  Menus, ORClasses, ORFn;
+  Menus, ORClasses, ORFn, fBase508Form, VA508AccessibilityManager,
+  VA508ImageListLabeler;
 
 type
@@ -16,5 +17,5 @@
   TDrawers = set of TDrawer;
 
-  TfrmDrawers = class(TForm)
+  TfrmDrawers = class(TfrmBase508Form)
     lbOrders: TORListBox;
     sbOrders: TORAlignSpeedButton;
@@ -52,4 +53,8 @@
     N5: TMenuItem;
     mnuViewTemplateIconLegend: TMenuItem;
+    fldAccessTemplates: TVA508ComponentAccessibility;
+    fldAccessReminders: TVA508ComponentAccessibility;
+    imgLblReminders: TVA508ImageListLabeler;
+    imgLblTemplates: TVA508ImageListLabeler;
     procedure FormCanResize(Sender: TObject; var NewWidth,
       NewHeight: Integer; var Resize: Boolean);
@@ -105,6 +110,10 @@
     procedure tvRemindersNodeCaptioning(Sender: TObject;
       var Caption: String);
-    procedure tvRemindersAddition(Sender: TObject; Node: TTreeNode);
-    procedure tvRemindersDeletion(Sender: TObject; Node: TTreeNode);
+    procedure fldAccessTemplatesStateQuery(Sender: TObject; var Text: string);
+    procedure fldAccessTemplatesInstructionsQuery(Sender: TObject;
+      var Text: string);
+    procedure fldAccessRemindersInstructionsQuery(Sender: TObject;
+      var Text: string);
+    procedure fldAccessRemindersStateQuery(Sender: TObject; var Text: string);
   private
     FOpenToNode: string;
@@ -211,5 +220,5 @@
 uses fTemplateView, uCore, rTemplates, fTemplateEditor, dShared, uReminders,
   fReminderDialog, RichEdit, fRptBox, Clipbrd, fTemplateDialog, fIconLegend,
-  uAccessibleTreeView, uAccessibleTreeNode;
+  VA508AccessibilityRouter, uVA508CPRSCompatibility, VAUtils, fFindingTemplates;
 
 {$R *.DFM}
@@ -534,4 +543,6 @@
   end;
   ToggleDrawer(odTemplates);
+  if ScreenReaderActive then
+    pnlTemplatesButton.SetFocus;
 end;
 
@@ -559,4 +570,6 @@
       ToggleDrawer(odReminders)
   end;
+  if ScreenReaderActive then
+    pnlRemindersButton.SetFocus;
 end;
 
@@ -884,10 +897,14 @@
       begin
         CheckBoilerplate4Fields(txt, 'Template: ' + Template.PrintName);
-        BeforeLine := SendMessage(FRichEditControl.Handle, EM_EXLINEFROMCHAR, 0, FRichEditControl.SelStart);
-        FRichEditControl.SelText := txt;
-        FRichEditControl.SetFocus;
-        SendMessage(FRichEditControl.Handle, EM_SCROLLCARET, 0, 0);
-        AfterTop := SendMessage(FRichEditControl.Handle, EM_GETFIRSTVISIBLELINE, 0, 0);
-        SendMessage(FRichEditControl.Handle, EM_LINESCROLL, 0, -1 * (AfterTop - BeforeLine));
+        if txt <> '' then
+        begin
+          BeforeLine := SendMessage(FRichEditControl.Handle, EM_EXLINEFROMCHAR, 0, FRichEditControl.SelStart);
+          FRichEditControl.SelText := txt;
+          FRichEditControl.SetFocus;
+          SendMessage(FRichEditControl.Handle, EM_SCROLLCARET, 0, 0);
+          AfterTop := SendMessage(FRichEditControl.Handle, EM_GETFIRSTVISIBLELINE, 0, 0);
+          SendMessage(FRichEditControl.Handle, EM_LINESCROLL, 0, -1 * (AfterTop - BeforeLine));
+          SpeakTextInserted;
+        end;
       end;
     end;
@@ -960,5 +977,4 @@
 procedure TfrmDrawers.FormDestroy(Sender: TObject);
 begin
-  TAccessibleTreeView.UnwrapControl(tvReminders);
   dmodShared.RemoveDrawerTree(Self);
   KillObj(@FRemNotifyList);
@@ -973,4 +989,5 @@
 procedure TfrmDrawers.ReloadTemplates;
 begin
+  SetFindNext(FALSE);
   LoadTemplateData;
   if(UserTemplateAccessLevel <> taNone) and (assigned(MyTemplate)) and
@@ -986,66 +1003,35 @@
 procedure TfrmDrawers.btnFindClick(Sender: TObject);
 var
-  TmpNode: TTreeNode;
-  Found: boolean;
-  S1,S2: string;
+  Found, TmpNode: TTreeNode;
+  IsNext: boolean;
 
 begin
   if(edtSearch.text <> '') then
   begin
-    if(FEmptyNodeCount > 0) then
-    begin
-      FInternalExpand := TRUE;
-      FInternalHiddenExpand := TRUE;
-      try
-        TmpNode := tvTemplates.Items.GetFirstNode;
-        while(assigned(TmpNode)) do
-        begin
-          TmpNode.Expand(TRUE);
-          TmpNode := TmpNode.GetNextSibling;
-        end;
-      finally
-        FInternalExpand := FALSE;
-        FInternalHiddenExpand := FALSE;
-      end;
-    end;
-    if((FFindNext) and assigned (FLastFoundNode)) then
-      TmpNode := FLastFoundNode.GetNext
+    IsNext := ((FFindNext) and assigned (FLastFoundNode));
+    if IsNext then
+      TmpNode := FLastFoundNode
     else
       TmpNode := tvTemplates.Items.GetFirstNode;
-    Found := FALSE;
-    if(assigned(TmpNode)) then
-    begin
-      S1 := edtSearch.Text;
-      if(not cbMatchCase.Checked) then
-        S1 := UpperCase(S1);
-      while (assigned(TmpNode) and (not Found)) do
-      begin
-        S2 := TmpNode.Text;
-        if(not cbMatchCase.Checked) then
-          S2 := UpperCase(S2);
-        Found := SearchMatch(S1, S2, cbWholeWords.Checked);
-        if(not Found) then
-          TmpNode := TmpNode.GetNext;
-      end;
-    end;
-    if(Found) then
-    begin
-      FLastFoundNode := TmpNode;
+    FInternalExpand := TRUE;
+    FInternalHiddenExpand := TRUE;
+    try
+      Found := FindTemplate(edtSearch.Text, tvTemplates, Application.MainForm, TmpNode,
+                            IsNext, not cbMatchCase.Checked, cbWholeWords.Checked);
+    finally
+      FInternalExpand := FALSE;
+      FInternalHiddenExpand := FALSE;
+    end;
+
+    if assigned(Found) then
+    begin
+      FLastFoundNode := Found;
       SetFindNext(TRUE);
       FInternalExpand := TRUE;
       try
-        tvTemplates.Selected := TmpNode;
+        tvTemplates.Selected := Found;
       finally
         FInternalExpand := FALSE;
       end;
-    end
-    else
-    begin
-      if(FFindNext) then
-        S1 := ''
-      else
-        S1 := '  "' + edtSearch.Text + '" was not Found.';
-      SetFindNext(FALSE);
-      InfoBox('Search Complete.' + S1, 'Information', MB_OK or MB_ICONINFORMATION);
     end;
   end;
@@ -1132,5 +1118,4 @@
   dmodShared.AddDrawerTree(Self);
   FHasPersonalTemplates := FALSE;
-  TAccessibleTreeView.WrapControl(tvReminders);
 end;
 
@@ -1143,4 +1128,45 @@
   FEmptyNodeCount := 0;
   ReloadTemplates;
+end;
+
+procedure TfrmDrawers.fldAccessRemindersInstructionsQuery(Sender: TObject;
+  var Text: string);
+begin
+  inherited;
+  if FOpenDrawer = odReminders then
+    Text := 'to close'
+  else
+    Text := 'to open';
+  Text := Text + ' drawer press space bar';
+end;
+
+procedure TfrmDrawers.fldAccessRemindersStateQuery(Sender: TObject;
+  var Text: string);
+begin
+  inherited;
+  if FOpenDrawer = odReminders then
+    Text := ', Drawer Open'
+  else
+    Text := ', Drawer Closed';
+end;
+
+procedure TfrmDrawers.fldAccessTemplatesInstructionsQuery(Sender: TObject;
+  var Text: string);
+begin
+  inherited;
+  if FOpenDrawer = odTemplates then
+    Text := 'to close'
+  else
+    Text := 'to open';
+  Text := Text + ' drawer press space bar';
+end;
+
+procedure TfrmDrawers.fldAccessTemplatesStateQuery(Sender: TObject;
+  var Text: string);
+begin
+  if FOpenDrawer = odTemplates then
+    Text := ', Drawer Open'
+  else
+    Text := ', Drawer Closed';
 end;
 
@@ -1390,5 +1416,5 @@
 var
   OldInternalHE, OldInternalEX: boolean;
-  
+
 begin
   if(Path <> '') then
@@ -1425,5 +1451,5 @@
     tmpl := TTemplate(tvTemplates.Selected.Data);
     if(tmpl.Description = '') then
-      ShowMessage('No notes found for ' + tmpl.PrintName)
+      ShowMsg('No notes found for ' + tmpl.PrintName)
     else
     begin
@@ -1454,5 +1480,8 @@
     CheckBoilerplate4Fields(txt, 'Template: ' + Template.PrintName);
     if txt <> '' then
+    begin
       Clipboard.SetTextBuf(PChar(txt));
+      GetScreenReader.Speak('Text Copied to Clip board');
+    end;
   end;
   if txt <> '' then
@@ -1531,16 +1560,4 @@
 end;
 
-procedure TfrmDrawers.tvRemindersAddition(Sender: TObject;
-  Node: TTreeNode);
-begin
-  TAccessibleTreeNode.WrapControl(Node as TORTreeNode);
-end;
-
-procedure TfrmDrawers.tvRemindersDeletion(Sender: TObject;
-  Node: TTreeNode);
-begin
-  TAccessibleTreeNode.UnwrapControl(Node as TORTreeNode);
-end;
-
 procedure TfrmDrawers.DisableArrowKeyMove(Sender: TObject);
 var
@@ -1561,4 +1578,7 @@
 end;
 
+initialization
+  SpecifyFormIsNotADialog(TfrmDrawers);
+
 end.
 
