Class TCastleComponent
Unit
CastleClassUtils
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, can have custom logic when serializing/deserializing (CustomSerialization).
Note that everywhere in CGE (in particular in editor and when serializing) we handle a standard Pascal TComponent as well. So there's no need to derive all your components from TCastleComponent
, so you derive from standard TComponent too. You can use TCastleComponent
only if necessary, i.e. only if you need one of the extra features in this class.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
Overview
Methods
Properties
Description
Methods
|
function GetInternalText: String; virtual; |
This item has no description. |
|
procedure SetInternalText(const Value: String); virtual; |
This item has no description. |
|
procedure SetName(const Value: TComponentName); override; |
This item has no description. |
|
destructor Destroy; override; |
This item has no description. |
|
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.
|
|
function PropertySections(const PropertyName: String): TPropertySections; virtual; |
Section where to show property in the editor.
|
|
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 lists enumerated by CustomSerialization (see internal TCastleUserInterface.SerializeChildrenEnumerate , TCastleTransform.SerializeChildrenEnumerate, TCastleTransform.SerializeBehaviorsEnumerate).
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 a children component make it csSubComponent and/or csTransient, and do not publish it.
|
|
procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent); |
Remove component previously added by AddNonVisualComponent.
|
|
function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer; |
Index of component previously added non-visual component. Returns -1 if component was not found.
|
|
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
- Add non-visual component to this component.
|
|
function ValueIsStreamed: Boolean; virtual; |
Whether the current value of this object should be written to the stream. This should be True if anything inside this object should be serialized (which means it has non-default value or "stored" specifier indicates that it should be serialized).
This is used by CastleComponentSerialize, which is used in Castle Game Engine for all serialization.
In simple cases, this just says whether the current value of this object equals to some default value.
The default implementation of this class returns True (so always write).
Descendants that override this to sometimes return False (so no need to write) must be very careful: any addition of a new field requires extending this method, otherwise new field may not be saved sometimes (when all other fields are default). Descentants of such classes must also be aware of it. This check must include everything that is inside this object in JSON, including subcomponents and children objects (as done e.g. by TSerializationProcess.ReadWriteList). In practice, overriding this method is only reasonable for simple classes that will not change much in the future, like TCastleVector3Persistent.
The name of this method is consistent with TPropertyEditor.ValueIsStreamed in LCL.
|
|
procedure DesignerInfo(const SList: TStrings); virtual; |
Override to add information that should be visible at design-time. Call SList.Add for each new line of information.
|
|
procedure DesignerWarnings(const SList: TStrings); virtual; |
Override to add warnings that should be visible at design-time. Call SList.Add for each new warning.
|
Properties
|
property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents; |
Components added by AddNonVisualComponent.
|
|
property IsLoading: Boolean read FIsLoading; |
Is the component during deserialization now.
Note: We can't use csLoading in ComponentState because in Delphi it is not possible to control it from CastleComponentSerialize.
|
Generated by PasDoc 0.16.0-snapshot.