Changeset 1719 for cprs/branches/HealthSevak-CPRS/CPRS-Chart/fHunSpell.pas
- Timestamp:
- May 19, 2015, 3:06:26 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/HealthSevak-CPRS/CPRS-Chart/fHunSpell.pas
r1700 r1719 45 45 OpenDialog1: TOpenDialog; 46 46 SpellCheck1: TskaHunSpellChecker; 47 Edit1: TEdit;47 edtDictionary: TEdit; 48 48 btnSelectDict: TBitBtn; 49 49 lblOpenMedURL: TLabel; … … 54 54 lstSuggestions: TListBox; 55 55 Label4: TLabel; 56 Edit2: TEdit;56 edtMisSpelt: TEdit; 57 57 btnReplaceWith: TButton; 58 58 btnChangeAll: TButton; … … 61 61 btnIgnoreAll: TButton; 62 62 btnIgnoreOnce: TButton; 63 btn Cancel: TButton;63 btnAbort: TButton; 64 64 btnAbout: TButton; 65 65 pnlAbout: TPanel; 66 66 Button1: TButton; 67 67 btnUndo: TButton; 68 cbIgnoreAllCaps: TCheckBox; 69 cbIgnoreDigit: TCheckBox; 68 70 procedure FormCreate(Sender: TObject); 69 71 procedure btnIgnoreOnceClick(Sender: TObject); … … 74 76 procedure FormActivate(Sender: TObject); 75 77 procedure btnSelectDictClick(Sender: TObject); 76 procedure Edit1Enter(Sender: TObject);78 procedure edtDictionaryEnter(Sender: TObject); 77 79 procedure btnReplaceWithClick(Sender: TObject); 78 80 procedure btnAddToDictionaryClick(Sender: TObject); 79 81 procedure FormShow(Sender: TObject); 80 82 procedure FormClose(Sender: TObject; var Action: TCloseAction); 81 procedure btn CancelClick(Sender: TObject);83 procedure btnAbortClick(Sender: TObject); 82 84 procedure lblOpenMedURLClick(Sender: TObject); 83 85 procedure btnAboutClick(Sender: TObject); … … 88 90 procedure RichEdit1KeyDown(Sender: TObject; var Key: Word; 89 91 Shift: TShiftState); 92 procedure lstSuggestionsDblClick(Sender: TObject); 93 procedure SpellCheck1StateChange(const Sender: TObject; 94 const State: TSpellState); 95 procedure SpellCheck1Abort(Sender: TObject); 96 procedure SpellCheck1Start(Sender: TObject); 97 procedure cbIgnoreAllCapsClick(Sender: TObject); 98 procedure cbIgnoreDigitClick(Sender: TObject); 99 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 90 100 private 91 101 { Private declarations } 92 102 NoEngineOpted: Boolean; 93 103 FSourceControl: TCustomMemo; 94 WaitForUser: Boolean;95 104 procedure GoToURL(const aURL: String); 105 procedure UpdateGUI; 96 106 public 97 107 { Public declarations } … … 104 114 end; 105 115 116 Resourcestring 117 TX_AFF_NOT_FOUND = 'Correspong AFF file named not found!' 118 + #13 119 + ' Specify dictionary file whose *.aff is also ' 120 + 'present in same directory.' ; 121 TX_DIC_FILE_NOT_FOUND = 'Dictionary File for SpellCheck Engine not found!'; 122 TX_SPELL_COMPLETE = 'Spell Check Complete'; 123 TX_SPELL_CANCELLED = 'Spell Check Aborted' 124 + #13 125 + 'No Changes applied to the original text!'; 126 127 Const 128 DefaultDicFile = 'dict\en-US-OpenMedSpel.dic'; 129 106 130 var 107 131 frmHunSpell: TfrmHunSpell; … … 130 154 procedure TfrmHunSpell.FormShow(Sender: TObject); 131 155 begin 132 if SpellCheck1.SpellCheckState = ss NotStartedthen156 if SpellCheck1.SpellCheckState = ssReady then 133 157 SpellCheck1.CheckSpelling; 134 135 158 try 136 159 if lstSuggestions.Count > 0 then 137 160 btnChange.SetFocus; 138 161 except 139 140 162 end; 141 163 end; … … 153 175 end; 154 176 177 procedure TfrmHunSpell.lstSuggestionsDblClick(Sender: TObject); 178 begin 179 inherited; 180 btnChangeClick(sender); 181 end; 182 155 183 procedure TfrmHunSpell.RichEdit1KeyDown(Sender: TObject; var Key: Word; 156 184 Shift: TShiftState); 157 185 begin 158 186 inherited; 159 SpellCheck1.ManualChangeStart; 187 if SpellCheck1.SpellCheckState = ssChecking then 188 SpellCheck1.ManualChangeStart; 160 189 end; 161 190 … … 164 193 begin 165 194 inherited; 166 SpellCheck1.ManualChangeDone; 195 if SpellCheck1.SpellCheckState in [ssCancelled, ssCompleted] then 196 SpellCheck1.Reopen; 197 198 if SpellCheck1.SpellCheckState = ssChecking then 199 SpellCheck1.ManualChangeDone; 200 end; 201 202 procedure TfrmHunSpell.SpellCheck1Abort(Sender: TObject); 203 begin 204 inherited; 205 UpdateGUI; 206 end; 207 208 procedure TfrmHunSpell.SpellCheck1Start(Sender: TObject); 209 begin 210 inherited; 211 UpdateGUI; 212 end; 213 214 procedure TfrmHunSpell.SpellCheck1StateChange(const Sender: TObject; 215 const State: TSpellState); 216 begin 217 inherited; 218 if State = ssCompleted then 219 ShowMessage(TX_SPELL_COMPLETE); 220 UpdateGUI; 221 end; 222 223 procedure TfrmHunSpell.UpdateGUI; 224 var 225 Checking: Boolean; 226 begin 227 if csDestroying in componentstate then 228 exit; 229 Checking := SpellCheck1.SpellCheckState = ssChecking; 230 pnlMisSpelled.Visible := Checking; 231 pnlMisSpelled.Enabled := Checking; 232 btnClose.Visible := not Checking; 167 233 end; 168 234 … … 185 251 end; 186 252 187 procedure TfrmHunSpell.btn CancelClick(Sender: TObject);253 procedure TfrmHunSpell.btnAbortClick(Sender: TObject); 188 254 begin 189 255 //popup 508 compliant confirmation/warning box if isModified 190 if SpellCheck1.AbortSpellCheck( False) then256 if SpellCheck1.AbortSpellCheck(True) then 191 257 begin 192 258 Close; … … 207 273 procedure TfrmHunSpell.btnCloseClick(Sender: TObject); 208 274 begin 209 close;275 close; 210 276 end; 211 277 … … 232 298 if not FileExists(aff) then 233 299 begin 234 ShowMessage( 'Correspong AFF file named "'+ aff + '" not found!' + #13 + ' Specify dictionary file whose *.aff is also present in same directory.');300 ShowMessage(TX_AFF_NOT_FOUND); 235 301 OpenDialog1.FileName := ''; 236 302 btnSelectDictClick(self); … … 240 306 if SpellCheck1.SpellCheckState = ssChecking then 241 307 SpellCheck1.AbortSpellCheck(False); 242 Edit1.Text := OpenDialog1.FileName;243 SpellCheck1.DictionaryFileName := OpenDialog1.FileName;308 edtDictionary.Text := OpenDialog1.FileName; 309 SpellCheck1.DictionaryFileName := edtDictionary.Text; 244 310 SpellCheck1.AffixFileName := aff; 245 311 SpellCheck1.Open; 246 WaitForUser := False;247 SpellCheck1.CheckSpelling;248 312 end; 249 313 end; … … 262 326 end; 263 327 264 procedure TfrmHunSpell.Edit1Enter(Sender: TObject); 328 procedure TfrmHunSpell.cbIgnoreAllCapsClick(Sender: TObject); 329 begin 330 inherited; 331 if SpellCheck1.IgnoreAllCaps <> cbIgnoreAllCaps.Checked then 332 SpellCheck1.IgnoreAllCaps := cbIgnoreAllCaps.Checked; 333 end; 334 335 procedure TfrmHunSpell.cbIgnoreDigitClick(Sender: TObject); 336 begin 337 inherited; 338 if SpellCheck1.IgnoreWordWithDigits <> cbIgnoreDigit.Checked then 339 SpellCheck1.IgnoreWordWithDigits := cbIgnoreDigit.Checked; 340 end; 341 342 procedure TfrmHunSpell.edtDictionaryEnter(Sender: TObject); 265 343 begin 266 344 btnSelectDict.SetFocus; … … 274 352 NoEngineOpted := True; 275 353 end; 354 if cbIgnoreAllCaps.Checked <> SpellCheck1.IgnoreAllCaps then 355 cbIgnoreAllCaps.Checked := SpellCheck1.IgnoreAllCaps; 356 357 if cbIgnoreDigit.Checked <> SpellCheck1.IgnoreWordWithDigits then 358 cbIgnoreDigit.Checked := SpellCheck1.IgnoreWordWithDigits; 276 359 end; 277 360 … … 283 366 if Assigned(FSourceControl) then 284 367 FSourceControl.Text := RichEdit1.Text; 368 end; 369 {else 370 ShowMsg(TX_SPELL_CANCELLED + CRLF + TX_NO_CORRECTIONS, 371 TShow508MessageIcon(1), smbOK) ;} 372 end; 373 374 procedure TfrmHunSpell.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 375 begin 376 inherited; 377 378 CanClose := (SpellCheck1.SpellCheckState <> ssChecking) 379 or (SpellCheck1.AbortSpellCheck(True)); 380 if CanClose then 381 ModalResult := mrCancel; 382 end; 383 384 procedure TfrmHunSpell.FormCreate(Sender: TObject); 385 var 386 dicFile: String; 387 function affFile: String; 388 begin 389 Result := ChangeFileExt(dicFile, '.aff'); 390 end; 391 begin 392 if (SpellCheck1.DictionaryFileName <> '') then 393 dicFile := SpellCheck1.DictionaryFileName 394 else 395 dicFile := ExtractFilePath(Application.ExeName)+ DefaultDicFile; 396 397 if (FileExists(dicFile)) and (FileExists(affFile)) then 398 begin 399 SpellCheck1.AffixFileName := affFile; 400 edtDictionary.Text := SpellCheck1.DictionaryFileName; 285 401 end 286 402 else 287 ShowMsg(TX_SPELL_CANCELLED + CRLF + TX_NO_CORRECTIONS,TShow508MessageIcon(1), smbOK) ; 288 end; 289 290 procedure TfrmHunSpell.FormCreate(Sender: TObject); 291 begin 292 if FileExists(ExtractFilePath(Application.ExeName)+'\dict\en-US-OpenMedSpel.dic') 293 and FileExists(ExtractFilePath(Application.ExeName)+'\dict\en-US-OpenMedSpel.aff') then 294 begin 295 SpellCheck1.AffixFileName := ExtractFilePath(Application.ExeName)+'\dict\en-US-OpenMedSpel.aff'; 296 SpellCheck1.DictionaryFileName := ExtractFilePath(Application.ExeName)+'\dict\en-US-OpenMedSpel.dic'; 297 Edit1.Text := SpellCheck1.DictionaryFileName; 298 SpellCheck1.Active := True; 299 end 300 else 301 Edit1.Text := 'Dictionary File for SpellCheck Engine not found!'; 302 403 edtDictionary.Text := TX_Dic_File_Not_Found; 404 405 if edtDictionary.Text = TX_Dic_File_Not_Found then 406 btnSelectDictClick(self); 303 407 SpellCheck1.SourceTextControl := RichEdit1; 304 408 SpellCheck1.SuggestionList := lstSuggestions; 305 SpellCheck1.MisSpeltWord := Edit2; 306 SpellCheck1.btnClose := btnClose; 409 SpellCheck1.MisSpeltWord := edtMisSpelt; 410 SpellCheck1.Active := (SpellCheck1.DictionaryFileName <> '') 411 and FileExists(dicFile); 307 412 end; 308 413
Note:
See TracChangeset
for help on using the changeset viewer.