Difference between revisions of "TW3Component"

From Smart Mobile Studio
Jump to: navigation, search
 
Line 13: Line 13:
 
!Properties
 
!Properties
 
|-
 
|-
| [[File:property-icon.png|16px|link=]] [[#Name|Name]]
+
| {{Icon-property-16px-nolink}} [[#Name|Name]]
 
|-
 
|-
| [[File:property-icon.png|16px|link=]] [[#Parent|Parent]]
+
| {{Icon-property-16px-nolink}} [[#Parent|Parent]]
 
|-
 
|-
 
!Protected Methods
 
!Protected Methods
 
|-
 
|-
| [[File:protected_method-icon.png|16px|link=]] [[#ChildAdded|ChildAdded]]
+
| {{Icon-protected method-16px-nolink}}[[#ChildAdded|ChildAdded]]
 
|-
 
|-
| [[File:protected_method-icon.png|16px|link=]] [[#GetChildCount|GetChildCount]]
+
| {{Icon-protected method-16px-nolink}}[[#GetChildCount|GetChildCount]]
 
|-
 
|-
| [[File:protected_method-icon.png|16px|link=]] [[#GetChildObject|GetChildObject]]
+
| {{Icon-protected method-16px-nolink}}[[#GetChildObject|GetChildObject]]
 
|-
 
|-
 
!Methods
 
!Methods
 
|-
 
|-
| [[File:method-icon.png|16px|link=]] [[#ChildByHandle|ChildByHandle]]
+
| {{Icon-method-16px-nolink}} [[#ChildByHandle|ChildByHandle]]
 
|-
 
|-
| [[File:method-icon.png|16px|link=]] [[#ChildByName|ChildByName]]
+
| {{Icon-method-16px-nolink}} [[#ChildByName|ChildByName]]
 
|-
 
|-
| [[File:method-icon.png|16px|link=]] [[#TopLevelParent|TopLevelParent]]
+
| {{Icon-method-16px-nolink}} [[#TopLevelParent|TopLevelParent]]
 
|}
 
|}
  
Line 37: Line 37:
 
= Properties =
 
= Properties =
 
<div id="Name"></div>
 
<div id="Name"></div>
== [[File:property-icon.png|16px|link=]] Name ==
+
== {{Icon-property-16px-nolink}} Name ==
 
Specifies the name of the component as referenced in code.  
 
Specifies the name of the component as referenced in code.  
  
Line 58: Line 58:
  
 
<div id="Parent"></div>
 
<div id="Parent"></div>
== [[File:property-icon.png|16px|link=]] Parent ==
+
== {{Icon-property-16px-nolink}} Parent ==
 
Determine parent (container) of component.
 
Determine parent (container) of component.
  
Line 70: Line 70:
 
= Protected Methods =
 
= Protected Methods =
 
<div id="ChildAdded"></div>
 
<div id="ChildAdded"></div>
== [[File:protected_method-icon.png|16px|link=]] ChildAdded ==
+
== {{Icon-protected method-16px-nolink}}ChildAdded ==
 
Called when component is created and Parent is set inside constructor.
 
Called when component is created and Parent is set inside constructor.
  
Line 83: Line 83:
  
 
<div id="GetChildCount"></div>
 
<div id="GetChildCount"></div>
== [[File:protected_method-icon.png|16px|link=]] GetChildCount ==
+
== {{Icon-protected method-16px-nolink}}GetChildCount ==
 
Return number of components inside Children array. This method count only direct children (it is not recursive).
 
Return number of components inside Children array. This method count only direct children (it is not recursive).
  
Line 90: Line 90:
  
 
<div id="GetChildObject"></div>
 
<div id="GetChildObject"></div>
== [[File:protected_method-icon.png|16px|link=]] GetChildObject ==
+
== {{Icon-protected method-16px-nolink}}GetChildObject ==
 
Return child at specified index within Childs array.
 
Return child at specified index within Childs array.
  
Line 104: Line 104:
 
= Methods =
 
= Methods =
 
<div id="ChildByHandle"></div>
 
<div id="ChildByHandle"></div>
== [[File:method-icon.png|16px|link=]] ChildByHandle ==
+
== {{Icon-method-16px-nolink}} ChildByHandle ==
 
Returns child component based on Component’s Handler.
 
Returns child component based on Component’s Handler.
  
Line 120: Line 120:
  
 
<div id="ChildByName"></div>
 
<div id="ChildByName"></div>
== [[File:method-icon.png|16px|link=]] ChildByName ==
+
== {{Icon-method-16px-nolink}} ChildByName ==
 
Returns child component based on Component’s name.
 
Returns child component based on Component’s name.
  
Line 137: Line 137:
  
 
<div id="TopLevelParent"></div>
 
<div id="TopLevelParent"></div>
== [[File:method-icon.png|16px|link=]] TopLevelParent ==
+
== {{Icon-method-16px-nolink}} TopLevelParent ==
 
Determine root component (TDocumentBody).
 
Determine root component (TDocumentBody).
  

Latest revision as of 12:36, 14 September 2014


Unit: W3Components.pas


Hierarchy
TObject
TW3TagObj
TW3Component
Properties
Property-icon.png Name
Property-icon.png Parent
Protected Methods
Protected method-icon.pngChildAdded
Protected method-icon.pngGetChildCount
Protected method-icon.pngGetChildObject
Methods
Method-icon.png ChildByHandle
Method-icon.png ChildByName
Method-icon.png TopLevelParent


Properties

Property-icon.png Name

Specifies the name of the component as referenced in code.

property Name: String read FName write setName;

Component’s name is automatically generated by Smart Mobile Studio when component is placed on Form.


Warning:

If Name is changed in run-time, new name can not be directly used (e.g. MyNewName.Property := Value). Methods such as ChildByName must be used instead.


Example:

W3Button1.Name := 'MyButton';
// Next line will stop with: Syntax Error: Unknown name "MyButton" [line: 41, column: 3, file: Form1]
MyButton.Caption := 'Click me!';


Property-icon.png Parent

Determine parent (container) of component.

property Parent: TW3Component read FParent;

TW3Component object may contain (be a Parent of) one or more child TW3Component components (Childs). Child component are referenced inside private array of TW3Component class. Child components may be accessed either by ChildByName or ChildByHandle methods.

TW3Component.Parent


Protected Methods

Protected method-icon.pngChildAdded

Called when component is created and Parent is set inside constructor.

procedure ChildAdded(aChild: TW3Component); virtual;

Descendants may override this method.

aChild

TW3Component
Reference of component being added.


Protected method-icon.pngGetChildCount

Return number of components inside Children array. This method count only direct children (it is not recursive).

function GetChildCount: Integer;


Protected method-icon.pngGetChildObject

Return child at specified index within Childs array.

function GetChildObject(index: Integer): TW3Component;

Parameters:

index

Integer
Indicate index of child. This parameter is zero-based.


Methods

Method-icon.png ChildByHandle

Returns child component based on Component’s Handler.

function ChildByHandle(const aHandle: THandle): TW3Component;

If component with specified Handler doesn’t exists, method return nil.


Parameters:

aHandle

THandle
Indicate THandle of Component’s reference searching for.


Method-icon.png ChildByName

Returns child component based on Component’s name.

function ChildByName(const compName: String): TW3Component;

Parameters:

compName

String
Indicate name of Component’s reference searching for.


Remarks:

If component with specified name doesn’t exists, method return nil.


Method-icon.png TopLevelParent

Determine root component (TDocumentBody).

function TopLevelParent : TW3Component;

This method iterate trough all Parent components (as displayed on diagram) back to the root Parent.


TW3Component.TopLevelParent