Class TCastleCheckbox

Unit

Declaration

type TCastleCheckbox = class(TCastleUserInterface)

Description

Checkbox with a caption.

Hierarchy

Overview

Fields

Public nested const DefaultCaptionMargin = 10;
Public nested const DefaultCheckboxSize = 24;

Methods

Protected procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); override;
Protected function GetInternalText: String; override;
Protected procedure SetInternalText(const Value: String); override;
Protected procedure DoChange; virtual;
Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function Press(const Event: TInputPressRelease): boolean; override;
Public function Release(const Event: TInputPressRelease): boolean; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public procedure EditorAllowResize( out ResizeWidth, ResizeHeight: Boolean; out Reason: String); override;

Properties

Public property TextColor: TCastleColor read FTextColor write SetTextColor;
Public property CheckboxColor: TCastleColor read FCheckboxColor write SetCheckboxColor;
Published property Checked: Boolean read FChecked write SetChecked default false;
Published property Caption: String read FCaption write SetCaption;
Published property CaptionTranslate: Boolean read FCaptionTranslate write FCaptionTranslate default true;
Published property CaptionMargin: Single read FCaptionMargin write SetCaptionMargin default DefaultCaptionMargin;
Published property OnChange: TNotifyEvent read FOnChange write FOnChange;
Published property AutoSize: Boolean read FAutoSize write SetAutoSize default true;
Published property FontSize: Single read FFontSize write SetFontSize default 0.0;
Published property CheckboxSize: Single read FCheckboxSize write SetCheckboxSize default DefaultCheckboxSize;
Published property CustomFont: TCastleAbstractFont read GetCustomFont write SetCustomFont;
Published property TextColorPersistent: TCastleColorPersistent read FTextColorPersistent ;
Published property CheckboxColorPersistent: TCastleColorPersistent read FCheckboxColorPersistent ;

Description

Fields

Public nested const DefaultCaptionMargin = 10;

This item has no description.

Public nested const DefaultCheckboxSize = 24;

This item has no description.

Methods

Protected 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.

Protected function GetInternalText: String; override;

This item has no description.

Protected procedure SetInternalText(const Value: String); override;

This item has no description.

Protected procedure DoChange; virtual;

This item has no description.

Protected 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.

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public function Press(const Event: TInputPressRelease): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Press.

Handle press or release of a key, mouse button or mouse wheel. Return True if the event was somehow handled, which prevents from passing this event to other UI controls.

When implementing in descendants it is best to override it like this:

function TMyControl.Press(const Event: TInputPressRelease): boolean;
begin
  Result := inherited;
  if Result then Exit; // exit if ancestor already handled event

  if Event.IsKey(keyEnter) then
  begin
    // do something in reaction on Enter
    Exit(ExclusiveEvents); // ExclusiveEvents is true by default
  end;

  if Event.IsMouseButton(buttonLeft) then
  begin
    // do something in reaction on Enter
    Exit(ExclusiveEvents); // ExclusiveEvents is true by default
  end;
end;

Note that releasing of the mouse wheel is not reported now by any backend. Only releasing of keys and mouse buttons is reported.

The events PreviewPress and PreviewRelease are passed first to the parent control, before children have a chance to process this event. Overriding them makes sense if you draw something in TCastleUserInterface.RenderOverChildren.

The events Press and Release are passed to the parent only after the children had a chance to process this event. Overriding them makes sense if you draw something in TCastleUserInterface.Render. This is usually more natural, and adviced.

Public function Release(const Event: TInputPressRelease): boolean; override;

This item has no description.

Public 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.

Public 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.

Properties

Public property TextColor: TCastleColor read FTextColor write SetTextColor;

Color of the label. By default opaque black.

Public property CheckboxColor: TCastleColor read FCheckboxColor write SetCheckboxColor;

Color of the checkbox square and checkmark. By default opaque black.

Published property Checked: Boolean read FChecked write SetChecked default false;

This item has no description.

Published property Caption: String read FCaption write SetCaption;

This item has no description.

Published 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.

Published property CaptionMargin: Single read FCaptionMargin write SetCaptionMargin default DefaultCaptionMargin;

Margin between checkbox square and a text Caption.

Published property OnChange: TNotifyEvent read FOnChange write FOnChange;

Event sent when Checked value was changed by a user click. Note that this is not called when you change Checked property programmatically.

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

Should our size be determined by checkbox image size and caption.

Published property FontSize: Single read FFontSize write SetFontSize default 0.0;

Caption font size.

Published property CheckboxSize: Single read FCheckboxSize write SetCheckboxSize default DefaultCheckboxSize;

Size of the square checkbox.

Published property CustomFont: TCastleAbstractFont read GetCustomFont write SetCustomFont;

Font used for the caption. When this is Nil then the TCastleContainer.DefaultFont is used, or (when TCastleContainer.DefaultFont is also Nil) the global UIFont.

Published property TextColorPersistent: TCastleColorPersistent read FTextColorPersistent ;

TextColor 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 TextColor directly.

See also
TextColor
Color of the label.
Published property CheckboxColorPersistent: TCastleColorPersistent read FCheckboxColorPersistent ;

CheckboxColor 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 CheckboxColor directly.

See also
CheckboxColor
Color of the checkbox square and checkmark.

Generated by PasDoc 0.16.0.