Index...
Centrallix Documentation
|
widget/component-decl
component-decl :: A widget which defines a custom component
Metadata:
type: | widget/component-decl |
visual: | yes |
container: | yes |
form element: | no |
Overview:
The component-decl widget is used to define a new component which can be used and reused in other applications or components. Creating a component is very similar to creating an application - except that the top-level widget in a component is "widget/component-decl" instead of "widget/page".
Usage:
A widget/component-decl widget must occur at the top level of a component (.cmp) file.
Other visual and nonvisual widgets may be placed inside a component-decl, in addition to parameters and declarations of Events and Actions that the component generates and handles.
To declare that a component generates an Event, place a "widget/component-decl-event" inside the component at the top level. No parameters are needed for that Event. To cause the component to generate the Event, trigger an Action with the same name on the component-decl from inside, and the event will be activated for the containing application or component.
Similarly, to declare that a component can receive an Action, place a "widget/component-decl-action" inside the component at the top level. Again, no parameters are needed. The containing application or component can then trigger the Action, which will cause an event to occur inside the component. The event occurs on the component-decl widget (top level of the component), and can be caught with a connector widget.
Components can take parameters just like applications can. See the "widget/parameter" widget for details on how to declare parameters on applications and components.
Several of the properties of a component-decl are used to make it easy to wrap another widget or component. The expose_actions_for, expose_events_for, and expose_properties_for properties cause the actions, events, and properties of a widget or component inside the component-decl to be exposed to the "outside world". The apply_hints_to property causes any presentation hints ("widget/hints") that are applied in the instantiation of a component-decl (inside the "widget/component") to be applied to the specified widget or component inside the component-decl.
Properties:
Property | Type | Description |
width |
integer |
The design width, in pixels, of the component. When the component is instantiated, it is subject to resizing; this width value will be used as a reference in that process. |
height |
integer |
The design height, in pixels, of the component. |
expose_actions_for |
string |
Specifies a widget inside the component-decl whose actions (methods) we want to expose on the external interface of this component-decl. |
expose_events_for |
string |
Specifies a widget inside the component-decl whose events we want to expose on the external interface of this component-decl. |
expose_properties_for |
string |
Specifies a widget inside the component-decl whose client-side properties we want to expose on the external interface of this component-decl. |
apply_hints_to |
string |
Specifies a widget inside the component-decl that will receive any presentation hints constraints ("widget/hints") that are applied to the instantiation of this component-decl. |
Sample Code:
// Declare a component having a button that triggers an event
my_button "widget/component-decl"
{
width=100; height=32;
button_txt "widget/parameter" { type=string; default="OK"; }
button_clk "widget/component-decl-event" { }
btn "widget/textbutton"
{
x=0; y=0; width=100; height=32;
text = runserver(:this:button_txt);
fgcolor1="white"; fgcolor2="black";
tristate=no;
bgcolor="#c0c0c0";
onclk "widget/connector"
{
event="Click";
target=my_button;
action="button_clk";
}
}
}
Comments...
(none yet)
Add a Comment...
|