Class TCastleComponent

Unit

Declaration

type TCastleComponent = class(TComponent)

Description

Component with various CGE extensions: can be a parent of other non-visual components (to display them in CGE editor and serialize them to files), can be translated.

Note that everywhere in CGE (in particular in editor and when serializing) we handle a standard Pascal TComponent. There's no need to derive all your components from TCastleComponent. Use TCastleComponent only if you want to benefit from some extra features in this class.

Hierarchy

  • TObject
  • TPersistent
  • TComponent
  • TCastleComponent

Overview

Methods

Protected function GetInternalText: String; virtual;
Protected procedure SetInternalText(const Value: String); virtual;
Protected procedure SetName(const Value: TComponentName); override;
Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;
Public destructor Destroy; override;
Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual;
Public function PropertySections(const PropertyName: String): TPropertySections; virtual;
Public procedure SetTransient;
Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);
Public function NonVisualComponentsCount: Integer;
Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;

Description

Methods

Protected function GetInternalText: String; virtual;
 
Protected procedure SetInternalText(const Value: String); virtual;
 
Protected procedure SetName(const Value: TComponentName); override;
 
Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;

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 destructor Destroy; override;
 
Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); virtual;

Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field.

Public function PropertySections(const PropertyName: String): TPropertySections; virtual;

Section where to show property in the editor.

Public procedure SetTransient;

Ignore this component when serializing parent's TCastleUserInterface.Controls list or TCastleTransform.List, and do not show this component in CGE editor. This simply sets csTransient flag in ComponentStyle.

This is useful for children that are automatically managed by the parent, and should not be modified by user code. For example, TCastleCheckbox is internally composed from TCastleImageControl and TCastleLabel children, but we don't want to serialize or even show these children to user.

Note that if you want to prevent this component from serializing as part of TCastleUserInterface.Controls list or TCastleTransform.List, but you still want it to be visible in CGE editor, then make it a "subcomponent" instead, by SetSubComponent(true).

Note that both csSubComponent and csTransient only disable the component serialization as part of parent's TComponent.GetChildren list. If you will make the component published in its own property (which is normal for "subcomponents") then it will be serialized anyway, just as part of it's own property (like TCastleScrollView.ScrollArea). So to really avoid serializing the component (that you have to insert to TComponent.GetChildren list), make it csSubComponent and/or csTransient, and do not publish it.

Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);

Use this component as a container to easily reference any other TComponent instances, and add given TComponent to it. This is useful to group non-visual components, esp. in CGE editor.

See also
NonVisualComponentsCount
Count of components added by AddNonVisualComponent.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....
Public function NonVisualComponentsCount: Integer;

Count of components added by AddNonVisualComponent.

See also
AddNonVisualComponent
Use this component as a container to easily reference any other TComponent instances, and add given TComponent to it.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....
Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;

You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do .... Do not call this method in other contexts, it is only useful for "for..in" construction.

See also
AddNonVisualComponent
Use this component as a container to easily reference any other TComponent instances, and add given TComponent to it.

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;

Components added by AddNonVisualComponent.


Generated by PasDoc 0.16.0.