Objects
Objects are things in an XHTML document. Images, applets, and plugins are instances of objects. _object command describes the object in general. The attributes 'classid', 'codebase', and 'codetype' specify the object code. To specify the location of an object, 'classid' attribute has a URL value. In addition, 'codebase' attribute defines the base path to resolve the relative URL in the classid. To specify the content type of a media, 'codetype' has the MIME format such as 'application/mpeg'.
The 'data' and 'type' attributes also work for object data. The 'data' attribute defines the location of an object's data. The 'type' attribute specifies the data type. To describe the relevant resources of an object, 'archive' is a urllist. Finally, boolean 'declare' attribute specifies that the object is only a declaration and does not execute during loading.
_html( "xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'" );
_head();
_title(); quote( "Object" ); title_();
head_();
_object( "title='space' classid='space.sml'" );
quote( "Space" );
object_();
html_();
-
Render Object
_object command specifies how to render an object data. The object's code, data, and parameters may be required to specify an objcet. The _object's content is an alternation when the object is not available. Following example demonstrates the rendering of a Snaml animation. If this Tcl animation object is not available it renders a mpeg video, otherwise it shows a gif picture.
_object( "title='space' classid='space.java' );
_object( "data='space.mpg' "
+ "type='application/mpeg'" );
_object( "data='space.gif' type='image/gif'" );
quote( "Space Animation" );
objcet_();
object_();
object_();
-
Initialize Object
_param command specifies a set of runtime values of an object. Any number of the _param commands in arbitrary order may be the content of an object. Its 'name' attribute specifies a runtime parameter that is known by object's implementation. Its 'value' attribute is the value of the runtime parameter. In addition, its 'valuetype' may be data (default), ref, and object. Where data is a string, ref refers to a location of parameters, and object refers to another object in the same document. 'type' is the 'content-type'.
_object( "classid='space.tcl'" );
_param( "name='width' value='320' valuetype='data' );
_param( "name='height' value='200' valuetype='data' );
object_();
-
Naming Schemes
_object command may insert a java applet with a prefix 'java:'. To insert an ActiveX object it must have a prefix 'clsid:'. Following paragraphs are two examples:
Java Applet
_object( "codetype='application/java-archive' "
+ "classid='java:program.start'" );
quote( "Java Applet Example." );
object_();
ActiveX
_object( "classid='clsid:663A8FEE-1EF7-12CF-B3DB070036F12432' "
+ "data='program.stm'" );
quote( "ActiveX Example." );
object_();
-
Declare and
Instantiate Object
Boolean 'declare'attribute in the _object will not execute the object after loading. The 'id' attribute sets a unique id for later using. In the following example, an anchor declares an object and instaniates it. You can click the linking text and active the object.
_object( "declare='declare' id='SpaceID' "
+ "data='space.mpg' type='application/mpeg'" );
quote( "Load MPEG Object." );
object_();
...
_a( "href='#SpaceID'" );
quote( "MPEG Animation" );
a_();
Images
__img command embeds an image in the current document. It is a special case of the _object. Its 'src' attribute specifies the location of the image resource. The URL value of the 'longdesc' attribute specifies a location for a long description of the image. When an image is loading, the alternate text of the 'alt' attribute will display at first. This attribute is useful to display a web page in the low speed Internet. 'hspace' and 'vspace' specifies the horizontal and vertical space with the unit of pixel. __img command may have width adn height attributes to specify the rect size of a picture.
__img( "src='http://www.neatware.com/default.gif' "
+ "alt='Snaml GIF Demo'" + "border='0'"
+ "hspace='6' vspace='0');
the equivalent _object code is
_object( "data='http://www.neatware.com/default.gif' "
+ "type='image/gif'" );
quote( "Snaml GIF Demo" );
object_();
_map is an image map command. It specifies regions of an image or an object and assign a specific action to each region. When a user actives a region, browser will invoke the corresponding action. A browser or a server may interpret the coordinates of a region. _map command's 'name''shape' attribute specifies the region shape with the value default, rect, circle, and poly. In addition, 'coords' attribute specifies the position of a shape on the screen. The rect shape may have the coord list left, top, right, bottom; the coord list of circle is center-x, center-y, radius; and the coord list of poly is the pair of x0, y0, x1, y1, etal. To disable a region that associates a link, you must set 'nohref' boolean attribute. Furthermore, 'usemap' attribute associates an image map with an element. Finally, the _area command acts like _a command in the _map content.
_object( "data='toolbar.gif' type='image/gif' usemap='#map'" );
object_();
_map( "name='map'" );
_area( "href='beginner.html' shape='rect' coords='0,0,31,31'" );
area_();
_area( "href='professional.html' shape='rect' coords='31,0,63,31'" );
area_();
_area( "href='executive.html' shape='rect' coords='63,0,95,31'" );
area_();
map_();
Here is a source code of an image map procedure. Comparing to other web page editing method, Snaml code automatically compute the coordinates and flexible to change. Resuable Snaml code is another benefit.
Rect Image Map | |
name |
image name | |
w |
image width | |
h |
image height | |
n |
number of sub-area | |
refer |
url list for each area | |
public void ImageMap( String name,
String[] refer, int w, int h, int n )
{
String[] rect;
set coords
for (i = 0; i < n; i++) {
a = w*i/n;
b = w*(i+1)/n;
rect(i) = a.toString() + ","
+ "0" + ","
+ b.toString() + ","
+ h.toString();
}
image setting
__img( " src='" + name + "'"
+ " width='" + w + "'"
+ " height='" + h + "'"
+ " usemap='#map'" );
map setting
_map( "name='map'" );
for (i = 0; i < n; i++) {
_area( " href='" + refer(i) + "'"
+ " coords='" + rect(i) + "'"
+ " shape='rect'" );
area_();
}
map_();
}
usage
String[] refer = {one two three};
ImageMap( "toolbar.gif", refer, 480 32 3 );