diff options
author | xue <> | 2005-12-26 15:54:54 +0000 |
---|---|---|
committer | xue <> | 2005-12-26 15:54:54 +0000 |
commit | 9be8859d92e4bbec2462e82457d014f0a0d720db (patch) | |
tree | 8d674a443ab0785d2a68dbfa326abfae3230bbb5 /demos/quickstart/protected/pages/Fundamentals/Components.page | |
parent | a433c6c39bdaa5a53238596853617228be8ad07f (diff) |
Diffstat (limited to 'demos/quickstart/protected/pages/Fundamentals/Components.page')
-rw-r--r-- | demos/quickstart/protected/pages/Fundamentals/Components.page | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/demos/quickstart/protected/pages/Fundamentals/Components.page b/demos/quickstart/protected/pages/Fundamentals/Components.page new file mode 100644 index 00000000..ec6dbd48 --- /dev/null +++ b/demos/quickstart/protected/pages/Fundamentals/Components.page @@ -0,0 +1,49 @@ +<com:TContent ID="body" >
+<h1>Components</h1>
+<p>
+A component is an instance of <code>TComponent</code> or its child class. The base class <code>TComponent</code> implements the mechanism of component properties and events.
+</p>
+
+<h2>Component Properties</h2>
+<p>
+A component property can be viewed as a public variable describing a specific aspect of the component, such as the background color, the font size, etc. A property is defined by the existence of a getter and/or a setter method in the component class. For example, in <code>TControl</code>, we have
+<pre class="source">
+class TControl extends TComponent {
+ public function getID() {
+ ...
+ }
+ public function setID($value) {
+ ...
+ }
+}
+</pre>
+This defines a property named <code>ID</code>. Reading the property (e.g. <code>echo $component->ID;</code>) is equivalent to invoking the getter method (e.g. <code>echo $component->getID();</code>); and writing the property (e.g. <code>$component->ID='Button';</code>) is equivalent to invoking the setter method (e.g. <code>$component->setID('Button');</code>).
+</p>
+<p>
+A property is read-only if it has a getter method but no setter method. Since PHP method names are case-insensitive, property names are also case-insensitive. A component class inherits all its ancestor classes' properties.
+</p>
+
+<h2>Component Events</h2>
+<p>
+Component events are special properties that take method names as their values. Attaching (setting) a method to an event will hook up the method to the places at which the event is raised. Therefore, the behavior of a component can be modified in a way that may not be foreseen during the development of the component.
+</p>
+<p>
+A component event is defined by the existence of an <code>on</code>-method. For example, in <code>TButton</code>, we have
+<pre class="source">
+class TButton extends TWebControl {
+ public function onClick($param) {
+ ...
+ }
+}
+</pre>
+This defines an event named <code>Click</code>, and a handler can be attached to the event using one of the following ways,
+<pre class="source">
+$button->Click=$callback;
+$button->Click->add($callback);
+$button->Click[]=$callback;
+$button->attachEventHandler('Click',$callback);
+</pre>
+where <code>$callback</code> refers to a valid PHP callback (e.g. a function name, a class method <code>array($object,'method')</code>, etc.)
+</p>
+
+</com:TContent>
\ No newline at end of file |