Index: cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck/Demo/fHunSpell.pas
===================================================================
--- cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck/Demo/fHunSpell.pas	(revision 1718)
+++ cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck/Demo/fHunSpell.pas	(revision 1725)
@@ -36,9 +36,8 @@
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   StdCtrls, ComCtrls, RichEdit, Buttons, ExtCtrls, ShellAPI, 
-  skaSpellCheck;
+  skaSpellCheck, jpeg;
 
 type
   TfrmHunSpell = class(TForm)
-    lblDictionary: TLabel;
     btnClose: TButton;
     OpenDialog1: TOpenDialog;
@@ -46,12 +45,10 @@
     edtDictionary: TEdit;
     btnSelectDict: TBitBtn;
-    lblDictionariesURL: TLabel;
     RichEdit1: TRichEdit;
-    btnStart: TButton;
     pnlMisSpelled: TPanel;
     Label1: TLabel;
+    lstSuggestions: TListBox;
     Label4: TLabel;
-    lstSuggestions: TListBox;
-    edtMisSpeltWordForExtraHint: TEdit;  //required for screenreaders which are MOSTLY colour blind
+    edtMisSpelt: TEdit;
     btnReplaceWith: TButton;
     btnChangeAll: TButton;
@@ -61,7 +58,26 @@
     btnIgnoreOnce: TButton;
     btnAbort: TButton;
+    btnAbout: TButton;
+    pnlAbout: TPanel;
+    btnHideAbout: TButton;
     btnUndo: TButton;
     cbIgnoreAllCaps: TCheckBox;
     cbIgnoreDigit: TCheckBox;
+    btnRestat: TButton;
+    cbHyphenatedWord: TCheckBox;
+    StaticText1: TStaticText;
+    StaticText2: TStaticText;
+    StaticText3: TStaticText;
+    Label2: TLabel;
+    StaticText4: TStaticText;
+    Label3: TLabel;
+    StaticText5: TStaticText;
+    StaticText6: TStaticText;
+    Image1: TImage;
+    lblDictionariesURL: TLabel;
+    lblDictionary: TLabel;
+    lblOpenMedURL: TLabel;
+    Label5: TLabel;
+    Label6: TLabel;
     procedure FormCreate(Sender: TObject);
     procedure btnIgnoreOnceClick(Sender: TObject);
@@ -75,7 +91,10 @@
     procedure btnReplaceWithClick(Sender: TObject);
     procedure btnAddToDictionaryClick(Sender: TObject);
+    procedure FormShow(Sender: TObject);
     procedure FormClose(Sender: TObject; var Action: TCloseAction);
     procedure btnAbortClick(Sender: TObject);
-    procedure btnStartClick(Sender: TObject);
+    procedure lblOpenMedURLClick(Sender: TObject);
+    procedure btnAboutClick(Sender: TObject);
+    procedure btnHideAboutClick(Sender: TObject);
     procedure btnUndoClick(Sender: TObject);
     procedure RichEdit1KeyUp(Sender: TObject; var Key: Word;
@@ -83,14 +102,17 @@
     procedure RichEdit1KeyDown(Sender: TObject; var Key: Word;
       Shift: TShiftState);
-    procedure UpdateGUI;
+    procedure lstSuggestionsDblClick(Sender: TObject);
+    procedure SpellCheck1StateChange(const Sender: TObject;
+      const State: TSpellState);
     procedure SpellCheck1Abort(Sender: TObject);
     procedure SpellCheck1Start(Sender: TObject);
-    procedure SpellCheck1StateChange(const Sender: TObject;
-      const State: TSpellState);
-    procedure lblDictionariesURLClick(Sender: TObject);
-    procedure lstSuggestionsDblClick(Sender: TObject);
     procedure cbIgnoreAllCapsClick(Sender: TObject);
     procedure cbIgnoreDigitClick(Sender: TObject);
     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
+    procedure btnRestatClick(Sender: TObject);
+    procedure cbHyphenatedWordClick(Sender: TObject);
+    procedure Image1Click(Sender: TObject);
+    procedure Label6Click(Sender: TObject);
+    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
   private
     { Private declarations }
@@ -98,4 +120,5 @@
     FSourceControl: TCustomMemo;
     procedure GoToURL(const aURL: String);
+    procedure UpdateGUI;
   public
     { Public declarations }
@@ -105,6 +128,5 @@
     OldRichEditWndProc: {integer}pointer;
     PRichEditWndProc:pointer;
-    class function DoHunSpellCheck(AnEditControl: TCustomMemo): TModalResult;
-                                                                      static;
+    class function DoHunSpellCheck(AnEditControl: TCustomMemo): TModalResult; static;
   end;
 
@@ -121,5 +143,6 @@
 
  Const
-   DefaultDicFile =  'dict\en_GB.dic';//  'dict\en-US-OpenMedSpel.dic';
+   DefaultDicFile =  '\dict\en_US-large.dic';
+
  var
   frmHunSpell: TfrmHunSpell;
@@ -129,8 +152,5 @@
 
 
-class function TfrmHunSpell.DoHunSpellCheck(AnEditControl: TCustomMemo):
-                                                                   TModalResult;
-{This function could be invoked from some other form by using this as modalform
-without creating the instance of this form in advance}
+class function TfrmHunSpell.DoHunSpellCheck(AnEditControl: TCustomMemo): TModalResult;
 var
   frm: TfrmHunSpell;
@@ -148,5 +168,16 @@
 
  {************ HighLight ***********888}
- procedure TfrmHunSpell.GoToURL(const aURL: String);
+ procedure TfrmHunSpell.FormShow(Sender: TObject);
+begin
+ if SpellCheck1.SpellCheckState = ssReady then
+   SpellCheck1.CheckSpelling;
+ try
+   if lstSuggestions.Count > 0 then
+     btnChange.SetFocus;
+ except
+ end;
+end;
+
+procedure TfrmHunSpell.GoToURL(const aURL: String);
 begin
 if length(trim(aURL)) > 4 then
@@ -154,6 +185,19 @@
 end;
 
-procedure TfrmHunSpell.lblDictionariesURLClick(Sender: TObject);
-begin
+procedure TfrmHunSpell.Image1Click(Sender: TObject);
+begin
+  inherited;
+  GoToURL('http://www.healthsevak.com');
+end;
+
+procedure TfrmHunSpell.Label6Click(Sender: TObject);
+begin
+  inherited;
+   GoToURL('mailto: digitiger@gmail.com');
+end;
+
+procedure TfrmHunSpell.lblOpenMedURLClick(Sender: TObject);
+begin
+  inherited;
   GoToURL(TLabel(sender).Caption);
 end;
@@ -161,6 +205,6 @@
 procedure TfrmHunSpell.lstSuggestionsDblClick(Sender: TObject);
 begin
-if lstSuggestions.ItemIndex >= 0 then
-   btnChangeClick(Self);
+  inherited;
+  btnChangeClick(sender);
 end;
 
@@ -168,4 +212,5 @@
   Shift: TShiftState);
 begin
+  inherited;
   if SpellCheck1.SpellCheckState = ssChecking then
     SpellCheck1.ManualChangeStart;
@@ -175,7 +220,8 @@
   Shift: TShiftState);
 begin
- if SpellCheck1.SpellCheckState in [ssCancelled, ssCompleted] then
+  inherited;
+  if SpellCheck1.SpellCheckState in [ssCancelled, ssCompleted] then
    SpellCheck1.Reopen;
-   
+
  if SpellCheck1.SpellCheckState = ssChecking then
     SpellCheck1.ManualChangeDone;
@@ -184,4 +230,5 @@
 procedure TfrmHunSpell.SpellCheck1Abort(Sender: TObject);
 begin
+  inherited;
   UpdateGUI;
 end;
@@ -189,4 +236,5 @@
 procedure TfrmHunSpell.SpellCheck1Start(Sender: TObject);
 begin
+  inherited;
   UpdateGUI;
 end;
@@ -195,4 +243,5 @@
   const State: TSpellState);
 begin
+  inherited;
   if State = ssCompleted then
     ShowMessage(TX_SPELL_COMPLETE);
@@ -204,9 +253,6 @@
   Checking: Boolean;
 begin
- if  csDestroying in componentstate then
-   exit;
-  btnStart.Enabled := (SpellCheck1.SpellCheckState in [ssReady, ssCancelled])
-                      and (trim(RichEdit1.Text) <> '');
-
+  if  csDestroying in componentstate then
+     exit;
   Checking := SpellCheck1.SpellCheckState = ssChecking;
   pnlMisSpelled.Visible := Checking;
@@ -216,12 +262,9 @@
 
 {************* FormCreate **********}
-procedure TfrmHunSpell.btnStartClick(Sender: TObject);
-begin
-  if SpellCheck1.SpellCheckState <> ssChecking then
-   SpellCheck1.CheckSpelling;
-
-  UpdateGUI;
-  if (lstSuggestions.Count > 0) and btnChange.Visible and btnChange.Enabled then
-      btnChange.SetFocus;
+procedure TfrmHunSpell.btnAboutClick(Sender: TObject);
+begin
+  inherited;
+  pnlAbout.Show;
+  pnlAbout.BringToFront;
 end;
 
@@ -236,8 +279,13 @@
 end;
 
+procedure TfrmHunSpell.btnRestatClick(Sender: TObject);
+begin
+  inherited;
+    SpellCheck1.ReStart
+end;
+
 procedure TfrmHunSpell.btnAbortClick(Sender: TObject);
 begin
-  if SpellCheck1.AbortSpellCheck(False) then
-    UpdateGUI;
+  if SpellCheck1.AbortSpellCheck(True) then
 end;
 
@@ -254,5 +302,5 @@
 procedure TfrmHunSpell.btnCloseClick(Sender: TObject);
 begin
- close;
+  close;
 end;
 
@@ -301,14 +349,38 @@
 end;
 
+procedure TfrmHunSpell.btnHideAboutClick(Sender: TObject);
+begin
+  inherited;
+  pnlAbout.hide;
+end;
+
+procedure TfrmHunSpell.cbHyphenatedWordClick(Sender: TObject);
+begin
+  inherited;
+    if SpellCheck1.HyphenatedWords <> cbHyphenatedWord.Checked then
+    SpellCheck1.HyphenatedWords := cbHyphenatedWord.Checked;
+
+    if SpellCheck1.SpellCheckState = ssChecking then
+      SpellCheck1.ReStart;
+end;
+
 procedure TfrmHunSpell.cbIgnoreAllCapsClick(Sender: TObject);
 begin
+  inherited;
   if SpellCheck1.IgnoreAllCaps <> cbIgnoreAllCaps.Checked then
     SpellCheck1.IgnoreAllCaps := cbIgnoreAllCaps.Checked;
+
+  if SpellCheck1.SpellCheckState = ssChecking then
+      SpellCheck1.ReStart;
 end;
 
 procedure TfrmHunSpell.cbIgnoreDigitClick(Sender: TObject);
 begin
+  inherited;
   if SpellCheck1.IgnoreWordWithDigits <> cbIgnoreDigit.Checked then
     SpellCheck1.IgnoreWordWithDigits := cbIgnoreDigit.Checked;
+
+  if SpellCheck1.SpellCheckState = ssChecking then
+      SpellCheck1.ReStart;
 end;
 
@@ -320,10 +392,9 @@
 procedure TfrmHunSpell.FormActivate(Sender: TObject);
 begin
-  if ( not SpellCheck1.Active) and (not NoEngineOpted) then
+  if ( not btnRestat.Enabled) and (not NoEngineOpted) then
   begin
      btnSelectDictClick(self);
      NoEngineOpted := True;
   end;
-
   if cbIgnoreAllCaps.Checked <> SpellCheck1.IgnoreAllCaps then
     cbIgnoreAllCaps.Checked := SpellCheck1.IgnoreAllCaps;
@@ -331,20 +402,26 @@
   if cbIgnoreDigit.Checked <> SpellCheck1.IgnoreWordWithDigits then
     cbIgnoreDigit.Checked := SpellCheck1.IgnoreWordWithDigits;
+
+  if cbHyphenatedWord.Checked <> SpellCheck1.HyphenatedWords then
+    cbHyphenatedWord.Checked := SpellCheck1.HyphenatedWords;
 end;
 
 procedure TfrmHunSpell.FormClose(Sender: TObject; var Action: TCloseAction);
 begin
- { if SpellCheck1.SpellCheckState = ssCompleted then
+  if SpellCheck1.SpellCheckState = ssCompleted then
   begin
-    ShowMessage(TX_SPELL_COMPLETE) ;
+   // ShowMsg(TX_SPELL_COMPLETE, TShow508MessageIcon(1), smbOK) ;
     if Assigned(FSourceControl) then
       FSourceControl.Text := RichEdit1.Text;
-  end
-  else
-        ShowMessage(TX_SPELL_CANCELLED) ;  }
+  end;
+  {else
+  ShowMsg(TX_SPELL_CANCELLED + CRLF + TX_NO_CORRECTIONS,
+                                              TShow508MessageIcon(1), smbOK) ;}
 end;
 
 procedure TfrmHunSpell.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
 begin
+  inherited;
+
   CanClose := (SpellCheck1.SpellCheckState <> ssChecking)
                or (SpellCheck1.AbortSpellCheck(True));
@@ -361,13 +438,11 @@
   end;
 begin
-  if (SpellCheck1.DictionaryFileName <>  '') then
-      dicFile := SpellCheck1.DictionaryFileName
-  else
-      dicFile := ExtractFilePath(Application.ExeName)+ DefaultDicFile;
+  dicFile := ExtractFilePath(Application.ExeName)+ DefaultDicFile;
 
   if (FileExists(dicFile)) and (FileExists(affFile)) then
   begin
       SpellCheck1.AffixFileName := affFile;
-      edtDictionary.Text := SpellCheck1.DictionaryFileName;
+      SpellCheck1.DictionaryFileName := dicFile;
+      edtDictionary.Text := dicFile;
   end
   else
@@ -376,14 +451,20 @@
   if edtDictionary.Text = TX_Dic_File_Not_Found then
     btnSelectDictClick(self);
- // SpellCheck1.SourceTextControl := RichEdit1;
- // SpellCheck1.SuggestionList := lstSuggestions;
-  //SpellCheck1.MisSpeltWord := Edit2;
-  SpellCheck1.Active :=  (SpellCheck1.DictionaryFileName <>  '')
+    
+  SpellCheck1.SourceTextControl := RichEdit1;
+  SpellCheck1.SuggestionList := lstSuggestions;
+  SpellCheck1.MisSpeltWord := edtMisSpelt;
+  btnRestat.Enabled :=  (SpellCheck1.DictionaryFileName <>  '')
                                                       and FileExists(dicFile);
-  UpdateGUI;
-end;
-
-
+end;
+
+
+
+procedure TfrmHunSpell.FormKeyUp(Sender: TObject; var Key: Word;
+  Shift: TShiftState);
+begin
+  if (key = 27) and (pnlAbout.Showing) then
+    btnHideAboutClick(self);
+end;
 
 end.
-
