From 6ee65d5dbb8962bb8086e06ec4d2faa89bf32441 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Mon, 12 Mar 2018 10:04:11 +0000 Subject: [PATCH] jvcllaz: Make JvSpellChecker platform-independent git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6238 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../JvSpellChecker/JvSpellCheckerDemo.lpi | 3 - .../JvSpellChecker/JvSpellCheckerDemo.lpr | 4 +- .../JvSpellChecker/JvSpellCheckerForm.lfm | 113 ++++++++++-------- .../JvSpellChecker/JvSpellCheckerForm.pas | 13 +- .../examples/JvSpellChecker/MainFrm.pas | 8 +- .../jvcllaz/run/JvCmp/JvSpellChecker.pas | 14 +-- components/jvcllaz/run/JvCmp/JvSpellIntf.pas | 19 --- .../jvcllaz/run/JvCmp/JvSpellerForm.lfm | 55 +++++---- .../jvcllaz/run/JvCmp/JvSpellerForm.pas | 17 +-- 9 files changed, 114 insertions(+), 132 deletions(-) diff --git a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpi b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpi index efafeaf78..0b9aa983d 100644 --- a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpi +++ b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpi @@ -4,9 +4,6 @@ - - - diff --git a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpr b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpr index 5a0328106..39d1af8f5 100644 --- a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpr +++ b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerDemo.lpr @@ -1,14 +1,16 @@ program JvSpellCheckerDemo; uses - Forms, Interfaces, + Forms, Interfaces, LCLVersion, MainFrm in 'MainFrm.pas' {frmMain}, JvSpellCheckerForm in 'JvSpellCheckerForm.pas' {frmSpellChecker}; {$R *.res} begin + {$IF LCL_FullVersion >= 1080000} Application.Scaled := True; + {$ENDIF} Application.Initialize; Application.CreateForm(TfrmMain, frmMain); Application.CreateForm(TfrmSpellChecker, frmSpellChecker); diff --git a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.lfm b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.lfm index d374dcc1b..e30bad165 100644 --- a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.lfm +++ b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.lfm @@ -1,104 +1,107 @@ -object frmSpellChecker: TfrmSpellChecker +object frmSpellChecker: TfrmSpellChecker Left = 338 + Height = 334 Top = 177 + Width = 384 BorderStyle = bsDialog Caption = 'Spell check document' ClientHeight = 334 ClientWidth = 384 Color = clBtnFace DefaultMonitor = dmDesktop - Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Shell Dlg 2' - Font.Style = [] FormStyle = fsStayOnTop - OldCreateOrder = False - Position = poMainFormCenter - Scaled = False OnCreate = FormCreate OnShow = FormShow - PixelsPerInch = 96 - TextHeight = 13 + Position = poMainFormCenter + LCLVersion = '1.9.0.0' + Scaled = False object Label1: TLabel Left = 16 + Height = 15 Top = 16 - Width = 72 - Height = 13 + Width = 81 Caption = 'Not in wordlist:' + ParentColor = False end object Label2: TLabel Left = 16 + Height = 15 Top = 102 - Width = 62 - Height = 13 + Width = 67 Caption = 'Suggestions:' + ParentColor = False end object lblNoSuggestions: TLabel - Left = 179 + AnchorSideRight.Control = edNewWord + AnchorSideRight.Side = asrBottom + Left = 166 + Height = 15 Top = 101 - Width = 93 - Height = 13 + Width = 104 + Anchors = [akTop, akRight] Caption = '(nothing to display)' + ParentColor = False Visible = False end object Label3: TLabel Left = 16 + Height = 15 Top = 56 - Width = 65 - Height = 13 + Width = 70 Caption = 'Replace with:' + ParentColor = False end object edNewWord: TEdit Left = 16 + Height = 23 Top = 72 Width = 254 - Height = 21 - Anchors = [akLeft, akTop, akRight] + Anchors = [akTop, akLeft, akRight] TabOrder = 1 end object lbSuggestions: TListBox Left = 16 + Height = 82 Top = 120 Width = 254 - Height = 82 - Anchors = [akLeft, akTop, akRight, akBottom] - ItemHeight = 13 - TabOrder = 2 + Anchors = [akTop, akLeft, akRight, akBottom] + ItemHeight = 0 OnClick = lbSuggestionsClick + TabOrder = 2 end object btnIgnore: TButton Left = 294 + Height = 25 Top = 32 Width = 75 - Height = 25 Action = acIgnore Anchors = [akTop, akRight] TabOrder = 3 end object btnIgnoreAll: TButton Left = 294 + Height = 25 Top = 61 Width = 75 - Height = 25 Action = acIgnoreAll Anchors = [akTop, akRight] TabOrder = 4 end object btnChange: TButton Left = 294 + Height = 25 Top = 120 Width = 75 - Height = 25 Action = acChange Anchors = [akTop, akRight] TabOrder = 5 end object btnClose: TButton Left = 294 - Top = 286 - Width = 75 Height = 25 + Top = 289 + Width = 75 Action = acClose Anchors = [akRight, akBottom] Cancel = True @@ -106,68 +109,78 @@ end object btnAdd: TButton Left = 294 + Height = 25 Top = 149 Width = 75 - Height = 25 Action = acAdd Anchors = [akTop, akRight] TabOrder = 6 end object GroupBox1: TGroupBox Left = 16 - Top = 209 - Width = 257 Height = 105 + Top = 209 + Width = 254 Anchors = [akLeft, akRight, akBottom] Caption = ' Ignore: ' + ClientHeight = 85 + ClientWidth = 250 TabOrder = 7 object chkUpperCase: TCheckBox + AnchorSideTop.Control = GroupBox1 Left = 24 - Top = 23 - Width = 207 - Height = 17 + Height = 19 + Top = 4 + Width = 118 + BorderSpacing.Top = 4 Caption = '&UPPERCASE words' TabOrder = 0 end object chkNumber: TCheckBox + AnchorSideTop.Control = chkUpperCase + AnchorSideTop.Side = asrBottom Left = 24 - Top = 39 - Width = 207 - Height = 17 + Height = 19 + Top = 23 + Width = 130 Caption = 'Words with &numbers' TabOrder = 1 end object chkURL: TCheckBox + AnchorSideTop.Control = chkNumber + AnchorSideTop.Side = asrBottom Left = 24 - Top = 55 - Width = 207 - Height = 17 + Height = 19 + Top = 42 + Width = 135 Caption = 'Internet and file &paths' TabOrder = 2 end object chkHTML: TCheckBox + AnchorSideTop.Control = chkURL + AnchorSideTop.Side = asrBottom Left = 24 - Top = 71 - Width = 207 - Height = 17 + Height = 19 + Top = 61 + Width = 82 Caption = 'HT&ML code' TabOrder = 3 end end object edBadWord: TEdit Left = 16 + Height = 23 Top = 32 Width = 254 - Height = 21 - Anchors = [akLeft, akTop, akRight] + Anchors = [akTop, akLeft, akRight] Color = clBtnFace ReadOnly = True TabOrder = 0 end object alSpell: TActionList OnUpdate = alSpellUpdate - Left = 296 - Top = 224 + left = 296 + top = 224 object acIgnore: TAction Caption = '&Ignore' OnExecute = acIgnoreExecute @@ -186,8 +199,8 @@ end object acClose: TAction Caption = '&Close' - ShortCut = 27 OnExecute = acCloseExecute + ShortCut = 27 end end end diff --git a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.pas b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.pas index c11c927e8..5824f3c2c 100644 --- a/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.pas +++ b/components/jvcllaz/examples/JvSpellChecker/JvSpellCheckerForm.pas @@ -29,10 +29,10 @@ unit JvSpellCheckerForm; interface {$mode objfpc}{$H+} -//{$I jvcl.inc} uses - Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + LCLIntf, LMessages, + SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, JvSpellChecker, ActnList; type @@ -94,6 +94,7 @@ type ASpellChecker: TJvSpellChecker; FOnReplaceText: TJvReplaceTextEvent; FOnSelectText: TJvSelectTextEvent; + procedure AsyncClose(Data: PtrInt); procedure CloseAndReport(ReportSuccess: boolean); function GetNextWord: boolean; procedure DoReplaceText(Sender: TObject; StartIndex, ALength: integer; const NewText: string); @@ -116,6 +117,11 @@ implementation {$R *.lfm} +procedure TfrmSpellChecker.AsyncClose(Data: PtrInt); +begin + Close; +end; + procedure TfrmSpellChecker.FormCreate(Sender: TObject); var S:string; begin @@ -256,7 +262,8 @@ begin S := 'There is nothing to spell check'; ShowMessage(S); // delay since we might have been called from the OnShow event (can't close in OnShow) - PostMessage(Handle, WM_CLOSE, 0, 0); + Application.QueueAsyncCall(@AsyncClose, 0); +// PostMessage(Handle, LM_CLOSE, 0, 0); end; procedure TfrmSpellChecker.acIgnoreExecute(Sender: TObject); diff --git a/components/jvcllaz/examples/JvSpellChecker/MainFrm.pas b/components/jvcllaz/examples/JvSpellChecker/MainFrm.pas index 8d650e5a3..4073c9175 100644 --- a/components/jvcllaz/examples/JvSpellChecker/MainFrm.pas +++ b/components/jvcllaz/examples/JvSpellChecker/MainFrm.pas @@ -26,11 +26,13 @@ unit MainFrm; +{$mode objfpc}{$H+} + interface uses - Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, - Dialogs, StdCtrls, Menus, ComCtrls, JvComponent; + SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, Menus, ComCtrls; type TfrmMain = class(TForm) @@ -68,7 +70,9 @@ type var frmMain: TfrmMain; + implementation + uses JvSpellCheckerForm; diff --git a/components/jvcllaz/run/JvCmp/JvSpellChecker.pas b/components/jvcllaz/run/JvCmp/JvSpellChecker.pas index 1d20e07ba..d15495aa2 100644 --- a/components/jvcllaz/run/JvCmp/JvSpellChecker.pas +++ b/components/jvcllaz/run/JvCmp/JvSpellChecker.pas @@ -30,14 +30,12 @@ Known Issues: unit JvSpellChecker; {$mode objfpc}{$H+} -//{$I jvcl.inc} interface uses SysUtils, Classes, - Windows, Controls, Messages, - JvSpellIntf; //, JvComponentBase; + JvSpellIntf; type TJvSpellChecker = class(TComponent) //TJvComponent) @@ -69,20 +67,10 @@ type property OnCanIgnore: TJvSpellCheckIgnoreEvent read GetCanIgnore write SetCanIgnore; end; -{$IFDEF UNITVERSIONING} -const - UnitVersioning: TUnitVersionInfo = ( - RCSfile: '$URL$'; - Revision: '$Revision$'; - Date: '$Date$'; - LogPath: 'JVCL\run' - ); -{$ENDIF UNITVERSIONING} implementation uses -// JclStrings, // StrAddRef, StrDecRef JvTypes, JvResources; // NOTE: hash table and soundex lookup code originally from Julian Bucknall's diff --git a/components/jvcllaz/run/JvCmp/JvSpellIntf.pas b/components/jvcllaz/run/JvCmp/JvSpellIntf.pas index 0a23bb714..1fff7690f 100644 --- a/components/jvcllaz/run/JvCmp/JvSpellIntf.pas +++ b/components/jvcllaz/run/JvCmp/JvSpellIntf.pas @@ -30,7 +30,6 @@ Known Issues: unit JvSpellIntf; {$mode objfpc}{$H+} -//{$I jvcl.inc} interface @@ -100,25 +99,7 @@ type var CreateSpellChecker: function: IJvSpellChecker = nil; -{$IFDEF UNITVERSIONING} -const - UnitVersioning: TUnitVersionInfo = ( - RCSfile: '$URL$'; - Revision: '$Revision$'; - Date: '$Date$'; - LogPath: 'JVCL\run' - ); -{$ENDIF UNITVERSIONING} implementation - -{$IFDEF UNITVERSIONING} -initialization - RegisterUnitVersion(HInstance, UnitVersioning); - -finalization - UnregisterUnitVersion(HInstance); -{$ENDIF UNITVERSIONING} - end. diff --git a/components/jvcllaz/run/JvCmp/JvSpellerForm.lfm b/components/jvcllaz/run/JvCmp/JvSpellerForm.lfm index db23b916f..b48073e40 100644 --- a/components/jvcllaz/run/JvCmp/JvSpellerForm.lfm +++ b/components/jvcllaz/run/JvCmp/JvSpellerForm.lfm @@ -1,64 +1,69 @@ -object JvSpellerForm: TJvSpellerForm +object JvSpellerForm: TJvSpellerForm Left = 306 + Height = 153 Top = 251 + Width = 371 BorderStyle = bsDialog Caption = 'Spelling checker' ClientHeight = 153 ClientWidth = 371 Color = clBtnFace - Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText - Font.Height = -11 - Font.Name = 'MS Sans Serif' - Font.Style = [] - OldCreateOrder = False - PixelsPerInch = 96 - TextHeight = 13 + LCLVersion = '1.9.0.0' object LblContext: TLabel - Left = 0 - Top = 33 - Width = 371 + Left = 8 Height = 86 Hint = 'look ahead box' + Top = 33 + Width = 355 Align = alClient + BorderSpacing.Left = 8 + BorderSpacing.Right = 8 Caption = 'LblContext' + ParentColor = False ParentShowHint = False ShowHint = True WordWrap = True end object TextPanel: TPanel Left = 0 + Height = 33 Top = 0 Width = 371 - Height = 33 Align = alTop BevelInner = bvRaised BevelOuter = bvLowered + ClientHeight = 33 + ClientWidth = 371 + Font.Color = clWindowText + ParentFont = False TabOrder = 0 object TxtSpell: TEdit - Left = 7 + Left = 8 + Height = 23 Top = 7 Width = 293 - Height = 21 TabOrder = 0 Text = 'TxtSpell' end end object ButtonPanel: TPanel Left = 0 + Height = 34 Top = 119 Width = 371 - Height = 34 Align = alBottom BevelInner = bvRaised BevelOuter = bvLowered + ClientHeight = 34 + ClientWidth = 371 TabOrder = 1 object BtnSkip: TButton Left = 13 - Top = 7 - Width = 61 Height = 20 Hint = 'Skip this word' + Top = 7 + Width = 61 Caption = '&Skip' ParentShowHint = False ShowHint = True @@ -66,10 +71,10 @@ end object BtnChange: TButton Left = 228 - Top = 7 - Width = 60 Height = 20 Hint = 'Change to corrected word' + Top = 7 + Width = 60 Caption = '&Change' ParentShowHint = False ShowHint = True @@ -77,10 +82,10 @@ end object BtnCancel: TButton Left = 299 - Top = 7 - Width = 61 Height = 20 Hint = 'Abort all changes' + Top = 7 + Width = 61 Caption = 'Cancel' ModalResult = 2 ParentShowHint = False @@ -89,10 +94,10 @@ end object BtnAdd: TButton Left = 156 - Top = 7 - Width = 61 Height = 20 Hint = 'Add to user Dictionary' + Top = 7 + Width = 61 Caption = '&Add' ParentShowHint = False ShowHint = True @@ -100,10 +105,10 @@ end object BtnSkipAll: TButton Left = 85 - Top = 7 - Width = 60 Height = 20 Hint = 'Skip all, update and finish' + Top = 7 + Width = 60 Caption = 'S&kip All' ModalResult = 1 ParentShowHint = False diff --git a/components/jvcllaz/run/JvCmp/JvSpellerForm.pas b/components/jvcllaz/run/JvCmp/JvSpellerForm.pas index 1f4cb574e..b96c8a668 100644 --- a/components/jvcllaz/run/JvCmp/JvSpellerForm.pas +++ b/components/jvcllaz/run/JvCmp/JvSpellerForm.pas @@ -26,14 +26,11 @@ Known Issues: unit JvSpellerForm; {$mode objfpc}{$H+} -//{$I jvcl.inc} interface uses - SysUtils, Classes, Windows, Messages, Graphics, Controls, Forms, Dialogs, - StdCtrls, ExtCtrls, - JvComponent; + SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TJvSpeller = class; @@ -89,23 +86,11 @@ type property UserDictionary: TFileName read FUserDictionary write SetUserDictionary; end; -{$IFDEF UNITVERSIONING} -const - UnitVersioning: TUnitVersionInfo = ( - RCSfile: '$URL$'; - Revision: '$Revision$'; - Date: '$Date$'; - LogPath: 'JVCL\run' - ); -{$ENDIF UNITVERSIONING} implementation uses StrUtils, - {$IFNDEF COMPILER12_UP} - JvJCLUtils, - {$ENDIF ~COMPILER12_UP} JvConsts, JvResources, JvTypes; {$R *.lfm}