Class TCastleLabel

Unit

Declaration

type TCastleLabel = class(TCastleUserInterfaceFont)

Description

Label with possibly multiline text, in an optional box.

Hierarchy

Overview

Fields

Public nested const DefaultLineSpacing = 2;

Methods

Protected procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Render; override;
Public procedure EditorAllowResize( out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override;
Public function DisplayChars: Cardinal;

Properties

Public property Color: TCastleColor read FColor write FColor;
Public property FrameColor: TCastleColor read FFrameColor write FFrameColor;
Published property AutoSize: boolean read FAutoSize write SetAutoSize default true;
Published property Text: TStrings read FText write SetText;
Published property Caption: string read GetCaption write SetCaption stored false;
Published property PaddingHorizontal: Single read FPaddingHorizontal write FPaddingHorizontal default 0;
Published property PaddingVertical: Single read FPaddingVertical write FPaddingVertical default 0;
Published property Padding: Single read FPadding write FPadding default 0;
Published property LineSpacing: Single read FLineSpacing write FLineSpacing default DefaultLineSpacing;
Published property Html: boolean read FHtml write FHtml default false;
Published property Tags: boolean read FHtml write FHtml stored false default false; deprecated 'use Html instead';
Published property Frame: boolean read FFrame write FFrame default false;
Published property MaxWidth: Single read FMaxWidth write SetMaxWidth default 0;
Published property Alignment: THorizontalPosition read FAlignment write SetAlignment default hpLeft;
Published property VerticalAlignment: TVerticalPosition read FVerticalAlignment write SetVerticalAlignment default vpBottom;
Published property MaxDisplayChars: Integer read FMaxDisplayChars write SetMaxDisplayChars default -1;
Published property ColorPersistent: TCastleColorPersistent read FColorPersistent;
Published property FrameColorPersistent: TCastleColorPersistent read FFrameColorPersistent;

Description

Fields

Public nested const DefaultLineSpacing = 2;
 

Methods

Protected procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override;
 
Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure Render; override;
 
Public procedure EditorAllowResize( out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override;
 
Public function DisplayChars: Cardinal;
 

Properties

Public property Color: TCastleColor read FColor write FColor;

Text color. By default it's opaque black.

Public property FrameColor: TCastleColor read FFrameColor write FFrameColor;

Color tint of the background image, see Frame. By default white.

Published property AutoSize: boolean read FAutoSize write SetAutoSize default true;

Should we automatically adjust size to the text size. The size of the label determines where does it display the Frame, where does it catch events, to what width is it aligned (see Alignment) and so on.

When this is True (the default) then Width, Height, FullSize values are ignored.

Published property Text: TStrings read FText write SetText;

Caption displayed on the label, each line as a string. Setting this property merely copies the contents using TStrings.Assign.

Published property Caption: string read GetCaption write SetCaption stored false;

Caption displayed on the label. This is just a shortcut to get/set Text as a single string.

Use LineEnding or NL constant when setting this to indicate a newline. The two examples below are equivalent:

// one way
Label1.Text.Clear;
Label1.Text.Add('First line');
Label1.Text.Add('Second line');

// alternative way to do the same
Label1.Caption := 'First line' + LineEnding + 'Second line';

Published property PaddingHorizontal: Single read FPaddingHorizontal write FPaddingHorizontal default 0;

Inside the label rectangle, padding between rect borders and text. Total horizontal padding is the sum PaddingHorizontal + Padding, total vertical padding is the sum PaddingVertical + Padding.

Published property PaddingVertical: Single read FPaddingVertical write FPaddingVertical default 0;
 
Published property Padding: Single read FPadding write FPadding default 0;
 
Published property LineSpacing: Single read FLineSpacing write FLineSpacing default DefaultLineSpacing;

Extra spacing between lines. May be negative to squeeze lines tighter together.

Published property Html: boolean read FHtml write FHtml default false;

Does the text use HTML markup. This allows to easily change colors or use bold, italic text.

See the example examples/fonts/html_text.lpr and examples/fonts/html_text_demo.html for a demo of what HTML tags can do. See TCastleFont.PrintStrings documentation for a list of support HTML markup.

Note that to see the bold/italic font variants in the HTML markup, you need to set the font to be TFontFamily with bold/italic variants. See the example mentioned above, examples/fonts/html_text.lpr, for a code how to do it.

Published property Tags: boolean read FHtml write FHtml stored false default false; deprecated 'use Html instead';

Warning: this symbol is deprecated: use Html instead

 
Published property Frame: boolean read FFrame write FFrame default false;

Draw frame around the text. Frame uses theme image tiLabel, see TCastleTheme.Images if you want to customize it.

Published property MaxWidth: Single read FMaxWidth write SetMaxWidth default 0;

If non-zero, limit the width of resulting label. The text will be broken in the middle of lines, to make it fit (together with PaddingHorizontal) inside MaxWidth.

Published property Alignment: THorizontalPosition read FAlignment write SetAlignment default hpLeft;

Horizontal alignment of the text.

Published property VerticalAlignment: TVerticalPosition read FVerticalAlignment write SetVerticalAlignment default vpBottom;

Vertical alignment of the text. Usually you don't want to use this, instead leave AutoSize = True and align the label to the parent using anchors, like MyLabel.Anchor(vpMiddle); or MyLabel.Anchor(vpTop);.

This property is useful if you really need to manually control the size. It only matters when AutoSize is False. Then it controls where the text is, with respect to it's rectangle defined by properties like Height or FullSize.

Published property MaxDisplayChars: Integer read FMaxDisplayChars write SetMaxDisplayChars default -1;

Limit the displayed label text, if not -1. This doesn't affect the label size, only the rendered text. It's nice to show the animation of text "expanding", filling some area. Use DisplayChars as the maximum sensible value for this.

Published property ColorPersistent: TCastleColorPersistent read FColorPersistent;

Color that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Color directly.

See also
Color
Text color.
Published property FrameColorPersistent: TCastleColorPersistent read FFrameColorPersistent;

FrameColor that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write FrameColor directly.

See also
FrameColor
Color tint of the background image, see Frame.

Generated by PasDoc 0.15.0.