HOME   PRODUCTS   PARTNERS   STORE   COMPANY     

    Objects

    Objects, Applets, Images

  1. 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.sml'
        _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 id='SpaceID' 
              data='space.mpg' type='application/mpeg'"
        quote "Load MPEG Object."
      object_
          ...
      _a "href='#SpaceID'"
        quote "MPEG Animation"
      a_
      
  2. Applets

    _applet command enables a java applet in an XHTML document. This command is depreciated in favor of the _object command. Its 'code' attribute specifies the applet location.

    _applet "code='audio' width='30' height='20'"
      _param "name='wave' value='sound.wav'"
    applet_
    

    the equivalent _object code is

    _object "codetype='application/java' 
            classid='audio' width='30' height='20'"
      _param "name='wave' value='sound.wav'"
    object_
    
  3. 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. __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'"
    

    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
    # ********************************************

    proc ImageMap {name w h n {refer {}}} {
      for {set i 0} {$i < $n} {incr i} {
        set a [expr $w*$i/$n]
        set b [expr $w*($i+1)/$n]
        set rect($i) "$a,0,$b,$h" 
      }
    

    mapping

      __img "src='$name' width='$w' 
           height='$h' usemap='#map'"
      _map "name='map'"
        for {set i 0} {$i < $n} {incr i} {
          _area "href='[list index $refer $i]' 
            shape='rect' coords='$rect($i)'"
          area_
        }
      map_
    }
    

    # usage

    ImageMap "toolbar.gif" 480 32 3 {One Two Three}