Class TCastleLabel
Unit
Declaration
type TCastleLabel = class(TCastleUserInterfaceFont)
Description
Label with possibly multiline text. See manual about displaying text and fonts.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleUserInterface
- TCastleUserInterfaceFont
- TCastleLabel
Overview
Fields
nested const DefaultLineSpacing = 2; |
Methods
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
function GetInternalText: String; override; |
|
procedure SetInternalText(const Value: String); override; |
|
procedure UIScaleChanged; override; |
|
procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); override; |
|
procedure Loaded; override; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Render; override; |
|
procedure EditorAllowResize( out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure FontChanged; override; |
|
function DisplayChars: Cardinal; |
Properties
property Color: TCastleColor read FColor write FColor; |
|
property FrameColor: TCastleColor read FFrameColor write FFrameColor; deprecated 'display frame around label using Border or parent UI control'; |
|
property AutoSize: boolean read FAutoSize write SetAutoSize default true; |
|
property Text: TStrings read FText write SetText; |
|
property Caption: String read GetCaption write SetCaption stored false; |
|
property PaddingHorizontal: Single
read FPaddingHorizontal write SetPaddingHorizontal default 0; |
|
property PaddingVertical: Single
read FPaddingVertical write SetPaddingVertical default 0; |
|
property Padding: Single
read FPadding write SetPadding default 0; |
|
property LineSpacing: Single read FLineSpacing write FLineSpacing default DefaultLineSpacing; |
|
property Html: boolean read FHtml write SetHtml default false; |
|
property Tags: boolean read FHtml write SetHtml stored false default false; deprecated 'use Html instead'; |
|
property Frame: boolean read FFrame write FFrame default false; deprecated 'display frame around label using Border or parent UI control'; |
|
property MaxWidth: Single read FMaxWidth write SetMaxWidth default 0; |
|
property Alignment: THorizontalPosition
read FAlignment write SetAlignment default hpLeft; |
|
property VerticalAlignment: TVerticalPosition
read FVerticalAlignment write SetVerticalAlignment default vpBottom; |
|
property MaxDisplayChars: Integer
read FMaxDisplayChars write SetMaxDisplayChars default -1; |
|
property CaptionTranslate: Boolean read FCaptionTranslate write FCaptionTranslate default true; |
|
property ColorPersistent: TCastleColorPersistent read FColorPersistent ; |
|
property FrameColorPersistent: TCastleColorPersistent read FFrameColorPersistent ; |
Description
Fields
nested const DefaultLineSpacing = 2; |
|
This item has no description. |
Methods
procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.PreferredSize. Controls that have a preferred size should override this. By default this contains values derived from Width, WidthFraction, Height, HeightFraction, with Border subtracted. Note that the arguments should be already scaled, i.e. multiplied by UIScale, i.e. expressed in final device pixels. Note that the returned PreferredWidth and PreferredHeight must not include the space for Border. Border size will be added later. |
function GetInternalText: String; override; |
|
This item has no description. |
procedure SetInternalText(const Value: String); override; |
|
This item has no description. |
procedure UIScaleChanged; override; |
|
This item has no description. |
procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); override; |
|
This item has no description. Showing description inherited from TCastleComponent.TranslateProperties. Enumerate all properties that are possible to translate in this component. E.g. in TCastleLabel it will return TCastleLabel.Caption, in TCastleEdit it will return TCastleEdit.Text and TCastleEdit.Placeholder. Returns only non-empty properties, thus assuming that if current (by convention, English) text is empty, then there is no point in translating it. Moreover descendants may define boolean properties to exclude particular text from translating, e.g. TCastleLabel.CaptionTranslate, TCastleEdit.TextTranslate, TCastleEdit.PlaceholderTranslate. It is not recursive (it doesn't enumerate children properties). Use global TranslateProperties procedure to call this on a hierarchy of TComponent. You usually don't want to call this method (it is called by other engine routines). But you may find it useful to override this, if you define new component. |
procedure Loaded; override; |
|
This item has no description. |
constructor Create(AOwner: TComponent); override; |
|
This item has no description. |
destructor Destroy; override; |
|
This item has no description. |
procedure Render; override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.Render. Render a control. Called only when Exists and render context is initialized. Do not call this method. It will be automatically called by the engine when needed. It will be called when UI is part of TCastleContainer.Controls list or rendered (e.g. for off-screen rendering) by TCastleContainer.RenderControl. You should only override this method. See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here. You can depend on some OpenGL state being set before calling this method. You can depend on it being set, and you can carelessly change it. This state we set:
Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines do it already, this is only a concern if you make direct OpenGL / OpenGLES calls). |
procedure EditorAllowResize( out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override; |
|
This item has no description. Showing description inherited from TCastleUserInterface.EditorAllowResize. Override this to prevent resizing some dimension in CGE editor. |
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
This item has no description. Showing description inherited from TCastleComponent.PropertySections. Section where to show property in the editor. |
procedure FontChanged; override; |
|
This item has no description. Showing description inherited from TCastleUserInterfaceFont.FontChanged. Force considering font changed (font instance, or glyphs, or sizes changed). Usually, you don't need to call this explicitly from the outside. Changing font, like CustomFont or TCastleContainer.DefaultFont or UIFont, or any property that may affect the font is automatically applied. But there are exceptions: right now, if you call Load on a font, it's measurements will change but some controls using it will not recalculate sizes automatically. In this case, call this method. |
function DisplayChars: Cardinal; |
|
This item has no description. |
Properties
property Color: TCastleColor read FColor write FColor; |
|
Text color. By default it's opaque black. |
property FrameColor: TCastleColor read FFrameColor write FFrameColor; deprecated 'display frame around label using Border or parent UI control'; |
|
Warning: this symbol is deprecated: display frame around label using Border or parent UI control Color tint of the background image, see Frame. By default white. |
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 |
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. |
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'; |
property PaddingHorizontal: Single
read FPaddingHorizontal write SetPaddingHorizontal default 0; |
|
Inside the label rectangle, padding between rect borders and text. Total horizontal padding is the sum |
property PaddingVertical: Single
read FPaddingVertical write SetPaddingVertical default 0; |
|
This item has no description. |
property Padding: Single
read FPadding write SetPadding default 0; |
|
This item has no description. |
property LineSpacing: Single read FLineSpacing write FLineSpacing default DefaultLineSpacing; |
|
Extra spacing between lines. May be negative to squeeze lines tighter together. |
property Html: boolean read FHtml write SetHtml 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 TCastleAbstractFont.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 TCastleFontFamily with bold/italic variants. See the example mentioned above, examples/fonts/html_text.lpr, for a code how to do it. |
property Tags: boolean read FHtml write SetHtml stored false default false; deprecated 'use Html instead'; |
|
Warning: this symbol is deprecated: use Html instead This item has no description. |
property Frame: boolean read FFrame write FFrame default false; deprecated 'display frame around label using Border or parent UI control'; |
|
Warning: this symbol is deprecated: display frame around label using Border or parent UI control Draw frame around the text. Frame uses theme image tiLabel, see TCastleTheme.Images if you want to customize it. |
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 |
property Alignment: THorizontalPosition
read FAlignment write SetAlignment default hpLeft; |
|
Horizontal alignment of the text. |
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 = This property is useful if you really need to manually control the size. It only matters when AutoSize is |
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. |
property CaptionTranslate: Boolean read FCaptionTranslate write FCaptionTranslate default true; |
|
Should the Caption be localized (translated into other languages). Determines if the property is enumerated by TCastleComponent.TranslateProperties, which affects the rest of localization routines. |
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
|
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
|
Generated by PasDoc 0.16.0-snapshot.