源代码中看到很多不会被明白看到的输出类。
这一点,可以取代仅仅存在于C/C++编写的组件中的“虚类”的概念。
控件是会出现在IDE控件工具箱中的特殊的输出类。
控件通常是显示某些东西以及和用户实现交互的图形化控件。
但是也可以是正常的类,没有显示,就像
UserControl用法的好实例请看
FileView
控件的源代码。
该控件在一个UserControl里面内嵌了一个
TreeView
和一个
IconView
,
根据用户要求的查看种类显示它们中的一个。
UserContainer用法的好实例请看
ListContainer
控件的源代码,
该控件是一个允许创建一个条目为其他控件的
ListBox
控件的容器
此外,控件需要声明一些特殊的隐含常数,它们被IDE用于管理控件:
Constant
Default
Description
_IsControl
Boolean
FALSE
This property must be set to
TRUE
, so that an exported class becomes a control.
_IsContainer
Boolean
FALSE
If a control is a container, i.e. if you can put other controls inside in the IDE form editor.
_IsMultiContainer
Boolean
FALSE
If a control is a multiple container, like a
TabStrip
.
_IsVirtual
Boolean
FALSE
If a control is virtual, i.e. just a normal class that you can put in the form editor, like the Timer or
Printer
class.
_IsForm
Boolean
FALSE
If a control is actually a form, i.e. the top-level container of all controls of the same family.
_Family
String
The family of the control, i.e. the kind of top-level object where you will be able to put the control.
For example:
"Form"
for a form control,
"Report"
for a control report, and
"*"
for a control that can be put anywhere.
_Group
String
_Family
The IDE toolbox tab name where the control will be put. By default, the family name will be used, or the
"Special"
group if the control has no family.
_Similar
String
A comma separated list of similarity groups. The IDE form editor will allow the control to be replaced by any other control sharing the same similarity groups.
A similarity group is normally a control name.
_Properties
String
The list of control properties. See below.
_DefaultEvent
String
The control default event. See below.
_DefaultSize
String
The control default size. See below.
_DefaultArrangement
String
The automatic arrangement if the control is a container and if it arranges its children automatically.
See below.
_DrawWith
String
The real GUI control used for drawing the control inside the form editor. See below
Only the
_IsControl
and the
_Properties
constants are mandatory.
这些隐藏的常量和其他任何常量一样都是继承的。因此,只要它们之间存在一些继承关系,就不必在每个控件中实际声明它们。
该常数是最重要的,而且是必须的。描述所有将出现在IDE的控件属性表中的属性的类型、缺省值和其他依赖于属性类型的信息。
该指定常数是一个符合下面格式的字符串:
PUBLIC CONST
_Properties
AS String =
"
[
* ,
]
Property1
,
Property2
,
...
"
每个属性符合下面的语法:
[
-
]
Name
[
{
Kind
[
Arguments
]
}
]
=
Default
Kind
是属性的种类,是比属性数据类型更精确的描述。例如,"
Color
"意味着属性是一个整数,但是IDE属性表会打开一个颜色选择器来定义它的值。如果没有定义,属性的种类是它的数据类型。
Arguments
是依赖于_Kind_值的可选参数。
Default
是属性的缺省值。语法依赖于属性种类。
第一个属性可以是一个星号,意味着控件自动获得它的父类在
Property1
常数中所有的属性声明。
在这种情况下,一个属性名称可以用减号开头,这意味着该属性必须被从其父类继承来的列表中移除。
这是目前支持的_Kind_的不同值:
Color
描述颜色的一个整数。
IDE将弹出一个颜色选择器来编辑该属性的值。
一个字体。
IDE将弹出一个字体选择器来编辑该属性的值。
Font
[
:Fixed
]
用=Font:Fixed=可以仅仅允许固定字体。
一个文件路径。
IDE将弹出一个文件选择器来编辑该属性的值。
Picture
一个位于工程目录的图片,或一个库存的图标。
IDE将弹出一个图片选择器来编辑该属性的值。
Range
一个有最大值和最小值限制的整数值。
IDE将使用一个
SpinBox
控件来编辑该属性的值。
Range:
Minimum
;
Maximum
示例,
Control
._Properties 的值是:
X{Position},Y{Position},Width{Dimension},Height{Dimension},Visible=True,Enabled=True,Font{Font},
Background{Color}=-1,Foreground{Color}=-1,Tag,
Mouse{Mouse.Default;Blank;Arrow;Cross;Wait;Text;SizeAll;SizeH;SizeV;SizeN;SizeS;SizeW;SizeE;SizeNWSE;SizeNESW;SplitH;SplitV;Pointing}=Default,
ToolTip,Drop,Expand,Ignore
它被其他所有的控件和容器继承。
这是 ListBox._Properties 的值: