You've already forked lazarus-ccr
jvcllaz: Add html test demo for JvNet packages. Fix some bugs in html conversion routines.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6948 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
93
components/jvcllaz/examples/JvHTML/JvHTMLTest.lpi
Normal file
93
components/jvcllaz/examples/JvHTML/JvHTMLTest.lpi
Normal file
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="JvHTMLTest"/>
|
||||
<Scaled Value="True"/>
|
||||
<ResourceType Value="res"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<XPManifest>
|
||||
<DpiAware Value="True"/>
|
||||
</XPManifest>
|
||||
<Icon Value="0"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
<Modes Count="0"/>
|
||||
</RunParams>
|
||||
<RequiredPackages Count="3">
|
||||
<Item1>
|
||||
<PackageName Value="SynEdit"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="JvNetLazR"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<PackageName Value="LCL"/>
|
||||
</Item3>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="JvHTMLTest.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="htmltestform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="MainForm"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="HTMLTestForm"/>
|
||||
</Unit>
|
||||
<Unit>
|
||||
<Filename Value="demoform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form2"/>
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="DemoForm"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="..\..\bin\JvHTMLTest"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Options>
|
||||
<Win32>
|
||||
<GraphicApplication Value="True"/>
|
||||
</Win32>
|
||||
</Options>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
22
components/jvcllaz/examples/JvHTML/JvHTMLTest.lpr
Normal file
22
components/jvcllaz/examples/JvHTML/JvHTMLTest.lpr
Normal file
@ -0,0 +1,22 @@
|
||||
program JvHTMLTest;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}{$IFDEF UseCThreads}
|
||||
cthreads,
|
||||
{$ENDIF}{$ENDIF}
|
||||
Interfaces, // this includes the LCL widgetset
|
||||
Forms, HTMLTestForm, DemoForm
|
||||
{ you can add units after this };
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
RequireDerivedFormResource:=True;
|
||||
Application.Scaled:=True;
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TMainForm, MainForm);
|
||||
Application.Run;
|
||||
end.
|
||||
|
205
components/jvcllaz/examples/JvHTML/demoform.lfm
Normal file
205
components/jvcllaz/examples/JvHTML/demoform.lfm
Normal file
@ -0,0 +1,205 @@
|
||||
object Form2: TForm2
|
||||
Left = 445
|
||||
Height = 386
|
||||
Top = 170
|
||||
Width = 487
|
||||
Caption = 'Find'
|
||||
ClientHeight = 386
|
||||
ClientWidth = 487
|
||||
LCLVersion = '2.1.0.0'
|
||||
object lblTextToFind: TLabel
|
||||
Left = 24
|
||||
Height = 15
|
||||
Top = 16
|
||||
Width = 59
|
||||
Caption = 'Text to find'
|
||||
ParentColor = False
|
||||
end
|
||||
object edName: TEdit
|
||||
Left = 128
|
||||
Height = 23
|
||||
Top = 11
|
||||
Width = 337
|
||||
TabOrder = 0
|
||||
Text = 'object'
|
||||
end
|
||||
object btnFind: TButton
|
||||
Left = 264
|
||||
Height = 25
|
||||
Top = 344
|
||||
Width = 75
|
||||
Caption = 'Find'
|
||||
ModalResult = 1
|
||||
TabOrder = 8
|
||||
end
|
||||
object btnCancel: TButton
|
||||
Left = 390
|
||||
Height = 25
|
||||
Top = 344
|
||||
Width = 75
|
||||
Caption = 'Cancel'
|
||||
ModalResult = 2
|
||||
TabOrder = 9
|
||||
end
|
||||
object cmbReplaceWidth: TComboBox
|
||||
Left = 128
|
||||
Height = 23
|
||||
Top = 46
|
||||
Width = 337
|
||||
ItemHeight = 15
|
||||
TabOrder = 2
|
||||
Text = 'class'
|
||||
end
|
||||
object btnHelp: TButton
|
||||
Left = 16
|
||||
Height = 25
|
||||
Top = 344
|
||||
Width = 75
|
||||
Caption = 'Help'
|
||||
ModalResult = 6
|
||||
TabOrder = 7
|
||||
end
|
||||
object cbReplaceWith: TCheckBox
|
||||
Left = 24
|
||||
Height = 19
|
||||
Top = 48
|
||||
Width = 87
|
||||
Caption = 'Replace with'
|
||||
TabOrder = 1
|
||||
end
|
||||
object gbOptions: TGroupBox
|
||||
Left = 24
|
||||
Height = 231
|
||||
Top = 89
|
||||
Width = 232
|
||||
Caption = 'Options'
|
||||
ClientHeight = 211
|
||||
ClientWidth = 228
|
||||
TabOrder = 3
|
||||
object cbCaseSensitive: TCheckBox
|
||||
Left = 18
|
||||
Height = 19
|
||||
Top = 8
|
||||
Width = 93
|
||||
Caption = 'Case sensitive'
|
||||
TabOrder = 0
|
||||
end
|
||||
object cbWholeWordsOnly: TCheckBox
|
||||
Left = 18
|
||||
Height = 19
|
||||
Top = 36
|
||||
Width = 115
|
||||
Caption = 'Whole words only'
|
||||
TabOrder = 1
|
||||
end
|
||||
object cbRegularExpressions: TCheckBox
|
||||
Left = 18
|
||||
Height = 19
|
||||
Top = 64
|
||||
Width = 123
|
||||
Caption = 'Regular expressions'
|
||||
TabOrder = 2
|
||||
end
|
||||
object cbMultilinePattern: TCheckBox
|
||||
Left = 18
|
||||
Height = 19
|
||||
Top = 96
|
||||
Width = 108
|
||||
Caption = 'Multiline pattern'
|
||||
TabOrder = 3
|
||||
end
|
||||
object cbPromptOnReplace: TCheckBox
|
||||
Left = 18
|
||||
Height = 19
|
||||
Top = 128
|
||||
Width = 118
|
||||
Caption = 'Prompt on replace'
|
||||
Enabled = False
|
||||
TabOrder = 4
|
||||
end
|
||||
end
|
||||
object gbOrigin: TGroupBox
|
||||
Left = 280
|
||||
Height = 71
|
||||
Top = 89
|
||||
Width = 185
|
||||
Caption = 'Origin'
|
||||
ClientHeight = 51
|
||||
ClientWidth = 181
|
||||
TabOrder = 4
|
||||
object rbFromCursor: TRadioButton
|
||||
Left = 16
|
||||
Height = 19
|
||||
Top = 0
|
||||
Width = 84
|
||||
Caption = 'From cursor'
|
||||
Checked = True
|
||||
TabOrder = 0
|
||||
TabStop = True
|
||||
end
|
||||
object rbFromBeginning: TRadioButton
|
||||
Left = 16
|
||||
Height = 19
|
||||
Top = 24
|
||||
Width = 105
|
||||
Caption = 'From beginning'
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object gbSearchScope: TGroupBox
|
||||
Left = 280
|
||||
Height = 72
|
||||
Top = 168
|
||||
Width = 185
|
||||
Caption = 'Search scope'
|
||||
ClientHeight = 52
|
||||
ClientWidth = 181
|
||||
TabOrder = 5
|
||||
object rbSelectedText: TRadioButton
|
||||
Left = 16
|
||||
Height = 19
|
||||
Top = 1
|
||||
Width = 86
|
||||
Caption = 'Selected text'
|
||||
Checked = True
|
||||
TabOrder = 0
|
||||
TabStop = True
|
||||
end
|
||||
object rbGlobal: TRadioButton
|
||||
Left = 16
|
||||
Height = 19
|
||||
Top = 24
|
||||
Width = 54
|
||||
Caption = 'Global'
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
object gbDirection: TGroupBox
|
||||
Left = 280
|
||||
Height = 72
|
||||
Top = 248
|
||||
Width = 185
|
||||
Caption = 'Direction'
|
||||
ClientHeight = 52
|
||||
ClientWidth = 181
|
||||
TabOrder = 6
|
||||
object rbBackwardSearch: TRadioButton
|
||||
Left = 16
|
||||
Height = 19
|
||||
Top = 0
|
||||
Width = 108
|
||||
Caption = 'Backward search'
|
||||
Checked = True
|
||||
TabOrder = 0
|
||||
TabStop = True
|
||||
end
|
||||
object rbForwardSearch: TRadioButton
|
||||
Left = 16
|
||||
Height = 19
|
||||
Top = 24
|
||||
Width = 100
|
||||
Caption = 'Forward search'
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
end
|
51
components/jvcllaz/examples/JvHTML/demoform.pas
Normal file
51
components/jvcllaz/examples/JvHTML/demoform.pas
Normal file
@ -0,0 +1,51 @@
|
||||
unit DemoForm;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;
|
||||
|
||||
type
|
||||
|
||||
{ TForm2 }
|
||||
|
||||
TForm2 = class(TForm)
|
||||
btnFind: TButton;
|
||||
btnCancel: TButton;
|
||||
btnHelp: TButton;
|
||||
cbReplaceWith: TCheckBox;
|
||||
cbCaseSensitive: TCheckBox;
|
||||
cbWholeWordsOnly: TCheckBox;
|
||||
cbRegularExpressions: TCheckBox;
|
||||
cbMultilinePattern: TCheckBox;
|
||||
cbPromptOnReplace: TCheckBox;
|
||||
cmbReplaceWidth: TComboBox;
|
||||
edName: TEdit;
|
||||
gbOptions: TGroupBox;
|
||||
gbOrigin: TGroupBox;
|
||||
gbSearchScope: TGroupBox;
|
||||
gbDirection: TGroupBox;
|
||||
lblTextToFind: TLabel;
|
||||
rbFromCursor: TRadioButton;
|
||||
rbFromBeginning: TRadioButton;
|
||||
rbSelectedText: TRadioButton;
|
||||
rbGlobal: TRadioButton;
|
||||
rbBackwardSearch: TRadioButton;
|
||||
rbForwardSearch: TRadioButton;
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
Form2: TForm2;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
end.
|
||||
|
1221
components/jvcllaz/examples/JvHTML/htmltestform.lfm
Normal file
1221
components/jvcllaz/examples/JvHTML/htmltestform.lfm
Normal file
File diff suppressed because it is too large
Load Diff
111
components/jvcllaz/examples/JvHTML/htmltestform.pas
Normal file
111
components/jvcllaz/examples/JvHTML/htmltestform.pas
Normal file
@ -0,0 +1,111 @@
|
||||
unit HTMLTestForm;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
|
||||
ExtCtrls, SynEdit, SynHighlighterHTML, JvStringListToHtml, JvStrToHtml,
|
||||
JvFormToHtml;
|
||||
|
||||
type
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
TMainForm = class(TForm)
|
||||
Button1: TButton;
|
||||
cbIncludeHeader: TCheckBox;
|
||||
edHTMLTitle: TEdit;
|
||||
edTextOut: TEdit;
|
||||
edTextIn: TEdit;
|
||||
edHTML: TEdit;
|
||||
JvFormToHtml1: TJvFormToHtml;
|
||||
JvStringListToHtml1: TJvStringListToHtml;
|
||||
lblHTMLTitle: TLabel;
|
||||
lblTextIn: TLabel;
|
||||
lblTextAsHTML: TLabel;
|
||||
lblTextOut: TLabel;
|
||||
Memo: TMemo;
|
||||
PageControl: TPageControl;
|
||||
Splitter1: TSplitter;
|
||||
FormSynEdit: TSynEdit;
|
||||
StringsSynEdit: TSynEdit;
|
||||
SynHTMLSyn: TSynHTMLSyn;
|
||||
pgFormToHTML: TTabSheet;
|
||||
pgStringToHTML: TTabSheet;
|
||||
pgStringsToHTML: TTabSheet;
|
||||
procedure Button1Click(Sender: TObject);
|
||||
procedure cbIncludeHeaderChange(Sender: TObject);
|
||||
procedure edHTMLTitleChange(Sender: TObject);
|
||||
procedure edTextInChange(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure MemoChange(Sender: TObject);
|
||||
procedure Splitter1Moved(Sender: TObject);
|
||||
private
|
||||
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
MainForm: TMainForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
uses
|
||||
DemoForm;
|
||||
|
||||
{ TMainForm }
|
||||
|
||||
procedure TMainForm.Button1Click(Sender: TObject);
|
||||
var
|
||||
F: TForm2;
|
||||
begin
|
||||
F := TForm2.Create(nil);
|
||||
try
|
||||
JvFormToHtml1.FormToHtml(F, FormSynEdit.Lines);
|
||||
F.ShowModal;
|
||||
finally
|
||||
F.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.cbIncludeHeaderChange(Sender: TObject);
|
||||
begin
|
||||
JvStringListToHTML1.IncludeHeader := cbIncludeHeader.Checked;
|
||||
MemoChange(nil);
|
||||
end;
|
||||
|
||||
procedure TMainForm.edHTMLTitleChange(Sender: TObject);
|
||||
begin
|
||||
MemoChange(nil);
|
||||
end;
|
||||
|
||||
procedure TMainForm.edTextInChange(Sender: TObject);
|
||||
begin
|
||||
edHTML.Text := StringToHTML(edTextIn.Text);
|
||||
edTextOut.Text := HTMLToString(edHTML.Text);
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
begin
|
||||
edTextInChange(nil);
|
||||
MemoChange(nil);
|
||||
end;
|
||||
|
||||
procedure TMainForm.MemoChange(Sender: TObject);
|
||||
begin
|
||||
StringsSynEdit.Lines.Clear;
|
||||
JvStringListToHTML1.ConvertToHTMLStrings(Memo.Lines, StringsSynEdit.Lines);
|
||||
end;
|
||||
|
||||
procedure TMainForm.Splitter1Moved(Sender: TObject);
|
||||
begin
|
||||
MemoChange(nil);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user