Neatware Header
Home   Products   Forums   Partners   Buy   Company   Contact   Blog   

Objects

Objects are things in an XHTML document. Images, applets, and plugins are instances of objects.

  1. 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. The name is the image name; w is the image width; h is the image height; n is the number of sub-area; refer is the url list for each area.

    Comparing to other web page editing method, Snaml code automatically compute the coordinates and flexible to change. Resuable Snaml code is another benefit.

    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='[lindex $refer $i]' 
            shape='rect' coords='$rect($i)'"
          area_
        }
      map_
    }
    

    usage

    ImageMap "toolbar.gif" 480 32 3 {One Two Three}
    
  4. Table
  5. Table Modules are divided into Basic and Advanced Table Modules. The Basic Table Module is the set of Advanced Table Module and is primiarily used for wireless Internet.

    _table is a command to construct a table. The _tr command specifies table row and the _td command specifies table data. _table content may include a _caption command.

    The attributes of basic _table include COMMON, summary, and width attributes. The attributes of advanced _table are: 'border' attribute sets the table border with the integer from 0 to n. To declare the position of cells, the 'cellspacing' attribute specifies the space between two cells; 'cellpadding' attribute sets the space between the border and the content of a cell; and the 'height' and 'width' attributes specify the height and width of a table respectively. Finally 'bgcolor' attribute specifies the background color of a table.

    Table Demo
    Title 1 Title 2
    Area A Area B
    Area C

    To specify visible sides, 'frame' attribute may be one of the value: void, above, below, hsides, vsides, lhs, rhs, box, and border. They represent the none side(default), top side, bottom side, top&bottom side, left&right side, left-hand side, right-hand side, and all four sides respectively. To describe which rules will appear between cells, the 'rules' attribute may have one of a value none, groups, rows, cols, or all. In default when there are no frame and rules attributes, border='0' implies frame='void' and rules='none'; border='2' implies frame='border', rules='all', and border width is 2.

    The _tr command defines a row. Its attributes may be COMMON, align (left | center | right), or valign (top | middle | bottom). The content of _th in Advanced Table Module may be divied into head (_thead), foot (_tfoot), and body (_tbody) sections. To group columns, _colgroup and _col commands define the property of group.

    _th command specifies a cell head in the _tr. Usually it can be replaced by the _td command that defines a cell (data) in the content.

    _td command may have the attributes 'align', 'valign', 'height', 'width', 'bgcolor', and other COMMON attributes. 'align' attribute controls the horizontal alignment of the cell with the value left, right, or center; 'valign' attribute controls the verticle alignment with the value top, bottom, or middle. In addition, The 'colspan' attribute allows a cell span its width to one or more cells (default is 1). The 'rowspan' attribute spans its height to more cells. There are abbr, headers, axis, scope(row | col) attributes for _td command.

    _html "xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'"
    _head
      _title; quote "Table"; title_ 
    head_
    _body
      _table "border='1' cellspacing='4' cellpadding='8'
        bgcolor='#FFFFFF' nowrap='nowrap';
        align='center' valign='middle' 
        width='320' height='200'
        frame='hsides' rules='groups'" 
    
      _caption 
        quote "Table Demo"
      caption_
      _thead
        _tr
          _td; quote "Title 1'; td_
          _td; quote "Title 2"; td_
        tr_
      thead_
    
      _tbody
      _tr "width='30%'"
        _td "colspan='1' bgcolor='#FF0000'"
          quote "Area A"
        td_
        _td "bgcolor='#0000FF'"
          quote "Area B"
        td_
      tr_
      _tr
        _td "colspan='2' bgcolor=#00FF00"
          quote "Area C"
        td_
      tr_
      tbody_
      table_
    body_
    html_