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:
parent
12a03ba23c
commit
bdedb40277
@ -19,7 +19,7 @@ uses
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents(RsPaletteJvcl, [
|
||||
RegisterComponents(RsPaletteJvclNonVisual, [
|
||||
TJvHtmlParser, TJvFormToHtml, TJvStringListToHtml, TJvStrToHtml
|
||||
]);
|
||||
end;
|
||||
|
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.
|
||||
|
@ -37,6 +37,7 @@ type
|
||||
TJvFormToHtml = class(TComponent) //TJvComponent)
|
||||
public
|
||||
procedure FormToHtml(const Form: TCustomForm; const Filename: string);
|
||||
procedure FormToHtml(const Form: TCustomForm; HTML: TStrings);
|
||||
end;
|
||||
|
||||
|
||||
@ -54,206 +55,215 @@ end;
|
||||
|
||||
procedure TJvFormToHtml.FormToHtml(const Form: TCustomForm; const Filename: string);
|
||||
var
|
||||
I, J: Integer;
|
||||
C: TComponent;
|
||||
S, S2, St: string;
|
||||
HTML: TStringList;
|
||||
begin
|
||||
HTML := TStringList.Create;
|
||||
try
|
||||
HTML.Add('<HTML><BODY>');
|
||||
for I := 0 to Form.ComponentCount - 1 do
|
||||
begin
|
||||
C := Form.Components[I];
|
||||
St := '';
|
||||
if C is TLabel then
|
||||
begin
|
||||
St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TLabel(C).Left, TLabel(C).Top, TLabel(C).Height, TLabel(C).Width]) +
|
||||
FontToCss((C as TLabel).Font) + '"' +
|
||||
' TITLE="' + (C as TLabel).Hint + '"' +
|
||||
' NAME=' + (C as TLabel).Name +
|
||||
'>' +
|
||||
TLabel(C).Caption + '</LABEL>';
|
||||
end
|
||||
else
|
||||
if C is TButton then
|
||||
begin
|
||||
if not TButton(C).Enabled then
|
||||
S := ' DISABLED'
|
||||
else
|
||||
S := '';
|
||||
|
||||
St := Format('<BUTTON style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TButton(C).Left, TButton(C).Top, TButton(C).Height, TButton(C).Width]) +
|
||||
FontToCss(TButton(C).Font) + '"' +
|
||||
' TITLE="' + TButton(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TButton(C).TabOrder) +
|
||||
' NAME=' + TButton(C).Name +
|
||||
S +
|
||||
'>' +
|
||||
TButton(C).Caption + '</BUTTON>';
|
||||
end
|
||||
else
|
||||
if C is TMemo then
|
||||
begin
|
||||
S := '';
|
||||
if TMemo(C).ReadOnly then
|
||||
S := S + ' ReadOnly';
|
||||
if not TMemo(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
|
||||
S2 := '';
|
||||
if TMemo(C).WordWrap then
|
||||
S2 := S2 + ' WRAP=PHYSICAL'
|
||||
else
|
||||
S2 := S2 + ' WRAP=OFF';
|
||||
|
||||
St := Format('<TEXTAREA style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TMemo(C).Left, TMemo(C).Top, TMemo(C).Height, TMemo(C).Width]) +
|
||||
FontToCss(TMemo(C).Font) + '"' +
|
||||
' TITLE="' + TMemo(C).Hint + '"' +
|
||||
S +
|
||||
' NAME=' + TMemo(C).Name +
|
||||
' TABORDER=' + IntToStr(TMemo(C).TabOrder) +
|
||||
S2 +
|
||||
'>' +
|
||||
TMemo(C).Text + '</TEXTAREA>';
|
||||
end
|
||||
else
|
||||
if C is TCheckBox then
|
||||
begin
|
||||
S := '';
|
||||
if not TCheckBox(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
if TCheckBox(C).Checked then
|
||||
S := S + ' CHECKED';
|
||||
|
||||
St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TCheckBox(C).Left, TCheckBox(C).Top, TCheckBox(C).Height, 10]) +
|
||||
FontToCss(TCheckBox(C).Font) + '"' +
|
||||
' TITLE="' + TCheckBox(C).Hint + '"' +
|
||||
S +
|
||||
' TABORDER=' + IntToStr(TCheckBox(C).TabOrder) +
|
||||
' NAME=' + TCheckBox(C).Name +
|
||||
' TYPE="CHECKBOX">';
|
||||
HTML.Add(St);
|
||||
St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TCheckBox(C).Left + 13, TCheckBox(C).Top, TCheckBox(C).Height, TCheckBox(C).Width]) +
|
||||
FontToCss(TCheckBox(C).Font) + '"' +
|
||||
' TITLE="' + TCheckBox(C).Hint + '"' +
|
||||
'>' +
|
||||
TCheckBox(C).Caption + '</LABEL>';
|
||||
end
|
||||
else
|
||||
if C is TRadioButton then
|
||||
begin
|
||||
S := '';
|
||||
if not TRadioButton(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
if TRadioButton(C).Checked then
|
||||
S := S + ' CHECKED';
|
||||
|
||||
St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TRadioButton(C).Left, TRadioButton(C).Top, TRadioButton(C).Height, 10]) +
|
||||
FontToCss(TRadioButton(C).Font) + '"' +
|
||||
' TITLE="' + TRadioButton(C).Hint + '"' +
|
||||
S +
|
||||
' NAME=' + TRadioButton(C).Parent.Name +
|
||||
' TABORDER=' + IntToStr(TRadioButton(C).TabOrder) +
|
||||
' TYPE="RADIO">';
|
||||
HTML.Add(St);
|
||||
St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TRadioButton(C).Left + 13, TRadioButton(C).Top,
|
||||
TRadioButton(C).Height, TRadioButton(C).Width]) +
|
||||
FontToCss(TRadioButton(C).Font) + '"' +
|
||||
' TITLE="' + TRadioButton(C).Hint + '"' +
|
||||
'>' +
|
||||
TRadioButton(C).Caption + '</LABEL>';
|
||||
end
|
||||
else
|
||||
if C is TEdit then
|
||||
begin
|
||||
S := '';
|
||||
if TEdit(C).ReadOnly then
|
||||
S := S + ' ReadOnly';
|
||||
if TEdit(C).MaxLength <> 0 then
|
||||
S := S + ' MAXLENGTH=' + IntToStr(TEdit(C).MaxLength);
|
||||
if not TEdit(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
|
||||
St := Format('<INPUT TYPE="TEXT" style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TEdit(C).Left, TEdit(C).Top, TEdit(C).Height, TEdit(C).Width]) +
|
||||
FontToCss(TEdit(C).Font) + '"' +
|
||||
' TITLE="' + TEdit(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TEdit(C).TabOrder) +
|
||||
' NAME=' + TEdit(C).Name +
|
||||
S +
|
||||
' Value=' + TEdit(C).Text +
|
||||
'>';
|
||||
end
|
||||
else
|
||||
if C is TComboBox then
|
||||
begin
|
||||
if not TComboBox(C).Enabled then
|
||||
S := ' DISABLED'
|
||||
else
|
||||
S := '';
|
||||
|
||||
St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TComboBox(C).Left, TComboBox(C).Top, TComboBox(C).Height, TComboBox(C).Width]) +
|
||||
FontToCss(TComboBox(C).Font) + '"' +
|
||||
' TITLE="' + TComboBox(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TComboBox(C).TabOrder) +
|
||||
' NAME=' + TComboBox(C).Name +
|
||||
S +
|
||||
'>';
|
||||
HTML.Add(St);
|
||||
for J := 0 to TComboBox(C).Items.Count - 1 do
|
||||
begin
|
||||
if TComboBox(C).ItemIndex = J then
|
||||
HTML.Add('<OPTION SELECTED>' + TComboBox(C).Items[J])
|
||||
else
|
||||
HTML.Add('<OPTION>' + TComboBox(C).Items[J]);
|
||||
end;
|
||||
St := '</SELECT>';
|
||||
end
|
||||
else
|
||||
if C is TListBox then
|
||||
begin
|
||||
if not TListBox(C).Enabled then
|
||||
S := ' DISABLED'
|
||||
else
|
||||
S := '';
|
||||
|
||||
St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TListBox(C).Left, TListBox(C).Top, TListBox(C).Height, TListBox(C).Width]) +
|
||||
FontToCss(TListBox(C).Font) + '"' +
|
||||
' MULTIPLE TITLE="' + TListBox(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TListBox(C).TabOrder) +
|
||||
' NAME=' + TListBox(C).Name +
|
||||
S +
|
||||
'>';
|
||||
HTML.Add(St);
|
||||
for J := 0 to TListBox(C).Items.Count - 1 do
|
||||
begin
|
||||
if TListBox(C).ItemIndex = J then
|
||||
HTML.Add('<OPTION SELECTED>' + TListBox(C).Items[J])
|
||||
else
|
||||
HTML.Add('<OPTION>' + TListBox(C).Items[J]);
|
||||
end;
|
||||
St := '</SELECT>';
|
||||
end;
|
||||
|
||||
if St <> '' then
|
||||
HTML.Add(St);
|
||||
end;
|
||||
HTML.Add('</BODY></HTML>');
|
||||
|
||||
HTML.SaveToFile(Filename);
|
||||
FormToHTML(Form, HTML);
|
||||
HTML.SaveToFile(FileName);
|
||||
finally
|
||||
HTML.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TJvFormToHtml.FormToHtml(const Form: TCustomForm;
|
||||
HTML: TStrings);
|
||||
var
|
||||
I, J: Integer;
|
||||
C: TComponent;
|
||||
S, S2, St: string;
|
||||
begin
|
||||
if HTML = nil then
|
||||
exit;
|
||||
|
||||
HTML.Add('<HTML><BODY>');
|
||||
for I := 0 to Form.ComponentCount - 1 do
|
||||
begin
|
||||
C := Form.Components[I];
|
||||
St := '';
|
||||
if C is TLabel then
|
||||
begin
|
||||
St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TLabel(C).Left, TLabel(C).Top, TLabel(C).Height, TLabel(C).Width]) +
|
||||
FontToCss((C as TLabel).Font) + '"' +
|
||||
' TITLE="' + (C as TLabel).Hint + '"' +
|
||||
' NAME=' + (C as TLabel).Name +
|
||||
'>' +
|
||||
TLabel(C).Caption + '</LABEL>';
|
||||
end
|
||||
else
|
||||
if C is TButton then
|
||||
begin
|
||||
if not TButton(C).Enabled then
|
||||
S := ' DISABLED'
|
||||
else
|
||||
S := '';
|
||||
|
||||
St := Format('<BUTTON style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TButton(C).Left, TButton(C).Top, TButton(C).Height, TButton(C).Width]) +
|
||||
FontToCss(TButton(C).Font) + '"' +
|
||||
' TITLE="' + TButton(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TButton(C).TabOrder) +
|
||||
' NAME=' + TButton(C).Name +
|
||||
S +
|
||||
'>' +
|
||||
TButton(C).Caption + '</BUTTON>';
|
||||
end
|
||||
else
|
||||
if C is TMemo then
|
||||
begin
|
||||
S := '';
|
||||
if TMemo(C).ReadOnly then
|
||||
S := S + ' ReadOnly';
|
||||
if not TMemo(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
|
||||
S2 := '';
|
||||
if TMemo(C).WordWrap then
|
||||
S2 := S2 + ' WRAP=PHYSICAL'
|
||||
else
|
||||
S2 := S2 + ' WRAP=OFF';
|
||||
|
||||
St := Format('<TEXTAREA style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TMemo(C).Left, TMemo(C).Top, TMemo(C).Height, TMemo(C).Width]) +
|
||||
FontToCss(TMemo(C).Font) + '"' +
|
||||
' TITLE="' + TMemo(C).Hint + '"' +
|
||||
S +
|
||||
' NAME=' + TMemo(C).Name +
|
||||
' TABORDER=' + IntToStr(TMemo(C).TabOrder) +
|
||||
S2 +
|
||||
'>' +
|
||||
TMemo(C).Text + '</TEXTAREA>';
|
||||
end
|
||||
else
|
||||
if C is TCheckBox then
|
||||
begin
|
||||
S := '';
|
||||
if not TCheckBox(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
if TCheckBox(C).Checked then
|
||||
S := S + ' CHECKED';
|
||||
|
||||
St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TCheckBox(C).Left, TCheckBox(C).Top, TCheckBox(C).Height, 10]) +
|
||||
FontToCss(TCheckBox(C).Font) + '"' +
|
||||
' TITLE="' + TCheckBox(C).Hint + '"' +
|
||||
S +
|
||||
' TABORDER=' + IntToStr(TCheckBox(C).TabOrder) +
|
||||
' NAME=' + TCheckBox(C).Name +
|
||||
' TYPE="CHECKBOX">';
|
||||
HTML.Add(St);
|
||||
St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TCheckBox(C).Left + 13, TCheckBox(C).Top, TCheckBox(C).Height, TCheckBox(C).Width]) +
|
||||
FontToCss(TCheckBox(C).Font) + '"' +
|
||||
' TITLE="' + TCheckBox(C).Hint + '"' +
|
||||
'>' +
|
||||
TCheckBox(C).Caption + '</LABEL>';
|
||||
end
|
||||
else
|
||||
if C is TRadioButton then
|
||||
begin
|
||||
S := '';
|
||||
if not TRadioButton(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
if TRadioButton(C).Checked then
|
||||
S := S + ' CHECKED';
|
||||
|
||||
St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TRadioButton(C).Left, TRadioButton(C).Top, TRadioButton(C).Height, 10]) +
|
||||
FontToCss(TRadioButton(C).Font) + '"' +
|
||||
' TITLE="' + TRadioButton(C).Hint + '"' +
|
||||
S +
|
||||
' NAME=' + TRadioButton(C).Parent.Name +
|
||||
' TABORDER=' + IntToStr(TRadioButton(C).TabOrder) +
|
||||
' TYPE="RADIO">';
|
||||
HTML.Add(St);
|
||||
St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TRadioButton(C).Left + 13, TRadioButton(C).Top,
|
||||
TRadioButton(C).Height, TRadioButton(C).Width]) +
|
||||
FontToCss(TRadioButton(C).Font) + '"' +
|
||||
' TITLE="' + TRadioButton(C).Hint + '"' +
|
||||
'>' +
|
||||
TRadioButton(C).Caption + '</LABEL>';
|
||||
end
|
||||
else
|
||||
if C is TEdit then
|
||||
begin
|
||||
S := '';
|
||||
if TEdit(C).ReadOnly then
|
||||
S := S + ' ReadOnly';
|
||||
if TEdit(C).MaxLength <> 0 then
|
||||
S := S + ' MAXLENGTH=' + IntToStr(TEdit(C).MaxLength);
|
||||
if not TEdit(C).Enabled then
|
||||
S := S + ' DISABLED';
|
||||
|
||||
St := Format('<INPUT TYPE="TEXT" style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TEdit(C).Left, TEdit(C).Top, TEdit(C).Height, TEdit(C).Width]) +
|
||||
FontToCss(TEdit(C).Font) + '"' +
|
||||
' TITLE="' + TEdit(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TEdit(C).TabOrder) +
|
||||
' NAME=' + TEdit(C).Name +
|
||||
S +
|
||||
' Value=' + TEdit(C).Text +
|
||||
'>';
|
||||
end
|
||||
else
|
||||
if C is TComboBox then
|
||||
begin
|
||||
if not TComboBox(C).Enabled then
|
||||
S := ' DISABLED'
|
||||
else
|
||||
S := '';
|
||||
|
||||
St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TComboBox(C).Left, TComboBox(C).Top, TComboBox(C).Height, TComboBox(C).Width]) +
|
||||
FontToCss(TComboBox(C).Font) + '"' +
|
||||
' TITLE="' + TComboBox(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TComboBox(C).TabOrder) +
|
||||
' NAME=' + TComboBox(C).Name +
|
||||
S +
|
||||
'>';
|
||||
HTML.Add(St);
|
||||
for J := 0 to TComboBox(C).Items.Count - 1 do
|
||||
begin
|
||||
if TComboBox(C).ItemIndex = J then
|
||||
HTML.Add('<OPTION SELECTED>' + TComboBox(C).Items[J])
|
||||
else
|
||||
HTML.Add('<OPTION>' + TComboBox(C).Items[J]);
|
||||
end;
|
||||
St := '</SELECT>';
|
||||
end
|
||||
else
|
||||
if C is TListBox then
|
||||
begin
|
||||
if not TListBox(C).Enabled then
|
||||
S := ' DISABLED'
|
||||
else
|
||||
S := '';
|
||||
|
||||
St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d',
|
||||
[TListBox(C).Left, TListBox(C).Top, TListBox(C).Height, TListBox(C).Width]) +
|
||||
FontToCss(TListBox(C).Font) + '"' +
|
||||
' MULTIPLE TITLE="' + TListBox(C).Hint + '"' +
|
||||
' TABORDER=' + IntToStr(TListBox(C).TabOrder) +
|
||||
' NAME=' + TListBox(C).Name +
|
||||
S +
|
||||
'>';
|
||||
HTML.Add(St);
|
||||
for J := 0 to TListBox(C).Items.Count - 1 do
|
||||
begin
|
||||
if TListBox(C).ItemIndex = J then
|
||||
HTML.Add('<OPTION SELECTED>' + TListBox(C).Items[J])
|
||||
else
|
||||
HTML.Add('<OPTION>' + TListBox(C).Items[J]);
|
||||
end;
|
||||
St := '</SELECT>';
|
||||
end;
|
||||
|
||||
if St <> '' then
|
||||
HTML.Add(St);
|
||||
end;
|
||||
HTML.Add('</BODY></HTML>');
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -130,12 +130,13 @@ end;
|
||||
|
||||
procedure TJvStringListToHtml.DoStringsChange(Sender: TObject);
|
||||
begin
|
||||
FreeAndNil(FHTML);
|
||||
FHTML.Clear; // wp: clear instead of Free
|
||||
// FreeAndNil(FHTML);
|
||||
end;
|
||||
|
||||
function TJvStringListToHtml.GetHTML: TStrings;
|
||||
begin
|
||||
if ComponentState * [csLoading, csDestroying] <> [] then
|
||||
// if ComponentState * [csLoading, csDestroying] <> [] then // wp: removed
|
||||
if FHTML.Count = 0 then
|
||||
ConvertToHTMLStrings(Strings, FHTML);
|
||||
Result := FHTML;
|
||||
|
@ -320,12 +320,8 @@ const
|
||||
var
|
||||
ConversionsHash: array of Word;
|
||||
|
||||
{$IFNDEF UNICODE}
|
||||
const
|
||||
MB_ERR_INVALID_CHARS = 8;
|
||||
{$ENDIF ~UNICODE}
|
||||
|
||||
{ TJvStrToHtml }
|
||||
{ TJvStrToHtml }
|
||||
|
||||
constructor TJvStrToHtml.Create(AOwner: TComponent);
|
||||
begin
|
||||
@ -478,6 +474,7 @@ begin
|
||||
if not found then begin
|
||||
Delete(html, Length(html), 1);
|
||||
Delete(html, 1, 1);
|
||||
if html[1] = '#' then Delete(html, 1, 1);
|
||||
if html[1] = 'x' then html[1] := '$';
|
||||
Append(UnicodeToUTF8(StrToInt(html)));
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user