All Projects → jackdp → DzHTMLText2

jackdp / DzHTMLText2

Licence: MIT License
A HTML Label component for Delphi and Lazarus.

Programming Languages

pascal
1382 projects
PHP
23972 projects - #3 most used programming language
Batchfile
5799 projects

Projects that are alternatives of or similar to DzHTMLText2

JPPack
A collection of VCL/LCL components for Delphi/Lazarus - buttons, panels, LinkLabel, ProgressBar, ColorComboBox, ColorListBox, Timer and other
Stars: ✭ 99 (+518.75%)
Mutual labels:  lazarus, delphi-component, lazarus-package, lazarus-component
PospoliteView
Pospolite View aims to be a simple HTML viewer engine fully made in Free Pascal.
Stars: ✭ 29 (+81.25%)
Mutual labels:  lazarus, lazarus-package, lazarus-component
VALIS
Vote ALlocating Immune System, an immune-inspired classification algorithm
Stars: ✭ 21 (+31.25%)
Mutual labels:  lazarus
Dam
Delphi and Lazarus Message Dialogs with Formatted Text
Stars: ✭ 85 (+431.25%)
Mutual labels:  lazarus
Delphi OSMMap
Visual control for Delphi and Lazarus to display OSM map
Stars: ✭ 27 (+68.75%)
Mutual labels:  lazarus
Fairtris
Clone of the official classic Tetris® game for the NES console, intended for Windows and Linux systems. It implements the original mechanics and includes many regional versions and several RNGs (all in one executable).
Stars: ✭ 30 (+87.5%)
Mutual labels:  lazarus
xavier
Xavier is a small object-oriented XML library for Lazarus and Delphi
Stars: ✭ 38 (+137.5%)
Mutual labels:  lazarus
unboundbible
Unbound Bible is an open source and a free, multilingual Bible-reader program for Mac, Linux and Windows.
Stars: ✭ 25 (+56.25%)
Mutual labels:  lazarus
Asuite
ASuite is a simple open source portable launcher for Microsoft Windows.
Stars: ✭ 58 (+262.5%)
Mutual labels:  lazarus
lazarus
Notepas sources and other derived lazarus projects using the editor module.
Stars: ✭ 26 (+62.5%)
Mutual labels:  lazarus
DfmExtractor
Small command line utility which allows you to extract DFM, LFM and FRM forms from executable files compiled by Delphi, Lazarus and CodeTyphon.
Stars: ✭ 22 (+37.5%)
Mutual labels:  lazarus
csscontrols
Implementation of basic css drawing for pascal (fpc, lazarus, delphi)
Stars: ✭ 26 (+62.5%)
Mutual labels:  lazarus
troll-hunter
Trollhunter is a single-player roguelike game.
Stars: ✭ 28 (+75%)
Mutual labels:  lazarus
treelistview
A Pascal treelistview component, showing a treeview together with the columns of a listview (for Delphi and Lazarus)
Stars: ✭ 41 (+156.25%)
Mutual labels:  lazarus
fp-telegram
Wrapper classes library for telegram bots API (FreePascal)
Stars: ✭ 59 (+268.75%)
Mutual labels:  lazarus
LazProfiler
One-Click-Profiler addon for Lazarus
Stars: ✭ 25 (+56.25%)
Mutual labels:  lazarus
MRIcroGL
v1.2 GLSL volume rendering. Able to view NIfTI, DICOM, MGH, MHD, NRRD, AFNI format images.
Stars: ✭ 101 (+531.25%)
Mutual labels:  lazarus
brookframework
Microframework which helps to develop web Pascal applications.
Stars: ✭ 161 (+906.25%)
Mutual labels:  lazarus
sizectrl
TSizeCtrl v8.2
Stars: ✭ 16 (+0%)
Mutual labels:  lazarus
Ascension
A metaheuristic optimization framework
Stars: ✭ 24 (+50%)
Mutual labels:  lazarus

TDzHTMLText2 - An advanced HTML label for Delphi, Lazarus and CodeTyphon

Extended version of the DzHTMLText by Rodrigo Depiné Dalpiaz

Original README


Example program compiled with Lazarus

Example_Tourmaline.png



Changelog

  • 2020.04.13 - Support for CodeTyphon and older Delphi versions: 2009, 2010, XE, XE2, XE3.
  • 2019.10.16 - Tag LN support - 1-pixel high line drawn in the given color. Eg. red line: <ln:#FF0000>

My modifications

New tags

  • <HR> - Horizontal line
  • <H1> - Header 1
  • <H2> - Header 2
  • <H3> - Header 3
  • <LI> - List item - 1st level
  • <LI2> - List item - 2nd level
  • <LC> - Background line color drawn from the current position to the end of the current line
  • <BBC> - Body background color drawn from the beginning of the current line to the end of the document
  • <SUB> - Subscript
  • <SUP> - Superscript
  • <IMG> - Image
  • <LN> - Horizontal line with 1 pixel width drawn from the current position to the end of line.

<HR> - Horizontal line

Horizontal line drawn in the color selected for the text with the FC tag.
The HR tag accepts one optional numeric parameter that specifies the length of the line in pixels. If this parameter is negative, the line will be cut at the end by the given number of pixels.

In the Object Inspector (TagHRParams property) you can set two additional parameters:

LineHeight: integer;
Style: TPenStyle;

Example 1

The line drawn in the current color from the left to right edge of the component:

<HR>

hr_1.png

Example 2

The line drawn from the position of 70 pixels to the right edge:

<T:70><HR>

hr_2.png

Example 3

The line truncated from the left and the right by 120 pixels:

<T:120><HR:-120>

hr_3.png

Example 4

A red line cut off by 256 pixels on the right:

<FC:clRed><HR:-256></FC>
OR
<FC:#FF0000><HR:-256></FC>
OR
<FC:rgb(255,0,0)><HR:-256></FC>

hr_4.png


<H1>, <H2>, <H3> - Headers

All header parameters can be set in the Object Inspector. Properties: TagH1Params, TagH2Params and TagH3Params.
For each header, you can set the following properties:

Alignment: TAlignment; // center, left or right
BackgroundColor: TColor;
Font: TFont;
Transparent: Boolean; // default True

Example

<H1>Header 1</H1>
<H2>Header 2</H2>
<H3>Header 3</H3>

headers.png


<LI>, <LI2> - List items (1st and 2nd level)

List parameters can be set in the Object Inspector using properties: TagLIParams and TagLI2Params. You can set here:

BulletType: TDHBulletType;
CustomString: string;
Margin: integer;
Spacing: Byte;

Bullet types:

Type Char
btBullet
btCircle
btDash -
btLongDash
btCustomString string specified in the CustomString field

Margin - margin from the left edge of the control to the first character of the text.
Spacing - space (in pixels) from the bullet char to the text.

The LI and LI2 tags accept one parameter - a string used as the list bullet. If specified, the value set in the Object Inspector in the BulletType property will be ignored.

Example

<li>List item 1
<li>List item 2
<li>List item 3
<li:4.>List item 4 (forced bullet "4.")
<li:5.>List item 5 (forced bullet "5.")
<li2>Subitem 1
<li2>Subitem 2
<li2:*>Subitem 3 (forced bullet "*")

list.png


<LC> - Line color

Background line color drawn from the current position to the end of the current line.

Example

ABCD <LC:#87CEEB> 1234

lc_line_color.png


<BBC> - Body background color

Body background color drawn from the beginning of the current line to the end of the document. You can use several BBC tags to draw rectangles in the document.

Example

<bbc:clGray>
<c><fc:rgb(255,255,255)>Gray background</fc></c>

<bbc:#EEE8AA>
<c>Yellow - PaleGoldenrod</c>

<bbc:#CD853F>
<c><fc:clWhite>Brown - Peru</fc></c>

<bbc:#4682B4>
<c><fc:clWhite>SteelBlue</fc></c>

bbc_body_background_color.png


<SUB> - Subscript

The text in the the SUB tag is displayed in a slightly smaller font and below the normal text. The size and position are calculated automatically, but you can change these automatically calculated values using TagSUBParams.FontSizeDelta and TagSUBParams.PosYDelta.

Example

<c><fs:11>Tourmaline - general formula</fs>
<fs:14><fn:Verdana>XY<sub>3</sub>Z<sub>6</sub>[(OH)<sub>4</sub>(BO<sub>3</sub>)<sub>3</sub>(Si<sub>6</sub>O<sub>18</sub>)]</fn></fs></c>

sub_subscript.png


<SUP> - Superscript

The text in the the SUB tag is displayed in a slightly smaller font and above the normal text. The size and position are calculated automatically, but you can change these automatically calculated values using TagSUPParams.FontSizeDelta and TagSUPParams.PosYDelta.

Example

<c><fs:16>a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup></fs></c>

sup_superscript.png


<IMG> - Images

The IMG tag accepts one parameter, which may be the file name or PNG image index from the image collection associated with the component.

Example

<fs:12>
<bbc:#DB8A8A>
<c>My beautiful logo

<img:D:\SomeDir\my_logo.png>
</c>
</fs>

img_image.png

If you want to use the PNG collection, drop the TDzPngCollection from the Component Palette on the form and associate your DzHTMLText component with this collection using property DzHTMLText.PngCollection. TDzPngCollection is a non-visual component which can store any number of PNG images. Unlike TImageList, each image can have a different size. Images are stored internally as PNG, not bitmaps, which reduces the size of the DFM file. Of course, assuming that PNG images are compressed.

Add some images to DzPngCollection using the Items property in the Object Inspector. You can also add images at runtime using methods: AddPngImage, AddPngImageFromFile.

To display image from the collection you can use, eg:

<img:0>

where 0 is the index of the PNG image in the DzPngCollection component.


<LN> - 1-pixel line

Horizontal line with 1 pixel width drawn from the current position to the end of line. Accepts one parameter - line color.

Example

<bbc:clSilver>

<bbc:#C8E9FD><ln:#8DB6FA>
<c>Blue line above</c>

<bbc:#EEDBEE><ln:#CA91CA>
<c>Pink line above</c>

<bbc:#D2E8DA><ln:#7EBE98>
<c>Green line above</c>

<bbc:clSilver>

img_image.png


Additional changes

Older Delphi versions support

Added support for Delphi 2009 - XE3, so now all Unicode versions of Delphi are supported.


Lazarus support

Tested on Lazarus 2.0.6 + FPC 3.0.4, Lazarus 2.0.7 + FPC 3.3.1, CodeTyphon 7.00 + FPC 3.3.1


Support for additional colors notations

In addition to the original component, which uses the Delphi color names (clWhite, clRed...) and hexadecimal BGR notation with the $00 prefix, you can also use HTML/CSS colors, eg.:

  • <lc:#FFAA88>
  • <fc:#00FF00>
  • <bc:#ABC> - short notation for #AABBCC

and RGB colors, eg:

  • <bbc:Rgb(50,100,150)>
  • <fc:RGB(255,128,128)>
  • <fc:rgb(128 64 32)> - spaces can also be separators
  • <fc:rgb(200)> - short notation for rgb(200,200,200)

HTML Entites

I changed the name of the ReplaceForcedChars function to ReplaceHtmlEntities and added support for the additional HTML entities. The original component only supported &lt; (<) and &gt; (>) entites.

A full list of supported HTML entities

HTML Entity Symbol
&lt; <
&gt; >
&euro;
&cent; ¢
&pound; £
&yen; ¥
&amp; &
&copy; ©
&reg; ®
&sect; §
&deg; °
&sup2; ²
&sup3; ³
&Integral;
&micro; µ
&para;
&middot; ·
&plusmn; ±
&times; ×
&divide; ÷
&plusmn; ±
&times; ×
&divide; ÷
&Omega; Ω
&alpha; α
&beta; β
&gamma; γ
&Gamma; Γ
&delta; δ
&Delta; Δ
&pi; π
&Pi; Π
&Sigma; Σ
&bull;
&ndash;
&trade;
&SmallCircle;

Example

<bbc:#555><fc:#DDD>
<fs:14><fn:Courier New>
&Delta; = b&sup2; &ndash; 4ac
E = mc&sup2;
P<sub>o</sub> = &Pi;r&sup2;
sin&sup2;&alpha; + cos&sup2;&alpha; = 1
</fn></fs></fc>

html_entities.png


ExtraLineSpacing

Additional vertical space between lines in pixels. Property TDzHTMLText.ExtraLineSpacing.

Default line spacing:

<t:20>ExtraLineSpacing = 0
<t:20>ExtraLineSpacing = 0
<t:20>ExtraLineSpacing = 0
<t:20>ExtraLineSpacing = 0

extra_line_spacing_0.png

ExtraLineSpacing = 6:

<t:20>ExtraLineSpacing = 6
<t:20>ExtraLineSpacing = 6
<t:20>ExtraLineSpacing = 6
<t:20>ExtraLineSpacing = 6

extra_line_spacing_6.png


ExtraWordSpacing

Additional horizontal space between words in pixels. Property TDzHTMLText.ExtraWordSpacing.

<t:20>The default spacing between words
<t:20>The default spacing between words
<t:20>The default spacing between words
<t:20>The default spacing between words

extra_word_spacing_0.png

<t:20>Extra word spacing = 4
<t:20>Extra word spacing = 4
<t:20>Extra word spacing = 4
<t:20>Extra word spacing = 4

extra_word_spacing_4.png


Internal margins

Example

<bbc:$00E6C8DC>

Some text
Some text
<t:10>Some text (10)
<t:20>Some text (20)
DzHTMLText.Color := $00A06596;
DzHTMLText.InternalMargins.Left := 20;
DzHTMLText.InternalMargins.Right := 20;

internal_margin_1.png

DzHTMLText.Color := $00E6C8DC;
DzHTMLText.InternalMargins.Left := 20;
DzHTMLText.InternalMargins.Right := 20;

internal_margin_2.png


Border

You can set the component's boder using TDzHTMLText.Border property.

Warnig! Flickering when border width > 1. Place DzHTMLText on TPanel/TForm with DoubleBuffered set to True.

border.png


Vertical alignment

The displayed text can be positioned vertically, but only when the AutoHeight is set to False.

vertical_alignment_top.png vertical_alignment_center.png vertical_alignment_bottom.png


Loading and saving

You can save and load text with the SaveToFile and LoadFromFile methods.

To save the displayed text (which is actually an image) to the bitmap, use SaveToBitmap or SaveToBitmapFile methods.

TODO

  • Text: string --> Lines: TStrings.
  • Implement BeginUpdate, EndUpdate.
  • Padding.
  • TCustomDzHTMLText
  • Fix bugs!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].